<?php
$c = pg_connect( $connectionString, PGSQL_CONNECT_FORCE_NEW );
$queries = array (
"SELECT COUNT(*) AS data FROM articles",
"SELECT * FROM posts WHERE visible = TRUE",
"SELECT * FROM countries WHERE visible = FALSE",
"SELECT * FROM types WHERE visible = TRUE"
);
foreach ( $queries as $query ) {
$res = @pg_query( $c, $query );
if ( empty( $res ) ) {
echo "[ERR] " . pg_last_error( $c ) . "\n";
} else {
echo "[OK]\n";
}
}
The snippet of code above is generating for the first time this:
[OK]
[OK]
[OK]
[OK]
but for the second time this:
[OK]
[OK]
[ERR] server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
[ERR] server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
This means that some cached queries cause a problem. We tried to change the order of quires, but it didn't help. Only simple queries like SELECT 1+8
, which are probably not cached always run well.
Similar problem can be simulated using psql and probably any other language driver (not only PHP).
All troubles came up when we installed PostgreSQL Query Cache.
Should the query cache be configured somehow not behave this way?
Our config files are here: http://pastebin.com/g2dBjba0 – pcqd_hba.conf http://pastebin.com/X9Y3zrjx – pcqd.conf
PostgreSQL
orPostgres
for short. There is no "Postgre". More here. – Erwin Brandstetter Dec 21 '11 at 22:10