Commit d372fde8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7c96cf5a
...@@ -420,6 +420,7 @@ package main ...@@ -420,6 +420,7 @@ package main
// XXX describe locking // XXX describe locking
// //
// head.zconnMu write by handleδZ; read by read // head.zconnMu write by handleδZ; read by read
// -> rlockZHead() + lockZHead() ?
// ... // ...
// XXX locking: test with -race (many bugs are reported) // XXX locking: test with -race (many bugs are reported)
...@@ -1438,8 +1439,8 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1438,8 +1439,8 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
f := w.file f := w.file
// register w to f here early, so that READs going in parallel to us // register w to f here early, so that READs going in parallel to us
// preparing and processing initial pins, also send pins for read // preparing and processing initial pins, also send pins to w for read
// blocks. If we don't, we can miss to send pin for a freshly read // blocks. If we don't, we can miss to send pin to w for a freshly read
// block which could have revision > w.at: XXX test // block which could have revision > w.at: XXX test
// //
// 1 3 2 4 // 1 3 2 4
...@@ -1456,7 +1457,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1456,7 +1457,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// pin for #3. // pin for #3.
// //
// NOTE for `unpin blk` head we can be sure there won't be simultaneous // NOTE for `unpin blk` head we can be sure there won't be simultaneous
// `pin blk` request, because: // `pin blk` request, because: XXX recheck
// //
// - unpin means blk was previously pinned, // - unpin means blk was previously pinned,
// - blk was pinned means it is tracked by δFtail, // - blk was pinned means it is tracked by δFtail,
...@@ -1464,7 +1465,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1464,7 +1465,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// there is indeed no blk change in that region, // there is indeed no blk change in that region,
// - which means that δblk with rev > w.at might be only > head, // - which means that δblk with rev > w.at might be only > head,
// - but such δblk are processed with zhead wlocked and we keep zhead // - but such δblk are processed with zhead wlocked and we keep zhead
// rlocked during pin setup. XXX rlock zhead // rlocked during pin setup. XXX rlock zhead during setupWatch
// //
// δ δ // δ δ
// ----x----.------------]----x---- // ----x----.------------]----x----
......
...@@ -178,9 +178,7 @@ class tDB: ...@@ -178,9 +178,7 @@ class tDB:
# committed: (tail, head] + δF history # committed: (tail, head] + δF history
t.tail = t.root._p_jar.db().storage.lastTransaction() t.tail = t.root._p_jar.db().storage.lastTransaction()
t.head = None # XXX -> property = dFtail[-1].rev ? t.dFtail = [] # of DF; head = dFtail[-1].rev
t._headv = [] # XXX -> just use dFtail[·].rev ?
t.dFtail = [] # of DF
# when ZBigFile(s) blocks were last accessed via wcfs. # when ZBigFile(s) blocks were last accessed via wcfs.
# this is updated only explicitly via ._blkaccess() . # this is updated only explicitly via ._blkaccess() .
...@@ -194,6 +192,10 @@ class tDB: ...@@ -194,6 +192,10 @@ class tDB:
t._files = set() t._files = set()
t._wlinks = set() t._wlinks = set()
@property
def head(t):
return t.dFtail[-1].rev
# close closes test database as well as all tracked files, watch links and wcfs. # close closes test database as well as all tracked files, watch links and wcfs.
def close(t): def close(t):
for tf in t._files.copy(): for tf in t._files.copy():
...@@ -253,8 +255,6 @@ class tDB: ...@@ -253,8 +255,6 @@ class tDB:
transaction.commit() transaction.commit()
head = last._p_serial head = last._p_serial
t.head = head
t._headv.append(head)
print('\nM: commit -> %s' % t.hat(head)) print('\nM: commit -> %s' % t.hat(head))
for zf, zfDelta in t._changed.items(): for zf, zfDelta in t._changed.items():
...@@ -279,14 +279,14 @@ class tDB: ...@@ -279,14 +279,14 @@ class tDB:
# _wcsync makes sure wcfs is synchronized to latest committed transaction. # _wcsync makes sure wcfs is synchronized to latest committed transaction.
def _wcsync(t): def _wcsync(t):
while len(t._wc_zheadv) < len(t._headv): while len(t._wc_zheadv) < len(t.dFtail):
l = t._wc_zheadfh.readline() l = t._wc_zheadfh.readline()
#print('> zhead read: %r' % l) #print('> zhead read: %r' % l)
l = l.rstrip('\n') l = l.rstrip('\n')
wchead = fromhex(l) wchead = fromhex(l)
i = len(t._wc_zheadv) i = len(t._wc_zheadv)
if wchead != t._headv[i]: if wchead != t.dFtail[i].rev:
raise RuntimeError("wcsync #%d: wczhead (%s) != zhead (%s)" % (i, h(wchead), h(t._headv[i]))) raise RuntimeError("wcsync #%d: wczhead (%s) != zhead (%s)" % (i, h(wchead), h(t.dFtail[i].rev)))
t._wc_zheadv.append(wchead) t._wc_zheadv.append(wchead)
# head/at = last txn of whole db # head/at = last txn of whole db
...@@ -357,7 +357,7 @@ class tDB: ...@@ -357,7 +357,7 @@ class tDB:
if len(blkhistoryat) == 0: if len(blkhistoryat) == 0:
# blk did not existed @at # XXX verify whether file was existing at all # blk did not existed @at # XXX verify whether file was existing at all
data = b'' data = b''
rev = t._headv[0] # was hole - at0 XXX -> pin to z64 rev = t.dFtail[0].rev # was hole - at0 XXX -> pin to z64
else: else:
_ = blkhistoryat[-1] _ = blkhistoryat[-1]
data = _.ddata[blk] data = _.ddata[blk]
...@@ -911,7 +911,7 @@ def _pinAt(t, zf, at): # -> pin = {} blk -> rev ...@@ -911,7 +911,7 @@ def _pinAt(t, zf, at): # -> pin = {} blk -> rev
# history of blk changes <= at # history of blk changes <= at
blkhistoryat = [_.rev for _ in vdf if blk in _.ddata and _.rev <= at] blkhistoryat = [_.rev for _ in vdf if blk in _.ddata and _.rev <= at]
if len(blkhistoryat) == 0: if len(blkhistoryat) == 0:
pinrev = t._headv[0] # was hole - at0 XXX -> pin to z64? pinrev = t.dFtail[0].rev # was hole - at0 XXX -> pin to z64?
else: else:
pinrev = blkhistoryat[-1] pinrev = blkhistoryat[-1]
assert pinrev <= at assert pinrev <= at
...@@ -1471,12 +1471,10 @@ def test_tidtime_notrough(): ...@@ -1471,12 +1471,10 @@ def test_tidtime_notrough():
# @at2 (03cf7850500b5f66) # @at2 (03cf7850500b5f66)
@func(tDB) @func(tDB)
def hat(t, at): def hat(t, at):
try: for i, dF in enumerate(t.dFtail):
i = t._headv.index(at) if dF.rev == at:
except ValueError: return "@at%d (%s)" % (i, h(at))
return "@" + h(at) return "@" + h(at)
return "@at%d (%s)" % (i, h(at))
# zfiles returns ZBigFiles that were ever changed under t. # zfiles returns ZBigFiles that were ever changed under t.
......
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