소스 검색

Assert primary indexing requires started shard (#96704)

Strengthen the assertion for when we can index into a shard to include
that the shard is started.
Henning Andersen 2 년 전
부모
커밋
60acb88cc1
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

+ 6 - 0
server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

@@ -2145,6 +2145,12 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
         } else {
             if (origin == Engine.Operation.Origin.PRIMARY) {
                 assert assertPrimaryMode();
+                // We only do indexing into primaries that are started since:
+                // * TransportReplicationAction.ReroutePhase only allows to index into active primaries.
+                // * A relocation will retry the reroute phase.
+                // * Allocation ids protect against spurious requests towards old allocations.
+                // * We apply the cluster state on IndexShard instances before making it available for routing
+                assert state == IndexShardState.STARTED : "must be started to do primary indexing";
             } else if (origin == Engine.Operation.Origin.REPLICA) {
                 assert assertReplicationTarget();
             } else {