mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-18 10:54:54 +00:00
Avoid background sync on relocated primary (#40800)
There were some test failures caused by the background retention lease sync running on a relocated primary. This commit fixes the situation that triggered the assertion and reactivates the failing test. Closes #40731
This commit is contained in:
parent
47a3c42bf2
commit
6ae7d593ea
@ -122,7 +122,6 @@ public class RecoveryIT extends AbstractRollingTestCase {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/40731")
|
|
||||||
public void testRecoveryWithConcurrentIndexing() throws Exception {
|
public void testRecoveryWithConcurrentIndexing() throws Exception {
|
||||||
final String index = "recovery_with_concurrent_indexing";
|
final String index = "recovery_with_concurrent_indexing";
|
||||||
Response response = client().performRequest(new Request("GET", "_nodes"));
|
Response response = client().performRequest(new Request("GET", "_nodes"));
|
||||||
|
@ -830,7 +830,11 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
|
|||||||
case STARTED:
|
case STARTED:
|
||||||
try {
|
try {
|
||||||
shard.runUnderPrimaryPermit(
|
shard.runUnderPrimaryPermit(
|
||||||
() -> sync.accept(shard),
|
() -> {
|
||||||
|
if (shard.isRelocatedPrimary() == false) {
|
||||||
|
sync.accept(shard);
|
||||||
|
}
|
||||||
|
},
|
||||||
e -> {
|
e -> {
|
||||||
if (e instanceof AlreadyClosedException == false
|
if (e instanceof AlreadyClosedException == false
|
||||||
&& e instanceof IndexShardClosedException == false) {
|
&& e instanceof IndexShardClosedException == false) {
|
||||||
|
@ -30,20 +30,28 @@ import org.elasticsearch.cluster.ClusterState;
|
|||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.Priority;
|
import org.elasticsearch.common.Priority;
|
||||||
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.shard.DocsStats;
|
import org.elasticsearch.index.shard.DocsStats;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.translog.Translog;
|
import org.elasticsearch.index.translog.Translog;
|
||||||
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.BackgroundIndexer;
|
import org.elasticsearch.test.BackgroundIndexer;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||||
@ -58,6 +66,23 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTi
|
|||||||
public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
|
public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
|
||||||
private final Logger logger = LogManager.getLogger(RecoveryWhileUnderLoadIT.class);
|
private final Logger logger = LogManager.getLogger(RecoveryWhileUnderLoadIT.class);
|
||||||
|
|
||||||
|
public static final class RetentionLeaseSyncIntervalSettingPlugin extends Plugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Setting<?>> getSettings() {
|
||||||
|
return Collections.singletonList(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
|
return Stream.concat(
|
||||||
|
super.nodePlugins().stream(),
|
||||||
|
Stream.of(RetentionLeaseSyncIntervalSettingPlugin.class))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public void testRecoverWhileUnderLoadAllocateReplicasTest() throws Exception {
|
public void testRecoverWhileUnderLoadAllocateReplicasTest() throws Exception {
|
||||||
logger.info("--> creating test index ...");
|
logger.info("--> creating test index ...");
|
||||||
int numberOfShards = numberOfShards();
|
int numberOfShards = numberOfShards();
|
||||||
@ -260,7 +285,8 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
|
|||||||
assertAcked(prepareCreate("test", 3, Settings.builder()
|
assertAcked(prepareCreate("test", 3, Settings.builder()
|
||||||
.put(SETTING_NUMBER_OF_SHARDS, numShards)
|
.put(SETTING_NUMBER_OF_SHARDS, numShards)
|
||||||
.put(SETTING_NUMBER_OF_REPLICAS, numReplicas)
|
.put(SETTING_NUMBER_OF_REPLICAS, numReplicas)
|
||||||
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)));
|
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
|
||||||
|
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), randomFrom("100ms", "1s", "5s", "30s", "60s"))));
|
||||||
|
|
||||||
final int numDocs = scaledRandomIntBetween(200, 9999);
|
final int numDocs = scaledRandomIntBetween(200, 9999);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user