mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-10 15:05:33 +00:00
Before, it was possible that the SameShardAllocationDecider would allow force allocation of an unassigned primary to the same node on which an active replica is assigned. This could only happen with shadow replica indices, because when a shadow replica primary fails, the replica gets promoted to primary but in the INITIALIZED state, not in the STARTED state (because the engine has specific reinitialization that must take place in the case of shadow replicas). Therefore, if the now promoted primary that is initializing fails also, the primary will be in the unassigned state, because replica to primary promotion only happens when the failed shard was in the started state. The now unassigned primary shard will go through the allocation deciders, where the SameShardsAllocationDecider would return a NO decision, but would still permit force allocation on the primary if all deciders returned NO. This commit implements canForceAllocatePrimary on the SameShardAllocationDecider, which ensures that a primary cannot be force allocated to the same node on which an active replica already exists.