fix: reap detached pgBackRest processes in the instance sidecar - #161
Open
melancholictheory wants to merge 1 commit into
Open
melancholictheory wants to merge 1 commit into
melancholictheory wants to merge 1 commit into
Conversation
With --archive-async, archive-push starts the async process detached (setsid and a second fork), so it is reparented to PID 1 of the sidecar. PID 1 was the manager, which only waits for the children it starts itself, so every async process that exited stayed a zombie until the sidecar restarted. With a quiet write load that is one zombie per archived segment, and each of them keeps its PID. The sidecar image now runs tini as PID 1 in front of the manager. It is installed in the existing Debian stage and copied in as tini-static, which needs nothing from the distroless base. The operator sets only args on the sidecar, so the entrypoint applies to the instance pods and to the restore job without other changes, and tini passes SIGTERM on to the manager. Refs: operasoftware#157 Signed-off-by: Vasiliy Fakunin <61789920+melancholictheory@users.noreply.github.com>
Contributor
Author
|
CI is red only on the e2e suite, for a reason unrelated to this change: #154 includes the switch to the Chainguard MinIO images from #155 and makes the restore specs pass on CloudNativePG main. Merged on top of #154, this branch passes the whole e2e suite against CloudNativePG main on our fork, 8 of 8 (#154 adds one spec): run. We will rebase once #154 is merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #157.
What
The sidecar image runs
tinias PID 1 in front of the manager, so the async pgBackRest processes that detach themselves are reaped when they exit instead of staying zombies until the sidecar restarts.How
containers/Dockerfile.sidecarinstallstiniin the existing Debian stage, rather than in a stage of its own as sketched in the issue, copiestini-staticin as/tiniand changes the entrypoint to["/tini", "--", "/manager"]. The static binary needs nothing from the distroless base. The operator only setsargson the sidecar, so the instance pods and the restore job pick up the new entrypoint without other changes. The startup probe runs/manager healthcheck unixdirectly and is not affected.Testing
["/tini","--","/manager"], runs as 26:26 and passes its arguments on to the manager.archive-pushdoes, in a new session with the parent exiting right away, leaves 30 zombies when it runs as PID 1 and none under this image's/tini.tiniarchived 30 segments one at a time and left no zombies. SIGTERM still reached the manager, which exited with 0, and PostgreSQL kept running.tinias PID 1.