Repository navigation
Sync ordinary objects with cached creation roots - #3322
Open
Kymorphius wants to merge 1 commit into
Open
Kymorphius wants to merge 1 commit into
Kymorphius wants to merge 1 commit into
Conversation
Request normal peer sync for all creation-root-only trees, including ordinary objects. Preserve complete trees and non-root snapshots. Validated treesyncer package tests and the original-code regression overlay. Fixes anyproto#3321 记录:1011|修复|补拉本地缓存的普通对象空根
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3321
Problem
A peer can advertise an object whose local tree contains only its creation root.
requestTreecallsGetTree, which can return that cached root without fetching the peer's newer changes. The existingIsEmptyDerivedTreeguard only callsSyncWithPeerfor derived objects, so ordinary objects can remain empty and repeatedly appear as missing in head-sync differences.Change
Use
objecttree.IsEmptyTreefor the cached-tree check. Inspect the tree while holding its lock, then release the lock before callingpingTree/SyncWithPeer. Root-only ordinary and derived objects now both request synchronization. Complete trees and a single non-root snapshot keep their existing behavior.This only changes when synchronization is requested. Incoming changes still use the normal native validation and persistence path; no changes are synthesized or written directly to storage.
Validation
go test -count=1 ./core/block/object/treesyncer/...on currentdevelop(base713bfdacc033158cd0f91d2e3fa57b439cbe7dd7), using Go 1.26.5 and the matching Tantivy v1.0.6 library.treesyncer.gois replaced with the unmodified base implementation through a Go overlay.Separately, a backport of this change to Anytype Heart v0.51.4 was exercised against an affected native store. All seven previously root-only objects recovered their remote changes, current native heads, content, and indexes, and all seven were readable through
ObjectShow. After recovery, two complete stop/start cycles (the patched runtime and the original algorithm) each produced three head-sync check rounds with a 40-byte protobuf response and zero range requests. A third stop/start cycle with the stock official CLI could still read all seven objects.That runtime evidence applies to the v0.51.4 backport, not to a runtime built from current
develop. The currentdevelopchange is validated by the package tests above. The 40-byte measurements are head-sync response protobuf sizes, not total network traffic. The diagnostic runtime also included a separate head-sync count-compatibility change; that change is not included in this PR.Related discovery-traffic fix: anyproto/any-sync#806