<?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";
        }
}

上面的代码片段是第一次生成:
[OK]
[OK]
[OK]
[OK]

但这已经是第二次了:
[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.

这意味着某些缓存查询会导致问题。我们试图改变怪癖的顺序,但没用。只有像SELECT 1+8这样的简单查询才能正常运行,而这些查询可能没有被缓存。
类似的问题可以使用psql和任何其他语言驱动程序(不仅仅是PHP)来模拟。
当我们安装PostgreSQL Query Cache时,所有的问题都出现了。
是否应该以某种方式配置查询缓存,而不是以这种方式运行?
我们的配置文件在这里:
http://pastebin.com/g2dBjba0–pcqd_hba.conf
http://pastebin.com/X9Y3zrjx–pcqd.conf文件

最佳答案

可能是PostgreSQL查询缓存中有一个错误,导致后端出现segfults。您最好的解决方案是卸载此加载项。

关于postgresql - PostgreSQL查询缓存-意外关闭连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8593879/

10-16 23:05
查看更多