sashapolo commented on code in PR #5612: URL: https://github.com/apache/ignite-3/pull/5612#discussion_r2042100387
########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/PartitionReplicaLifecycleManager.java: ########## @@ -535,30 +534,36 @@ private CompletableFuture<Void> createZoneReplicationNodes( int catalogVersion, int partitionCount ) { - return inBusyLockAsync(busyLock, () -> { - assert assignments != null : IgniteStringFormatter.format("Zone has empty assignments [id={}].", zoneId); - - var partitionsStartFutures = new CompletableFuture<?>[assignments.size()]; - - for (int partId = 0; partId < assignments.size(); partId++) { - Assignments zoneAssignment = assignments.get(partId); - - Assignment localMemberAssignment = localMemberAssignment(zoneAssignment); - - var zonePartitionId = new ZonePartitionId(zoneId, partId); - - partitionsStartFutures[partId] = createZonePartitionReplicationNode( - zonePartitionId, - localMemberAssignment, - zoneAssignment, - causalityToken, - partitionCount, - isVolatileZoneForCatalogVersion(zoneId, catalogVersion) - ); - } + // Zone nodes might be created in the same catalog version as a table in this zone, so there could be a race + // between storage creation due to replica start and storage creation due to table addition. To eliminate the race, + // we acquire a write lock on the zone (table addition acquires a read lock). + return inBusyLockAsync(busyLock, () -> executeUnderZoneWriteLock(zoneId, + () -> inBusyLockAsync(busyLock, () -> { + assert assignments != null : IgniteStringFormatter.format("Zone has empty assignments [id={}].", zoneId); Review Comment: I guess it would make more sense to move this assertion out of the closures. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org