且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PostgreSQL停止动作观察

更新时间:2022-09-22 23:02:06

实验过程如下:

启动一个客户端:

PostgreSQL停止动作观察
[postgres@cnrd56 bin]$ ./psql
psql (9.1.2)
Type "help" for help.

postgres=# begin;
BEGIN
postgres=# select count(*), pg_sleep(1000) from test;
PostgreSQL停止动作观察

然后强制停止:

pg_ctl stop -m f  -D /usr/local/pgsql/data

此时在客户端出现如下信息:

FATAL:  terminating connection due to administrator command
The connection to the server was lost. Attempting reset: Failed.
!> 

再看后台的log:

PostgreSQL停止动作观察
2013-07-14 10:17:17.280 CST,,,3422,,51e209eb.d5e,2,,2013-07-14 10:16:11 CST,,0,LOG,00000,"received fast shutdown request",,,,,,,,,""
2013-07-14 10:17:17.280 CST,,,3422,,51e209eb.d5e,3,,2013-07-14 10:16:11 CST,,0,LOG,00000,"aborting any active transactions",,,,,,,,,""
2013-07-14 10:17:17.280 CST,,,3427,,51e209ec.d63,2,,2013-07-14 10:16:12 CST,1/0,0,LOG,00000,"autovacuum launcher shutting down",,,,,,,,,""
2013-07-14 10:17:17.280 CST,"postgres","postgres",3431,"[local]",51e209ff.d67,1,"SELECT",2013-07-14 10:16:31 CST,2/2,0,FATAL,57P01,"terminating connection due to administrator command",,,,,,"select count(*), pg_sleep(1000) from test;",,,"psql"
2013-07-14 10:17:17.281 CST,,,3425,,51e209ec.d61,1,,2013-07-14 10:16:12 CST,,0,LOG,00000,"shutting down",,,,,,,,,""
2013-07-14 10:17:17.281 CST,"postgres","postgres",3435,"[local]",51e20a2d.d6b,1,"",2013-07-14 10:17:17 CST,,0,FATAL,57P03,"the database system is shutting down",,,,,,,,,""
2013-07-14 10:17:17.284 CST,,,3425,,51e209ec.d61,2,,2013-07-14 10:16:12 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,""
PostgreSQL停止动作观察

其中的:

2013-07-14 10:17:17.280 CST,"postgres","postgres",3431,"[local]",51e209ff.d67,1,"SELECT",2013-07-14 10:16:31 CST,2/2,0,FATAL,57P01,"terminating connection due to administrator command",,,,,,"select count(*), pg_sleep(1000) from test;",,,"psql"

表明,客户端正在执行sql文 select count(*), pg_sleep(1000) from test的时候,

收到了 "terminating connection due to administrator command" 命令。








本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/p/3189197.html,如需转载请自行联系原作者