You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2026/02/20 14:28:49 UTC

[PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

ibessonov opened a new pull request, #7644:
URL: https://github.com/apache/ignite-3/pull/7644

   https://issues.apache.org/jira/browse/IGNITE-27941
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "adityamukho (via GitHub)" <gi...@apache.org>.
adityamukho commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2845971568


##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {
+        int replicas = 2;
+        int partitions = 1;
+
+        LogInspector logInspector = new LogInspector(
+                BuildIndexCommandHandler.class.getName(),
+                evt -> evt.getMessage().getFormattedMessage().contains("Duplicated building the index command received")
+        );
+
+        logInspector.start();
+        try {
+            createAndPopulateTable(replicas, partitions);
+
+            ZonePartitionId tableGroupId = replicationGroupId(TABLE_NAME, 0);
+
+            IgniteImpl currentPrimary = primaryReplica(tableGroupId);
+
+            changeLeader(tableGroupId, currentPrimary);
+
+            createIndex(INDEX_NAME);
+
+            checkIndexBuild(partitions, replicas, INDEX_NAME);
+
+            assertFalse(logInspector.isMatched());
+        } finally {
+            logInspector.stop();
+        }
+    }
+
+    private static void changeLeader(ZonePartitionId groupId, IgniteImpl currentPrimary) throws Exception {

Review Comment:
   Maybe this method can be moved to the end of file to keep all test methods together?



##########
modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuilderTest.java:
##########
@@ -235,13 +239,25 @@ void testScheduleBuildIndexAfterDisasterRecovery() {
         assertThat(listenCompletionIndexBuildingAfterDisasterRecoveryFuture, willCompleteSuccessfully());
     }
 
-    private void scheduleBuildIndex(int indexId, int zoneId, int tableId, int partitionId, Collection<RowId> nextRowIdsToBuild) {
+    private void scheduleBuildIndex(int indexId, int zoneId, int tableId, int partitionId, Collection<RowId> rowIds) {
+        BinaryRowImpl binaryRow = new BinaryRowImpl(1, ByteBuffer.allocate(1));

Review Comment:
   Can we make this a `BinaryRow`, please.



##########
modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuilderTest.java:
##########
@@ -328,11 +344,9 @@ private CompletableFuture<Void> awaitSecondInvokeForReplicaService(CompletableFu
     }
 
     private static IndexStorage indexStorage(Collection<RowId> nextRowIdsToBuild) {

Review Comment:
   Can we remove the unused parameter?



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2847905443


##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {
+        int replicas = 2;
+        int partitions = 1;

Review Comment:
   Sure, I will



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2846232542


##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {
+        int replicas = 2;
+        int partitions = 1;
+
+        LogInspector logInspector = new LogInspector(
+                BuildIndexCommandHandler.class.getName(),
+                evt -> evt.getMessage().getFormattedMessage().contains("Duplicated building the index command received")
+        );
+
+        logInspector.start();
+        try {
+            createAndPopulateTable(replicas, partitions);
+
+            ZonePartitionId tableGroupId = replicationGroupId(TABLE_NAME, 0);
+
+            IgniteImpl currentPrimary = primaryReplica(tableGroupId);
+
+            changeLeader(tableGroupId, currentPrimary);
+
+            createIndex(INDEX_NAME);
+
+            checkIndexBuild(partitions, replicas, INDEX_NAME);
+
+            assertFalse(logInspector.isMatched());
+        } finally {
+            logInspector.stop();
+        }
+    }
+
+    private static void changeLeader(ZonePartitionId groupId, IgniteImpl currentPrimary) throws Exception {

Review Comment:
   Sure, why not



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2846235282


##########
modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuilderTest.java:
##########
@@ -235,13 +239,25 @@ void testScheduleBuildIndexAfterDisasterRecovery() {
         assertThat(listenCompletionIndexBuildingAfterDisasterRecoveryFuture, willCompleteSuccessfully());
     }
 
-    private void scheduleBuildIndex(int indexId, int zoneId, int tableId, int partitionId, Collection<RowId> nextRowIdsToBuild) {
+    private void scheduleBuildIndex(int indexId, int zoneId, int tableId, int partitionId, Collection<RowId> rowIds) {
+        BinaryRowImpl binaryRow = new BinaryRowImpl(1, ByteBuffer.allocate(1));

Review Comment:
   Oops



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2846256314


##########
modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuilderTest.java:
##########
@@ -328,11 +344,9 @@ private CompletableFuture<Void> awaitSecondInvokeForReplicaService(CompletableFu
     }
 
     private static IndexStorage indexStorage(Collection<RowId> nextRowIdsToBuild) {

Review Comment:
   Done, I also changed `scheduleBuildIndexAfterDisasterRecovery` because I forgot to do so. Thank you!



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644


-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27941 Fix nextRowIdToBuild handling in IndexBuildTask [ignite-3]

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #7644:
URL: https://github.com/apache/ignite-3/pull/7644#discussion_r2847450045


##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexBuildTask.java:
##########
@@ -276,13 +291,17 @@ private CompletableFuture<Void> handleNextBatch(@Nullable RowId highestRowId) {
                             if (!(cause instanceof ReplicationTimeoutException || cause instanceof GroupOverloadedException)) {
                                 return CompletableFuture.<Void>failedFuture(cause);
                             }
-                        } else if (indexStorage.getNextRowIdToBuild() == null) {
-                            // Index has been built.
-                            LOG.info("Index build completed [{}]", createCommonIndexInfo());
+                        } else {

Review Comment:
   Would it make sense to keep `else if` structure here for consistency? As current `else` is actually an if/else itself



##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {
+        int replicas = 2;
+        int partitions = 1;

Review Comment:
   Could you please explain the numbers? Like 'we have 3 nodes, so one node will be primary, one will be Raft leader, and one will not host the partition'? Or somehow else?



##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {
+        int replicas = 2;
+        int partitions = 1;
+
+        LogInspector logInspector = new LogInspector(
+                BuildIndexCommandHandler.class.getName(),
+                evt -> evt.getMessage().getFormattedMessage().contains("Duplicated building the index command received")
+        );
+
+        logInspector.start();
+        try {
+            createAndPopulateTable(replicas, partitions);
+
+            ZonePartitionId tableGroupId = replicationGroupId(TABLE_NAME, 0);
+
+            IgniteImpl currentPrimary = primaryReplica(tableGroupId);
+
+            changeLeader(tableGroupId, currentPrimary);

Review Comment:
   It seems important that the leader is chosen to be different from the primary. Please encode this either in the method name, or add a comment



##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -116,6 +119,46 @@ void testBuildIndexOnStableTopology(int replicas) throws Exception {
                 .check();
     }
 
+    @Test
+    void testRaftCommandsDuplicationOnPrimaryNotCollocatedWithLeader() throws Exception {

Review Comment:
   ```suggestion
       void testRaftCommandsDuplicationOnPrimaryNotColocatedWithLeader() throws Exception {
   ```
   While working on colocation feature, we decided to spell it with just 1 'l'



-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org