Keep a shadow replicas' allocation id when it is promoted to primary (#20863)

Shadow replicas can not be simply promoted to primary by updating boolean like normal shards. Instead the are reinitialized and shut down and rebuilt as primaries. Currently we also given them new allocation ids but that throws off the in-sync allocation ids management. This commit changes this behavior to keep the allocation id of the shard.

Closes #20650
This commit is contained in:
Boaz Leskes 2016-10-11 17:57:15 +02:00 committed by GitHub
parent bbf6e6d0bd
commit c6e1ef54f9
3 changed files with 2 additions and 7 deletions

View File

@ -390,7 +390,7 @@ public final class ShardRouting implements Writeable, ToXContent {
assert primary : this;
return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING,
StoreRecoverySource.EXISTING_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.REINITIALIZED, null),
AllocationId.newInitializing(), UNAVAILABLE_EXPECTED_SHARD_SIZE);
allocationId, UNAVAILABLE_EXPECTED_SHARD_SIZE);
}
/**

View File

@ -93,11 +93,6 @@ public class IndexMetaDataUpdater extends RoutingChangesObserver.AbstractRouting
removeAllocationId(removedRelocationSource);
}
@Override
public void startedPrimaryReinitialized(ShardRouting startedPrimaryShard, ShardRouting initializedShard) {
removeAllocationId(startedPrimaryShard);
}
/**
* Updates the current {@link MetaData} based on the changes of this RoutingChangesObserver. Specifically
* we update {@link IndexMetaData#getInSyncAllocationIds()} and {@link IndexMetaData#primaryTerm(int)} based on

View File

@ -122,7 +122,7 @@ public class AllocationIdTests extends ESTestCase {
shard = shard.reinitializePrimaryShard();
assertThat(shard.allocationId().getId(), notNullValue());
assertThat(shard.allocationId().getRelocationId(), nullValue());
assertThat(shard.allocationId().getId(), not(equalTo(allocationId.getId())));
assertThat(shard.allocationId().getId(), equalTo(allocationId.getId()));
}
public void testSerialization() throws IOException {