Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
450ba707
Commit
450ba707
authored
Jun 23, 2021
by
Kirill Smelkov
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Fix rebuild with ø @at2
parent
66bc41ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
46 deletions
+53
-46
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+12
-4
wcfs/internal/xbtree/δbtail_test.go
wcfs/internal/xbtree/δbtail_test.go
+41
-42
No files found.
wcfs/internal/xbtree/δbtail.go
View file @
450ba707
...
...
@@ -377,15 +377,20 @@ func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB
// widenTrackNew widens trackNew to cover δtkeycov.
// XXX -> widenTrackSet?
func
widenTrackNew
(
trackNew
PPTreeSubSet
,
δtkeycov
*
RangedKeySet
,
root
zodb
.
Oid
,
at
zodb
.
Tid
,
db
*
zodb
.
DB
)
error
{
func
widenTrackNew
(
trackNew
PPTreeSubSet
,
δtkeycov
*
RangedKeySet
,
root
zodb
.
Oid
,
at
zodb
.
Tid
,
db
*
zodb
.
DB
)
(
err
error
)
{
// XXX errctx, debug
defer
xerr
.
Contextf
(
&
err
,
"widenTrackNew tree<%s> @%s +%s"
,
root
,
at
,
δtkeycov
)
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
defer
txn
.
Abort
()
zhead
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at
});
/*X*/
if
err
!=
nil
{
return
err
}
xtree
,
err
:=
zhead
.
Get
(
ctx
,
root
);
/*X*/
if
err
!=
nil
{
return
err
}
xtree
,
err
:=
zgetNodeOrNil
(
ctx
,
zhead
,
root
);
/*X*/
if
err
!=
nil
{
return
err
}
if
xtree
==
nil
{
// root deleted -> root node covers [-∞,∞)
trackNew
.
AddPath
([]
zodb
.
Oid
{
root
})
return
nil
}
tree
:=
xtree
.
(
*
Tree
)
// must succeed XXX better explicit panic?
top
:=
&
nodeInRange
{
prefix
:
nil
,
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
tree
}
...
...
@@ -507,6 +512,9 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
//
// TODO optionally accept zconnOld/zconnNew from client
func
(
δBtail
*
ΔBtail
)
Update
(
δZ
*
zodb
.
EventCommit
)
(
_
ΔB
,
err
error
)
{
headOld
:=
δBtail
.
Head
()
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail.Update %s -> %s"
,
headOld
,
δZ
.
Tid
)
δB1
,
err
:=
δBtail
.
_Update1
(
δZ
)
δB
:=
ΔB
{
Rev
:
δZ
.
Tid
,
ΔByRoot
:
make
(
map
[
zodb
.
Oid
]
map
[
Key
]
ΔValue
)}
...
...
@@ -563,7 +571,7 @@ type _ΔTUpdate1 struct {
}
func
(
δBtail
*
ΔBtail
)
_Update1
(
δZ
*
zodb
.
EventCommit
)
(
δB1
_ΔBUpdate1
,
err
error
)
{
headOld
:=
δBtail
.
Head
()
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail
update
%s -> %s"
,
headOld
,
δZ
.
Tid
)
defer
xerr
.
Contextf
(
&
err
,
"ΔBtail
.update1
%s -> %s"
,
headOld
,
δZ
.
Tid
)
tracefΔBtail
(
"
\n
Update @%s -> @%s δZ: %v
\n
"
,
δBtail
.
Head
(),
δZ
.
Tid
,
δZ
.
Changev
)
tracefΔBtail
(
"trackSet: %v
\n
"
,
δBtail
.
trackSet
)
...
...
wcfs/internal/xbtree/δbtail_test.go
View file @
450ba707
...
...
@@ -710,36 +710,9 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
}()
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
// zconn, δbtail @at1 with initial tracked set
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at1
});
X
(
err
)
δbtail
:=
NewΔBtail
(
zconn
.
At
(),
db
)
xtree
,
err
:=
zgetNodeOrNil
(
ctx
,
zconn
,
treeRoot
);
X
(
err
)
var
ztree
*
Tree
// = nil if treeRoot was deleted
if
xtree
!=
nil
{
ztree
=
xtree
.
(
*
Tree
)
}
for
k
:=
range
initialTrackedKeys
{
if
ztree
!=
nil
{
_
,
_
,
path
,
err
:=
ZTreeGetBlkData
(
ctx
,
ztree
,
k
);
X
(
err
)
err
=
δbtail
.
Track
(
k
,
path
);
X
(
err
)
}
else
{
// if treeRoot is deleted - add it to tracked set with every key
// being a hole. This aligns with the following situation
//
// T1 -> ø -> T2
//
// where after T1->ø, even though the tree becomes deleted, its root
// continues to be tracked and all keys migrate to holes in the
// tracking set. By aligning initial state to the same as after
// T1->ø, we test what will happen on ø->T2.
err
=
δbtail
.
track
(
k
,
[]
zodb
.
Oid
{
treeRoot
});
X
(
err
)
}
}
// δbtail @at1 with initial tracked set
δbtail
:=
NewΔBtail
(
at1
,
db
)
xtrackKeys
(
δbtail
,
treeRoot
,
initialTrackedKeys
)
// TrackedδZ = Tracked ^ δZ (i.e. a tracked node has changed, or its coverage was changed)
TrackedδZ
=
SetKey
{}
...
...
@@ -1066,7 +1039,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
keys12R2
=
keys12R2_
}
/
//
*
/*
fmt.Printf("\n\n\nKKK\nkeys1=%s keys2=%s\n", keys1, keys2)
fmt.Printf("keys1R2: %s\n", keys1R2)
fmt.Printf("keys12R2: %s\n", keys12R2)
...
...
@@ -1081,7 +1054,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
fmt.Printf("t2.xkv.trackSet(keys2) \\ t2.xkv.trackSet(keys1R2) -> %s\n",
t2.xkv.trackSet(keys2).Difference(t2.xkv.trackSet(keys1R2)))
fmt.Printf("\n\n\n")
//
*/
*/
// δkvX_k12R2 = tX.δxkv / keys12R2
...
...
@@ -1140,19 +1113,10 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, db *zodb.DB, treeR
// xverifyΔBTail_rebuild_TR verifies ΔBtail state after Track(keys) + rebuild.
func
xverifyΔBTail_rebuild_TR
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
δbtail
*
ΔBtail
,
tj
*
tTreeCommit
,
treeRoot
zodb
.
Oid
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
,
trackSet
PPTreeSubSet
,
trackNew
,
trackSetAfterRebuild
PPTreeSubSet
,
vδTok
...
map
[
Key
]
Δstring
)
{
t
.
Helper
()
X
:=
exc
.
Raiseif
ø
:=
PPTreeSubSet
{}
// Track(keys)
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
tj
.
at
});
X
(
err
)
xtree
,
err
:=
zconn
.
Get
(
ctx
,
treeRoot
);
X
(
err
)
ztree
:=
xtree
.
(
*
Tree
)
for
k
:=
range
keys
{
_
,
_
,
path
,
err
:=
ZTreeGetBlkData
(
ctx
,
ztree
,
k
);
X
(
err
)
err
=
δbtail
.
Track
(
k
,
path
);
X
(
err
)
}
xtrackKeys
(
δbtail
,
treeRoot
,
keys
)
subj
:=
fmt
.
Sprintf
(
"@%s: after Track%v"
,
xat
[
tj
.
at
],
keys
)
δbtail
.
assertTrack
(
t
,
subj
,
trackSet
,
trackNew
)
...
...
@@ -1222,6 +1186,41 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, db *zodb.DB, tj
}
}
// xtrackKeys issues δbtail.Track requests for tree[keys].
// XXX place
func
xtrackKeys
(
δbtail
*
ΔBtail
,
treeRoot
zodb
.
Oid
,
keys
SetKey
)
{
X
:=
exc
.
Raiseif
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
zconn
,
err
:=
δbtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
δbtail
.
Head
()});
X
(
err
)
xtree
,
err
:=
zgetNodeOrNil
(
ctx
,
zconn
,
treeRoot
);
X
(
err
)
var
ztree
*
Tree
// = nil if treeRoot was deleted
if
xtree
!=
nil
{
ztree
=
xtree
.
(
*
Tree
)
}
for
k
:=
range
keys
{
if
ztree
!=
nil
{
_
,
_
,
path
,
err
:=
ZTreeGetBlkData
(
ctx
,
ztree
,
k
);
X
(
err
)
err
=
δbtail
.
Track
(
k
,
path
);
X
(
err
)
}
else
{
// if treeRoot is deleted - add it to tracked set with every key
// being a hole. This aligns with the following situation
//
// T1 -> ø -> T2
//
// where after T1->ø, even though the tree becomes deleted, its root
// continues to be tracked and all keys migrate to holes in the
// tracking set. By aligning initial state to the same as after
// T1->ø, we test what will happen on ø->T2.
err
=
δbtail
.
track
(
k
,
[]
zodb
.
Oid
{
treeRoot
});
X
(
err
)
}
}
}
// xverifyΔBTail_GetAt verifies δBtail.Get on series of vt ZODB changes.
// XXX
// XXX kill
...
...
Kirill Smelkov
@kirr
mentioned in commit
305d897b
·
Oct 27, 2021
mentioned in commit
305d897b
mentioned in commit 305d897b15ac0866de464de36b34c1fe1de90a63
Toggle commit list
Kirill Smelkov
@kirr
mentioned in commit
2ab4be93
·
Oct 28, 2021
mentioned in commit
2ab4be93
mentioned in commit 2ab4be938541c61bf881216bdffc5376241ccc30
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment