Skip to content

Commit b14405d

Browse files
committed
Reduce global checkpoint sync interval in disruption tests (#38931)
We verify seq_no_stats is aligned between copies at the end of some disruption tests. Sometimes, the assertion `assertSeqNos` is tripped due to a lagged global checkpoint on replicas. The global checkpoint on replicas is lagged because we sync the global checkpoint 30 seconds (by default) after the last replication operation. This change reduces the global checkpoint sync-internal to 1s in the disruption tests. Closes #38318 Closes #36789
1 parent 5e60200 commit b14405d

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
import org.elasticsearch.discovery.zen.FaultDetection;
3030
import org.elasticsearch.discovery.zen.UnicastZenPing;
3131
import org.elasticsearch.discovery.zen.ZenPing;
32+
import org.elasticsearch.index.IndexService;
3233
import org.elasticsearch.plugins.Plugin;
3334
import org.elasticsearch.test.ESIntegTestCase;
35+
import org.elasticsearch.test.InternalSettingsPlugin;
3436
import org.elasticsearch.test.InternalTestCluster;
3537
import org.elasticsearch.test.discovery.TestZenDiscovery;
3638
import org.elasticsearch.test.disruption.NetworkDisruption;
@@ -66,6 +68,13 @@ protected Settings nodeSettings(int nodeOrdinal) {
6668
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build();
6769
}
6870

71+
@Override
72+
public Settings indexSettings() {
73+
return Settings.builder().put(super.indexSettings())
74+
// sync global checkpoint quickly so we can verify seq_no_stats aligned between all copies after tests.
75+
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s").build();
76+
}
77+
6978
@Override
7079
protected int numberOfShards() {
7180
return 3;
@@ -132,7 +141,7 @@ List<String> startCluster(int numberOfNodes) {
132141

133142
@Override
134143
protected Collection<Class<? extends Plugin>> nodePlugins() {
135-
return Arrays.asList(MockTransportService.TestPlugin.class);
144+
return Arrays.asList(MockTransportService.TestPlugin.class, InternalSettingsPlugin.class);
136145
}
137146

138147
ClusterState getNodeClusterState(String node) {

server/src/test/java/org/elasticsearch/recovery/RelocationIT.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ protected void beforeIndexDeletion() throws Exception {
106106
internalCluster().assertSameDocIdsOnShards();
107107
}
108108

109+
@Override
110+
public Settings indexSettings() {
111+
return Settings.builder().put(super.indexSettings())
112+
// sync global checkpoint quickly so we can verify seq_no_stats aligned between all copies after tests.
113+
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s").build();
114+
}
115+
109116
public void testSimpleRelocationNoIndexing() {
110117
logger.info("--> starting [node1] ...");
111118
final String node_1 = internalCluster().startNode();
@@ -264,9 +271,8 @@ public void testRelocationWhileRefreshing() throws Exception {
264271
Settings.builder()
265272
.put("index.number_of_shards", 1)
266273
.put("index.number_of_replicas", numberOfReplicas)
267-
.put("index.refresh_interval", -1) // we want to control refreshes
268-
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
269-
.get();
274+
// we want to control refreshes
275+
.put("index.refresh_interval", -1)).get();
270276

271277
for (int i = 1; i < numberOfNodes; i++) {
272278
logger.info("--> starting [node_{}] ...", i);
@@ -442,8 +448,7 @@ public void testIndexAndRelocateConcurrently() throws ExecutionException, Interr
442448
final Settings.Builder settings = Settings.builder()
443449
.put("index.routing.allocation.exclude.color", "blue")
444450
.put(indexSettings())
445-
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1))
446-
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
451+
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1));
447452
assertAcked(prepareCreate("test", settings));
448453
assertAllShardsOnNodes("test", redNodes);
449454
int numDocs = randomIntBetween(100, 150);

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.core.internal.io.IOUtils;
4444
import org.elasticsearch.env.NodeEnvironment;
4545
import org.elasticsearch.index.Index;
46+
import org.elasticsearch.index.IndexService;
4647
import org.elasticsearch.index.engine.DocIdSeqNoAndTerm;
4748
import org.elasticsearch.index.seqno.SeqNoStats;
4849
import org.elasticsearch.index.seqno.SequenceNumbers;
@@ -60,6 +61,7 @@
6061
import org.elasticsearch.tasks.TaskInfo;
6162
import org.elasticsearch.test.ESIntegTestCase;
6263
import org.elasticsearch.test.ESTestCase;
64+
import org.elasticsearch.test.InternalSettingsPlugin;
6365
import org.elasticsearch.test.InternalTestCluster;
6466
import org.elasticsearch.test.NodeConfigurationSource;
6567
import org.elasticsearch.test.TestCluster;
@@ -125,7 +127,7 @@ public final void startClusters() throws Exception {
125127
stopClusters();
126128
NodeConfigurationSource nodeConfigurationSource = createNodeConfigurationSource();
127129
Collection<Class<? extends Plugin>> mockPlugins = Arrays.asList(ESIntegTestCase.TestSeedPlugin.class,
128-
TestZenDiscovery.TestPlugin.class, getTestTransportPlugin());
130+
TestZenDiscovery.TestPlugin.class, InternalSettingsPlugin.class, getTestTransportPlugin());
129131

130132
InternalTestCluster leaderCluster = new InternalTestCluster(randomLong(), createTempDir(), true, true, numberOfNodesPerCluster(),
131133
numberOfNodesPerCluster(), UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 0, false, "leader", mockPlugins,
@@ -382,6 +384,7 @@ protected String getIndexSettings(final int numberOfShards, final int numberOfRe
382384
builder.startObject("settings");
383385
{
384386
builder.field(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0);
387+
builder.field(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s");
385388
builder.field("index.number_of_shards", numberOfShards);
386389
builder.field("index.number_of_replicas", numberOfReplicas);
387390
for (final Map.Entry<String, String> additionalSetting : additionalIndexSettings.entrySet()) {

0 commit comments

Comments
 (0)