-
Notifications
You must be signed in to change notification settings - Fork 163
cardano-db-sync container doesn't gracefully shut down #1945
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
Comments
This might relate to #1010 which seems to reference Docker containers quite often and the stop should also be receiving a SIGKILL event. Although, I'm unsure if the volatile data handling (or anything else) is significantly different when receiving SIGINT vs. SIGKILL. The Docker image is built using Nix's If setting the STOPSIGNAL was possible I would normally suggest the Dockerfile use cardano-db-sync/nix/docker.nix Lines 94 to 96 in 0f1d93f
The next thing that comes to mind would be signal handling in the wrapper script (i.e. Since permalink isn't embedding here is a copy:
If this is a welcome approach I can open a PR based off this branch. |
I took a closer look at the code for dockerTools.buildImage and realized I had overlooked cardano-db-sync/nix/docker.nix Lines 25 to 28 in 0f1d93f
Could have line 27 modified to:
to set the If I didn't get the syntax wrong I would happily adjust my branch and open a PR so the containers now get gracefully shutdown and no longer reach the default (or set by |
This looks good to me. I'll do a bit of testing in the meantime. PS: It looks like you need to set up commit signing. |
New laptop, I must not have migrated my global git config. I'll sign and force push shortly. |
@sgillespie Commit is now signed. |
OS
Your OS: Ubuntu & RockyLinux
Versions
The
db-sync
version (egcardano-db-sync --version
): 13.6.0.4PostgreSQL version: 15.10
Build/Install Method
The method you use to build or install
cardano-db-sync
: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.4 container image.Run method
The method you used to run
cardano-db-sync
(eg Nix/Docker/systemd/none):[docker|podman] run
or by creating Quadlet (podman-systemd) based unit files.Problem Report
The cardano-db-sync Docker container doesn't shut down gracefully when
docker stop
is used. Instead of responding to SIGTERM, it eventually gets killed by SIGKILL after the 10-second grace period. This may lead to unclean shutdowns.Expected behavior
The container should gracefully shut down upon receiving SIGTERM. This is typically done by the application responding to a SIGINT signal.
Current behavior
The cardano-db-sync process inside the container doesn't respond to SIGTERM. The scripts that launch cardano-db-sync don't forward signals or handle shutdown requests, so the main process never receives a SIGINT, and the container is forcibly killed.
Additional context
The TL;DR breakdown:
exec
when calling thecardano-db-sync-${network}
bash script.cardano-db-sync/nix/docker.nix
Lines 83 to 86 in 0f1d93f
cardano-db-sync-${network}
bash script:exec
so it becomes the primary process of the container & does not usetrap
to pass along the signals to the cardano-db-sync process it starts.cardano-db-sync/nix/docker.nix
Lines 94 to 96 in 0f1d93f
cardano-db-sync
binary does not appear to handle SIGTERM.--stop-signal=SIGINT
when creating the container would not change the behavior, is it would only reach the bash wrapper script for the given network/environment, not the binary.To Reproduce
[docker|podman] stop <container_id>
.The text was updated successfully, but these errors were encountered: