Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15676: UpdateLog.RecentUpdates.getVersions to not return duplicate versions (#331)

Christine Poerschkebe2db7216464
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index a51ba148a50..ecdf23e2af2 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1455,10 +1455,18 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
public List<Long> getVersions(int n, long maxVersion) {
List<Long> ret = new ArrayList<>(n);
+ LongSet set = new LongSet(n);
+ final int nInput = n;
for (List<Update> singleList : updateList) {
for (Update ptr : singleList) {
if(Math.abs(ptr.version) > Math.abs(maxVersion)) continue;
+ if (!set.add(ptr.version)) {
+ if (debug) {
+ log.debug("getVersions(n={}, maxVersion={}) not returning duplicate version = {}", nInput, maxVersion, ptr.version);
+ }
+ continue;
+ }
ret.add(ptr.version);
if (--n <= 0) return ret;
}