Commit 349f1e7d authored by Kirill Smelkov's avatar Kirill Smelkov

Merge remote-tracking branch 'origin/master' into t

* origin/master:
  neoctl: make 'print ids' command display time of TIDs
  mysql: force _getNextTID() to use appropriate/whole index
parents 16d84f10 d9dd39f0
...@@ -81,6 +81,16 @@ def unpackTID(ptid): ...@@ -81,6 +81,16 @@ def unpackTID(ptid):
higher.reverse() higher.reverse()
return (tuple(higher), lower) return (tuple(higher), lower)
def timeStringFromTID(ptid):
"""
Return a string in the format "yyyy-mm-dd hh:mm:ss.ssssss" from a TID
"""
higher, lower = unpackTID(ptid)
seconds = lower * SECOND_PER_TID_LOW
return '%04d-%02d-%02d %02d:%02d:%09.6f' % (higher[0], higher[1], higher[2],
higher[3], higher[4], seconds)
def addTID(ptid, offset): def addTID(ptid, offset):
""" """
Offset given packed TID. Offset given packed TID.
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
from operator import itemgetter from operator import itemgetter
from .neoctl import NeoCTL, NotReadyException from .neoctl import NeoCTL, NotReadyException
from neo.lib.util import p64, u64, tidFromTime from neo.lib.util import p64, u64, tidFromTime, timeStringFromTID
from neo.lib.protocol import uuid_str, ClusterStates, NodeTypes, \ from neo.lib.protocol import uuid_str, ClusterStates, NodeTypes, \
UUID_NAMESPACES, ZERO_TID UUID_NAMESPACES, ZERO_TID
...@@ -89,11 +89,13 @@ class TerminalNeoCTL(object): ...@@ -89,11 +89,13 @@ class TerminalNeoCTL(object):
ptid, backup_tid, truncate_tid = self.neoctl.getRecovery() ptid, backup_tid, truncate_tid = self.neoctl.getRecovery()
if backup_tid: if backup_tid:
ltid = self.neoctl.getLastTransaction() ltid = self.neoctl.getLastTransaction()
r = "backup_tid = 0x%x" % u64(backup_tid) r = "backup_tid = 0x%x (%s)" % (u64(backup_tid),
timeStringFromTID(backup_tid))
else: else:
loid, ltid = self.neoctl.getLastIds() loid, ltid = self.neoctl.getLastIds()
r = "last_oid = 0x%x" % u64(loid) r = "last_oid = 0x%x" % (u64(loid))
return r + "\nlast_tid = 0x%x\nlast_ptid = %u" % (u64(ltid), ptid) return r + "\nlast_tid = 0x%x (%s)\nlast_ptid = %u" % \
(u64(ltid), timeStringFromTID(ltid), ptid)
def getPartitionRowList(self, params): def getPartitionRowList(self, params):
""" """
...@@ -311,4 +313,3 @@ class Application(object): ...@@ -311,4 +313,3 @@ class Application(object):
" e.g. '257684787499560686', '0x3937af2eeeeeeee' or '1325421296.'" " e.g. '257684787499560686', '0x3937af2eeeeeeee' or '1325421296.'"
" for 2012-01-01 12:34:56 UTC") " for 2012-01-01 12:34:56 UTC")
return '\n'.join(output_list) return '\n'.join(output_list)
...@@ -335,7 +335,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -335,7 +335,7 @@ class MySQLDatabaseManager(DatabaseManager):
# ANSWER -> index name is SHOW INDEX FROM tbl; -> Key_name # ANSWER -> index name is SHOW INDEX FROM tbl; -> Key_name
# " FORCE INDEX(`partition`)" # " FORCE INDEX(`partition`)"
r = self.query("SELECT tid FROM obj" r = self.query("SELECT tid FROM obj"
" USE INDEX(`partition`)" " FORCE INDEX(`partition`)"
" WHERE `partition`=%d AND oid=%d AND tid>%d" " WHERE `partition`=%d AND oid=%d AND tid>%d"
" ORDER BY tid LIMIT 1" % args) " ORDER BY tid LIMIT 1" % args)
return r[0][0] if r else None return r[0][0] if r else None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment