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

mysql_real_query() does not automatically reconnect

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • Windows 7/8, Using SQLyog and Mariadb C Client

    Description

      When executing queries on the server, if the client gets disconnected, we get the error "MySQL server gone away". After this even when the server is connected/restarted, the client still does not attempt to reconnect to the server. This does not happen in MySQL 5.5

      Attachments

        Activity

          georg Georg Richter added a comment -

          There was an additional bug in mysql_reconnect: The reconnect flag for the new connection wasn't set properly. This was fixed in rev. 58

          georg Georg Richter added a comment - There was an additional bug in mysql_reconnect: The reconnect flag for the new connection wasn't set properly. This was fixed in rev. 58
          georg Georg Richter added a comment -

          Am Donnerstag, den 09.05.2013, 09:37 +0300 schrieb Janani SriGuha

          Hi,

          sorry for the delay, we had (and have today also) some public holidays.

          I was finally able to compile SqlYog with Visual Studio 2012 (for this I
          had to change WINVER to 501 otherwise GetProcessID is unknown).

          Also I had to fix CONC-9 (removing winsock.h) before.

          I did some debugging sessions and think I found the reason: The first
          reconnect attempt will always connect, while subsequent calls will fail,
          since in mysql_reconnect we don't set the reconnect flag for the new
          connection.

          I just pushed the fixes with revision 58.

          Thank you for your patience and for your help!

          Kind regards

          /Georg

          (JIRA):

          georg Georg Richter added a comment - Am Donnerstag, den 09.05.2013, 09:37 +0300 schrieb Janani SriGuha Hi, sorry for the delay, we had (and have today also) some public holidays. I was finally able to compile SqlYog with Visual Studio 2012 (for this I had to change WINVER to 501 otherwise GetProcessID is unknown). Also I had to fix CONC-9 (removing winsock.h) before. I did some debugging sessions and think I found the reason: The first reconnect attempt will always connect, while subsequent calls will fail, since in mysql_reconnect we don't set the reconnect flag for the new connection. I just pushed the fixes with revision 58. Thank you for your patience and for your help! Kind regards /Georg (JIRA):

          Hi,

          We are getting the same issue in a different case. When we insert data which is greater than the size of max_allowed_packet we get the "MySQL server gone away" error (2006). After this, executing any query fails to reconnect to the server.

          Regards,
          Janani

          janani_87 Janani SriGuha added a comment - Hi, We are getting the same issue in a different case. When we insert data which is greater than the size of max_allowed_packet we get the "MySQL server gone away" error (2006). After this, executing any query fails to reconnect to the server. Regards, Janani
          vishal.pr Vishal PR added a comment -

          Regarding above issue reported by Janani,

          Source file: net.c
          Function: net_clear

          The function *net_check_if_data_available* tries to *select* the socket to determine whether its readable and *vio_read* calls *recv* to read the data. The problem here is, its not a must that *recv* will have some data even if *select* is successful. For example if the socket is not properly shutdown. In such situation *recv* will return -1 instead of 0. Since the return type is casted to size_t, which is an unsigned type and the condition check is only for non-zero, it iterates infinitely.

          A simple patch would be to check the return value from *vio_read* against -1. But I just want to make sure that I didn't overlook anything there.

          vishal.pr Vishal PR added a comment - Regarding above issue reported by Janani, Source file: net.c Function: net_clear The function * net_check_if_data_available * tries to * select * the socket to determine whether its readable and * vio_read * calls * recv * to read the data. The problem here is, its not a must that * recv * will have some data even if * select * is successful. For example if the socket is not properly shutdown. In such situation * recv * will return -1 instead of 0. Since the return type is casted to size_t, which is an unsigned type and the condition check is only for non-zero, it iterates infinitely. A simple patch would be to check the return value from * vio_read * against -1. But I just want to make sure that I didn't overlook anything there.
          georg Georg Richter added a comment -

          Hi,

          afaik this was already fixed in rev. 64. Could you please test against latest rev?

          Thanks!

          /Georg

          georg Georg Richter added a comment - Hi, afaik this was already fixed in rev. 64. Could you please test against latest rev? Thanks! /Georg

          People

            georg Georg Richter
            janani_87 Janani SriGuha
            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.