Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-681

Loading service users error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.4.2
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Debian GNU/Linux 8.2 (jessie)
      MaxScale 1.4.1
      MySQL 5.7.12-log

      Description

      After a installing MaxScale on a freshly installed VM using the default config (expect server locations) it fails with the following error in the log:

      2016-04-21 12:24:48 debug : Dbusers : Loading data from backend database with Master role [10.0.3.26:3306] for service [Read-Write Service]
      2016-04-21 12:24:48 error : Loading users for service [Read-Write Service] encountered error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'B' at line 1].

      MaxScale doesn't log internal queries so I used tcpdump to capture the query

      13:24:55.798079 IP 10.0.3.16.52185 > 10.0.3.26.3306: Flags [P.], seq 2183529305:2183529981, ack 3775999896, win 229, options [nop,nop,TS val 42627172 ecr 42101003], length 676
      E...r.@.@...
      ...
      ........&.Y../............
      ..pd..i......SELECT COUNT(1) AS nusers_db FROM (SELECT DISTINCT user.user AS user, user.host AS host, user.authentication_string AS password, concat(user.user,user.host,user.authentication_string, IF((user.Select_priv+0)||find_in_set('Select',Coalesce(tp.Table_priv,0)),'Y','N') , COALESCE( db.db,tp.db, '')) AS userdata, user.Select_priv AS anydb, COALESCE( db.db,tp.db, NULL) AS db FROM mysql.user LEFT JOIN mysql.db ON user.user=db.user AND user.host=db.host LEFT JOIN mysql.tables_priv tp ON user.user=tp.user AND user.host=tp.host WHERE user.user IS NOT NULL AND user.user <> '' AND user.user NOT IN ('root') ORDER B

      13:24:55.798440 IP 10.0.3.26.3306 > 10.0.3.16.52185: Flags [P.], seq 3775999896:3776000056, ack 2183529981, win 246, options [nop,nop,TS val 42101003 ecr 42627172], length 160
      E...F3@.@...
      ...
      ........./..&.............
      ..i...pd.....(.#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'B' at line 1

      Looking at the code I think I found the cause in server/core/dbusers.c. It seems that the MAX_QUERY_STR_LEN is incorrect.

      The definition is:

      /** The maximum possible length of the query */
      #define MAX_QUERY_STR_LEN strlen(MYSQL_USERS_COUNT_TEMPLATE_START \
      MYSQL_USERS_COUNT_TEMPLATE_END MYSQL_USERS_DB_QUERY_TEMPLATE \
      MYSQL_USERS_ORDER_BY) + strlen(MYSQL57_PASSWORD) * 2 + 1

      While the code in the get_usercount_query function actually uses:

      snprintf(buffer, MAX_QUERY_STR_LEN, MYSQL_USERS_COUNT_TEMPLATE_START
      MYSQL_USERS_DB_QUERY_TEMPLATE "%s" MYSQL_USERS_ORDER_BY
      MYSQL_USERS_COUNT_TEMPLATE_END, password, password,
      include_root ? "" : USERS_QUERY_NO_ROOT);

      The USERS_QUERY_NO_ROOT seems to be missing in the MAX_QUERY_STR_LEN.

        Attachments

          Activity

            People

            Assignee:
            markus makela markus makela
            Reporter:
            osteenbergen Onno Steenbergen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: