Skip to content

(tree) Fix incremental summary stale handle paths#26990

Open
agarwal-navin wants to merge 5 commits intomainfrom
fixIncrSummaryBug
Open

(tree) Fix incremental summary stale handle paths#26990
agarwal-navin wants to merge 5 commits intomainfrom
fixIncrSummaryBug

Conversation

@agarwal-navin
Copy link
Copy Markdown
Contributor

@agarwal-navin agarwal-navin commented Apr 9, 2026

Bug

When a parent incremental chunk was re-encoded with a new referenceId, child chunks that became handles still held a summaryPath string referencing the old referenceId. On the next summary, those handle URLs pointed to keys that no longer existed in the preceding summary tree.

Fix

Replaced summaryPath: string in ChunkSummaryProperties and ChunkLoadProperties with parentReferenceId: ChunkReferenceId | undefined. The full handle path is now computed on demand by walking up the parent chain via latestSummaryRefIdMap — a Map<ChunkReferenceId, ChunkSummaryProperties> built at the start of each summary and scoped to TrackedSummaryProperties. This keeps every entry correct regardless of ancestor re-encodings.

Tests

Added parameterized test cases covering the stale-path scenarios ([1,1], [2,2], [1,0,1], [2,0,2], etc.), a multi-handle test (simultaneous handles at depth 3 and 4), and a fullTree=true test.

🤖 Generated with Claude Code

@agarwal-navin agarwal-navin requested a review from a team as a code owner April 9, 2026 23:52
Copilot AI review requested due to automatic review settings April 9, 2026 23:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incremental summary handle paths becoming stale when ancestor chunks are re-encoded with new referenceIds by changing chunk tracking to store parentReferenceId and computing handle paths on demand from the latest summary’s tracking map.

Changes:

  • Replaced stored chunk summaryPath strings with parentReferenceId-based tracking and added on-demand handle-path computation via parent-chain traversal.
  • Updated chunk loading/decoding to persist parentReferenceId rather than parsing/storing path strings.
  • Expanded ForestSummarizer tests with parameterized scenarios covering repeated-depth and copy-propagation stale-handle cases; adjusted handle-path validation to allow chained handles.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/dds/tree/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts Switches tracking from path strings to parent reference IDs and computes handle paths by walking the latest-summary parent chain.
packages/dds/tree/src/test/feature-libraries/forest-summary/forestSummarizer.spec.ts Adds targeted regression tests for stale handle paths and relaxes validation for chained-handle cases.

@CraigMacomber
Copy link
Copy Markdown
Contributor

This seems like it could impact users, so it should have a changeset.

It seems like this bug could have corrupted documents: we should document in a user facing way (the changeset) what the symptoms of this corruption would be and in what cases they might have occurred. Ideally we should also note how people can recover (I guess just roll back to an earlier version of the document?). Might be worth calling out https://fluidframework.com/docs/api/fluid-framework/#foresttypeexpensivedebug-variable as way to validate a given document is not corrupted such that it's out of schema.

@agarwal-navin agarwal-navin requested a review from a team as a code owner April 10, 2026 21:03
Comment thread .changeset/plain-comics-bake.md Outdated
Comment thread .changeset/plain-comics-bake.md Outdated
Comment thread .changeset/plain-comics-bake.md Outdated
Comment thread .changeset/plain-comics-bake.md Outdated
Comment thread .changeset/plain-comics-bake.md Outdated
Comment thread .changeset/plain-comics-bake.md Outdated
@agarwal-navin
Copy link
Copy Markdown
Contributor Author

This seems like it could impact users, so it should have a changeset.

It seems like this bug could have corrupted documents: we should document in a user facing way (the changeset) what the symptoms of this corruption would be and in what cases they might have occurred. Ideally we should also note how people can recover (I guess just roll back to an earlier version of the document?). Might be worth calling out https://fluidframework.com/docs/api/fluid-framework/#foresttypeexpensivedebug-variable as way to validate a given document is not corrupted such that it's out of schema.

Added a changeset. The document corruption will not happen because an incorrect summary was uploaded because summary upload would fail. What may result in document corruption is multiple falied summaries leading to ops accumulation which can reach a threshold after which service will reject future ops.
As such, I did not mention https://fluidframework.com/docs/api/fluid-framework/#foresttypeexpensivedebug-variable because I don't suppose it's applicable. Please let me know if it still is and I can add it.

@agarwal-navin agarwal-navin changed the title [tree] Fix incremental summary stale handle paths (tree) Fix incremental summary stale handle paths Apr 15, 2026
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.

3 participants