1

I have Spring boot application, that goes to database using HikariCP. The thing is, when application gets stop (SIGTERM or other) signal, it must go to database and change some data, after that it closes ("gracefull shutdown"). This logic is written in myShutdownHook (Runtime.getRuntime().addShutdownHook(myShutdownHook)). So the app needs to use connection pool for that. But problem is, that Hikari pool closes right after getting stop signal:

2022-09-18 18:26:44,796 INFO  [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown initiated...
2022-09-18 18:26:44,798 INFO  [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown completed.

And context is closing before my logic is completed. How can I make HikariCP not to close before my logic in myShutdownHook is done?

programmer
  • 75
  • 8
  • What is the issue of pool closing at once application close? – YJR Sep 18 '22 at 16:00
  • if I get Your question wright, pool closing with its own Spting shutdownHook. And mine hook launches concurrently, and can't get access to pool – programmer Sep 18 '22 at 16:34
  • Please don't ask [the same question](https://stackoverflow.com/questions/73764875/how-change-data-in-database-after-getting-close-sigterm-for-example-command-i) again! – M. Deinum Sep 19 '22 at 06:47
  • Does this answer your question? [How change data in database after getting close (SIGTERM, for example) command in Spring boot application using HikariCP?](https://stackoverflow.com/questions/73764875/how-change-data-in-database-after-getting-close-sigterm-for-example-command-i) – knittl Sep 19 '22 at 07:08

0 Answers0