Skip to content

Commit

Permalink
enforced check that there is only one allocation id on adding/removin…
Browse files Browse the repository at this point in the history
…g fake allocation id
  • Loading branch information
Vladimir Dolzhenko committed Oct 2, 2018
1 parent 8b697ef commit e331b1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -142,7 +142,8 @@ boolean validate(MetaData metaData) {
if (shardRouting.primary() && shardRouting.initializing() &&
shardRouting.recoverySource().getType() == RecoverySource.Type.EXISTING_STORE &&
inSyncAllocationIds.contains(shardRouting.allocationId().getId()) == false &&
inSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false)
(inSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false
|| inSyncAllocationIds.size() != 1))
throw new IllegalStateException("a primary shard routing " + shardRouting + " is a primary that is recovering from " +
"a known allocation id but has no corresponding entry in the in-sync " +
"allocation set " + inSyncAllocationIds);
Expand Down
Expand Up @@ -177,6 +177,11 @@ private IndexMetaData.Builder updateInSyncAllocations(RoutingTable newRoutingTab
inSyncAllocationIds.addAll(updates.addedAllocationIds);
inSyncAllocationIds.removeAll(updates.removedAllocationIds);

assert oldInSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false
|| inSyncAllocationIds.size() == 1
&& inSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false :
"fake allocation id has to be removed, inSyncAllocationIds:" + inSyncAllocationIds;

// Prevent set of inSyncAllocationIds to grow unboundedly. This can happen for example if we don't write to a primary
// but repeatedly shut down nodes that have active replicas.
// We use number_of_replicas + 1 (= possible active shard copies) to bound the inSyncAllocationIds set
Expand Down

0 comments on commit e331b1f

Please sign in to comment.