`IndexMetadataUpdater.applyChanges` asserts the indices lookup for the old and new metadata is the same instance. Somehow this assertion does not always hold.

**Build scan:**
https://gradle-enterprise.elastic.co/s/kbk2xlunkwkfu/tests/:server:internalClusterTest/org.elasticsearch.aliases.IndexAliasesIT/testGetAllAliasesWorks

**Reproduction line:**
`./gradlew ':server:internalClusterTest' --tests "org.elasticsearch.aliases.IndexAliasesIT.testGetAllAliasesWorks" -Dtests.seed=2C9E27B978B87A4E -Dtests.locale=ja-JP -Dtests.timezone=America/Cancun -Druntime.java=17`

**Applicable branches:**
master

**Reproduces locally?:**
No

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.aliases.IndexAliasesIT&tests.test=testGetAllAliasesWorks

**Failure excerpt:**
```
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=783, name=elasticsearch[node_s0][masterService#updateTask][T#1], state=RUNNABLE, group=TGRP-IndexAliasesIT]

  at __randomizedtesting.SeedInfo.seed([2C9E27B978B87A4E:7B9FD0D51559F652]:0)

  Caused by: java.lang.AssertionError: (No message provided)

    at __randomizedtesting.SeedInfo.seed([2C9E27B978B87A4E]:0)
    at org.elasticsearch.cluster.routing.allocation.IndexMetadataUpdater.applyChanges(IndexMetadataUpdater.java:134)
    at org.elasticsearch.cluster.routing.allocation.RoutingAllocation.updateMetadataWithRoutingChanges(RoutingAllocation.java:274)
    at org.elasticsearch.cluster.routing.allocation.AllocationService.buildResultAndLogHealthChange(AllocationService.java:150)
    at org.elasticsearch.cluster.routing.allocation.AllocationService.applyStartedShards(AllocationService.java:143)
    at org.elasticsearch.cluster.action.shard.ShardStateAction$ShardStartedClusterStateTaskExecutor.execute(ShardStateAction.java:734)
    at org.elasticsearch.cluster.service.MasterService.innerExecuteTasks(MasterService.java:901)
    at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:871)
    at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:253)
    at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:153)
    at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:114)
    at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:170)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:714)
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:260)
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:223)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:833)

```
server/src/main/java/org/elasticsearch/cluster/routing/allocation/IndexMetadataUpdater.java
assert oldInSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false
                || inSyncAllocationIds.contains(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID) == false
                : "fake allocation id has to be removed, inSyncAllocationIds:" + inSyncAllocationIds;
            
            
            
            
            
            int maxActiveShards = oldIndexMetadata.getNumberOfReplicas() + 1; 
            IndexShardRoutingTable newShardRoutingTable = newRoutingTable.shardRoutingTable(shardId);
            assert newShardRoutingTable.assignedShards()
                .stream()
                .filter(ShardRouting::isRelocationTarget)
                .map(s -> s.allocationId().getId())
                .noneMatch(inSyncAllocationIds::contains) : newShardRoutingTable.assignedShards() + " vs " + inSyncAllocationIds;
            if (inSyncAllocationIds.size() > oldInSyncAllocationIds.size() && inSyncAllocationIds.size() > maxActiveShards) {
                
                List<ShardRouting> assignedShards = newShardRoutingTable.assignedShards()
                    .stream()
                    .filter(s -> s.isRelocationTarget() == false)
                    .toList();
                assert assignedShards.size() <= maxActiveShards
                    : "cannot have more assigned shards " + assignedShards + " than maximum possible active shards " + maxActiveShards;
                Set<String> assignedAllocations = assignedShards.stream().map(s -> s.allocationId().getId()).collect(Collectors.toSet());
                inSyncAllocationIds = inSyncAllocationIds.stream()
                    .sorted(Comparator.comparing(assignedAllocations::contains).reversed()) 
                    .limit(maxActiveShards)
                    .collect(Collectors.toSet());
            }