Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6726

CONNECTION_ATTRS not stored in performance schema

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 10.0.12
    • Fix Version/s: N/A
    • Component/s: OTHER
    • Labels:
    • Environment:
      Linux x64

      Description

      Both mysql_client_test (from MySQL Server package) and mariadb-native-client test suite suite fail, since connection attributes are not stored in performance schema.

      Test:

      static void test_wl5924()
      {
        int rc;
        MYSQL *l_mysql;
        MYSQL_RES *res;
        MYSQL_ROW row;
      
        myheader("test_wl5924");
      
        l_mysql= mysql_client_init(NULL);
        DIE_UNLESS(l_mysql != NULL);
      
        /* we want a non-default character set */
        rc= mysql_set_character_set(l_mysql, "cp1251");
        DIE_UNLESS(rc == 0);
      
        /* put in an attr */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key1", "value1");
        DIE_UNLESS(rc == 0);
      
        /* put a second attr */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key2", "value2");
        DIE_UNLESS(rc == 0);
      
        /* put the second attr again : should fail */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key2", "value2");
        DIE_UNLESS(rc != 0);
      
        /* delete the second attr */
        rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_DELETE,
                          "key2");
        DIE_UNLESS(rc == 0);
      
        /* put the second attr again : should pass */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key2", "value2");
        DIE_UNLESS(rc == 0);
      
        /* full reset */
        rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_RESET, NULL);
        DIE_UNLESS(rc == 0);
      
        /* put the second attr again : should pass */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key2", "value2");
        DIE_UNLESS(rc == 0);
      
        /* full reset */
        rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_RESET, NULL);
        DIE_UNLESS(rc == 0);
      
        /* add a third attr */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key3", "value3");
        DIE_UNLESS(rc == 0);
      
        /* add a fourth attr */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "key4", "value4");
        DIE_UNLESS(rc == 0);
      
        /* add a non-ascii attr */
        /* note : this is Георги, Кодинов in windows-1251 */
        rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                           "\xc3\xe5\xee\xf0\xe3\xe8",
                           "\xca\xee\xe4\xe8\xed\xee\xe2");
        DIE_UNLESS(rc == 0);
      
        l_mysql= mysql_real_connect(l_mysql, opt_host, opt_user,
                               opt_password, current_db, opt_port,
                               opt_unix_socket, 0);
        DIE_UNLESS(l_mysql != 0);
      
        rc= mysql_query(l_mysql,
                        "SELECT ATTR_NAME, ATTR_VALUE "
                        " FROM performance_schema.session_account_connect_attrs"
                        " WHERE ATTR_NAME IN ('key1','key2','key3','key4',"
                        "  '\xc3\xe5\xee\xf0\xe3\xe8') AND"
                        "  PROCESSLIST_ID = CONNECTION_ID() ORDER BY ATTR_NAME");
        myquery2(l_mysql,rc);
        res= mysql_use_result(l_mysql);
        DIE_UNLESS(res);
      
        row= mysql_fetch_row(res);
        DIE_UNLESS(row);
        DIE_UNLESS(0 == strcmp(row[0], "key3"));
        DIE_UNLESS(0 == strcmp(row[1], "value3"));
      
        row= mysql_fetch_row(res);
        DIE_UNLESS(row);
        DIE_UNLESS(0 == strcmp(row[0], "key4"));
        DIE_UNLESS(0 == strcmp(row[1], "value4"));
      
        row= mysql_fetch_row(res);
        DIE_UNLESS(row);
        DIE_UNLESS(0 == strcmp(row[0], "\xc3\xe5\xee\xf0\xe3\xe8"));
        DIE_UNLESS(0 == strcmp(row[1], "\xca\xee\xe4\xe8\xed\xee\xe2"));
      
        mysql_free_result(res);
      
        l_mysql->reconnect= 1;
        rc= mysql_reconnect(l_mysql);
        myquery2(l_mysql,rc);
      
        mysql_close(l_mysql);
      }
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Are you running the server with --performance-schema?
            Keep in mind that it's disabled by default in 10.0 (unlike 5.6 where it's enabled by default).

            Show
            elenst Elena Stepanova added a comment - Are you running the server with --performance-schema? Keep in mind that it's disabled by default in 10.0 (unlike 5.6 where it's enabled by default).
            Hide
            georg Georg Richter added a comment - - edited

            Hi Elena,

            i wasn't aware that performance-schema was disabled by default.
            However in this case I would expect that testing

            mysql->server_capabilities & CLIENT_CONNECT_ATTRS
            

            will fail.

            Show
            georg Georg Richter added a comment - - edited Hi Elena, i wasn't aware that performance-schema was disabled by default. However in this case I would expect that testing mysql->server_capabilities & CLIENT_CONNECT_ATTRS will fail.
            Hide
            elenst Elena Stepanova added a comment -

            According to the documentation (http://dev.mysql.com/doc/internals/en/capability-flags.html), the flag only means that the server allows connection attributes in Protocol::HandshakeResponse41. It still does, whether performance schema is enabled or not, so why should this check fail?

            Show
            elenst Elena Stepanova added a comment - According to the documentation ( http://dev.mysql.com/doc/internals/en/capability-flags.html ), the flag only means that the server allows connection attributes in Protocol::HandshakeResponse41. It still does, whether performance schema is enabled or not, so why should this check fail?
            Hide
            elenst Elena Stepanova added a comment -

            In any case, it's an upstream problem. It would be particularly unfortunate if our server or clients became incompatible with the upstream on this level.

            Georg Richter
            Do you want to report it to MySQL to see what they say?

            Show
            elenst Elena Stepanova added a comment - In any case, it's an upstream problem. It would be particularly unfortunate if our server or clients became incompatible with the upstream on this level. Georg Richter Do you want to report it to MySQL to see what they say?
            Hide
            serg Sergei Golubchik added a comment -

            I believe it is not a bug. The server supports connection attributes, it knows how to parse the packet with them, that's why the capability bit is set.

            Whether the server will store them or throw away is a separate issue. Currently, the server stores them in the performance schema, that's why if performance schema is disabled — connection attributes are not stored.

            Show
            serg Sergei Golubchik added a comment - I believe it is not a bug. The server supports connection attributes, it knows how to parse the packet with them, that's why the capability bit is set. Whether the server will store them or throw away is a separate issue. Currently, the server stores them in the performance schema, that's why if performance schema is disabled — connection attributes are not stored.

              People

              • Assignee:
                Unassigned
                Reporter:
                georg Georg Richter
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: