|
28 | 28 | import org.elasticsearch.cluster.block.ClusterBlockException; |
29 | 29 | import org.elasticsearch.cluster.block.ClusterBlockLevel; |
30 | 30 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
| 31 | +import org.elasticsearch.cluster.metadata.IndexReshardingState; |
31 | 32 | import org.elasticsearch.cluster.metadata.ProjectId; |
32 | 33 | import org.elasticsearch.cluster.metadata.ProjectMetadata; |
33 | 34 | import org.elasticsearch.cluster.node.DiscoveryNode; |
@@ -459,14 +460,22 @@ void runWithPrimaryShardReference(final PrimaryShardReference primaryShardRefere |
459 | 460 | try { |
460 | 461 | final ClusterState clusterState = clusterService.state(); |
461 | 462 | final Index index = primaryShardReference.routingEntry().index(); |
462 | | - final ProjectId projectId = clusterState.metadata().projectFor(index).id(); |
| 463 | + final ProjectMetadata project = clusterState.metadata().projectFor(index); |
| 464 | + final ProjectId projectId = project.id(); |
| 465 | + final IndexMetadata indexMetadata = project.index(index); |
463 | 466 |
|
464 | 467 | final ClusterBlockException blockException = blockExceptions(clusterState, projectId, index.getName()); |
465 | 468 | if (blockException != null) { |
466 | 469 | logger.trace("cluster is blocked, action failed on primary", blockException); |
467 | 470 | throw blockException; |
468 | 471 | } |
469 | 472 |
|
| 473 | + int reshardSplitShardCount = primaryRequest.getRequest().reshardSplitShardCount(); |
| 474 | + assert (reshardSplitShardCount == 0 |
| 475 | + || reshardSplitShardCount == indexMetadata.getReshardSplitShardCount( |
| 476 | + primaryRequest.getRequest().shardId().getId(), |
| 477 | + IndexReshardingState.Split.TargetShardState.HANDOFF |
| 478 | + )); |
470 | 479 | if (primaryShardReference.isRelocated()) { |
471 | 480 | primaryShardReference.close(); // release shard operation lock as soon as possible |
472 | 481 | setPhase(replicationTask, "primary_delegation"); |
|
0 commit comments