你如何找到当前的postgres虚拟交易ID?

时间:2017-05-18 05:18:00

标签: postgresql

[Thu May 18 08:15:18.375748 2017] [mpm_prefork:notice] [pid 2271] AH00170: caught SIGWINCH, shutting down gracefully [Thu May 18 08:15:19.475015 2017] [core:notice] [pid 2366] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Thu May 18 08:15:19.475823 2017] [suexec:notice] [pid 2366] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message [Thu May 18 08:15:19.494156 2017] [auth_digest:notice] [pid 2366] AH01757: generating secret for digest authentication ... [Thu May 18 08:15:19.494865 2017] [lbmethod_heartbeat:notice] [pid 2366] AH02282: No slotmem from mod_heartmonitor [Thu May 18 08:15:19.498230 2017] [mpm_prefork:notice] [pid 2366] AH00163: Apache/2.4.6 (CentOS) SVN/1.9.5 configured -- resuming normal operations [Thu May 18 08:15:19.498255 2017] [core:notice] [pid 2366] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Thu May 18 08:15:41.422674 2017] [auth_basic:error] [pid 2369] [client 192.168.2.145:54289] AH01618: user korkutefe not found: /svn postgres表格的pg_locks列的值为virtualtransaction。您如何确定当前的虚拟交易ID?

您可以从20/49779获取交易ID,但是如何获得虚拟交易ID?

1 个答案:

答案 0 :(得分:0)

您可以这样获得它:

SELECT virtualtransaction
    FROM pg_locks
    WHERE transactionid::text = (txid_current() % (2^32)::bigint)::text;

最后一部分看起来有些毛茸茸,但这是必要的,因为txid_current返回一个int,而transactionid列具有特殊的xid类型。

(有关更多详细信息,请参见https://dba.stackexchange.com/a/123183/10371