Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-322

mysql_real_connect - EAGAIN treated like EINPROGRESS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.0.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu artful, ppc64le, p9

      Description

      Version from mariadb-server-10.3 branch built last week

      dpkg -l | grep mariadb-dev
      ii  libmariadb-dev                                 10.3.6+maria~artful                          ppc64el      MariaDB database development files
      

      Stracing sysbench liked against libmariadb-dev:

      $  egrep -v '(send|recv)'  sysbench-oltp_read_only-64-mysqld-n8-1_split12.strace  | grep -C 10 -i failed      
      56416 fcntl(11, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
      56416 connect(11, {sa_family=AF_UNIX, sun_path="//var/run/mysqld//mysqld-n8-1.sock"}, 110) = -1 EAGAIN (Resource temporarily unavailable)
      56416 poll([{fd=11, events=POLLOUT}], 1, -1) = 1 ([{fd=11, revents=POLLOUT|POLLHUP}])
      56416 getsockopt(11, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
      56416 fcntl(11, F_SETFL, O_RDONLY)      = 0
      56416 setsockopt(11, SOL_IP, IP_TOS, [8], 4) = -1 EOPNOTSUPP (Operation not supported)
      56416 setsockopt(11, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
      56416 close(11)                         = 0
      56416 write(1, "FATAL: unable to connect to MySQL server on socket '//var/run/mysqld//mysqld-n8-1.sock', aborting...\n", 101) = 101
      56416 write(1, "FATAL: error 2013: Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 22\n", 121) = 121
      56416 write(1, "FATAL: `thread_init' function failed: /usr/local/share/sysbench/oltp_common.lua:352: connection creation failed\n", 112) = 112
      

      The EAGAIN was returned by the connect syscall.

      In https://github.com/MariaDB/mariadb-connector-c/blob/master/plugins/pvio/pvio_socket.c#L614 its handled like EINPROGRESS where eventually via poll (pvio_socket_wait_io_or_timeout) a file the connection will be ready.

      Looking at linux source (net/unix/af_unix.c) this happens when the recv queue is full. When this state the socket isn't in a connected state and polling it won't make it connect.

      So options are:

      • connect code should EAGAIN be handled like EINTR and another attempt is made and the server clears its backlog
      • attempt again while within timeout period
      • an immediate error return

        Attachments

        1. p.p
          1 kB
          Daniel Black

          Activity

            People

            Assignee:
            georg Georg Richter
            Reporter:
            danblack Daniel Black
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.