Bug#849121: $dbh->state sometimes trashed
Ian Jackson
ian.jackson at eu.citrix.com
Thu Dec 22 19:21:08 UTC 2016
Package: libdbd-pg-perl
Version: 2.19.2-2+deb7u1
my $dbh= DBI->connect("dbi:Pg:$pg", '','', {
AutoCommit => 1,
HandleError => sub {
my ($emsg,$edbh,$firstval) = @_;
if (Osstest::JobDB::Executive::_need_retry($edbh)) {
chomp $emsg;
printf STDERR "DB confict (err=%s state=%s): %s\n",
($edbh->err // 'undef'),
$edbh->state,
$emsg;
die new Osstest::JobDB::Executive::RetryException $emsg;
}
...
[ do things with $dbh ]
...
package Osstest::JobDB::Executive;
sub _need_retry ($) {
my ($dbh) = @_;
return
($dbh->err() // 0)==7 &&
($dbh->state =~ m/^(?:40P01|40001|23|40002|$)/);
# ...
}
Sometimes, when used with SET TRANSACTION ISOLATION LEVEL
SERIALIZABLE, generates this message:
DB confict (err=7 state=): DBD::Pg::db selectrow_hashref failed: ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot, during conflict out checking.
HINT: The transaction might succeed if retried. [for Statement " SELECT *
[...rest of message deleted -iwj...]
Observe that the "state" value is "", meaning no error. This is
AFAICT contrary to the documentation and also not very helpful.
I conjecture that DBD::Pg is doing "something else" which completes
successfully, trashing the error code. But, if this is true, it is
funny that $dbh->err is not reset.
I have no real knowledge of whether this is a bug in DBD::Pg, or some
lower layer. I could perhaps test a debugging patch to something if
that would be helpful.
I can't easily retest with a new Debian release.
Ian.
More information about the pkg-perl-maintainers
mailing list