perl5-dbi/DBD-MariaDB

Can't disconnect and connect again

Tekki opened this issue · 10 comments

Tekki commented

Using the code from Github at 7eba1f3
Perl 5.28.0 (https://hub.docker.com/_/perl)
MySQL libraries from repo.mysql.com
MariaDB 10.3 on host 'maria3'

Test script (disconnect.t):

#!/usr/bin/env perl
use strict;
use warnings;

use DBI;
use Test::More tests => 3;

note 'One';
ok my $dbh = DBI->connect(split /--/, $ENV{TEST_DB});

note 'Two';
ok $dbh->disconnect;

note 'Three';
ok $dbh = DBI->connect(split /--/, $ENV{TEST_DB});

Try with DBD::MariaDB.

# export TEST_DB=DBI:MariaDB:database=test:host=maria3--testuser--mysecretpassword
# prove -v disconnect.t
disconnect.t ..
1..3
# One
ok 1
# Two
ok 2
# Three
Failed 1/3 subtests

Test Summary Report
-------------------
disconnect.t (Wstat: 11 Tests: 2 Failed: 0)
  Non-zero wait status: 11
  Parse errors: Bad plan.  You planned 3 tests but ran 2.

Try the same with DBD::mysql.

# export TEST_DB=DBI:mysql:database=test:host=maria3--testuser--mysecretpassword
# prove -v disconnect.t
1..3
# One
ok 1
# Two
ok 2
# Three
ok 3
ok
All tests successful.

This is weird. The test passes for me. What version of the server and client do you use? Is there any proxy involved? Also, does the test t/13disconnect.t pass for you? It does basically the same thing.

Tekki commented

I run the tests in a Docker container based on image tekki/mojolicious:8.12-mysql that includes libmysqlclient-dev 8.0.15-1debian9, against databases in other containers. Whatever db I use, MariaDB 10.3, 10.4, MySQL 5.6 or 5.7, the script always exits at the second ->connect.
I'm not able to try t/13... because it doesn't seem to accept export DBI_DSN=....
By the way, did you notice that you have 100 % failures on CPAN with the new release?

There's already a fix for the failures (it was a pass in an END block which didn't get skipped on smokers without a database).

Also, when I add exit or POSIX::_exit instead of the third test, there's usually a line like

Dubious, test returned 11 (wstat 2816, 0xb00)

or

# Looks like your test exited with 11 just after 2.

that's missing in your output. It seems it crashes really hard. I'm not sure we're able to create a similar docker configuration, but we should at least try :-)

pali commented

I'm not able to try t/13... because it doesn't seem to accept export DBI_DSN=....

This is not truth. It accepts DBI_DSN env variable in case you have not already configured DBD::MariaDB for compilation and running tests via Makefile.PL.

And if you already have configured DBD::MariaDB for running tests via Makefile.PL why you cannot run that test?

Btw, if you configured it incorrectly, just run Makefile.PL again. See perl Makefile.PL --help for test options.

Tekki commented

Yes, if I configure it via Makefile.PL it works.

t/13disconnect.t ..
1..17
ok 1
ok 2
ok 3
Failed 14/17 subtests

It's a segmentation fault. The same with Docker on Windows and Docker on Debian.

@pali I can reproduce it with provided docker image.
Backtrace:

#0  std::__detail::_Mod_range_hashing::operator() (this=0x0, __den=<optimized out>, __num=<optimized out>)
    at /usr/include/c++/6/bits/hashtable_policy.h:446
No locals.
#1  std::__detail::_Hash_code_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int>, std::__detail::_Select1st, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::_M_bucket_index (this=0x0, __n=<optimized out>, __c=<optimized out>) at /usr/include/c++/6/bits/hashtable_policy.h:1260
No locals.
#2  std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_bucket_index (this=0x0, __k="utf8mb4", __c=<optimized out>) at /usr/include/c++/6/bits/hashtable.h:623
No locals.
#3  std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::find (this=0x0, __k="utf8mb4") at /usr/include/c++/6/bits/hashtable.h:1293
        __code = 6858175801217817897
        __n = <error reading variable __n (Cannot access memory at address 0x8)>
        __p = <optimized out>
#4  0x00007f89ab9b537f in std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, int> > >::find (__x=..., this=<optimized out>) at /usr/include/c++/6/bits/unordered_map.h:851
No locals.
#5  get_charset_number_internal (charset_name=charset_name@entry=0x55bd2e6f2780 "utf8mb4", cs_flags=cs_flags@entry=32)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/mysys/charset.cc:476
        name_num_map_it = <optimized out>
        lower_case_name = "utf8mb4", '\000' <repeats 248 times>
#6  0x00007f89ab9b54c1 in get_charset_number (charset_name=0x55bd2e6f2780 "utf8mb4", cs_flags=32)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/mysys/charset.cc:504
        id = <optimized out>
#7  0x00007f89ab9b5545 in my_charset_get_by_name (loader=0x7ffd6c8c2df0, cs_name=0x55bd2e6f2780 "utf8mb4", cs_flags=32, flags=16)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/mysys/charset.cc:640
        cs_number = <optimized out>
        cs = <optimized out>
#8  0x00007f89ab9b55cb in get_charset_by_csname (cs_name=0x55bd2e6f2780 "utf8mb4", cs_flags=cs_flags@entry=32, flags=flags@entry=16)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/mysys/charset.cc:656
        loader = {errcode = 0, 
          errarg = "\000\000\000\000@\305z.\275U\000\000\200b{.\275U\000\000\000\000\000\000\000\000\000\000@.\214l\375\177\000\000\070\006\227\253\211\177\000\000\\\000\000\000n\000\000\000\200b{.\275U\000\000R\000\000\000\000\000\000\000\250.\214l\375\177\000\000\200.\214l\375\177\000\000G\t\227\253\211\177\000\000\020\000\000\000\000\000\000\000R\000\000\000\000\000\000\000k\000\000\000p\000\000\000\200b{.\275U\000\000\000\000\000\000\000\000\000\000\250.\214l\375\177\000\000\340.\214l\375\177\000\000\024\022\227\253\211\177\000\000' \000\000\000\000\000\000\a \000\000\001\000\000\000' ", '\000' <repeats 17 times>, 
          once_alloc = 0x7f89ab9b40d0 <my_once_alloc_c(size_t)>, mem_malloc = 0x7f89ab9b4110 <my_malloc_c(size_t)>, 
          mem_realloc = 0x7f89ab9b40f0 <my_realloc_c(void*, size_t)>, mem_free = 0x7f89ab9b40e0 <my_free_c(void*)>, 
          reporter = 0x7f89ab9b40a0 <default_reporter(loglevel, uint, ...)>, 
          add_collation = 0x7f89ab9b6150 <add_collation(CHARSET_INFO*)>}
#9  0x00007f89ab969132 in mysql_set_character_set_with_default_collation (mysql=0x55bd2e7b6280)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/sql-common/client.cc:2962
        save = 0x0
#10 mysql_init_character_set (mysql=0x55bd2e7b6280)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/sql-common/client.cc:2993
No locals.
#11 0x00007f89ab96d49c in mysql_real_connect (mysql=0x55bd2e7b6280, host=0x55bd2e7b3010 "127.0.0.1", user=<optimized out>, 
    passwd=0x55bd2e7b2d10 "password", db=0x55bd2e7b31d0 "test", port=3306, unix_socket=0x0, client_flag=2147614722)
    at /export/home/pb2/build/sb_0-32399779-1548458155.51/release/mysql-8.0.15/sql-common/client.cc:4629
        buff = "127.0.0.1 via TCP/IP", '\000' <repeats 52 times>, "\003\000\000\000\000\000\000\000(", '\000' <repeats 88 times>, "\253\b\255\211\177\000\000(\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000(\000\000\000\000\000\000\000"...
        scramble_data_len = 9
        pkt_scramble_len = 21
        end = 0x55bd2e7ac56f "ui1WA!}w[BuI"
        host_info = 0x7ffd6c8c3060 "127.0.0.1 via TCP/IP"
        server_version_end = 0x55bd2e7ac54f ""
        pkt_end = <optimized out>
        scramble_data = 0x55bd2e7ac554 "{Si:\"<H7"
        scramble_buffer = 0x0
        scramble_plugin = 0x0
        pkt_length = 82
        net = 0x55bd2e7b6280
        scramble_buffer_allocated = false
        UNIXaddr = {sun_family = 13107, sun_path = "06", '\000' <repeats 105 times>}
#12 0x00007f89ac08ba6d in mariadb_db_my_login () from blib/arch/auto/DBD/MariaDB/MariaDB.so
---Type <return> to continue, or q <return> to quit--- 
No symbol table info available.
#13 0x00007f89ac08e959 in mariadb_db_login6_sv () from blib/arch/auto/DBD/MariaDB/MariaDB.so
No symbol table info available.
#14 0x00007f89ac088d4b in XS_DBD__MariaDB__db__login () from blib/arch/auto/DBD/MariaDB/MariaDB.so
No symbol table info available.
#15 0x00007f89adef3802 in Perl_pp_entersub () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#16 0x00007f89adee9523 in Perl_runops_standard () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#17 0x00007f89ade69363 in Perl_call_sv () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#18 0x00007f89ac8d5072 in XS_DBI_dispatch () from /usr/local/lib/perl5/site_perl/5.28.0/x86_64-linux-gnu/auto/DBI/DBI.so
No symbol table info available.
#19 0x00007f89adef3802 in Perl_pp_entersub () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#20 0x00007f89adee9523 in Perl_runops_standard () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#21 0x00007f89ade70993 in perl_run () from /usr/local/lib/perl5/5.28.0/x86_64-linux-gnu/CORE/libperl.so
No symbol table info available.
#22 0x000055bd2c465e5b in main ()
No symbol table info available.

When I downgrade MySQL in docker to 5.7, test pass.
So it connected to MySQL 8.

Tekki commented

@janchochol you mean the problem comes with libmysqlclient-dev 8.0.15-1debian9?

@Tekki yes, there is bug https://bugs.mysql.com/bug.php?id=93276, which should be fixed in 8.0.15 (so we are not workarounding it for this version), but it obviously is not fixed.
@pali will contact Oracle and re-introduce workaround for 8.0.15, so it will work even for this version.

pali commented

@Tekki New version 1.21 of DBD::MariaDB is now on cpan. It includes workaround for this issue.