1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Avoid races in connect.test.

The problem was in a test case for Bug33507:
  - when the number of active connections reaches the limit,
    the server accepts only root connections. That's achieved by
    accepting a connection, negotiating with the client and
    checking user credentials. If it is not SUPER, the connection
    is dropped.
  - when the server accepts connection, it increases the counter;
  - when the server drops connection, it decreases the counter;
  - the race was in between of decreasing the counter and accepting
    new connection:
    - max_user_connections = 2;
    - 2 oridinary user connections accepted;
    - extra user connection is establishing;
    - server checked user credentials, and sent 'Too many connections'
      error;
    - the client receives the error and establishes extra SUPER user
      connection;
    - the server however didn't decrease the counter (the extra
      user connection still is "alive" in the server) -- so, the new
      SUPER-user connection, will be dropped, because it exceeds
      (max_user_connections + 1).

The fix is to implement "safe connect", which makes several attempts
to connect and use it in the test script.


mysql-test/r/connect.result:
  Update test file.
mysql-test/t/connect.test:
  Avoid races in connect.test.
mysql-test/include/connect2.inc:
  Auxiliary routine to establish a connection reliably.
This commit is contained in:
unknown
2008-03-17 14:26:00 +03:00
parent 30d644f859
commit c1e69a77a6
3 changed files with 114 additions and 59 deletions

View File

@ -127,8 +127,7 @@ GRANT USAGE ON *.* TO mysqltest_u1@localhost;
SET GLOBAL max_connections = 3;
SET GLOBAL event_scheduler = ON;
# -- Waiting for old connections to close...
# -- Waiting for Event Scheduler to start...
# -- Disconnecting default connection...
@ -136,22 +135,33 @@ SET GLOBAL event_scheduler = ON;
# -- many threads are running.
# -- Connecting (1)...
# -- Waiting for root connection to close...
# -- Establishing connection 'con_1' (user: mysqltest_u1)...
# -- Connection 'con_1' has been established.
# -- Connecting (2)...
# -- Connecting (3)...
# -- Connecting (4)...
ERROR 08004: Too many connections
# -- Establishing connection 'con_2' (user: mysqltest_u1)...
# -- Connection 'con_2' has been established.
# -- Waiting for the last connection to close...
# -- Connecting (3)...
# -- Establishing connection 'con_3' (user: mysqltest_u1)...
# -- Connection 'con_3' has been established.
# -- Connecting (4) [should fail]...
# -- Establishing connection 'con_4' (user: mysqltest_u1)...
# -- Error: can not establish connection 'con_4'.
# -- Check that we allow one extra SUPER-user connection.
# -- Connecting super (1)...
# -- Connecting super (2)...
ERROR HY000: Too many connections
# -- Establishing connection 'con_super_1' (user: root)...
# -- Connection 'con_super_1' has been established.
# -- Connecting super (2) [should fail]...
# -- Establishing connection 'con_super_2' (user: root)...
# -- Error: can not establish connection 'con_super_2'.
# -- Ensure that we have Event Scheduler thread, 3 ordinary user
# -- connections and one extra super-user connection.
SELECT user FROM information_schema.processlist ORDER BY id;
user
event_scheduler
@ -165,6 +175,7 @@ SET GLOBAL max_connections = 151;
# -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
# -- Waiting for Event Scheduler to stop...
# -- That's it. Closing connections...