Re: pqReadData() -- read() failed: errno=32 - Mailing list pgsql-general

From Craig Stratton
Subject Re: pqReadData() -- read() failed: errno=32
Date
Msg-id 001b01c3c573$8e660f30$0314a8c0@cpsws
Whole thread Raw
In response to pqReadData() -- read() failed: errno=32  ("Craig Stratton" <craig@avnet.co.uk>)
Responses Re: pqReadData() -- read() failed: errno=32
Re: pqReadData() -- read() failed: errno=32
List pgsql-general
> > I get this error, as in subject:-
> > pqReadData() -- read() failed: errno=32
> > and then followed by this
> > pqReadData() -- backend closed the channel unexpectedly.
> >
> > I can find no reference to errno=32 in the mailing lists.
>
> From memory and google, it's a broken pipe, traditionally from php's
> persistent connections. Assuming a backend isn't dying, I'm a bit puzzled.
> Check your logs and see if all is OK.

This is running as a cgi script, not php. The backend dies afterwards.
I think it is dbi/thread/child related, so i modified the code, but still no
joy.
I am fairly sure its dbi thread related still though.

>
> > If i define and connect the database handle within the function that
does
> > my processing, then i get no errors (but very slow processing due to
> > connecting on each event).
> >
> >  If i define and connect the database handle as a global variable
outside
> > of the function, then i get that error on the first insert.
>
> Can you give a short example of what works and what doesn't.

1) connect within sub
my $dbv;
sub SQLLogging {
  $dbv = DBI->connect("DBI:Pg:dbname=dbv","admin", "", {'PrintError' => 0});
and then all following inserts work fine

2) connect outside of sub
my $dbv;
$dbv = DBI->connect("DBI:Pg:dbname=dbv","admin", "", {'PrintError' => 0});
sub SQLLogging {
and then i get the error on the first insert attempt

3) connect outside, connect inside if not defined (in case missed by thread
fork)
my $dbv;
$dbv = DBI->connect("DBI:Pg:dbname=dbv","admin", "", {'PrintError' => 0});
sub SQLLogging {
  unless(defined($dbv)){
    $dbv = DBI->connect("DBI:Pg:dbname=dbv","admin", "", {'PrintError' =>
0});
  }
this gives me the same problem as (2)


I didn't write the rest of the script, only the logging routine, so until i
go back and study the code, i am not sure where the fork(s) happen.
I was hoping that the errno=32 would give a clear indication that there was
a client/connection problem to follow up.

Regards
Craig



pgsql-general by date:

Previous
From: Shridhar Daithankar
Date:
Subject: Re: Which file system do i have to choose?
Next
From: Alvaro Herrera
Date:
Subject: Re: pqReadData() -- read() failed: errno=32