Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better management of Ebean Shutdown on SIGTERM #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AntoineDuComptoirDesPharmacies

This pull request aims to fix the problem of Ebean Issue 3420 (ebean-orm/ebean#3420) where SIGTERM signal will immediately shutdown the ThreadPoolExecutor of Ebean, causing some reject on async count tasks while HTTP request is in progress.

This is solved by calling ShutdownManager.shutdown() on application lifecycle stopHook instead of closing each database individually.
Note that we have to call ShutdownManager.deregisterShutdownHook() to avoid Ebean triggering shutdown on SIGTERM signal.

@mkurz
Copy link
Member

mkurz commented Jul 9, 2024

Can you please

  1. Run sbt formatCode
  2. Squash your changes into one single commit on top of main?

Thanks!

@AntoineDuComptoirDesPharmacies AntoineDuComptoirDesPharmacies force-pushed the bugfix/ebean-3420 branch 2 times, most recently from d61f503 to 530712d Compare July 9, 2024 11:42
@AntoineDuComptoirDesPharmacies
Copy link
Author

Can you please

  1. Run sbt formatCode
  2. Squash your changes into one single commit on top of main?

Thanks!

Done ! 👍

@mkurz
Copy link
Member

mkurz commented Jul 9, 2024

Also can you please give the commit a better commit message instead of just # Ebean 3420? It's hard to tell what the commit does when just looking at the git log.

@AntoineDuComptoirDesPharmacies
Copy link
Author

Also can you please give the commit a better commit message instead of just # Ebean 3420? It's hard to tell what the commit does when just looking at the git log.

Current commit message is :

# Ebean 3420
Create EbeanLifecycle component to manage Ebean shutdown

But I will try to add more line to explain the content. 👍

@mkurz
Copy link
Member

mkurz commented Jul 9, 2024

Also can you please give the commit a better commit message instead of just # Ebean 3420? It's hard to tell what the commit does when just looking at the git log.

Current commit message is :

# Ebean 3420
Create EbeanLifecycle component to manage Ebean shutdown

But I will try to add more line to explain the content. 👍

No need to add more lines, just the first line should be more meaningful.

@AntoineDuComptoirDesPharmacies
Copy link
Author

Commit message changed and comment taken into account. 👍

() -> {
databases.forEach((key, database) -> database.shutdown(false, false));
return CompletableFuture.completedFuture(null);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you actually not just replace this code with the code you added in EbeanLifecycle? Why do you even need the EbeanLifecycle class? Isn't it much more straigt forward to change this code here and thats it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mkurz ,
It is clearly possible to change the code in-place.
The objective of adding it to a new class named EbeanLifecycle is about separation of concern between Ebean lifecycle and Evolution feature.

Do you want us to change the code in-place and delete EbeanLifecycle class ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants