Skip to content

Sync ordinary objects with cached creation roots - #3322

Open
Kymorphius wants to merge 1 commit into
anyproto:developfrom
Kymorphius:fix/GH-3321-sync-cached-page-roots
Open

Kymorphius wants to merge 1 commit into
anyproto:developfrom
Kymorphius:fix/GH-3321-sync-cached-page-roots

Conversation

@Kymorphius

@Kymorphius Kymorphius commented Oct 11, 2026 •

Copy link
Copy Markdown

Fixes #3321

Problem

A peer can advertise an object whose local tree contains only its creation root. requestTree calls GetTree, which can return that cached root without fetching the peer's newer changes. The existing IsEmptyDerivedTree guard only calls SyncWithPeer for derived objects, so ordinary objects can remain empty and repeatedly appear as missing in head-sync differences.

Change

Use objecttree.IsEmptyTree for the cached-tree check. Inspect the tree while holding its lock, then release the lock before calling pingTree / 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 current develop (base 713bfdacc033158cd0f91d2e3fa57b439cbe7dd7), using Go 1.26.5 and the matching Tantivy v1.0.6 library.
  • Added cases for ordinary and derived cached roots, complete trees, a single non-root snapshot, tree-load failure, and retry after a failed sync queue request. These unit tests cover the request/queue behavior, not completion of remote synchronization.
  • The ordinary cached-root regression fails when treesyncer.go is 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 current develop change 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

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|修复|补拉本地缓存的普通对象空根
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Kymorphius

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ordinary cached creation roots never request advertised peer content

1 participant