Skip to content

Commit

Permalink
ReindexDataStreamIndex bug in assertion caused by reference equality (#…
Browse files Browse the repository at this point in the history
…121325) (#121414)

Assertion was using reference equality on two boxed longs. So assertion could produce false positives. Change to Objects.equals to check value and avoid null check.

(cherry picked from commit eeb745c)
  • Loading branch information
parkertimmins authored Jan 31, 2025
1 parent e68edcd commit 1df7f45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog/121325.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 121325
summary: '`ReindexDataStreamIndex` bug in assertion caused by reference equality'
area: Data streams
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

import java.util.Locale;
import java.util.Map;
import java.util.Objects;

import static org.elasticsearch.cluster.metadata.IndexMetadata.APIBlock.WRITE;

Expand Down Expand Up @@ -372,7 +373,7 @@ private void sanityCheck(
listener.delegateFailureAndWrap((delegate, ignored) -> {
getIndexDocCount(sourceIndexName, parentTaskId, delegate.delegateFailureAndWrap((delegate1, sourceCount) -> {
getIndexDocCount(destIndexName, parentTaskId, delegate1.delegateFailureAndWrap((delegate2, destCount) -> {
assert sourceCount == destCount
assert Objects.equals(sourceCount, destCount)
: String.format(
Locale.ROOT,
"source index [%s] has %d docs and dest [%s] has %d docs",
Expand Down

0 comments on commit 1df7f45

Please sign in to comment.