New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBD::mysql::st execute failed: MySQL server has gone away #13
Comments
I honestly have no idea, since I don't use MySQL. I think someone who knows MySQL well will have to provide some feedback… |
I asked Ask. He said:
Dunno if that helps. But someone more familiar with MySQL than I will have to diagnose this, since I don't use it. Happy to accept a patch to fix it if it's DBIx::Connector that needs to be fixed (or needs to work around some other "fix"). |
No more complaints. Issue resolved? |
encountering this issue. I checked MySQL's processlist to find the connection that
|
Likely a MySQL (or DBD::mysql) expert will have to weigh in. I don't use it. :-( |
Worth knowing that:
http://search.cpan.org/~michielb/DBD-mysql-4.043/lib/DBD/mysql.pm
|
DBIx::Connector::Driver::mysql turns it off. |
I'm surprised by how this is handled though. My script is something like this: my $dsn = "DBI:mysql:database=$conf{'db_name'};host=$conf{'db_host'}";
my $conn = DBIx::Connector->new($dsn, $conf{'db_user'}, $conf{'db_passwd'}, {
RaiseError => 1, # save having to check each method call
AutoCommit => 0, # we'll handle transactions ourselves
mysql_server_prepare => 1
});
$conn->txn(fixup => sub {
my $dbh = shift;
my $statement = $dbh->prepare(<<SQL);
SELECT *
FROM whatever
WHERE key = ?;
SQL
# other stuff
}); I've killed the connection, so we see the error as expected:
But I expected that the behaviour of fixup would be that we would try to re-establish the connection, and run the block again. Instead: it fails, and does not try again. Let's ignore the MySQL-specific part of the problem for now. Why is there no attempt at a retry? I thought one of the main things that |
It thinks it's still connected. This works:
Output:
DBIx::Connector determines if a database has disconnected by looking at:
One of these tests must have DBIx::Connector thinking that the database has not been disconnected. Maybe see what |
thanks for the explanation. I'll try and find the guilty check. |
Actually, it never seems to enter the use IO::Handle;
sub connected {
my $self = shift;
STDOUT->printflush("Checking if seems connected\n");
return unless $self->_seems_connected;
STDOUT->printflush("Seems connected. Checking if dbh\n");
my $dbh = $self->{_dbh} or return;
STDOUT->printflush("Dbh available. Pinging\n");
return $self->driver->ping($dbh);
} None of those lines gets printed. As a sanity-check: I confirmed that my tracing technique does work (this got printed): sub _connect {
my $self = shift;
STDOUT->printflush("_connect\n"); |
Huh. Try putting some |
Was this ever solved? We are still seeing this issue. |
Not to my knowledge. Can you try the |
Isn't this simply that the MySQL/MariaDB driver prints errors to STDERR by default? Try switching off the PrintError option - e.g. my $dsn = "DBI:mysql:database=$conf{db_name};host=$conf{db_host}";
my $conn = DBIx::Connector->new( $dsn, $conf{db_user}, $conf{db_passwd}, {
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
}); |
Hello,
I used to get this issue on another server which was fixed by setting mysql_auto_reconnect => 0.
I am now getting this on an additional server. I tried this setting with no such luck.
Here is how I am using the code
https://gist.github.com/1219198
DBD::mysql is up to date (4.020).
DBIx::Connector is up to date (0.46).
I saw theres a 0.47 version here on github but I am using cpan to update.
Are there any suggestions on how I can fix this?
The text was updated successfully, but these errors were encountered: