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

[Segment Replication] Remove codec name string match check for checkp… #7786

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- OpenJDK Update (April 2023 Patch releases) ([#7448](https://github.com/opensearch-project/OpenSearch/pull/7448)

### Changed
- [Segment Replication] Remove codec name string match check for checkpoints ([#7741](https://github.com/opensearch-project/OpenSearch/pull/7741))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1623,12 +1623,6 @@ public final boolean shouldProcessCheckpoint(ReplicationCheckpoint requestCheckp
);
return false;
}
if (localCheckpoint.getCodec().equals(requestCheckpoint.getCodec()) == false) {
logger.trace(
() -> new ParameterizedMessage("Shard does not support the received lucene codec version {}", requestCheckpoint.getCodec())
);
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.opensearch.OpenSearchException;
import org.opensearch.action.ActionListener;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.util.CancellableThreads;
import org.opensearch.common.util.concurrent.ConcurrentCollections;
import org.opensearch.index.IndexService;
import org.opensearch.index.shard.IndexShard;
Expand Down Expand Up @@ -148,12 +147,6 @@ void startSegmentCopy(GetSegmentFilesRequest request, ActionListener<GetSegmentF
*/
CopyState prepareForReplication(CheckpointInfoRequest request, FileChunkWriter fileChunkWriter) throws IOException {
final CopyState copyState = getCachedCopyState(request.getCheckpoint());
if (copyState.getCheckpoint().getCodec().equals(request.getCheckpoint().getCodec()) == false) {
logger.trace("Requested unsupported codec version {}", request.getCheckpoint().getCodec());
throw new CancellableThreads.ExecutionCancelledException(
new ParameterizedMessage("Requested unsupported codec version {}", request.getCheckpoint().getCodec()).toString()
);
}
allocationIdToHandlers.compute(request.getTargetAllocationId(), (allocationId, segrepHandler) -> {
if (segrepHandler != null) {
logger.warn("Override handler for allocation id {}", request.getTargetAllocationId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class OngoingSegmentReplicationsTests extends IndexShardTestCase {

private final IndicesService mockIndicesService = mock(IndicesService.class);
private ReplicationCheckpoint testCheckpoint, olderCodecTestCheckpoint;
private ReplicationCheckpoint testCheckpoint;
private DiscoveryNode primaryDiscoveryNode;
private DiscoveryNode replicaDiscoveryNode;
private IndexShard primary;
Expand Down Expand Up @@ -79,7 +79,6 @@ public void setUp() throws Exception {

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

public void testSuccessfulCodecCompatibilityCheck() throws Exception {
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
primary.refresh("Test");
OngoingSegmentReplications replications = spy(new OngoingSegmentReplications(mockIndicesService, recoverySettings));
// replica checkpoint is on same/higher lucene codec than primary
final CheckpointInfoRequest request = new CheckpointInfoRequest(
1L,
replica.routingEntry().allocationId().getId(),
replicaDiscoveryNode,
testCheckpoint
);
final FileChunkWriter segmentSegmentFileChunkWriter = (fileMetadata, position, content, lastChunk, totalTranslogOps, listener) -> {
listener.onResponse(null);
};
final CopyState copyState = replications.prepareForReplication(request, segmentSegmentFileChunkWriter);
}

public void testFailCodecCompatibilityCheck() throws Exception {
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
primary.refresh("Test");
OngoingSegmentReplications replications = spy(new OngoingSegmentReplications(mockIndicesService, recoverySettings));
// replica checkpoint is on lower/older lucene codec than primary
final CheckpointInfoRequest request = new CheckpointInfoRequest(
1L,
replica.routingEntry().allocationId().getId(),
replicaDiscoveryNode,
olderCodecTestCheckpoint
);
final FileChunkWriter segmentSegmentFileChunkWriter = (fileMetadata, position, content, lastChunk, totalTranslogOps, listener) -> {
listener.onResponse(null);
};
try {
final CopyState copyState = replications.prepareForReplication(request, segmentSegmentFileChunkWriter);
} catch (CancellableThreads.ExecutionCancelledException ex) {
Assert.assertTrue(ex.getMessage().contains("Requested unsupported codec version"));
}
}

public void testPrepareAndSendSegments() throws IOException {
indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar");
primary.refresh("Test");
Expand Down