【发布时间】:2017-11-11 01:35:54
【问题描述】:
抱歉,我到处寻找,但找不到可行的解决方案:/ 我非常需要这个来进行异常测试。
我在这里尝试做的是:
- 在表 A 中插入行
- 锁定此记录
- (在单独的终端)服务 postgresql-9.6 停止
- 等一下
- (在单独的终端)服务 postgresql-9.6 启动
- “try”通过执行“COMMIT;”来解锁记录在与 #2 相同的终端中。
#2 我的做法是这样的:
BEGIN;
SELECT * FROM TABLE A WHERE X=Y FOR UPDATE;
问题是,一旦我执行了 #6,就会出现此错误:
DB=# commit;
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
所以当我执行“COMMIT;”时同样,它只显示:
DB=# commit;
WARNING: there is no transaction in progress
COMMIT
现在无法解锁记录。
我试过获取那个锁定的东西的 PID,然后执行 pg_terminate(或取消),但它不起作用。
DB=# select pg_class.relname,pg_locks.* from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation;
DB=# select pg_terminate_backend(2450);
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
DB=# select pg_cancel_backend(3417);
ERROR: canceling statement due to user request
请帮忙。有没有人有任何想法? :/ ..或者这甚至可能吗?
我的规格:
- Postgresql-9.6
- 红帽 Linux
【问题讨论】:
标签: postgresql