Repository navigation
fix: reap detached pgBackRest processes in the instance sidecar - #161
Conversation
|
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. |
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>
218b63d to
63e830a
Compare
|
Rebased onto |
Agalin
left a comment
There was a problem hiding this comment.
Yeah, that's perfectly reasonable change and likely improves sidecar's behaviour when it comes to signals in general.
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.