-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Breaking postgrest with SIG_INT (Ctrl+C) has problem with docker #3884
Comments
Could you elaborate on the actual issue here? It exits, that's the goal. PID 1 processes must install their own signal handlers, and we do so: https://github.com/PostgREST/postgrest/blob/main/src/PostgREST/Unix.hs#L23-L31 If we didn't do that, PostgREST wouldn't exit at all.
How do threads need to be shutdown properly? We are not spawning subprocesses, so I fail to see what we need to do here.
Do:
hit CTRL+C. Observe - the exit code is 255. Note: When doing the same by running So yeah... apparently we still do something different. Not sure what, though. My assumption is that when running as pid > 1, the default signal handlers kick in and return 130 as the exit code, while the way we implemented our custom handlers for the pid 1 case ends up with 255 as the exit code. |
You can close gracefully (exit with code 130 or 0) or not. When a program exits with an error code (i.e., an exit code different from the expected one), supervisor scripts (e.g., health checks, service management scripts) may trigger rescue actions. Fortunately, this is not an issue in my case—I can live with this error. Closing with an error means that the shutdown process was interrupted and may not have completed correctly (e.g., some resources might not have been freed). I am unsure whether PostgREST manages to clean up everything it needs to during exit—maybe it does, maybe it doesn't. I also don't know the consequences of this issue for PostgREST itself. It is better to close threads properly rather than risk being caught by some random issues. I reported this issue because I couldn't find any information about it, and I want to make you aware that it exists. However, I don't know how important this is to you. |
I recall there was a problem with
We'll track it as "minor" bug for now, thanks for reporting. |
Environment
Linux 6.8.0-45-generic #45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 11 15:25:05 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
27.3.1, build ce12230
Description of the issue
When PostgREST is started in Docker as the main process, terminating it with
SIGINT
causes Docker to exit with code255
instead of130
(128 + 2
forSIGINT
).The solution is to use
tini
as the Docker init process (via the--init
option in
docker run
). However, this suggests that PostgREST itself may haveissues with handling signals or properly shutting down its threads.
I encountered this issue while working with the Hive
HAF
andHivemind
applications.A quick way to reproduce it is by running Hive blockchain containers for the
development branches of:
HAF
(I used tag
b7870f22
).Hivemind
(I used tag
e75121fd
).After executing the code above, you should see PostgREST running. Now, break
it with
Ctrl+C
and checkecho $?
. The exit code is255
, not130
.I suppose the problem occurs in a much simpler setup, but to be sure you can
repeat it, I wanted to share my environment with you.
Hivemind issue connected with the problem: https://gitlab.syncad.com/hive/hivemind/-/issues/277
The text was updated successfully, but these errors were encountered: