我正在遭受 AgensGraph 的缓慢交易。CPU 使用率极低。我猜是锁定等待的情况。
如何找到锁定等待查询?
您可以尝试使用 AgnsGraph 的 lock-wait log。
首先,更改“postgresql.conf”上的参数
log_lock_waits = on
deadlock_timeout = 1s
二、重启AgensGraph。
$ ag_ctl stop
waiting for server to shut down.... done
server stopped
$ ag_ctl start
server starting
最后,运行查询并检查日志文件。
[会话1:块传输]
agens=# begin;
BEGIN
agens=# create (:n{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# rollback;
ROLLBACK
agens=#
[会话2:锁定等待事务]
agens=# create (:n{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
从日志文件中检查日志。
LOG: process 3908 still waiting for ShareLock on transaction 1586 after 1001.058 ms
DETAIL: Process holding the lock: 3906. Wait queue: 3908.
CONTEXT: while inserting index tuple (0,7) in relation "n_id_idx"
STATEMENT: create (:n{id:1});
LOG: process 3908 acquired ShareLock on transaction 1586 after 4639.630 ms
CONTEXT: while inserting index tuple (0,7) in relation "n_id_idx"
STATEMENT: create (:n{id:1});