Skip to content

Commit

Permalink
Fix counter leak in nonsuper_connections (#1069)
Browse files Browse the repository at this point in the history
Summary:
If a non-super user connects to mysqld with an invalid database name,
nonsuper_connections is incremented, but never decremented.

Squash with D13987618

8.0 porting notes:
Since nonsuper_connections is already decremented by calling
release_user_connection(), changes to the code are not needed. Test is
ported though to make sure the leak won't appear again.

Reference Patch: 3cc5162fdc2

Pull Request resolved: #1069

Reviewed By: yizhang82

Differential Revision: D19129736

Pulled By: hermanlee

fbshipit-source-id: 64a9117
  • Loading branch information
Herman Lee authored and facebook-github-bot committed Dec 30, 2019
1 parent b7d4260 commit 8a269ee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions mysql-test/r/max_nonsuper_connections.result
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ disconnect con4;
disconnect con3;
disconnect con2;
disconnect con1;
Verifying nonsuper_connections is decremented when db is denied
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'bogus_db'
connection default;
connect con$i, localhost, test_user,,test;
connect con$i, localhost, test_user,,test;
Expand Down
11 changes: 11 additions & 0 deletions mysql-test/t/max_nonsuper_connections.test
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ while ($i)
dec $i;
}

# Verify counter leak is fixed when permission to a database is denied
--echo Verifying nonsuper_connections is decremented when db is denied
--disable_query_log
--let $i = 20
--while ($i) {
--error ER_DBACCESS_DENIED_ERROR
--connect (con_denied_$i, localhost, test_user,,bogus_db)
--dec $i
--}
--enable_query_log

# able to refill up max_nonsuper_connections
connection default;
let $i = 10;
Expand Down

0 comments on commit 8a269ee

Please sign in to comment.