Commit e8804bd5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8316aa92
......@@ -67,6 +67,7 @@ import (
"context"
"fmt"
"sort"
"sync"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
......@@ -137,7 +138,11 @@ type ΔFtail struct {
// ΔFtail merges ΔBtail with history of ZBlk
δBtail *xbtree.ΔBtail
// XXX mu sync.Mutex + comment
// mu protects ΔFtail data _and_ all _ΔFileTail data for all files.
//
// NOTE: even though this lock is global, since ... XXX
// working with retrieved vδE snapshot(?) does not need to hold the lock.
mu sync.Mutex
byFile map[zodb.Oid]*_ΔFileTail // file -> vδf tail
filesByRoot map[zodb.Oid]setOid // tree-root -> {} ZBigFile<oid> as of @head
......@@ -324,7 +329,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
δBtail := δFtail.δBtail
err = δftail._rebuild1(foid, δBtail.ΔZtail(), δBtail.DB())
}
return δftail, err
return δftail.vδE, δftail.root, err
}
// _rebuild1 rebuilds vδE.
......@@ -542,7 +547,7 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) {
// TODO keep index which file changed epoch where (similarly to ΔBtail),
// and, instead of scanning all files, trim vδE only on files that is really necessary.
for _, δftail := range δFtail.byFile {
δftail.forgetPast(revCut)
δftail._forgetPast(revCut)
}
}
......@@ -844,13 +849,14 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
// XXX locking
δftail, err := δFtail.rebuild1IfNeeded(foid)
// δftail, err := δFtail.rebuild1IfNeeded(foid)
vδE, headRoot, err := δFtail.rebuild1IfNeeded(foid)
if err != nil {
return zodb.InvalidTid, false, err
}
// find epoch that covers at and associated blktab root/object
vδE := δftail.vδE
// vδE := δftail.vδE
//fmt.Printf(" vδE: %v\n", vδE)
l := len(vδE)
i := sort.Search(l, func(i int) bool {
......@@ -862,7 +868,8 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
// root
var root zodb.Oid
if i == l {
root = δftail.root
// root = δftail.root
root = headRoot
} else {
root = vδE[i].oldRoot
}
......
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