Skip to content

Commit

Permalink
add assertions that Search Replicas are not in the in-sync id set nor…
Browse files Browse the repository at this point in the history
… the AllAllocationIds set in the routing table

Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 committed Dec 10, 2024
1 parent 8935bc7 commit 55689cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public class IndexShardRoutingTable extends AbstractDiffable<IndexShardRoutingTa
if (shard.assignedToNode()) {
assignedShards.add(shard);
}
assert shard.allocationId() == null || allAllocationIds.contains(shard.allocationId().getId()) == false
: "Search replicas should not be part of the allAllocationId set";
continue;
}
if (shard.relocating()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,8 @@ void openEngineAndSkipTranslogRecovery(boolean syncFromRemote) throws IOExceptio
recoveryState.validateCurrentStage(RecoveryState.Stage.TRANSLOG);
loadGlobalCheckpointToReplicationTracker();
innerOpenEngineAndTranslog(replicationTracker, syncFromRemote);
assert routingEntry().isSearchOnly() == false || translogStats().estimatedNumberOfOperations() == 0
: "Translog is expected to be empty but holds " + translogStats().estimatedNumberOfOperations() + "Operations.";
getEngine().translogManager().skipTranslogRecovery();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ public ReplicationGroup(
this.inSyncAllocationIds = inSyncAllocationIds;
this.trackedAllocationIds = trackedAllocationIds;
this.version = version;

this.unavailableInSyncShards = Sets.difference(inSyncAllocationIds, routingTable.getAllAllocationIds());
this.replicationTargets = new ArrayList<>();
this.skippedShards = new ArrayList<>();
for (final ShardRouting shard : routingTable) {
// search only replicas never receive any replicated operations
if (shard.unassigned() || shard.isSearchOnly()) {
assert shard.primary() == false : "primary shard should not be unassigned in a replication group: " + shard;
skippedShards.add(shard);
if (shard.isSearchOnly()) {
assert shard.allocationId() == null || inSyncAllocationIds.contains(shard.allocationId().getId()) == false
: " Search replicas should not be part of the inSync id set";
}
} else {
if (trackedAllocationIds.contains(shard.allocationId().getId())) {
replicationTargets.add(shard);
Expand Down

0 comments on commit 55689cf

Please sign in to comment.