事务保持快照的原因(PostgreSQL,DBeaver)

huangapple go评论52阅读模式
英文:

reason for transaction holding snapshot (postgres, dbeaver)

问题

根据我的理解,我可以看到,一项交易通过pg_stat_activity中的backend_xidbackend_xmin列之一不为NULL来保持快照。

我目前正在调查来自dbeaver的会话中backend_xid不为空的情况,但我不明白为什么这个交易需要一个快照。这很重要,因为持有快照的长时间运行交易可能会引发问题,例如自动清理。

我的问题是:我(服务器端)能找到交易为何保持快照的原因吗?是否有一个表可以显示交易为何保持快照?

英文:

As per my understanding, I can see that a transaction is holding a snapshot by either of the columns backend_xid or backend_xmin not being NULL in pg_stat_activity.

I am currently investigating cases where backend_xid is not null for sessions from dbeaver and I don't understand why the transaction is requiring a snapshot. This is of interest as long running transaction that are holding a snapshot can cause problems, for autovacuum for instance.

My question is: Can I (serverside) find the reason why a transaction is holding a snapshot? Is there a table where I can see why the transaction is holding a snapshot?

答案1

得分: 1

backend_xid 是会话的事务ID,并不表示该会话具有活动快照。文档 表示:

如果有的话,这是该后端的顶层事务标识符。

backend_xmin 被描述为:

当前后端的 xmin 地平线。

"xmin 地平线" 是 PostgreSQL 术语,指的是在快照创建时活动的最低事务ID。它是 VACUUM 允许移除的上限。

英文:

backend_xid is the transaction ID of the session and does not mean that the session has an active snapshot. The documentation says:

> Top-level transaction identifier of this backend, if any.

backend_xmin is described as

> The current backend's xmin horizon.

“xmin horizon” is PostgreSQL jargon and refers to the lowest transaction ID that was active when the snapshot was taken. It is an upper limit of what VACUUM is allowed to remove.

huangapple
  • 本文由 发表于 2023年2月8日 17:02:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75383372.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定