Skip to content

Apache Lucene open-source search software

SOLR-14058: fix peersync bounds check iterating over versions

yonikc3e44e1fecc7
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 86c0e20c749..72a566b3d98 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -153,6 +153,9 @@ Bug Fixes
* SOLR-14038: Admin UI display for "state.json" should be in a scollable region (Kevin Risden)
+* SOLR-14058: Fix IndexOutOfBoundsException in PeerSync that can prevent nodes from recovering
+ under certain circumstances. (yonik)
+
Other Changes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java b/solr/core/src/java/org/apache/solr/update/PeerSync.java
index 801e48f8d42..187a416a455 100644
--- a/solr/core/src/java/org/apache/solr/update/PeerSync.java
+++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java
@@ -753,7 +753,7 @@ public class PeerSync implements SolrMetricProducer {
ourUpdatesIndex--;
} else {
long rangeStart = otherVersions.get(otherUpdatesIndex);
- while ((otherUpdatesIndex < otherVersions.size())
+ while (otherUpdatesIndex >= 0
&& (Math.abs(otherVersions.get(otherUpdatesIndex)) < Math.abs(ourUpdates.get(ourUpdatesIndex)))) {
otherUpdatesIndex--;
totalRequestedVersions++;