dengzhhu653 commented on code in PR #6621:
URL: https://github.com/apache/hive/pull/6621#discussion_r3629030495


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/leader/LeaderElectionContext.java:
##########
@@ -66,24 +68,26 @@ public String getName() {
 
   private final Configuration conf;
   private final String servHost;
-  // Whether the context should be started as a daemon
-  private final boolean startAsDaemon;
   // Audit the event of election
   private AuditLeaderListener auditLeaderListener;
   // State change listeners group by type
   private final Map<TTYPE, List<LeadershipStateListener>> listeners;
   // Collection of leader candidates
   private final List<LeaderElection<?>> leaderElections = new ArrayList<>();
-  // Property for testing, a single leader will be created
+  // Ensures the abort action runs at most once even if both electors fail 
concurrently.
+  private final AtomicBoolean isAborting = new AtomicBoolean(false);
+  // Action to run when a leader election exhausts retries. Defaults to 
triggering an
+  // orderly JVM shutdown via System.exit, which fires the HMS shutdown-hook 
chain
+  // (election close, ZK deregistration, metrics, servlet server). Overridable 
for tests.
+  private Runnable abortAction = () -> System.exit(1);

Review Comment:
   Can you use `ExitUtil.terminate` instead, refer to 
`https://github.com/apache/hive/pull/5914`?
   And before exiting the system, try best to close the opened electors in 
`leaderElections`, note this `leaderElections` might be modified during the 
close, might be better to copy it to a new list, then travel the new list to 
close them.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to