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

mariadb: Increase timeout for MariaDB shutdown #3570

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

agners
Copy link
Member

@agners agners commented Apr 17, 2024

Currently, when MariaDB takes longer than 20s to shutdown, Docker will simply kill it. This can be problematic on upgrade, as the new MariaDB version cannot handle a not cleanly shutdown MariaDB (see #3566).

Increase the timeout of the container shutdown to 60s. Also define a per-service kill timeout for mariadb-core. This is largely optional, and essentially leads to the same outcome if MariaDB takes even longer (it will get killed, one way or another). But by defining this as part of the s6 service makes sure that the add-on log itself shows that MariaDB had to be killed, and makes sure the rest of the s6 service tree gets a chance to shutdown gracefully still:

[09:29:37] INFO: Service mariadb exited with code 256 (by signal 9) s6-rc: info: service mariadb-core successfully stopped s6-rc: info: service mariadb-pre: stopping
...

The 18s timeout of S6_SERVICES_GRACETIME seems to apply for legacy services only which are no longer used in this add-on. So drop this definition.

Fixes #3566

Currently, when MariaDB takes longer than 20s to shutdown, Docker will
simply kill it. This can be problematic on upgrade, as the new MariaDB
version cannot handle a not cleanly shutdown MariaDB (see #3566).

Increase the timeout of the container shutdown to 60s. Also define a
per-service kill timeout for mariadb-core. This is largely optional, and
essentially leads to the same outcome if MariaDB takes even longer (it
will get killed, one way or another). But by defining this as part of
the s6 service makes sure that the add-on log itself shows that MariaDB
had to be killed, and makes sure the rest of the s6 service tree gets
a chance to shutdown gracefully still:

[09:29:37] INFO: Service mariadb exited with code 256 (by signal 9)
s6-rc: info: service mariadb-core successfully stopped
s6-rc: info: service mariadb-pre: stopping
...

The 18s timeout of S6_SERVICES_GRACETIME seems to apply for legacy
services only which are no longer used in this add-on. So drop this
definition.

Fixes #3566
@agners agners marked this pull request as ready for review April 17, 2024 07:53
@lmagyar
Copy link
Contributor

lmagyar commented Apr 17, 2024

@lmagyar review welcome 😄

Maybe increase it even further? 300 and 295000???

@lmagyar
Copy link
Contributor

lmagyar commented Apr 17, 2024

Maybe add a note to the beginning of the changelog, to "restart the addon before upgrade if the current version is lower than 2.7.1", and delete it a few month version later.

@agners
Copy link
Member Author

agners commented Apr 17, 2024

I was actually considering a bit higher value too 🤔 . I guess we should not make too much assumption of how long this takes. It also doesn't hurt much... If it takes long... well that is what it takes 😅

Increased to 5 minutes.

@agners
Copy link
Member Author

agners commented Apr 17, 2024

Maybe add a note to the beginning of the changelog, to "restart the addon before upgrade if the current version is lower than 2.7.1", and delete it a few month version later.

I've added a comment. However, I only mention "lower than 2.7.0 only": We don't do a major bump, so even if 2.7.0 fails to terminate gracefully, the problem won't appear as 2.7.1 will be able to recover just like 2.7.0 will be.

@lmagyar
Copy link
Contributor

lmagyar commented Apr 17, 2024

Yes, you are right, "version is lower than 2.7.0" should be fine:

  • even if 2.7.0 shutdown fails, 2.7.1 has the same MariaDB version, so no problem to recover, no need to prior restart
  • 2.7.0 had only a few days to run, it has a good chance to shutdown correctly

Copy link
Contributor

@mdegat01 mdegat01 left a comment

Choose a reason for hiding this comment

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

I wonder if there's some way to get s6 to run a script when it does do kill. It would be nice if it could make a sentry issue when that happens so we can get a sense of whether we picked the right value or not

@agners
Copy link
Member Author

agners commented Apr 18, 2024

I wonder if there's some way to get s6 to run a script when it does do kill. It would be nice if it could make a sentry issue when that happens so we can get a sense of whether we picked the right value or not

The finish script has the exit code, we can do things based on that (see PR description, that INFO line is printed by the finish script). The exit code of the container should be 137 for this case, as we use the regular "exit code when killed by signal" logic (128 + signal).

@agners agners merged commit ff6d99f into master Apr 18, 2024
10 checks passed
@agners agners deleted the mariadb-increase-shutdown-timeout branch April 18, 2024 07:42
miguelrjim pushed a commit to miguelrjim/ha-addons that referenced this pull request Apr 26, 2024
* mariadb: Increase timeout for MariaDB shutdown

Currently, when MariaDB takes longer than 20s to shutdown, Docker will
simply kill it. This can be problematic on upgrade, as the new MariaDB
version cannot handle a not cleanly shutdown MariaDB (see home-assistant#3566).

Increase the timeout of the container shutdown to 60s. Also define a
per-service kill timeout for mariadb-core. This is largely optional, and
essentially leads to the same outcome if MariaDB takes even longer (it
will get killed, one way or another). But by defining this as part of
the s6 service makes sure that the add-on log itself shows that MariaDB
had to be killed, and makes sure the rest of the s6 service tree gets
a chance to shutdown gracefully still:

[09:29:37] INFO: Service mariadb exited with code 256 (by signal 9)
s6-rc: info: service mariadb-core successfully stopped
s6-rc: info: service mariadb-pre: stopping
...

The 18s timeout of S6_SERVICES_GRACETIME seems to apply for legacy
services only which are no longer used in this add-on. So drop this
definition.

Fixes home-assistant#3566

* Increase shutdown timeout to 5 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MariaDB is not starting after update to 2.7.0
3 participants