PostgreSQL查询缓存 - 意外关闭连接

时间:2011-12-21 17:31:06

标签: postgresql caching postgresql-9.0

<?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.

这意味着某些缓存查询会导致问题。我们试图改变quires的顺序,但它没有帮助。只有像SELECT 1+8这样可能没有缓存的简单查询才能运行良好。

可以使用psql和可能的任何其他语言驱动程序(不仅仅是PHP)模拟类似的问题。

当我们安装PostgreSQL Query Cache时,所有问题都出现了。

是否应该以某种方式配置查询缓存不以这种方式运行?

我们的配置文件在这里: http://pastebin.com/g2dBjba0 - pcqd_hba.conf http://pastebin.com/X9Y3zrjx - pcqd.conf

1 个答案:

答案 0 :(得分:0)

有可能在PostgreSQL查询缓存中有一个错误,它会在后端导致段错误。您最好的解决方案是卸载此附加组件。