Repository navigation
fix(nbstore): accumulate overlapping doc priority requests - #15595
darkskygit merged 2 commits into
Conversation
`DocFrontend.addPriority` and `IndexerSyncStatus.addPriority` overwrite `prioritySettings` with the incoming priority instead of adding it to the value already stored, while the release callback they return subtracts. When two holders prioritize the same doc, releasing one of them drops the doc to zero instead of back to the other holder's level. `DocSyncPeer.addPriority` was a third copy of the same code and was fixed in toeverything#15338; these two were missed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change makes priority updates cumulative in ChangesPriority accumulation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Priority requests remain accumulated while other holders are active, with coverage for document loading and indexer crawl ordering. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 79598393-d413-4136-af68-23f589c6b3a5
📒 Files selected for processing (3)
packages/common/nbstore/src/__tests__/frontend.spec.tspackages/common/nbstore/src/frontend/doc.tspackages/common/nbstore/src/sync/indexer/index.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The existing case goes through DocFrontend with DocSyncImpl.dummy, so IndexerSyncStatus.addPriority was never executed. This one drives IndexerSyncImpl: two holders take +10 on the same doc while the loop is held inside the root doc crawl, one of them releases, and the crawl order shows the doc still outranks a +5 neighbour instead of falling back to 0.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #15595 +/- ##
==========================================
+ Coverage 54.36% 54.41% +0.05%
==========================================
Files 4004 4004
Lines 191872 191876 +4
Branches 30920 30923 +3
==========================================
+ Hits 104306 104411 +105
+ Misses 83690 83352 -338
- Partials 3876 4113 +237
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
While reading
DocSyncPeer.addPriorityI noticed the fix from #15338 (commitcd6593c6) was applied to only one of the three near-identical copies of that method innbstore. The two others still carry the pre-#15338 code:DocFrontend.addPriority—packages/common/nbstore/src/frontend/doc.tsIndexerSyncStatus.addPriority—packages/common/nbstore/src/sync/indexer/index.tsBoth write the incoming priority over whatever was stored:
The two lines already disagree with each other, and the release callback returned by the method subtracts
priorityfrom the current value, so it only makes sense if the forward path adds. The result is that overlapping priority requests for the same doc don't stack, and releasing one of them drops the doc to zero instead of back to the level the remaining holder asked for.That overlap is reachable from the UI.
WorkspaceEngine.docis aDocFrontend(entities/engine.ts→client.docFrontend), and two call sites add +10 to the samepageId:detail-page-wrapper.tsxandpeek-view/view/utils.ts. Open a doc, peek the same doc, close the peek view, and the still-open doc is left at priority 0 — behind every other queued doc. The indexer has the same pair: the navigation panel node and the doc-summary store both add +10 to the samedocId.The fix is the same shape as #15338 — compute
newPriority/restoredPriorityonce and use it for both the map and the queue.Test
doc priority requests accumulateinpackages/common/nbstore/src/__tests__/frontend.spec.ts. Two holders take +10 onhighand one of them releases;lowsits at +5; both load jobs are queued beforestart()so the queue priority alone decides the load order, which the test reads by spying onstorage.getDoc.On
canaryit fails:With the fix, the whole package is green (
yarn vitest run packages/common/nbstore: 16 files, 86 tests).Checklist
canarybranch and its title follows Conventional Commitsyarn lintandyarn typecheckpass locallyAI tools used
Summary by CodeRabbit
Bug Fixes
Tests