forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable shard idle with segment replication. (opensearch-project#4118)
This change disables shard idle when segment replication is enabled. Primary shards will only push out new segments on refresh, we do not want to block this based on search behavior. Replicas will only refresh on an externally provided SegmentInfos, so we do not want search requests to hang waiting for a refresh. Signed-off-by: Marc Handalian <[email protected]>
- Loading branch information
1 parent
6c6e8b6
commit e6acd60
Showing
5 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.shard; | ||
|
||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.index.IndexSettings; | ||
import org.opensearch.index.engine.NRTReplicationEngineFactory; | ||
import org.opensearch.index.replication.OpenSearchIndexLevelReplicationTestCase; | ||
import org.opensearch.indices.replication.common.ReplicationType; | ||
|
||
public class SegmentReplicationIndexShardTests extends OpenSearchIndexLevelReplicationTestCase { | ||
|
||
private static final Settings settings = Settings.builder() | ||
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) | ||
.build(); | ||
|
||
public void testIgnoreShardIdle() throws Exception { | ||
try (ReplicationGroup shards = createGroup(1, settings, new NRTReplicationEngineFactory())) { | ||
shards.startAll(); | ||
final IndexShard primary = shards.getPrimary(); | ||
final IndexShard replica = shards.getReplicas().get(0); | ||
|
||
final int numDocs = shards.indexDocs(randomInt(10)); | ||
primary.refresh("test"); | ||
replicateSegments(primary, shards.getReplicas()); | ||
shards.assertAllEqual(numDocs); | ||
|
||
primary.scheduledRefresh(); | ||
replica.scheduledRefresh(); | ||
|
||
primary.awaitShardSearchActive(b -> assertFalse("A new RefreshListener should not be registered", b)); | ||
replica.awaitShardSearchActive(b -> assertFalse("A new RefreshListener should not be registered", b)); | ||
|
||
// Update the search_idle setting, this will put both shards into search idle. | ||
Settings updatedSettings = Settings.builder() | ||
.put(settings) | ||
.put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), TimeValue.ZERO) | ||
.build(); | ||
primary.indexSettings().getScopedSettings().applySettings(updatedSettings); | ||
replica.indexSettings().getScopedSettings().applySettings(updatedSettings); | ||
|
||
primary.scheduledRefresh(); | ||
replica.scheduledRefresh(); | ||
|
||
// Shards without segrep will register a new RefreshListener on the engine and return true when registered, | ||
// assert with segrep enabled that awaitShardSearchActive does not register a listener. | ||
primary.awaitShardSearchActive(b -> assertFalse("A new RefreshListener should not be registered", b)); | ||
replica.awaitShardSearchActive(b -> assertFalse("A new RefreshListener should not be registered", b)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters