Commit 8db3f96a authored by Kirill Smelkov's avatar Kirill Smelkov

X don't track embedded buckets

Reason: see comments.
Prerequisite to fix test_wcfs_watch_2files
parent 74bf1db8
...@@ -416,7 +416,6 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { // ...@@ -416,7 +416,6 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
} }
} }
_, ok := δBtail.byRoot[root] _, ok := δBtail.byRoot[root]
if !ok { if !ok {
δBtail.byRoot[root] = newΔTtail() δBtail.byRoot[root] = newΔTtail()
...@@ -446,13 +445,21 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) { ...@@ -446,13 +445,21 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) {
panic("empty path") panic("empty path")
} }
// don't explicitly keep track of embedded buckets - they all have
// InvalidOid, and thus, if kept in tidx, e.g. T/B1:a and another
// T/B2:b would lead to InvalidOid having multiple parents.
if l >= 2 && path[l-1] == zodb.InvalidOid {
path = path[:l-1]
}
parent := zodb.InvalidOid parent := zodb.InvalidOid
var ptrack *nodeTrack = nil var ptrack *nodeTrack = nil
var track *nodeTrack // XXX kill here var track *nodeTrack // XXX kill here
var oldTrack bool var oldTrack bool
for _, oid := range path { for _, oid := range path {
// XXX skip InvalidOid ? if oid == zodb.InvalidOid {
// InvalidOid means embedded bucket - e.g. T/B1:a with bucket not having its own oid. panicf("path has node with invalid oid: %v", path)
}
track, oldTrack = tidx[oid] track, oldTrack = tidx[oid]
if !oldTrack { if !oldTrack {
...@@ -994,7 +1001,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h ...@@ -994,7 +1001,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
for _, ac := range achildren { for _, ac := range achildren {
acOid := ac.node.POid() acOid := ac.node.POid()
_, tracked := trackIdx[acOid] _, tracked := trackIdx[acOid]
if !tracked { if !tracked && /*cannot skip embedded bucket:*/acOid != zodb.InvalidOid {
continue continue
} }
......
...@@ -339,11 +339,10 @@ func (rbs RBucketSet) trackIdx(tracked SetKey) trackIndex { ...@@ -339,11 +339,10 @@ func (rbs RBucketSet) trackIdx(tracked SetKey) trackIndex {
trackIdx := trackIndex{} trackIdx := trackIndex{}
for k := range tracked { for k := range tracked {
kb := rbs.Get(k) kb := rbs.Get(k)
// trackIdx records regular buckets or non-empty embedded bucket // trackIdx explicitly records only regular buckets.
// ( empty embedded bucket means there is just empty tree node // embedded buckets all have oid=zodb.InvalidOid and would lead to z
// and only that empty tree node is recorded in trackIdx )
newNode := false newNode := false
if (kb.oid != zodb.InvalidOid || len(kb.kv) != 0) { if kb.oid != zodb.InvalidOid {
track, already := trackIdx[kb.oid] track, already := trackIdx[kb.oid]
if !already { if !already {
track = &nodeTrack{parent: kb.parent.oid, nchild: 0} track = &nodeTrack{parent: kb.parent.oid, nchild: 0}
......
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