Bug#849121: $dbh->state sometimes trashed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#849121: $dbh->state sometimes trashed

Ian Jackson-11
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.

Reply | Threaded
Open this post in threaded view
|

Bug#849121: $dbh->state sometimes trashed

Christoph Berg-2
Control: tags -1 moreinfo

Re: Ian Jackson 2016-12-22 <[hidden email]>
> Package: libdbd-pg-perl
> Version: 2.19.2-2+deb7u1

> Sometimes, when used with SET TRANSACTION ISOLATION LEVEL
> SERIALIZABLE, generates this message:
[...]
> Observe that the "state" value is "", meaning no error.  This is
> AFAICT contrary to the documentation and also not very helpful.

Hi Ian,

are you still seeing this behavior with newer versions of DBD::Pg?
2.19.2 was in wheezy.

Christoph

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Bug#849121: $dbh->state sometimes trashed

Ian Jackson-11
Christoph Berg writes ("Re: Bug#849121: $dbh->state sometimes trashed"):
> Control: tags -1 moreinfo
...
> are you still seeing this behavior with newer versions of DBD::Pg?
> 2.19.2 was in wheezy.

Do you know if there has been a code change ?

I can probably retest this at some point but not until our
infrastructure is upgraded.  Yes, it's still running wheezy...

Ian.