Skip to content

Commit a3d2310

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 71aaa91 commit a3d2310

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-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
@@ -110,6 +110,13 @@ protected void beforeIndexDeletion() throws Exception {
110110
internalCluster().assertSameDocIdsOnShards();
111111
}
112112

113+
@Override
114+
public Settings indexSettings() {
115+
return Settings.builder().put(super.indexSettings())
116+
// sync global checkpoint quickly so we can verify seq_no_stats aligned between all copies after tests.
117+
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s").build();
118+
}
119+
113120
public void testSimpleRelocationNoIndexing() {
114121
logger.info("--> starting [node1] ...");
115122
final String node_1 = internalCluster().startNode();
@@ -278,9 +285,8 @@ public void testRelocationWhileRefreshing() throws Exception {
278285
Settings.builder()
279286
.put("index.number_of_shards", 1)
280287
.put("index.number_of_replicas", numberOfReplicas)
281-
.put("index.refresh_interval", -1) // we want to control refreshes
282-
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
283-
.get();
288+
// we want to control refreshes
289+
.put("index.refresh_interval", -1)).get();
284290

285291
for (int i = 1; i < numberOfNodes; i++) {
286292
logger.info("--> starting [node_{}] ...", i);
@@ -465,8 +471,7 @@ public void testIndexAndRelocateConcurrently() throws ExecutionException, Interr
465471
final Settings.Builder settings = Settings.builder()
466472
.put("index.routing.allocation.exclude.color", "blue")
467473
.put(indexSettings())
468-
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1))
469-
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
474+
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1));
470475
assertAcked(prepareCreate("test", settings));
471476
assertAllShardsOnNodes("test", redNodes);
472477
int numDocs = randomIntBetween(100, 150);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.elasticsearch.core.internal.io.IOUtils;
4343
import org.elasticsearch.env.NodeEnvironment;
4444
import org.elasticsearch.index.Index;
45+
import org.elasticsearch.index.IndexService;
4546
import org.elasticsearch.index.engine.DocIdSeqNoAndTerm;
4647
import org.elasticsearch.index.query.QueryBuilders;
4748
import org.elasticsearch.index.seqno.SeqNoStats;
@@ -61,6 +62,7 @@
6162
import org.elasticsearch.test.BackgroundIndexer;
6263
import org.elasticsearch.test.ESIntegTestCase;
6364
import org.elasticsearch.test.ESTestCase;
65+
import org.elasticsearch.test.InternalSettingsPlugin;
6466
import org.elasticsearch.test.InternalTestCluster;
6567
import org.elasticsearch.test.NodeConfigurationSource;
6668
import org.elasticsearch.test.TestCluster;
@@ -127,7 +129,8 @@ public final void startClusters() throws Exception {
127129

128130
stopClusters();
129131
Collection<Class<? extends Plugin>> mockPlugins = Arrays.asList(ESIntegTestCase.TestSeedPlugin.class,
130-
TestZenDiscovery.TestPlugin.class, getTestTransportPlugin(), MockTransportService.TestPlugin.class);
132+
TestZenDiscovery.TestPlugin.class, InternalSettingsPlugin.class, MockTransportService.TestPlugin.class,
133+
getTestTransportPlugin());
131134

132135
InternalTestCluster leaderCluster = new InternalTestCluster(randomLong(), createTempDir(), true, true, numberOfNodesPerCluster(),
133136
numberOfNodesPerCluster(), "leader_cluster", createNodeConfigurationSource(null), 0, false, "leader",
@@ -393,6 +396,7 @@ protected String getIndexSettings(final int numberOfShards, final int numberOfRe
393396
builder.startObject("settings");
394397
{
395398
builder.field(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0);
399+
builder.field(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s");
396400
builder.field("index.number_of_shards", numberOfShards);
397401
builder.field("index.number_of_replicas", numberOfReplicas);
398402
for (final Map.Entry<String, String> additionalSetting : additionalIndexSettings.entrySet()) {

0 commit comments

Comments
 (0)