Postgres因长时间查询而崩溃

时间:2014-11-07 16:45:40

标签: postgresql postgresql-9.3

我的postgres因长时间查询而崩溃。它在Debian 7 64bit和postgresql-9.3.2上。我使用所有默认配置。有人可以提出它可能存在什么问题吗?谢谢。


 --part1:
 SELECT r1.f2 as b, r1.e as l 
 FROM r r8,r r7,r r6,r r5,r r4,r r3,r r2,r r1
 WHERE
 r1.f2=r2.f1 AND 
 r1.f2=r3.f1 AND 
 r1.f2=r4.f1 AND 
 r1.f1=r5.f2 AND 
 r1.f1=r8.f1 AND 
 r2.f1=r3.f1 AND 
 r2.f1=r4.f1 AND
 r2.f2=r6.f2 AND 
 r2.f2=r7.f1 AND 
 r3.f1=r4.f1 AND 
 r3.f2=r7.f2 AND 
 r3.f2=r8.f2 AND 
 r4.f2=r5.f1 AND 
 r4.f2=r6.f1 AND 
 r5.f1=r6.f1 AND 
 r5.f2=r8.f1 AND 
 r6.f2=r7.f1 AND 
 r7.f2=r8.f2 AND 
 r1.d=1 AND
 r2.d=1 AND
 r3.d=2 AND
 r4.d=2 AND
 r5.d=2 AND
 r6.d=2 AND
 r7.d=2 AND
 r8.d=2
 -- part2
 group by r1.f2,r1.e
 having
 calc_empty_a() AND
 calc_empty_b();

在查询中,calc_empty_a()只是空布尔函数(返回true),因此它们应该没有问题。

  1. 如果我在客户端运行查询,服务器崩溃。日志中没有任何有用的信息(请参阅帖子末尾的错误信息)。

  2. 如果我运行第1部分查询,则查询效果很好。

  3. 如果我第一次运行第1部分查询,那么我运行整个查询,它运行良好。

  4. 如果我改变查询,减少r数,例如,只有r1到r6 FROM表,用r8,r7删除谓词,但保留第2部分的GROUP BY和HAVING子句。查询仍然有效。

  5. 如果查询在HVING子句中有一个空函数,则查询也可以正常工作,但如果有两个函数则会崩溃。

  6. 以下查询效果很好

     SELECT r1.f2 as b, r1.f1 as a , r1.e as e
     FROM r r8,r r7,r r6,r r5,r r4,r r3,r r2,r r1
     WHERE
     r1.f2=r2.f1 AND 
     r1.f2=r3.f1 AND 
     r1.f2=r4.f1 AND 
     r1.f1=r5.f2 AND 
     r1.f1=r8.f1 AND 
     r2.f1=r3.f1 AND 
     r2.f1=r4.f1 AND
     r2.f2=r6.f2 AND 
     r2.f2=r7.f1 AND 
     r3.f1=r4.f1 AND 
     r3.f2=r7.f2 AND 
     r3.f2=r8.f2 AND 
     r4.f2=r5.f1 AND 
     r4.f2=r6.f1 AND 
     r5.f1=r6.f1 AND 
     r5.f2=r8.f1 AND 
     r6.f2=r7.f1 AND 
     r7.f2=r8.f2  
     group by r1.f2,r1.f1, r1.e
     having
     calc_empty_a() AND
     calc_empty_a();
    
  7. 我已将os设置为使用严格过度使用模式:

    sysctl -w vm.overcommit_memory=2
    

    错误信息:

    在客户

     The connection to the server was lost. Attempting reset: Succeeded.
    

    在服务器

    LOG:  terminating any other active server processes
    WARNING:  terminating connection because of crash of another server process
    DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
    HINT:  In a moment you should be able to reconnect to the database and repeat your command.
    WARNING:  terminating connection because of crash of another server process
    DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
    HINT:  In a moment you should be able to reconnect to the database and repeat your command.
    LOG:  all server processes terminated; reinitializing
    LOG:  database system was interrupted; last known up at 2014-11-07 16:47:03 GMT
    LOG:  database system was not properly shut down; automatic recovery in progress
    LOG:  redo starts at 0/2126C98
    LOG:  record with zero length at 0/21A9D98
    LOG:  redo done at 0/21A9D68
    LOG:  last completed transaction was at log time 2014-11-07 16:47:26.844406+00
    LOG:  autovacuum launcher started
    LOG:  database system is ready to accept connections
    

0 个答案:

没有答案