php/postgres persistent connections fail

From: Palle Girgensohn <girgen(at)partitur(dot)se>
To: php-db(at)lists(dot)php(dot)net, freebsd-isp(at)freebsd(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: php/postgres persistent connections fail
Date: 2000-07-31 18:09:28
Message-ID: 3985C0D8.602224BC@partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi!

I am experiencing a very strange error usign this combination:

FreeBSD 4.0-STABLE
postgres 7.0.2
apache 1.3.12
php 4.0.1p2

Here's the problem:

PHP's pg_pconnect (persistent connect) will not keep the
connection open. What happens is, that after executing the page
just fine, upon pg_close (I guess), something happens and I get
this (when running postgres with -d 2):

ProcessQuery
CommitTransactionCommand
pq_recvbuf: unexpected EOF on client connection
proc_exit(0)
shmem_exit(0)
exit(0)
/usr/local/pgsql/bin/postmaster: reaping dead processes...
/usr/local/pgsql/bin/postmaster: CleanupProc: pid 32628 exited
with status 0
...

What happens here is, that the connection gets broken. Hence,
next time I try to connect to the same "persistent" connection
(i.e. next time i hit the same apache process from the process
pool) it fails, spitting this to the apache error log:

[Mon Jul 31 19:24:26 2000] [error] PHP Warning: PostgreSQL
query failed: pqReadData() -- read() failed: errno=9
Bad file descriptor
in /usr/local/www/www.sssf.se/data/internt/matrikel/foo.php on
line 20

What is happening here? I have ran tcpdump to try to see what
is going on between apache and postgres. I've attached two
dumps, one on the failing system, which will lead to the
"pq_recvbuf: unexpected EOF on client connection", and antoher
dump, doing exactly the same thing on another machine. The
machines both have php 4.0.1p2 and apache 1.3.12. Both run
FreeBSD. The failing machine has a slightly newer version of
the FreeBSD system, but both are 4.0-STABLE.

uname -a:

FreeBSD bastuba.partitur.se 4.0-STABLE FreeBSD 4.0-STABLE #0:
Sat Jul 1 15:56:11 CEST 2000
girgen(at)tuba(dot)partitur(dot)se:/usr/local/obj/usr/src/sys/TUBA i386

FreeBSD elbas.partitur.se 4.0-STABLE FreeBSD 4.0-STABLE #0: Wed
Jun 14 20:55:20 CEST 2000
girgen(at)tb303(dot)partitur(dot)se:/usr/obj/usr/src/sys/WORKSTATION i386

The two files attached show tcpdumps of the communication
between apache(php) and postgres. The failing machine is
bastuba while elbas is OK. Same php program, of course.

This might well be a configuration error. The bastuba is runs
around 50 virtual hosts (but not many use php), elbas is a
simple workstation running only a test setup. The problem is
finding the config error, in one exists, since I can't really
tamper too much with the bastuba setup, and I can't reporduce
the error elsewhere.

php.ini files are identical, as are phpinfo() outputs.

I'm out of ideas.

Best regards,
Palle Girgensohn
Partitur

Attachment Content-Type Size
bastuba-php-dump.txt text/plain 7.8 KB
elbas-php-dump.txt text/plain 5.8 KB

Browse pgsql-admin by date

  From Date Subject
Next Message Ken Kinder 2000-07-31 18:19:25 Re: How do I port data into Postgres from other RDBMSs
Previous Message ryan 2000-07-30 09:09:46 Installation problem