Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [Segment Replication ]Remove state update of singleIndexWithSegmentReplicationDisabled in TransportSegmentReplicationStatsAction Class #6527

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.opensearch.indices.replication;

import org.opensearch.OpenSearchStatusException;
import org.opensearch.action.admin.indices.replication.SegmentReplicationStatsResponse;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -144,30 +143,4 @@ public void testSegmentReplicationStatsResponseForActiveAndCompletedOnly() throw
waitForAssertions.countDown();
}

public void testSegmentReplicationStatsResponseOnDocumentReplicationIndex() {
final String primaryNode = internalCluster().startNode();
prepareCreate(
INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.DOCUMENT)

).get();
ensureYellowAndNoInitializingShards(INDEX_NAME);
final String replicaNode = internalCluster().startNode();
ensureGreen(INDEX_NAME);

// index 10 docs
for (int i = 0; i < 10; i++) {
client().prepareIndex(INDEX_NAME).setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
refresh(INDEX_NAME);
OpenSearchStatusException exception = assertThrows(
OpenSearchStatusException.class,
() -> client().admin().indices().prepareSegmentReplicationStats(INDEX_NAME).execute().actionGet()
);
// Verify exception message
String expectedMessage = "Segment Replication is not enabled on Index: test-idx-1";
assertEquals(expectedMessage, exception.getMessage());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.opensearch.action.admin.indices.replication;

import org.opensearch.OpenSearchStatusException;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.DefaultShardOperationFailedException;
import org.opensearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
Expand All @@ -27,7 +26,6 @@
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.replication.SegmentReplicationState;
import org.opensearch.indices.replication.SegmentReplicationTargetService;
import org.opensearch.rest.RestStatus;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand All @@ -52,7 +50,6 @@ public class TransportSegmentReplicationStatsAction extends TransportBroadcastBy

private final SegmentReplicationTargetService targetService;
private final IndicesService indicesService;
private String singleIndexWithSegmentReplicationDisabled = null;

@Inject
public TransportSegmentReplicationStatsAction(
Expand Down Expand Up @@ -91,12 +88,6 @@ protected SegmentReplicationStatsResponse newResponse(
List<DefaultShardOperationFailedException> shardFailures,
ClusterState clusterState
) {
// throw exception if API call is made on single index with segment replication disabled.
if (singleIndexWithSegmentReplicationDisabled != null) {
String index = singleIndexWithSegmentReplicationDisabled;
singleIndexWithSegmentReplicationDisabled = null;
throw new OpenSearchStatusException("Segment Replication is not enabled on Index: " + index, RestStatus.BAD_REQUEST);
}
String[] shards = request.shards();
Set<String> set = new HashSet<>();
if (shards.length > 0) {
Expand Down Expand Up @@ -135,11 +126,6 @@ protected SegmentReplicationState shardOperation(SegmentReplicationStatsRequest
IndexShard indexShard = indexService.getShard(shardRouting.shardId().id());
ShardId shardId = shardRouting.shardId();

// check if API call is made on single index with segment replication disabled.
if (request.indices().length == 1 && indexShard.indexSettings().isSegRepEnabled() == false) {
singleIndexWithSegmentReplicationDisabled = shardRouting.getIndexName();
return null;
}
if (indexShard.indexSettings().isSegRepEnabled() == false || shardRouting.primary()) {
return null;
}
Expand Down