Repository navigation
feat: serve several pools from one image with POOLS - #2
Merged
Merged
Conversation
They are parsed in one subshell, so a URL omitting a port, user, password or name silently reused the previous one's. Assisted-by: Claude:claude-opus-5[1m]
jclaveau
force-pushed
the
feat/multiple-pools
branch
from
August 13, 2026 15:18
2b0d951 to
5a5a10f
Compare
jclaveau
force-pushed
the
feat/multiple-pools
branch
5 times, most recently
from
August 13, 2026 22:41
75d32b5 to
fc14eec
Compare
Each name in POOLS becomes a [databases] entry inheriting the base settings, so one database can be served by pools of different sizes. Assisted-by: Claude:claude-opus-5[1m]
jclaveau
force-pushed
the
feat/multiple-pools
branch
from
August 14, 2026 09:40
fc14eec to
086277c
Compare
jclaveau
commented
Aug 14, 2026
| ENV_DB_PASSWORD="${DB_PASSWORD:-}" | ||
| ENV_DB_HOST="${DB_HOST:-}" | ||
| ENV_DB_PORT="${DB_PORT:-}" | ||
| ENV_DB_NAME="${DB_NAME:-}" |
Owner
Author
There was a problem hiding this comment.
this looks like smell, why no renaming the vars in the parse_url() function?
jclaveau
force-pushed
the
feat/multiple-pools
branch
3 times, most recently
from
August 14, 2026 10:55
8acbc93 to
590c545
Compare
jclaveau
force-pushed
the
feat/multiple-pools
branch
5 times, most recently
from
August 14, 2026 12:41
ef9a94d to
89e3df6
Compare
DATABASE_URLS spells topology and credentials in one value; POOLS and USERS split them, and a variable that means different things depending on its neighbours is worse than either behaviour alone. Assisted-by: Claude:claude-opus-5[1m]
jclaveau
force-pushed
the
feat/multiple-pools
branch
from
August 14, 2026 12:48
89e3df6 to
9426258
Compare
Every refusal now lands before a file is written, and each one carries the case that fails without it. Assisted-by: Claude:claude-opus-5[1m]
Same fallback as edoburu#135, applied to pool entries too, and inert wherever DB_USER is set. Assisted-by: Claude:claude-opus-5[1m]
A pool with no host failed mid-render, leaving a pgbouncer.ini that turned the next start into a complaint about a config nobody mounted. The rest of this round closes what the entrypoint was still taking in silence. Assisted-by: Claude:claude-opus-5[1m]
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.
Builds on #3 (the three misplaced database-line parameters, edoburu#132) and on #1, whose expectations are what show the new code is inert until asked for.
What I am after: one pooler serving the same database through several pools of different sizes, so a paid tier and a free tier cannot starve each other, nor the connections the app needs to authenticate anyone at all.
[databases]entry, chosen by the database name a client connects to.POOLS
POOL_<NAME>_<SETTING>.DATABASE_URLS.USERS
POOLSdescribes topology, so credentials needed their own home:userlist.txtentry per name.md5…,SCRAM-SHA-256$…, copied out ofpg_authid) is written through untouched rather than hashed again.USER_METRICS_NAME=metrics.exportercarries the real one.AUTH_USERand anauth_queryare in play — pgbouncer then reads passwords from the server, and one credential covers everyone.AUTH_USER reaches the entries
Same fallback as edoburu#135 (for edoburu#134), extended to pools:
auth_usertakesDB_USER, thenAUTH_USER, thenpostgres.AUTH_USERwas documented as the way to have pgbouncer look passwords up on the server, and the database entry asked aspostgresregardless.POOL_<NAME>_AUTH_USERwhere it names one.DB_USERis set, which is why no existing expectation moved —all-knobssets both and renders exactly as before.Passwords reach the file, never the logs
A pool forcing a server identity needs
password=on its database line, in the clear. The entrypoint echoes that file at startup, which would have put it indocker logs, the platform's log drain and every CI job that boots the image.live.shgreps the container's own log for the password and fails on finding it.What is refused, and what is only warned about
Everything below now fails before a single file is written, rather than being misread in silence:
POOL_BASE_REPORTING_POOL_SIZEwould belong to bothbaseandbase_reporting, and names differing only in case collide the same waypgbouncertoo: it is the admin console's own database, and pgbouncer refuses the whole file over itPOOL_BSAE_POOL_SIZEbesidePOOLS=baserendered a pool of plain defaults and said nothingPOOL_MODEandPOOL_SIZEare exempt — the pool mode of the process, and the default size of every entry — rather than settings of a pool namedMODEorSIZEUSERSname's do,NAMEandPASSWORDbeing read here and nowhere elseUSERSname with no password, every name checked before the first one is writtenuserlist.txtis usually a mounted volume and the writer skips names already in it, so a half-written file outlived the startup that made itUSERSthatDB_USERalready spells, whose credential is written first — the listed password went in nowhere and said so nowhereUSER_<LABEL>_NAMEis resolved before the two are comparedDB_HOSTto inheritPOOL_<NAME>_PASSWORDand noPOOL_<NAME>_USERto present it as — pgbouncer builds a forced credential only where a user carries one, so that password sat in the file in the clear and authenticated nothingPOOLSbeside a mountedpgbouncer.ini, which is served as it stands and left those pools rendered nowhereOne behaviour change to call out: a stray
POOL_*orUSER_*variable now fails startup even withPOOLSandUSERSunset. Upstream ships onlyPOOL_MODEandPOOL_SIZE, both exempt, so nothing documented breaks — but an unrelated variable sharing the prefix used to be ignored and no longer is.One case only warns: a pool forcing a user it holds no password for. A mounted
userlist.txtmay still carry that password, so it cannot be an error.DATABASE_URLS is refused beside either
DATABASE_URLSsays who may connect and what they connect to, in one value.POOLSandUSERSsplit those apart.DATABASE_URLSmeaning different things depending on whetherPOOLShappened to be set — worse than either behaviour alone.DATABASE_URL(singular) is untouched, and still provides the defaults a pool does not override.POOLSandUSERSare new, so no configuration in the wild combines them.Migrating off DATABASE_URLS
DATABASE_URLSgives youPOOLS+POOL_<NAME>_DBNAMEPOOL_<NAME>_HOST/POOL_<NAME>_PORTauth_userPOOL_<NAME>_AUTH_USERuserlist.txtUSERS+USER_<NAME>_PASSWORDUSERS, landing inuserlist.txtPOOL_<NAME>_USER, landing on the database line asuser=/password=tests/pools-own-usersrenders both, and itsuserlist.txtholds only the connection's own credential, not the pools' forced ones.pool_size,pool_mode, several pools onto one database, pre-hashed verifiers, usernames an environment variable cannot spell.One bug fixed on the way
DATABASE_URLSentries inherited each other's fields, being parsed in a single subshell.parse_urlnow resets to what the environment provided, leaving single-DATABASE_URLbehaviour exactly as it was.Testing
Every case renders and is compared against
expected/; those that can also boot the container, since pgbouncer parses its config only at startup and a text diff cannot tell a valid file from an unchanged one.live.shasserts what a session sees, not what the file claims:SHOW DATABASESreporting 20/34/10DEFAULT_POOL_SIZEis set to 7 there so those numbers mean something: pgbouncer's own default is 20, which a pool sized 20 could not be told apart fromtimezoneandclient_encodingread back through it, with an untouched pool as the witnesspool_sizecapping for real: a pool of one holds a transaction while a second client queuespool_sizeand that readscl_waiting=0, so it cannot pass vacuouslyUSERScredential authenticating: the test creates the role server-side and checksselect current_userThe
auth_userfallback has four cases — withAUTH_USERalone, besideDB_USER, across pools and besideUSERS. Reverting the fallback reddens exactly the three that name noDB_USER, and leaves the fourth green, which is what makes it the witness.It also reads the container's log, for the two things no rendered file can show:
password=***and nowhere the password itselfEvery refusal above has its case, and
coverage.shfails when the entrypoint reads a variable no case sets — 92 of 92 today.Decisions
DB_USERkeeps all three of its upstream meanings: auserlist.txtcredential, theauth_user=of every entry, and whatever the parsedDATABASE_URLcarries.AUTH_USERalready names the process-wide setting.USERSandPOOL_<NAME>_AUTH_USERcarry those meanings apart, so nothing new has to lean on it.run.shrewrites the failing line number toline Nsomissing-db-hoststops churning, and theAUTH_USERfallback landed here rather than waiting on the upstream PR.userlist.txtcan supply the first, nothing can rescue the second.DATABASE_URLis parsed once, before the checks that read the host and user it carries, and the two later re-parses are gone.pools-with-database-urlis what fails if the parse moves back down.set -fkeeps a name inPOOLS/USERSout of the shell's globbing — the lists are word-split unquoted, andPOOLS=*used to come back naming a file in the container's root.Out of scope: no change to how
userlist.txtis written for the single-connection path, and no per-user[users]section — tiering by database entry covers the need, and the user axis is a different feature.Assisted-by: Claude:claude-opus-5[1m]