Skip to content

Add post-start hook to remove stale PostgreSQL sockets#620

Closed
PiRomant wants to merge 1 commit intogreenbone:mainfrom
PiRomant:patch-1
Closed

Add post-start hook to remove stale PostgreSQL sockets#620
PiRomant wants to merge 1 commit intogreenbone:mainfrom
PiRomant:patch-1

Conversation

@PiRomant
Copy link

What

Added post_start exec action to the postgres service that safely removes common socket/lock files before PostgreSQL binds.

No data loss risk - only removes ephemeral socket/lock files.
Container now starts reliably even after abrupt SIGKILL

Tested: Verified volume cleanup works after forced inserted socket and lock files in greenbone-community-edition_psql_socket_vol before container started.

Why

PostgreSQL often fails to start due to stale socket files (like .s.PGSQL.5432) or lock files left from improper shutdowns, causing errors about existing sockets or locks.
Abstract sockets (@/tmp) avoid this entirely but can’t share across containers.

Checklist

@bjoernricks
Copy link
Contributor

IMHO it is better to address this issue already in the pg-gvm container directly. See greenbone/pg-gvm#119

auto-merge was automatically disabled March 24, 2026 14:28

Pull request was closed

@PiRomant
Copy link
Author

@bjoernricks, but with my approach, the deletion operation runs as the root user. At one point I faced an issue where a similar clearing from redis did not work.
Like this https://forum.greenbone.net/t/interrupted-scans-nvt-connection-redis-socket-errors/21923
rm: cannot remove ‘/run/redis/redis.sock’: Permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants