-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hi,
During qualification of package to migrate DBI connector from DBD::MySQL V4.06 to DBD::MariaDB V1.23, I get unwanted error 2006 after having disconnect.
Before all, here is execution environment:
Environment
Client:
- OS : RHEL 8.10
- Perl : V5.34.1
- MariaDB lib : MariaDB 10.5 - libmariadb.so.3
- DBI : V1.643
- DBD: V1.23
Server:
- OS : RHEL 6.6
- DB MySQL : 5.6.39
Application use of DBD
On application side, I use following DBD parameters to instantiate connection handler:
`$l_dbh = DBI->connect("dbi:MariaDB:database=$args->{DBname};host=$args->{DBhost};port=$args->{DBport}", "$args->{DBuser}", "$args->{DBpswd}", {
PrintError => 0,
RaiseError => 1,
AutoCommit => 1,
ShowErrorStatement => 1,
mariadb_auto_reconnect => 0,
mariadb_multi_statements => 1,
mariadb_server_prepare => 0,
} );`
Before calling DBD disconnect, I set up HandlError with application callback to format DB error return as the following.
`local ${$args->{DBhandleRef}}->{HandleError} = sub { handle_error_my_U (@_, $args->{DBthrdIdRef}, $args->{dbmyname_users}, $args->{isConnectRef}) };
if (defined(${$args->{DBhandleRef}})) {
${$args->{isConnectRef}} = 0;
$prepdQueryU->{$args->{DBname}} = {};
if (${$args->{DBhandleRef}}->disconnect()) {
## Enhancements againts leaking DBI datastructure ### http://stackoverflow.com/questions/13338308/perl-dbi-memory-leak
$DBI::lasth->{ChildHandles} = [];
${$args->{DBthrdIdRef}} = 0;
undef ${$args->{DBhandleRef}};
return(1);
} else {
return (0);
}`
Issue identification
During disconnect process, DB error 2006 'MySQL server has gone away' is raise by the internal error handle callback function such as:
>>> FATAL: MySQL DBI tripped on:.DBD::MariaDB::db STORE failed: MySQL server has gone away
Analyzing BDI trace I observe that the STORE operation is triggered by the error handler and generate the error message such as below:

Trace has been generated by the mariadb_db_STORE_attrib function at following lines:
https://github.com/perl5-dbi/DBD-MariaDB/blob/be52823a9a33a1d87a6fcaa162ecaa4765a27bdc/dbdimp.c#L3375C2-L3381C4
Comparing the mariadb_db_STORE_attrib function with the equivalent dbd_db_STORE_attrib function in DBD::mysql V4.06 I can see that the lines above implement additional logic that is creating the unwanted error in our envionment.
Does the logic behind that connection check is required for the module to work ? Is there a new way to call HandleError with DBD::MariaDB V1.23 module ?
Thank a lot for helping to understand what is going on
Theoverflow
PS
1 : Further tests showed that removing Perl key-word local at HandleError definition before disconnect at application level remove the STORE call from application to DBI, thus the raise of error 2006.
2 : Other tests showed that moving connection check logic of the dbdimp.c after the check of the AutoCommit (as below), allows to call the STORE but without raising the unwanted error 2006.
