Details

    • 5.5.49

    Description

      Client that is connected with SSL, that stays idle for a while, will be disconnected.
      To reproduce

      • start the server with ssl, e.g

        perl mysql-test-run.pl ssl --start

      • connect with ssl client, e.g

        mysql -uroot --port=16000 --ssl

      • issue a command, e.g SELECT 1
      • wait 1 minute
      • repeat SELECT 1
      • see

        ERROR 2013 (HY000): Lost connection to MySQL server during query

      Attachments

        Activity

          wlad Vladislav Vaintroub added a comment - - edited

          The actual reason why the connection is lost seems to be a bug in yassl's implementation of SSL_pending(), which is called inside vio_ssl_has_data().
          The socket is doing blocking recv() inside this function, and runs into net_read_timeout after a while. After that, connection breaks.

          Doing blocking reads inside vio_ssl_has_data (or SSL_pending) does not sound like a great idea.

          Below is the callstack of the blocking recv() calls

          >Debug.ListCallStack /T:No /ShowByteOffset:No /ShowValues:No /ShowExternalCode:Yes
           Index  Function
          --------------------------------------------------------------------------------
           1      ntdll.dll!_ZwWaitForSingleObject@12()
           2      mswsock.dll!_SockWaitForSingleObject@16()
           3      mswsock.dll!_WSPRecv@36()
           4      ws2_32.dll!_recv@16()
          *5      mysqld.exe!yaSSL::Socket::wait()
           6      mysqld.exe!yaSSL::DoProcessReply(ssl)
           7      mysqld.exe!yaSSL::processReply(ssl)
           8      mysqld.exe!yaSSL::receiveData(ssl, data, peek)
           9      mysqld.exe!yaSSL_peek(ssl, buffer, sz)
           10     mysqld.exe!yaSSL_pending(ssl)
           11     mysqld.exe!vio_ssl_has_data(vio)
           12     mysqld.exe!threadpool_process_request(thd)
           13     mysqld.exe!io_completion_callback(instance, context, overlapped, io_result, nbytes, io)
           
           ---------------------------------------------------------------------------------
           1      mysqld.exe!vio_read(vio, buf, size)
           2      mysqld.exe!yassl_recv(ptr, buf, len, flag)
           3      mysqld.exe!yaSSL::Socket::receive(buf, sz, flags)
           4      mysqld.exe!yaSSL::DoProcessReply(ssl)
           5      mysqld.exe!yaSSL::processReply(ssl)
           6      mysqld.exe!yaSSL::receiveData(ssl, data, peek)
           7      mysqld.exe!yaSSL_peek(ssl, buffer, sz)
           8      mysqld.exe!yaSSL_pending(ssl)
           9      mysqld.exe!vio_ssl_has_data(vio)
           10     mysqld.exe!threadpool_process_request(thd)
           11     mysqld.exe!io_completion_callback(instance, context, overlapped, io_result, nbytes, io)
          

          wlad Vladislav Vaintroub added a comment - - edited The actual reason why the connection is lost seems to be a bug in yassl's implementation of SSL_pending() , which is called inside vio_ssl_has_data() . The socket is doing blocking recv() inside this function, and runs into net_read_timeout after a while. After that, connection breaks. Doing blocking reads inside vio_ssl_has_data (or SSL_pending ) does not sound like a great idea. Below is the callstack of the blocking recv() calls >Debug.ListCallStack /T:No /ShowByteOffset:No /ShowValues:No /ShowExternalCode:Yes Index Function -------------------------------------------------------------------------------- 1 ntdll.dll!_ZwWaitForSingleObject@12() 2 mswsock.dll!_SockWaitForSingleObject@16() 3 mswsock.dll!_WSPRecv@36() 4 ws2_32.dll!_recv@16() *5 mysqld.exe!yaSSL::Socket::wait() 6 mysqld.exe!yaSSL::DoProcessReply(ssl) 7 mysqld.exe!yaSSL::processReply(ssl) 8 mysqld.exe!yaSSL::receiveData(ssl, data, peek) 9 mysqld.exe!yaSSL_peek(ssl, buffer, sz) 10 mysqld.exe!yaSSL_pending(ssl) 11 mysqld.exe!vio_ssl_has_data(vio) 12 mysqld.exe!threadpool_process_request(thd) 13 mysqld.exe!io_completion_callback(instance, context, overlapped, io_result, nbytes, io) --------------------------------------------------------------------------------- 1 mysqld.exe!vio_read(vio, buf, size) 2 mysqld.exe!yassl_recv(ptr, buf, len, flag) 3 mysqld.exe!yaSSL::Socket::receive(buf, sz, flags) 4 mysqld.exe!yaSSL::DoProcessReply(ssl) 5 mysqld.exe!yaSSL::processReply(ssl) 6 mysqld.exe!yaSSL::receiveData(ssl, data, peek) 7 mysqld.exe!yaSSL_peek(ssl, buffer, sz) 8 mysqld.exe!yaSSL_pending(ssl) 9 mysqld.exe!vio_ssl_has_data(vio) 10 mysqld.exe!threadpool_process_request(thd) 11 mysqld.exe!io_completion_callback(instance, context, overlapped, io_result, nbytes, io)

          People

            serg Sergei Golubchik
            wlad Vladislav Vaintroub
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.