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

Repeated mysql_library_init()+mysql_library_end() calls do not work

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.0.5
    • None
    • None

    Description

      When trying to call repeated mysql_library_init() and mysql_library_end() it fails on different error.

      With MariaDB Connector/C 2.3.2 I can call

      mysql_library_init(-1, NULL, NULL);
      mysql_library_end();
      

      above code only 1024 times. At 1025 step it fails with error:

      Can't initialize threads: error 95
      

      With client from MariaDB 10.3.6 above code can be called only one time. After second time it fails with error:

      Plugin pvio_socket could not be loaded: not initialized
      

      With client from MariaDB 10.1.26 everything is working fine and 10000 iteration passed without problem.

      This problem was found while developing Perl DBI driver DBD::MariaDB:
      http://github.com/gooddata/DBD-MariaDB

      In attachment is a simple application to testing mysql_library_init() and mysql_library_end() calls. Compile it with gcc test-init.c -o test-init `mysql_config --cflags --libs`

      Attachments

        Issue Links

          Activity

            pali Pali added a comment -

            And when above test-init.c is linked with `mysql_config --cflags --libmysqld-libs` then second run cause deadlock in inline_mysql_cond_destroy. Same reproducer, but third different error.

            $ gcc -W -Wall -O2 -g test-init.c -o test-init `mysql_config --cflags --libmysqld-libs`
            $ gdb --args ./test-init 2 127.0.0.1 3306 pali pali
            ...
            (gdb) r
            ...
            ^C
            Program received signal SIGINT, Interrupt.
            __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
            95      ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Adresár alebo súbor neexistuje.
            (gdb) bt
            #0  __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
            #1  0x00007ffff6184eb5 in __pthread_cond_destroy (cond=cond@entry=0x7ffff7568ae0 <COND_thread_count>) at pthread_cond_destroy.c:34
            #2  0x00007ffff67436c0 in inline_mysql_cond_destroy (that=0x7ffff7568ae0 <COND_thread_count>) at ./include/mysql/psi/mysql_thread.h:1131
            #3  clean_up_mutexes () at ./libmysqld/../sql/mysqld.cc:2264
            #4  0x00007ffff6748974 in end_embedded_server () at ./libmysqld/lib_sql.cc:648
            #5  0x00007ffff674c7ec in mysql_server_end () at ./libmysql/libmysql.c:213
            #6  0x00005555555549e4 in main (argc=<optimized out>, argv=<optimized out>) at test-init.c:49
            (gdb)
            

            This is from MariaDB version 10.1.26, which is available in current Debian stable.

            So it is not only problem of Connector/C, but also of MariaDB server itself.

            pali Pali added a comment - And when above test-init.c is linked with `mysql_config --cflags --libmysqld-libs` then second run cause deadlock in inline_mysql_cond_destroy. Same reproducer, but third different error. $ gcc -W -Wall -O2 -g test-init.c -o test-init `mysql_config --cflags --libmysqld-libs` $ gdb --args ./test-init 2 127.0.0.1 3306 pali pali ... (gdb) r ... ^C Program received signal SIGINT, Interrupt. __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 95 ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Adresár alebo súbor neexistuje. (gdb) bt #0 __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007ffff6184eb5 in __pthread_cond_destroy (cond=cond@entry=0x7ffff7568ae0 <COND_thread_count>) at pthread_cond_destroy.c:34 #2 0x00007ffff67436c0 in inline_mysql_cond_destroy (that=0x7ffff7568ae0 <COND_thread_count>) at ./include/mysql/psi/mysql_thread.h:1131 #3 clean_up_mutexes () at ./libmysqld/../sql/mysqld.cc:2264 #4 0x00007ffff6748974 in end_embedded_server () at ./libmysqld/lib_sql.cc:648 #5 0x00007ffff674c7ec in mysql_server_end () at ./libmysql/libmysql.c:213 #6 0x00005555555549e4 in main (argc=<optimized out>, argv=<optimized out>) at test-init.c:49 (gdb) This is from MariaDB version 10.1.26, which is available in current Debian stable. So it is not only problem of Connector/C, but also of MariaDB server itself.
            pali Pali added a comment -

            Now bug is marked closed. Does it mean that both Connector/C and also libmysqld are fixed? As in "Fix Version/s" field is only 3.0.5 version. What is state with 2.3 series?

            pali Pali added a comment - Now bug is marked closed. Does it mean that both Connector/C and also libmysqld are fixed? As in "Fix Version/s" field is only 3.0.5 version. What is state with 2.3 series?
            georg Georg Richter added a comment - - edited

            Hi Pali,

            we will not fix it in C/C 2.3 series.
            Please also note that there is no need to initialize the client library multiple times. If you don't call mysql_library_init explicitly a call to mysql_init will automatically initialize the library.

            georg Georg Richter added a comment - - edited Hi Pali, we will not fix it in C/C 2.3 series. Please also note that there is no need to initialize the client library multiple times. If you don't call mysql_library_init explicitly a call to mysql_init will automatically initialize the library.

            People

              georg Georg Richter
              pali Pali
              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.