Commit 1020ac40 authored by Julien Muchembled's avatar Julien Muchembled

reflink: add processing timestamp to transaction metadata in the reflink DB

Usually in ZODB, we can know when a transaction was committed by
decoding its TID, and by default it's the only way.

However in a reflink DB, transactions are committed with explicit TIDs,
which come from the main DB, for the following purpose: if you truncate
the main DB, just truncate the reflink DB at the same TID.

With this commit, it will be possible to know when reflink has processed
a TID by looking at transaction metadata.
parent abe5efff
......@@ -385,10 +385,11 @@ class Changeset(object):
def commit(self, tid, info=''):
storage = self.storage
now = time()
logger.info('commit @ %x (%s)', u64(tid), info or
'Δ %s' % timedelta(0, time() - TimeStamp(tid).timeTime()))
'Δ %s' % timedelta(0, now - TimeStamp(tid).timeTime()))
buckets = self.buckets
txn = TransactionMetaData()
txn = TransactionMetaData(extension={'time': now})
storage.tpc_begin(txn, tid)
def shortenVal(i):
if i:
......
......@@ -331,6 +331,7 @@ class GCTests(NEOThreadedTest):
track = threading.Lock()
with commit_patch, committed, track, NEOCluster() as reflink_cluster:
stop = False
start = time()
reflink_cluster.start()
reflink_thread = self.newThread(reflink_run)
t, conn = cluster.getTransaction()
......@@ -393,6 +394,13 @@ class GCTests(NEOThreadedTest):
self.assertLess(tid1, tid2)
self.assertEqual(tid2, reflink_cluster.last_tid)
end = time()
for x in reflink_cluster.client.iterator():
x = x.extension['time']
self.assertLess(start, x)
start = x
self.assertLess(x, end)
cluster.neoctl.truncate(tid1)
self.tic()
......
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