Fix login hang when pgtle.clientauth_db_name names a nonexistent database#317
Open
zjyzh wants to merge 1 commit into
Open
Fix login hang when pgtle.clientauth_db_name names a nonexistent database#317zjyzh wants to merge 1 commit into
zjyzh wants to merge 1 commit into
Conversation
…base
When clientauth_db_name names a nonexistent (or later-dropped) database,
clientauth workers FATAL at startup and clientauth_hook waits forever on
a rendezvous no worker completes. The GUC is PGC_POSTMASTER, so nobody
can log in to fix it.
Track per-shard worker liveness in shared memory. Workers publish it
after BackgroundWorkerInitializeConnection() and clear it via
before_shmem_exit. clientauth_hook waits 3s for the target shard; on
timeout it falls back to the existing "pg_tle not installed" path
('on' accepts, 'require' FATALs). The post-enqueue client_cv wait is
also bounded and rechecks liveness, so a worker dying mid-request
cannot hang the client either.
Adds TAP subtests aws#20-aws#22 with bounded psql timeouts.
zjyzh
force-pushed
the
fix/clientauth-missing-dbname
branch
from
July 22, 2026 23:42
f7588c2 to
23e1e46
Compare
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.
Description of the change
Bug
pgtle.clientauth_db_nameisPGC_POSTMASTER. If it names a nonexistent (or later-dropped) database, every clientauth worker FATALs and every login hangs on a rendezvous no worker completes. Nobody can log in to fix it.Root cause
clientauth_hookenqueues and waits onclient_cvwith no timeout and no check that the shard has a live worker. It can't look uppg_databaseitself — it runs beforeInitPostgres.Fix
Give the hook a way to know whether a worker will ever answer, so it stops waiting forever.
Each background worker now flips a shared "I'm alive" flag once it has successfully attached to the database, and flips it back on exit. When a login arrives, the hook first checks that flag:
enable_clientauth = 'on'accepts the connection,'require'rejects it with a clear message saying to checkclientauth_db_name.The flag is per-worker (not a single "any worker up" bit) because requests are split across workers by client PID, so the hook has to check the specific worker its request will route to.
Branches
aws/pg_tle:main—fix/clientauth-missing-dbname, commitf7588c2.Testing
Three new TAP subtests in
004_pg_tle_clientauth.pl(#20/#21/#22), all boundedtimeout => 15.on+ missing DB → accepts.require+ missing DB → clean FATAL.DROP DATABASE ... WITH (FORCE)→ new logins don't hang.Patched: 6/6 pass in ~20s. Unpatched baseline: 77s hang, bails.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.