Skip to content

Commit 6ea325c

Browse files
opensearch-trigger-bot[bot]github-actions[bot]dreamer-89
authored
[Segment Replication] Remove codec name string match check for checkpoints (#7741) (#7744)
* Remove codec name string match check for checkpoints * changelog added --------- (cherry picked from commit 89edd55) Signed-off-by: Poojita Raj <poojiraj@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Suraj Singh <surajrider@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Suraj Singh <surajrider@gmail.com>
1 parent bbbe203 commit 6ea325c

File tree

4 files changed

+2
-53
lines changed

4 files changed

+2
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6060
- Moved concurrent-search from sandbox plugin to server module behind feature flag ([#7203](https://github.com/opensearch-project/OpenSearch/pull/7203))
6161
- Allow access to indices cache clear APIs for read only indexes ([#7303](https://github.com/opensearch-project/OpenSearch/pull/7303))
6262
- Default search preference to _primary for searchable snapshot indices ([#7628](https://github.com/opensearch-project/OpenSearch/pull/7628))
63+
- [Segment Replication] Remove codec name string match check for checkpoints ([#7741](https://github.com/opensearch-project/OpenSearch/pull/7741))
6364
- Changed concurrent-search threadpool type to be resizable and support task resource tracking ([#7502](https://github.com/opensearch-project/OpenSearch/pull/7502))
6465

6566
### Deprecated

server/src/main/java/org/opensearch/index/shard/IndexShard.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,12 +1635,6 @@ public final boolean shouldProcessCheckpoint(ReplicationCheckpoint requestCheckp
16351635
);
16361636
return false;
16371637
}
1638-
if (localCheckpoint.getCodec().equals(requestCheckpoint.getCodec()) == false) {
1639-
logger.trace(
1640-
() -> new ParameterizedMessage("Shard does not support the received lucene codec version {}", requestCheckpoint.getCodec())
1641-
);
1642-
return false;
1643-
}
16441638
return true;
16451639
}
16461640

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.opensearch.OpenSearchException;
1515
import org.opensearch.action.ActionListener;
1616
import org.opensearch.cluster.node.DiscoveryNode;
17-
import org.opensearch.common.util.CancellableThreads;
1817
import org.opensearch.common.util.concurrent.ConcurrentCollections;
1918
import org.opensearch.index.IndexService;
2019
import org.opensearch.index.shard.IndexShard;
@@ -148,12 +147,6 @@ void startSegmentCopy(GetSegmentFilesRequest request, ActionListener<GetSegmentF
148147
*/
149148
CopyState prepareForReplication(CheckpointInfoRequest request, FileChunkWriter fileChunkWriter) throws IOException {
150149
final CopyState copyState = getCachedCopyState(request.getCheckpoint());
151-
if (copyState.getCheckpoint().getCodec().equals(request.getCheckpoint().getCodec()) == false) {
152-
logger.trace("Requested unsupported codec version {}", request.getCheckpoint().getCodec());
153-
throw new CancellableThreads.ExecutionCancelledException(
154-
new ParameterizedMessage("Requested unsupported codec version {}", request.getCheckpoint().getCodec()).toString()
155-
);
156-
}
157150
allocationIdToHandlers.compute(request.getTargetAllocationId(), (allocationId, segrepHandler) -> {
158151
if (segrepHandler != null) {
159152
logger.warn("Override handler for allocation id {}", request.getTargetAllocationId());

server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
public class OngoingSegmentReplicationsTests extends IndexShardTestCase {
4949

5050
private final IndicesService mockIndicesService = mock(IndicesService.class);
51-
private ReplicationCheckpoint testCheckpoint, olderCodecTestCheckpoint;
51+
private ReplicationCheckpoint testCheckpoint;
5252
private DiscoveryNode primaryDiscoveryNode;
5353
private DiscoveryNode replicaDiscoveryNode;
5454
private IndexShard primary;
@@ -79,7 +79,6 @@ public void setUp() throws Exception {
7979

8080
// This mirrors the creation of the ReplicationCheckpoint inside CopyState
8181
testCheckpoint = new ReplicationCheckpoint(testShardId, primary.getOperationPrimaryTerm(), 0L, 0L, defaultCodecName);
82-
olderCodecTestCheckpoint = new ReplicationCheckpoint(testShardId, primary.getOperationPrimaryTerm(), 0L, 0L, "Lucene94");
8382
IndexService mockIndexService = mock(IndexService.class);
8483
when(mockIndicesService.indexServiceSafe(testShardId.getIndex())).thenReturn(mockIndexService);
8584
when(mockIndexService.getShard(testShardId.id())).thenReturn(primary);
@@ -94,44 +93,6 @@ public void tearDown() throws Exception {
9493
super.tearDown();
9594
}
9695

97-
public void testSuccessfulCodecCompatibilityCheck() throws Exception {
98-
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
99-
primary.refresh("Test");
100-
OngoingSegmentReplications replications = spy(new OngoingSegmentReplications(mockIndicesService, recoverySettings));
101-
// replica checkpoint is on same/higher lucene codec than primary
102-
final CheckpointInfoRequest request = new CheckpointInfoRequest(
103-
1L,
104-
replica.routingEntry().allocationId().getId(),
105-
replicaDiscoveryNode,
106-
testCheckpoint
107-
);
108-
final FileChunkWriter segmentSegmentFileChunkWriter = (fileMetadata, position, content, lastChunk, totalTranslogOps, listener) -> {
109-
listener.onResponse(null);
110-
};
111-
final CopyState copyState = replications.prepareForReplication(request, segmentSegmentFileChunkWriter);
112-
}
113-
114-
public void testFailCodecCompatibilityCheck() throws Exception {
115-
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
116-
primary.refresh("Test");
117-
OngoingSegmentReplications replications = spy(new OngoingSegmentReplications(mockIndicesService, recoverySettings));
118-
// replica checkpoint is on lower/older lucene codec than primary
119-
final CheckpointInfoRequest request = new CheckpointInfoRequest(
120-
1L,
121-
replica.routingEntry().allocationId().getId(),
122-
replicaDiscoveryNode,
123-
olderCodecTestCheckpoint
124-
);
125-
final FileChunkWriter segmentSegmentFileChunkWriter = (fileMetadata, position, content, lastChunk, totalTranslogOps, listener) -> {
126-
listener.onResponse(null);
127-
};
128-
try {
129-
final CopyState copyState = replications.prepareForReplication(request, segmentSegmentFileChunkWriter);
130-
} catch (CancellableThreads.ExecutionCancelledException ex) {
131-
Assert.assertTrue(ex.getMessage().contains("Requested unsupported codec version"));
132-
}
133-
}
134-
13596
public void testPrepareAndSendSegments() throws IOException {
13697
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
13798
primary.refresh("Test");

0 commit comments

Comments
 (0)