当 PostgreSQL 进程“在事务中处于空闲状态”时意味着什么?

PostgreSQL进程“在事务中处于空闲状态”时意味着什么?

在我正在查看的一台服务器上,输出“ ps ax | grep postgres”,我看到9个 PostgreSQL 进程如下所示:

postgres: user db 127.0.0.1(55658) idle in transaction

这是否意味着某些进程被挂起,等待事务被提交?任何指向相关文件的建议都是值得赞赏的。

161598 次浏览

The PostgreSQL manual indicates that this means the transaction is open (inside BEGIN) and idle. It's most likely a user connected using the monitor who is thinking or typing. I have plenty of those on my system, too.

If you're using Slony for replication, however, the Slony-I FAQ suggests idle in transaction may mean that the network connection was terminated abruptly. Check out the discussion in that FAQ for more details.

As mentioned here: Re: BUG #4243: Idle in transaction it is probably best to check your pg_locks table to see what is being locked and that might give you a better clue where the problem lies.