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


##########
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:
   Building indexes on followers happens when we apply the write command, do 
you think we need to keep track of the first write command so we can print it 
to the log? I don't think it's worth it just yet.
   Will do later if needed.



-- 
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