X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 87B8C9DCA72 for ; Sun, 29 Jan 2006 02:37:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65216-06 for ; Sun, 29 Jan 2006 02:37:45 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by postgresql.org (Postfix) with ESMTP id 30DC39DC9D0 for ; Sun, 29 Jan 2006 02:37:43 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 13so960473nzn for ; Sat, 28 Jan 2006 22:37:43 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=QnybOXHKlcWs7zkNsBYf9CAfWGfHFSjVFm1ocqnVveK8FHOeF3AfwKFbSVhHGvm6yoWif+OljYtZqZDVccfVYRi8Cy2zzkiGSSsQPwmoOKuD5Xd4+t7HcY5BJMhSgfHroiDyw1f8wljUnVOBFbP4zWCGeL87g6zqpfgkYZ1w6B4= Received: by 10.37.12.58 with SMTP id p58mr706150nzi; Sat, 28 Jan 2006 22:37:43 -0800 (PST) Received: by 10.36.20.2 with HTTP; Sat, 28 Jan 2006 22:37:43 -0800 (PST) Message-ID: <3c1395330601282237r7ad3c003r25ba06ca4113b66f@mail.gmail.com> Date: Sun, 29 Jan 2006 17:37:43 +1100 From: chris smith To: pgsql-php@postgresql.org Subject: php pcntl functions and postgresql MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_693_13624180.1138516663693" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200601/45 X-Sequence-Number: 3416 ------=_Part_693_13624180.1138516663693 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, This is a bit of a strange one and I'm not sure where to start looking, so any / all suggestions welcome. I'm using php with the process control functions and want each thread to share the main db connection. Running php 5.1.2 and postgresql 8.1.2. My code looks like: #!/usr/local/php/bin/php -q When I run it I get: childcount: 0 resource(1) of type (pgsql link persistent) PostgreSQL 8.1.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5(Debi= an 1: 3.3.5-13) childcount: 1 resource(1) of type (pgsql link persistent) error: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. childcount: 2 resource(1) of type (pgsql link persistent) error: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The 'resource(1) of type (pgsql link persistent)' shows the connection is still valid as far as php is concerned. In the postgresql logs I get: LOG: connection received: host=3D[local] LOG: connection authorized: user=3Dxxxxxx database=3Dxxxxxx LOG: statement: select version() AS version LOG: duration: 3.516 ms LOG: duration: 3.516 ms statement: select version() AS version LOG: disconnection: session time: 0:00:00.02 user=3Dxxxxxx database=3Dxxxx= xx host=3D[local] Turning up debugging / logs in postgresql didn't show anything extra. So I think either: a) I'm doing something wrong b) It's a bug in php c) It's a bug in the postgresql php "driver" I don't think it's a or b because I change it all to mysql and it works, it doesn't drop the connection like it is here. I'm not sure where to start looking from here... so any ideas/comments please send them through! Thanks, Chris. ------=_Part_693_13624180.1138516663693 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all,

This is a bit of a strange one and I'm not sure where to start looking, so = any / all suggestions welcome.

I'm using php with the process control functions and want each thread to sh= are the main db connection.

Running php 5.1.2 and postgresql 8.1.2.

My code looks like:

#!/usr/local/php/bin/php -q
<?php
declare(ticks=3D1);
$time =3D time();

$connection_string =3D 'dbname=3Dxxxxxxxx user=3Dxxxxxxxx password=3D';
if (!$connection_result =3D pg_pconnect($connection_string)) {
    echo 'Unable to connect: ' . pg_last_error() . "\n&= quot;;
    exit();
}

echo "Connected ok\n";

$childcount =3D 0;
$childrencount =3D 10;
while($childcount < $childrencount) {
    $pid =3D pcntl_fork();

    if ( $pid =3D=3D -1 ) {
        die("error\n");
    }

    if ($pid =3D=3D 0) {
        $childcount++;
        usleep(100);
        pcntl_wait($status);
    } else {
        echo "\nchildcount: " . $ch= ildcount . "\n";
        var_dump($connection_result);
        $qry =3D "select version() AS ve= rsion";
        $result =3D pg_query($connection_resu= lt, $qry);
        if (!$result) {
            echo "error: = " . pg_last_error() . "\n";
        } else {
            $row =3D pg_fetch_= assoc($result);
            echo $row['version= '] . "\n";
        }
        exit();
    }
}

echo 'took ' . (time() - $time) . ' seconds' . "\n";
?>


When I run it I get:

childcount: 0
resource(1) of type (pgsql link persistent)
PostgreSQL 8.1.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5 (Deb= ian 1:3.3.5-13)

childcount: 1
resource(1) of type (pgsql link persistent)
error: server closed the connection unexpectedly
        This probably means the server t= erminated abnormally
        before or while processing the r= equest.

childcount: 2
resource(1) of type (pgsql link persistent)
error: server closed the connection unexpectedly
        This probably means the server t= erminated abnormally
        before or while processing the r= equest.


The 'resource(1) of type (pgsql link persistent)' shows the connection is s= till valid as far as php is concerned.

In the postgresql logs I get:

LOG:  connection received: host=3D[local]
LOG:  connection authorized: user=3Dxxxxxx database=3Dxxxxxx
LOG:  statement: select version() AS version
LOG:  duration: 3.516 ms
LOG:  duration: 3.516 ms  statement: select version() AS version<= br> LOG:  disconnection: session time: 0:00:00.02 user=3Dxxxxxx database= =3Dxxxxxx host=3D[local]


Turning up debugging / logs in postgresql didn't show anything extra.

So I think either:
a) I'm doing something wrong
b) It's a bug in php
c) It's a bug in the postgresql php "driver"

I don't think it's a or b because I change it all to mysql and it works, it= doesn't drop the connection like it is here.

I'm not sure where to start looking from here... so any ideas/comments plea= se send them through!

Thanks,
Chris.

------=_Part_693_13624180.1138516663693--