Skip to content

SOLR-11475: Endless loop and OOM in PeerSync - #5082

Open
nick-boss-tech wants to merge 7 commits into
apache:mainfrom
nick-boss-tech:solr-11475-submit
Open

nick-boss-tech wants to merge 7 commits into
apache:mainfrom
nick-boss-tech:solr-11475-submit

Conversation

@nick-boss-tech

@nick-boss-tech nick-boss-tech commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

https://issues.apache.org/jira/browse/SOLR-11475

What happens today

PeerSync loops forever when both replicas hold the same version with opposite signs.

PeerSync compares its own recent updates with the versions another replica reports. The same version can appear on both sides with opposite signs: an add on one side, a delete on the other. The comparison loop then never moves past that pair. It keeps adding the same range string until memory runs out (loop).

What this change does

The loop steps past a version that appears on both sides with opposite signs.

When the two absolute values match, the loop moves both positions down one step and requests nothing for that pair (new branch). The other branches of the loop are unchanged (loop).

Proof

Five PeerSync test classes pass with this change. A run without the fix is inconclusive, because the old code never ends on this input.

  • Five classes, 1 of 1 each: PeerSyncTest, PeerSyncWithLeaderTest, PeerSyncWithBufferUpdatesTest, PeerSyncWithIndexFingerprintCachingTest, and PeerSyncWithLeaderAndIndexFingerprintCachingTest. Five tests in total, 0 failures.
  • PeerSyncWithLeaderTest declares no test method of its own and runs the test() of PeerSyncTest. PeerSyncWithLeaderAndIndexFingerprintCachingTest runs the test() of PeerSyncWithIndexFingerprintCachingTest, which is a separate class.
  • The new check is testHandleVersionsWithRangesSameVersionDifferentSign. It runs from test() in PeerSyncTest through handleVersionsWithRangesTests(), so it runs in PeerSyncTest and in PeerSyncWithLeaderTest. It runs the walk on a thread and fails if the walk has not ended after 30 seconds.
  • On the code before the fix, this input never ends. So a run cannot show a clean failure. The test comment says so (comment).
  • Verified 2026-10-08 at this head.

A choice to check

The loop steps over the pair and does not request it.

The other route requests the other side's version of that update, so this replica fetches it. This branch steps over the pair instead. The cost is that this replica does not fetch the other side's version through this walk.

Was stepping over the pair the right call, or should the other side's version be requested?

Limits

The check calls the PeerSync helper directly, with one set of versions.

  • It does not run a peer sync between nodes. A follow-up submission is planned for a test that runs a peer sync between nodes.
  • The test covers one set of versions, run with both settings of the complete-list flag. Other arrangements of a same-version pair are not tested. A follow-up submission is planned to cover those arrangements.

Changelog: changelog/unreleased/SOLR-11475-peersync-version-ranges-loop.yml

AI assistance

AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution.

…n with opposite signs

Hypothetical, unrun regression test; see SOLR-11475-TESTING.md.
With the version pair as the only entries, the walk reaches the range
branch with otherUpdatesIndex at the end of the other list, and the old
code fails on an index error instead of looping. Surrounding the pair
with matching versions above and below makes the pre-fix failure the
documented endless loop appending ranges until it runs out of memory.
Assertions are unchanged.
…nly behavior

The comment said the old code fails on an index error instead of looping
when the sign-mismatched pair is the only entry. Tracing the base loop
shows it loops endlessly there too, adding the same range string on
every pass until memory runs out.
@nick-boss-tech
nick-boss-tech marked this pull request as ready for review October 9, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant