Skip to content

Commit

Permalink
fixed assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Oct 15, 2021
1 parent a9084c5 commit bbd4276
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1587,9 +1587,7 @@ public Metadata build(boolean builtIndicesLookupEagerly) {

SortedMap<String, IndexAbstraction> indicesLookup;
if (previousIndicesLookup != null) {
// Can't compare the values, because IndexMetadata uses IndexMetadata, which are allowed to be updated.
// TODO: change IndexAbstraction's getIndices() and getWriteIndex() methods to return String instead of IndexMetadata
assert previousIndicesLookup.keySet().equals(buildIndicesLookup(dataStreamMetadata, indices).keySet());
assert previousIndicesLookup.equals(buildIndicesLookup(dataStreamMetadata, indices));
indicesLookup = previousIndicesLookup;
} else {
if (builtIndicesLookupEagerly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.cluster.ClusterStateTaskListener;
import org.elasticsearch.cluster.coordination.ClusterStatePublisher;
import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException;
import org.elasticsearch.cluster.metadata.IndexAbstraction;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -52,6 +53,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
Expand Down Expand Up @@ -368,6 +370,7 @@ private ClusterState patchVersions(ClusterState previousClusterState, ClusterTas

if (previousClusterState != newClusterState) {
// only the master controls the version numbers
final var previousIndicesLookup = newClusterState.metadata().getIndicesLookup();
Builder builder = incrementVersion(newClusterState);
if (previousClusterState.routingTable() != newClusterState.routingTable()) {
builder.routingTable(RoutingTable.builder(newClusterState.routingTable())
Expand All @@ -378,9 +381,9 @@ private ClusterState patchVersions(ClusterState previousClusterState, ClusterTas
}

newClusterState = builder.build();
assert previousIndicesLookup == newClusterState.metadata().getIndicesLookup();
}

assert previousClusterState.metadata().getIndicesLookup() == newClusterState.metadata().getIndicesLookup();
return newClusterState;
}

Expand Down

0 comments on commit bbd4276

Please sign in to comment.