Commit d372fde8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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