Skip to content

Commit 9affe09

Browse files
committed
Fix up committed configuration on fake Zen1 nodes (#40065)
Today we test Zen1/Zen2 compatibility by running 7.x nodes with a "fake" Zen1 implementation. However this is not a truly faithful test because these nodes do known how to properly deserialize a 7.x cluster state, voting configurations and all, whereas a real Zen1 node is in 6.7 and ignores the coordination metadata. We only ever apply a cluster state that's been committed, which in Zen2 involves setting the last-committed configuration to equal the last-accepted configuration. Zen1 knows nothing about this adjustment, so it is possible for these to differ. This breaks the assertion that the cluster states are equal on all nodes after integration tests. This commit fixes this by implementing this adjustment in Zen1 before applying a cluster state. Fixes #40055.
1 parent 38b9329 commit 9affe09

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java

+6
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ private void applyChanges(UpdateTask task, ClusterState previousClusterState, Cl
460460

461461
nodeConnectionsService.disconnectFromNodesExcept(newClusterState.nodes());
462462

463+
assert newClusterState.coordinationMetaData().getLastAcceptedConfiguration()
464+
.equals(newClusterState.coordinationMetaData().getLastCommittedConfiguration())
465+
: newClusterState.coordinationMetaData().getLastAcceptedConfiguration()
466+
+ " vs " + newClusterState.coordinationMetaData().getLastCommittedConfiguration()
467+
+ " on " + newClusterState.nodes().getLocalNode();
468+
463469
logger.debug("set locally applied cluster state to version {}", newClusterState.version());
464470
state.set(newClusterState);
465471

server/src/main/java/org/elasticsearch/discovery/zen/PendingClusterStatesQueue.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.apache.logging.log4j.Logger;
2323
import org.elasticsearch.ElasticsearchException;
2424
import org.elasticsearch.cluster.ClusterState;
25+
import org.elasticsearch.cluster.coordination.CoordinationMetaData;
26+
import org.elasticsearch.cluster.metadata.MetaData;
2527
import org.elasticsearch.cluster.node.DiscoveryNode;
2628

2729
import java.util.ArrayList;
@@ -246,7 +248,16 @@ public synchronized ClusterState getNextClusterStateToProcess() {
246248
}
247249
}
248250
assert stateToProcess.committed() : "should only return committed cluster state. found " + stateToProcess.state;
249-
return stateToProcess.state;
251+
252+
final ClusterState committedState = stateToProcess.state;
253+
final CoordinationMetaData coordinationMetaData = committedState.coordinationMetaData();
254+
if (coordinationMetaData.getLastAcceptedConfiguration().equals(coordinationMetaData.getLastCommittedConfiguration())) {
255+
return committedState;
256+
} else {
257+
return ClusterState.builder(committedState).metaData(MetaData.builder(committedState.metaData())
258+
.coordinationMetaData(CoordinationMetaData.builder(coordinationMetaData)
259+
.lastCommittedConfiguration(committedState.getLastAcceptedConfiguration()).build())).build();
260+
}
250261
}
251262

252263
/** returns all pending states, committed or not */

0 commit comments

Comments
 (0)