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

mysql_stmt_fetch() returns 1, but mysql_stmt_errno() returns 0

    XMLWordPrintable

Details

    Description

      It appears some SELECT ... FOR UPDATE statements sometimes fail during mysql_stmt_fetch() but no mysql_stmt_errno() is set and mysql_stmt_error() is blank. It looks like we don't need to restart the connection or anything so the connection didn't fail or similar.

      I am using Percona XtraDB Cluster 5.7 (MySQL 5.7 + Galera) that is geo-distributed with a max latency between nodes of 10ms. The requests it occurs on are likely to be run on different nodes simultaneously, though I'm not sure if this is relevant to the issue or not, just a guess.

      I haven't seen if I could write a specific test case to reproduce this.

      The error is output from:
      https://github.com/Monetra/mstdlib/blob/master/sql/mysql/mstdlib_sql_mysql.c#L864

      Looking at the MariaDB Connector/C code, I can see mysql_stmt_fetch() calls out to methods->db_stmt_fetch (mthd_stmt_fetch_row) and methods->db_stmt_fetch_to_bind (mthd_stmt_fetch_to_bind).

      mthd_stmt_fetch_to_bind() can only return 0 or MYSQL_DATA_TRUNCATED(101), so the problem isn't there.

      mthd_stmt_fetch_row points to stmt->fetch_row_func, which appears to be either stmt_unbuffered_fetch() or stmt_cursor_fetch(). As far as I know, we aren't requesting cursors (and don't use STMT_ATTR_PREFETCH_ROWS which from what I know would create a cursor), so I'm pretty sure that means we're taking the stmt_unbuffered_fetch() path.

      In stmt_unbuffered_fetch() I do see a check for pkt_len == packet_error where it will return (1) as an error but never sets an errno or error message, so I'm pretty sure this is what we are hitting.

      This then means why are we getting a packet error?

      Attachments

        Activity

          People

            georg Georg Richter
            bradh352 Brad House
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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