Repository navigation
Fix stale cached match count in AbstractTextSearchResult - #4453
Merged
vogella merged 1 commit intoOct 9, 2026
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Partial exceptional removals can retain stale counts, and the regression test does not deterministically reproduce the race.
2 open findings
What changed in this PR
Fixes stale cached match counts during concurrent search-result updates.
Changes:
- Tags cached counts with a modification counter.
- Invalidates counts after add/remove operations.
- Adds a concurrent regression test and registers it in the suite.
| File | Description |
|---|---|
AbstractTextSearchResult.java |
Reworks match-count cache invalidation. |
AbstractTextSearchResultMatchCountTest.java |
Adds concurrent-add regression coverage. |
AllSearchTests.java |
Registers the new test. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
getMatchCount() cached its sum using 0 as "invalid" and writers reset it with set(0) before mutating. A reader that started summing while matches were still being added, for example the Search view updating its label on the UI thread during a forked foreground search, could publish an undercount through compareAndSet(0, n), because it cannot see that writers kept storing 0. The stale value survived until the next change, which made TextSearchResultTest.testBatchRemoveElements and ResultUpdaterTest.testRemoveFile flaky. The cache is now tagged with a modification counter that writers bump after mutating, and a cached value is only used while the counter is unchanged. Assisted-by: multiple AI agents and layers of automated tooling 🤖
vogella
force-pushed
the
lv/flaky-textsearchresulttest
branch
from
October 8, 2026 07:39
2e86171 to
01248cd
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The concurrency fix correctly prevents completed mutations from leaving a reusable stale count, with focused regression coverage.
0 open findings
2 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Contributor
Author
|
@iloveeclipse fine for you now? |
Contributor
iloveeclipse
approved these changes
Oct 8, 2026
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.

ResultUpdaterTest.testRemoveFile (
expected: <792> but was: <887>) and TextSearchResultTest.testBatchRemoveElements keep failing intermittently on Windows CI, even after #4343. The cause is in AbstractTextSearchResult.getMatchCount(): its cache used 0 as "invalid", so a reader summing while matches were still being added, such as the Search view during a foreground search, could publish an undercount that stayed cached until the next change. The cache is now tagged with a modification counter and only reused while that counter is unchanged, which keeps the cheap cached path but can no longer return a stale count. A new regression test reads the count concurrently with adds and fails on the old implementation.