fix!: remove skipping of unchanged subtrees
Intermediate rounds skipped a directory when its inode version and its ceph.dir.rctime matched the previous round. In the 10,000-file lab test a round snapshot taken seconds after changes skipped tree/ with about 250 changed files in its subdirectories: the inode version of tree/ changes only with its own entries, and Ceph had not yet propagated the rctime of the grandchildren. The target snapshot of that round was incomplete, and its verification skipped the same subtrees; only finalize closed the gap. Every round now scans all metadata again. Base index entries that the old version marked carried are never trusted, so such files are copied in full in the next round. The smallfiles verification now checks only snapshots that sync did not remove. BREAKING CHANGE: the configuration field "full_scan" and the transfer statistic "skipped_subtrees" are removed; a configuration with "full_scan" is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82c64f9908
commit
6dcb7b676f
16 files changed
+117
-448
No files matched your search
@@ -11,7 +11,7 @@ import (
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var nativeBuckets = []string{"meta", "paths", "groups", "aliases", "dirs", "full", "ranges", "changed", "delete", "relinked", "subtrees"}
|
||||
var nativeBuckets = []string{"meta", "paths", "groups", "aliases", "dirs", "full", "ranges", "changed", "delete", "relinked"}
|
||||
|
||||
type nativeIndex struct {
|
||||
db *bolt.DB
|
||||
@@ -19,9 +19,9 @@ type nativeIndex struct {
|
||||
}
|
||||
|
||||
// baseEntry is the inventory record of one source path. Carried marks an
|
||||
// entry taken over unexamined from the previous base because its subtree was
|
||||
// skipped: it still describes the state of an older round, so it must not
|
||||
// serve as base for a block delta.
|
||||
// entry that an earlier version took over unexamined when it skipped an
|
||||
// unchanged-looking subtree. Such an entry may describe an older round, so
|
||||
// it is never trusted. Current versions do not write it.
|
||||
type baseEntry struct {
|
||||
Inode, Version, Size, TargetInode uint64
|
||||
Carried bool
|
||||
@@ -163,68 +163,6 @@ func (x *nativeIndex) putEntryIfChanged(rel string, entry baseEntry) error {
|
||||
return x.put("paths", []byte(rel), encodeEntry(entry))
|
||||
}
|
||||
|
||||
// carry copies the inventory of the subtree rel, including rel itself, from
|
||||
// base and marks every entry Carried. It writes in bounded transactions.
|
||||
func (x *nativeIndex) carry(base *nativeIndex, rel string) error {
|
||||
type record struct{ k, v []byte }
|
||||
prefix := []byte(rel + "/")
|
||||
next := []byte(rel)
|
||||
for next != nil {
|
||||
var batch []record
|
||||
err := base.db.View(func(tx *bolt.Tx) error {
|
||||
c := tx.Bucket([]byte("paths")).Cursor()
|
||||
k, v := c.Seek(next)
|
||||
next = nil
|
||||
for ; k != nil && len(batch) < 4096; k, v = c.Next() {
|
||||
if string(k) != rel && !bytes.HasPrefix(k, prefix) {
|
||||
if string(k) > rel && bytes.Compare(k, prefix) < 0 {
|
||||
// Siblings such as "a b" sort between "a" and "a/".
|
||||
k, v = c.Seek(prefix)
|
||||
if k == nil || !bytes.HasPrefix(k, prefix) {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
e, ok := decodeEntry(v)
|
||||
if !ok {
|
||||
return errors.New("invalid base inventory entry")
|
||||
}
|
||||
|
||||
e.Carried = true
|
||||
batch = append(batch, record{bytes.Clone(k), encodeEntry(e)})
|
||||
}
|
||||
|
||||
if k != nil && bytes.HasPrefix(k, prefix) {
|
||||
next = bytes.Clone(k)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = x.db.Update(func(tx *bolt.Tx) error {
|
||||
b := tx.Bucket([]byte("paths"))
|
||||
for _, r := range batch {
|
||||
if err := b.Put(r.k, r.v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *nativeIndex) requireInventory() error {
|
||||
complete, err := x.get("meta", []byte("inventory_complete"))
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user