• unknown's avatar
    Avoid races in connect.test. · c1e69a77
    unknown authored
    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.
    c1e69a77
connect.test 7.88 KB