Commit 926408d3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1476e602
......@@ -325,7 +325,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
// vδE needs to be built
job := δftail.rebuildJob
// rebuild is currently in-progress -> wait for corrsponding job to complete
// rebuild is currently in-progress -> wait for corresponding job to complete
if job != nil {
δFtail.mu.Unlock()
<-job.ready
......@@ -362,7 +362,7 @@ func (δFtail *ΔFtail) rebuild1IfNeeded(foid zodb.Oid) (vδE []_ΔFileEpoch, he
// _rebuildAll rebuilds vδE for all files from ftrackNew requests.
//
// must be calledwith δFtail.mu locked.
// must be called with δFtail.mu locked.
func (δFtail *ΔFtail) _rebuildAll() (err error) {
defer xerr.Contextf(&err, "ΔFtail rebuildAll")
......@@ -619,7 +619,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) {
// func (δFtail *ΔFtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔF
// _ZinblkOverlay is used by SliceByFileRev.
// It combiness read-only Zinblk base with read-write adjustment.
// It combines read-only Zinblk base with read-write adjustment.
// It provides the following operations:
//
// - Get(zblk) -> {blk},
......@@ -627,7 +627,7 @@ func (δftail *_ΔFileTail) _forgetPast(revCut zodb.Tid) {
// - DelBlk(zblk, blk)
type _ZinblkOverlay struct {
Base map[zodb.Oid]setI64 // taken from _RootTrack.Zinblk or _ΔFileEpoch.oldZinblk
Adj map[zodb.Oid]setI64 // adjustement over base; blk<0 reresents whitout
Adj map[zodb.Oid]setI64 // adjustment over base; blk<0 represents whiteout
}
// SliceByFileRev returns history of file changes in (lo, hi] range.
......@@ -724,10 +724,37 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// head
root = headRoot
head = δFtail.Head()
rt, ok := δFtail.byRoot[root] // XXX locking
// take atomic Zinblk snapshot that covers vδZ
//
// - the reason we take snapshot is because simultaneous Track requests might
// change Zinblk concurrently, and without snapshotting this might result
// in changes to a block being not uniformly present in result (some
// revision indicates change to that block, while another one - where the
// block is too actually changed - does not indicate change to that block).
//
// - the reason we limit snapshot to vδZ is to reduce amount of under-lock
// copying, because original Zinblk is potentially very large.
ZinblkSnap := map[zodb.Oid]setI64{}
δZAllOid := setOid{}
for _, δZ := range vδZ {
for _, oid := range δZ.Changev {
δZAllOid.Add(oid)
}
}
δFtail.mu.Lock()
rt, ok := δFtail.byRoot[root]
if ok {
for oid := range δZAllOid {
inblk, ok := rt.Zinblk[oid]
if ok {
Zinblk.Base = rt.Zinblk
ZinblkSnap[oid] = inblk.Clone()
}
}
}
δFtail.mu.Unlock()
Zinblk.Base = ZinblkSnap
} else {
δE := vδE[ie+1]
root = δE.oldRoot
......@@ -1044,7 +1071,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zfile *ZBigFile, blk int6
}
// ---- vδEBuild (rebuild core) ----
// ---- vδEBuild (vδE rebuild core) ----
// vδEBuild builds vδE for file from vδZ.
func vδEBuild(foid zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (vδE []_ΔFileEpoch, err error) {
......
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