tkalkirill commented on code in PR #1800:
URL: https://github.com/apache/ignite-3/pull/1800#discussion_r1144856969


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionListener.java:
##########
@@ -437,4 +439,33 @@ public void onShutdown() {
     public MvPartitionStorage getMvStorage() {
         return storage.getStorage();
     }
+
+    /**
+     * Handler for the {@link BuildIndexCommand}.
+     *
+     * @param cmd Command.
+     * @param commandIndex RAFT index of the command.
+     * @param commandTerm RAFT term of the command.
+     */
+    void handleBuildIndexCommand(BuildIndexCommand cmd, long commandIndex, 
long commandTerm) {
+        // Skips the write command because the storage has already executed it.
+        if (commandIndex <= storage.lastAppliedIndex()) {
+            return;
+        }
+
+        storage.runConsistently(() -> {
+            storage.lastApplied(commandIndex, commandTerm);
+
+            storageUpdateHandler.buildIndex(cmd.indexId(), cmd.rowIds(), 
cmd.finish());
+
+            return null;
+        });
+
+        if (cmd.finish()) {
+            LOG.info(
+                    "Finish building the index: [tableId={}, partitionId={}, 
indexId={}]",

Review Comment:
   Because only the leader of the group manages the process of building 
indexes, and the building of indexes itself takes place on all members of the 
raft group.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to