kgusakov commented on code in PR #4905: URL: https://github.com/apache/ignite-3/pull/4905#discussion_r1895747419
########## modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java: ########## @@ -230,4 +230,64 @@ void testNoHaRecoveryForScZone() throws InterruptedException { assertRecoveryKeyIsEmpty(node); } + + @Test + void testScaleUpAfterHaRecoveryWhenMajorityLoss() throws Exception { + startNode(3); + + startNode(4); + + createHaZoneWithTable(); + + IgniteImpl node = igniteImpl(0); + + assertRecoveryKeyIsEmpty(node); + + stopNodes(1, 2, 3, 4); + + waitAndAssertRecoveryKeyIsNotEmpty(node); + + assertRecoveryRequestForHaZoneTable(node); + + waitAndAssertStableAssignmentsOfPartitionEqualTo(node, HA_TABLE_NAME, Set.of(0, 1), Set.of(node.name())); Review Comment: You can use org.apache.ignite.internal.table.distributed.disaster.AbstractHighAvailablePartitionsRecoveryTest#PARTITION_IDS here and there, it will scale with the number of partitions ########## modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/rebalance/ZoneRebalanceUtil.java: ########## @@ -155,7 +158,33 @@ public static CompletableFuture<Void> updatePendingAssignmentsKeys( ByteArray partAssignmentsStableKey = stablePartAssignmentsKey(zonePartitionId); - Set<Assignment> partAssignments = calculateAssignmentForPartition(dataNodes, partNum, replicas); + Set<Assignment> calculatedAssignments = calculateAssignmentForPartition(dataNodes, partNum, replicas); + + Set<Assignment> partAssignments; + + if (consistencyMode == ConsistencyMode.HIGH_AVAILABILITY) { Review Comment: If you will provide the example with tricky case in comments, it will be great and simplify the understanding process ########## modules/table/src/integrationTest/java/org/apache/ignite/internal/table/distributed/disaster/ItHighAvailablePartitionsRecoveryTest.java: ########## @@ -230,4 +230,64 @@ void testNoHaRecoveryForScZone() throws InterruptedException { assertRecoveryKeyIsEmpty(node); } + + @Test + void testScaleUpAfterHaRecoveryWhenMajorityLoss() throws Exception { + startNode(3); + + startNode(4); + + createHaZoneWithTable(); + + IgniteImpl node = igniteImpl(0); + + assertRecoveryKeyIsEmpty(node); + + stopNodes(1, 2, 3, 4); + + waitAndAssertRecoveryKeyIsNotEmpty(node); + + assertRecoveryRequestForHaZoneTable(node); + + waitAndAssertStableAssignmentsOfPartitionEqualTo(node, HA_TABLE_NAME, Set.of(0, 1), Set.of(node.name())); + + var node1 = startNode(1); + + waitAndAssertStableAssignmentsOfPartitionEqualTo( + node, + HA_TABLE_NAME, + Set.of(0, 1), + Set.of(node.name(), node1.name()) + ); + + var node2 = startNode(2); + + waitAndAssertStableAssignmentsOfPartitionEqualTo( + node, + HA_TABLE_NAME, + Set.of(0, 1), + Set.of(node.name(), node1.name(), node2.name()) + ); + } + + @Test + void testHaZoneScaleDownNodesDoNotRemovedFromStable() throws InterruptedException { + startNode(3); + + startNode(4); + + createHaZoneWithTable(); + + IgniteImpl node = igniteImpl(0); + + Set<String> allNodes = runningNodes().map(Ignite::name).collect(Collectors.toUnmodifiableSet()); + + stopNodes(3); Review Comment: stopNodes(3, 4) or stopNode(3) ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/GroupUpdateRequest.java: ########## @@ -337,7 +336,43 @@ private static CompletableFuture<Integer> partitionUpdate( : Assignments.toBytes(partAssignments, assignmentsTimestamp) ); - return metaStorageMgr.invoke(invokeClosure).thenApply(StatementResult::getAsInt); + return metaStorageMgr.invoke(invokeClosure).thenApply(sr -> { + switch (UpdateStatus.valueOf(sr.getAsInt())) { + case PENDING_KEY_UPDATED: + LOG.info( + "Force update metastore pending partitions key [key={}, partition={}, table={}, newVal={}]", + pendingChangeTriggerKey(partId).toString(), + partId.partitionId(), + partId.tableId(), + nextAssignment + ); + + break; + case ASSIGNMENT_NOT_UPDATED: Review Comment: It looks like this status can't be thrown here? Am I missing smth? -- 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