New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed connection with unknown stats_users or admin_users which throws… #817
Conversation
Thanks for the contribution. Could you add a regression test for this as well? |
@JelteF Surely I'll do this in a few days |
I found another case when we set up |
daf5804
to
9f97bfa
Compare
…in_users which throws '@src/objects.c:316 in function put_in_order(): put_in_order: found existing elem' Fixes a bug introduced by pgbouncer#314
4448ae3
to
335197e
Compare
…ncer#314 Co-authored-by: KnifeMaster007 <km@j4u.su>
335197e
to
045b3c6
Compare
@JelteF We have done all regression tests and are ready for review |
The check has been moved to |
* Moved checks within the prepare_auth_database function * Added additional check for [databases] section which prevents explicit usage of auth_dbname=pgbouncer Tests: * Fixed bug in "run_with_config" context manager * Added "stats" user creation in conftest.py * Added query parameter with default value "select 1" for functions test, atest, psql_test in Pgbouncer class * Refactored tests, now it covers the next cases: 1. Checking broken connection to pgbouncer using auth_dbname from client target DB 2. Checking broken connection to pgbouncer using auth_dbname from fallback DB definition 3. Checking reloading error using auth_dbname from DB definition 4. Checking broken connection to pgbouncer using global auth_dbname 5. Checking successful connection using auth_dbname from client DB, DB definition, and global setting
Going to add additional checks and tests soon:
|
* Implemented `cf_set_authdb` function for parsing auth_dbname in [pgbouncer] section * Added auth_dbname check for `cf_autodb_connstr` * Added warning message in prepare_auth_database Tests: * Adapted tests for cases when we are explicitly set auth_dbname ( * in [pgbouncer] section * in [databases] section: * for all explicitly defined databases * for autodb
21e626b
to
8d0ba3b
Compare
@goksgie The PR is ready to review. All fixes mentioned above were added in the last commit. I should mention that this issue we can meet in any version higher that 1.14, even though I didn’t try to perform the same tests with versions not from master branch. But I almost sure that the root cause is the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think mostly looks good. Though, I think we should remove the added loop in the "cf_autodb_connstr" parser, set_autodb.
Edit: I think I left the review incorrectly 😢 , please check the comments
… explicitly setting the PostgreSQL version, such as postgrsql@15 * Fixed python linters errors * Refactored python tests * Fixes according to reviewer request
8877ca8
to
b6fd901
Compare
Seems that this MR is ready for review.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is very close to merging. Some final feedback. Once that is adressed I think this is good.
3a9a195
to
3778826
Compare
3778826
to
1654ac1
Compare
Total notes about the last changes:
|
Description
This PR contains a bug fix for not existed stats or admin users when auth_query is turned on
This fixes #314
Clarification
I have found in my environment unexpected behavior when some user is trying to connect to pgbouncer. As a result pgbouncer instance crashed with error
@src/objects.c:316 in function put_in_order(): put_in_order: found existing elem
Debug setting
verbose=2
shows me that some that this user isstats
.The psql call is
psql "host=localhost port=6432 dbname=pgbouncer user=stats sslmode=disable"
I looked through
pgbouncer.ini
anduserlixt.txt
and found that the stats user was set inpgbouncer.ini
with the settingstats_users = stats
but it was not in theuserlixt.txt
file.So the original behavior (in this case) is:
It is right when we are connecting to the real database (not admin) or
auth_dbname
was defined and set up in the[databases]
section. But due to we are connecting to the admin DB we are using it as anauth_dbname
by default and the source code does not contain any checks about theadmin
flag. Eventually, before the login query we are adding existing db into the pool and it throws@src/objects.c:316 in function put_in_order(): put_in_order: found existing elem
To repeat this problem use config
pgbouncer.ini
userlist.txt