Jalina2007 opened a new pull request, #10435:
URL: https://github.com/apache/gravitino/pull/10435

   [#10327] improvement(server): ensure shutdown hook runs app cleanup on 
SIGTERM
   
   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): Support xxx"
        - "[#233] fix: Check null before access result in xxx"
        - "[MINOR] refactor: Fix typo in variable name"
        - "[MINOR] docs: Fix typo in README"
        - "[#255] test: Fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   
   This PR improves the shutdown handling of GravitinoServer.
   A new gracefulStop() method is introduced to ensure server.stop() is 
executed safely and only once. The shutdown hook now calls gracefulStop() after 
the shutdown timeout so that application-level cleanup runs when the JVM 
receives a termination signal (e.g., SIGTERM).
   The normal shutdown flow in main was also updated to call gracefulStop().
   A unit test was added to verify that the shutdown hook invokes server.stop() 
as given in the issue description.
   
   ### Why are the changes needed?
   
   Currently, the shutdown hook only sleeps while the cleanup logic runs after 
server.join(). When the process receives SIGTERM, the cleanup path may be 
skipped.
   This change ensures cleanup always runs during external termination and 
normal exits.
   
   Fix: #10327
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added the unit test suggested in the issue:
   testMainShutdownHookShouldInvokeServerStop()
   Also verified that gracefulStop() prevents stop() from executing multiple 
times using temporary logging.
   


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