Skip to content

Commit 1e9ec52

Browse files
[Segment Replication] Fix Flaky test SegmentReplicationRelocationIT.testPrimaryRelocation (#10701)
* Add primary mode check before assserting on primary mode. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * remove unnecessary shardRouting check. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Add test logging. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Addressing comments on PR. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> --------- Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
1 parent 4f8bcff commit 1e9ec52

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationRelocationIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.opensearch.index.shard.IndexShard;
2727
import org.opensearch.indices.IndicesService;
2828
import org.opensearch.test.OpenSearchIntegTestCase;
29+
import org.opensearch.test.junit.annotations.TestLogging;
2930
import org.opensearch.test.transport.MockTransportService;
3031
import org.opensearch.transport.TransportService;
3132

@@ -55,6 +56,7 @@ private void createIndex(int replicaCount) {
5556
* This test verifies happy path when primary shard is relocated newly added node (target) in the cluster. Before
5657
* relocation and after relocation documents are indexed and documents are verified
5758
*/
59+
@TestLogging(reason = "Getting trace logs from replication,shard and allocation package", value = "org.opensearch.indices.replication:TRACE, org.opensearch.index.shard:TRACE, org.opensearch.cluster.routing.allocation:TRACE")
5860
public void testPrimaryRelocation() throws Exception {
5961
final String oldPrimary = internalCluster().startNode();
6062
createIndex(1);

server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSourceHandler.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.opensearch.OpenSearchException;
1313
import org.opensearch.action.StepListener;
1414
import org.opensearch.cluster.node.DiscoveryNode;
15-
import org.opensearch.cluster.routing.IndexShardRoutingTable;
16-
import org.opensearch.cluster.routing.ShardRouting;
1715
import org.opensearch.common.logging.Loggers;
1816
import org.opensearch.common.util.CancellableThreads;
1917
import org.opensearch.common.util.concurrent.ListenableFuture;
@@ -22,7 +20,6 @@
2220
import org.opensearch.core.action.ActionListener;
2321
import org.opensearch.index.shard.IndexShard;
2422
import org.opensearch.index.store.StoreFileMetadata;
25-
import org.opensearch.indices.recovery.DelayRecoveryException;
2623
import org.opensearch.indices.recovery.FileChunkWriter;
2724
import org.opensearch.indices.recovery.MultiChunkTransfer;
2825
import org.opensearch.indices.replication.common.CopyState;
@@ -146,12 +143,6 @@ public synchronized void sendFiles(GetSegmentFilesRequest request, ActionListene
146143
);
147144
};
148145
cancellableThreads.checkForCancel();
149-
final IndexShardRoutingTable routingTable = shard.getReplicationGroup().getRoutingTable();
150-
ShardRouting targetShardRouting = routingTable.getByAllocationId(request.getTargetAllocationId());
151-
if (targetShardRouting == null) {
152-
logger.debug("delaying replication of {} as it is not listed as assigned to target node {}", shard.shardId(), targetNode);
153-
throw new DelayRecoveryException("source node does not have the shard listed in its state as allocated on the node");
154-
}
155146

156147
final StepListener<Void> sendFileStep = new StepListener<>();
157148
Set<String> storeFiles = new HashSet<>(Arrays.asList(shard.store().directory().listAll()));

0 commit comments

Comments
 (0)