Commit 9d20f8e8 authored by Kirill Smelkov's avatar Kirill Smelkov

X treediff: Fix BUG while computing AB coverage

Access to node entries is valid only after the node was activated.
And it fails otherwise.

--- FAIL: TestΔBTail (0.63s)
    --- FAIL: TestΔBTail/rebuild/T/T1/B0:a-B1:b→T/T1/T-T/B0:c-B1:d (0.00s)
        --- FAIL: TestΔBTail/rebuild/T/T1/B0:a-B1:b→T/T1/T-T/B0:c-B1:d/_T{};R (0.00s)
            --- FAIL: TestΔBTail/rebuild/T/T1/B0:a-B1:b→T/T1/T-T/B0:c-B1:d/_T{};R/_→T/T/B0:a (0.00s)
panic: BUG: T000000000000003a points to T000000000000000c as parent in trackSet, but not found in T000000000000000c children [recovered]
        panic: BUG: T000000000000003a points to T000000000000000c as parent in trackSet, but not found in T000000000000000c children
parent f60528c9
...@@ -487,6 +487,9 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet) ...@@ -487,6 +487,9 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
ABcov: ABcov:
for i := len(ABpath)-2; i >= 0; i-- { for i := len(ABpath)-2; i >= 0; i-- {
xparent, err := node.PJar().Get(ctx, ABpath[i]); /*X*/if err != nil { return nil,nil,nil, err } xparent, err := node.PJar().Get(ctx, ABpath[i]); /*X*/if err != nil { return nil,nil,nil, err }
err = xparent.PActivate(ctx); /*X*/if err != nil { return nil,nil,nil, err}
defer xparent.PDeactivate()
parent := xparent.(*Tree) // must succeed parent := xparent.(*Tree) // must succeed
// find node in parent children and constrain ABlo/ABhi accordingly // find node in parent children and constrain ABlo/ABhi accordingly
entryv := parent.Entryv() entryv := parent.Entryv()
...@@ -512,7 +515,14 @@ ABcov: ...@@ -512,7 +515,14 @@ ABcov:
} }
} }
panicf("BUG: T%s points to T%s as parent in trackSet, but not found in T%s children", node.POid(), parent.POid(), parent.POid()) emsg := fmt.Sprintf("BUG: T%s points to T%s as parent in trackSet, but not found in T%s children\n", node.POid(), parent.POid(), parent.POid())
children := []string{}
for _, entry := range entryv {
children = append(children, vnode(entry.Child()))
}
emsg += fmt.Sprintf("T%s children: %v\n", parent.POid(), children)
emsg += fmt.Sprintf("trackSet: %s\n", trackSet)
panic(emsg)
} }
......
...@@ -1084,6 +1084,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -1084,6 +1084,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
/* trackSet=*/ t2.xkv.trackSet(keys12R2), /* trackSet=*/ t2.xkv.trackSet(keys12R2),
/*vδT=*/ δkv1_k12R2, δkv2_k12R2) /*vδT=*/ δkv1_k12R2, δkv2_k12R2)
// XXX move vvv to separate test (out of this inner loop)
// ΔBtail.Clone had bug that aliased klon data to orig // ΔBtail.Clone had bug that aliased klon data to orig
assertΔTtail(t, "BUG: after clone check", δbtail, db, t2, treeRoot, xat, assertΔTtail(t, "BUG: after clone check", δbtail, db, t2, treeRoot, xat,
/*vδT=*/ δkv1_k1R2, δkv2_k1R2) /*vδT=*/ δkv1_k1R2, δkv2_k1R2)
......
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