xxubai commented on code in PR #4320:
URL: https://github.com/apache/amoro/pull/4320#discussion_r3800596329


##########
amoro-ams/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java:
##########
@@ -250,6 +250,26 @@ private void registerOptimizer(OptimizerInstance 
optimizer, boolean needPersiste
     optimizerScaleKeeper.onOptimizerRegistered(optimizer);
   }
 
+  /**
+   * Registers optimizers recovered from persistence at startup. An optimizer 
record referencing a
+   * resource group that no longer exists (e.g. the group was dropped while 
AMS was down) is removed
+   * instead of failing the whole initialization, mirroring the tolerant 
handling of the
+   * follower-sync path in {@code registerOptimizerWithoutPersist}.
+   */
+  void registerOptimizers(List<OptimizerInstance> optimizers) {
+    for (OptimizerInstance optimizer : optimizers) {
+      if (optimizingQueueByGroup.containsKey(optimizer.getGroupName())) {

Review Comment:
   In master-slave mode, another AMS instance may create a resource group and 
register an optimizer between these queries. Since the local queue map does not 
yet contain the new group, this code could incorrectly delete a valid optimizer 
record from the shared database.



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