小编The*_*ind的帖子

一组表上的同时更新和删除是否会导致使用 AccessExclusiveLock?

我正在使用 Postgres 9.3。

我有 2 个表 :authn_sessioncustomer. 每个都authn_session属于 a customer(因此有 acustomer_id作为列,这是客户的 FK id)。

注意:这些表包含对其他表和索引的额外 FK 引用。

现在,我开始 2 个不同的事务,它们按照下面提到的顺序执行以下操作:

发送:1

BEGIN; 
UPDATE customer 
    SET customer__created_by = 
            (case when customer__created_by = 1 then 5 
             else customer__created_by end), 
        customer__modified_by = 
            (case when customer__modified_by = 1 then 5 
             else customer__modified_by end);
UPDATE authn_session 
    SET authn_session__created_by = 
            (case when authn_session__created_by = 1 then 5
             else authn_session__created_by end),
        authn_session__modified_by = 
            (case when authn_session__modified_by = 1 …
Run Code Online (Sandbox Code Playgroud)

postgresql deadlock locking postgresql-9.3

6
推荐指数
1
解决办法
611
查看次数

标签 统计

deadlock ×1

locking ×1

postgresql ×1

postgresql-9.3 ×1