Skip to content

Commit

Permalink
Reduce global checkpoint sync interval in disruption tests (#38931)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dnhatn committed Feb 15, 2019
1 parent 5e60200 commit b14405d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import org.elasticsearch.discovery.zen.FaultDetection;
import org.elasticsearch.discovery.zen.UnicastZenPing;
import org.elasticsearch.discovery.zen.ZenPing;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.test.disruption.NetworkDisruption;
Expand Down Expand Up @@ -66,6 +68,13 @@ protected Settings nodeSettings(int nodeOrdinal) {
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build();
}

@Override
public Settings indexSettings() {
return Settings.builder().put(super.indexSettings())
// sync global checkpoint quickly so we can verify seq_no_stats aligned between all copies after tests.
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s").build();
}

@Override
protected int numberOfShards() {
return 3;
Expand Down Expand Up @@ -132,7 +141,7 @@ List<String> startCluster(int numberOfNodes) {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(MockTransportService.TestPlugin.class);
return Arrays.asList(MockTransportService.TestPlugin.class, InternalSettingsPlugin.class);
}

ClusterState getNodeClusterState(String node) {
Expand Down
15 changes: 10 additions & 5 deletions server/src/test/java/org/elasticsearch/recovery/RelocationIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ protected void beforeIndexDeletion() throws Exception {
internalCluster().assertSameDocIdsOnShards();
}

@Override
public Settings indexSettings() {
return Settings.builder().put(super.indexSettings())
// sync global checkpoint quickly so we can verify seq_no_stats aligned between all copies after tests.
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s").build();
}

public void testSimpleRelocationNoIndexing() {
logger.info("--> starting [node1] ...");
final String node_1 = internalCluster().startNode();
Expand Down Expand Up @@ -264,9 +271,8 @@ public void testRelocationWhileRefreshing() throws Exception {
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", numberOfReplicas)
.put("index.refresh_interval", -1) // we want to control refreshes
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
.get();
// we want to control refreshes
.put("index.refresh_interval", -1)).get();

for (int i = 1; i < numberOfNodes; i++) {
logger.info("--> starting [node_{}] ...", i);
Expand Down Expand Up @@ -442,8 +448,7 @@ public void testIndexAndRelocateConcurrently() throws ExecutionException, Interr
final Settings.Builder settings = Settings.builder()
.put("index.routing.allocation.exclude.color", "blue")
.put(indexSettings())
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1))
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1));
assertAcked(prepareCreate("test", settings));
assertAllShardsOnNodes("test", redNodes);
int numDocs = randomIntBetween(100, 150);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.engine.DocIdSeqNoAndTerm;
import org.elasticsearch.index.seqno.SeqNoStats;
import org.elasticsearch.index.seqno.SequenceNumbers;
Expand All @@ -60,6 +61,7 @@
import org.elasticsearch.tasks.TaskInfo;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource;
import org.elasticsearch.test.TestCluster;
Expand Down Expand Up @@ -125,7 +127,7 @@ public final void startClusters() throws Exception {
stopClusters();
NodeConfigurationSource nodeConfigurationSource = createNodeConfigurationSource();
Collection<Class<? extends Plugin>> mockPlugins = Arrays.asList(ESIntegTestCase.TestSeedPlugin.class,
TestZenDiscovery.TestPlugin.class, getTestTransportPlugin());
TestZenDiscovery.TestPlugin.class, InternalSettingsPlugin.class, getTestTransportPlugin());

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

0 comments on commit b14405d

Please sign in to comment.