postgresql死鎖


查看測試日志,發現了死鎖問題:

2020-05-14 09:07:11.454 CST,"abce_user","abce",1042,"10.10.15.127:42056",5ebc834a.412,1,"UPDATE",2020-05-14 07:31:22 CST,23/486488,14535553,ERROR,40P01,
"deadlock detected","Process 1042 waits for ShareLock on transaction 14535551; blocked by process 3169.
Process 3169 waits for ShareLock on transaction 14535552; blocked by process 5632.
Process 5632 waits for ExclusiveLock on tuple (2129,23) of relation 31042 of database 14386; blocked by process 1042.
Process 1042: update habp
    set uuid = $1,
      uuid_t = $2,
      creater = $3
    where id = $39 and uuid_t = $40
Process 3169: update habp
    set uuid = $1,
      uuid_t = $2,
      creater = $3
    where id = $39 and uuid_t = $40
Process 5632: update habp
    set uuid = $1,
      uuid_t = $2,
      creater = $3
    where id = $39 and uuid_t = $40",
"See server log for query details.",,,"while updating tuple (2129,23) in relation ""habp""","update habp
    set uuid = $1,
      uuid_t = $2,
      creater = $3
    where id = $39 and uuid_t = $40",,,"PostgreSQL JDBC Driver"

  

從日志可以看到進程1042被進程3169阻塞,3169被進程5632阻塞,5642被進程1042阻塞,從而形成了死鎖。

此外,從日志也可以看到relation 31042即表habp;database 14386即數據庫abce;

 

$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  14848       postgres  pg_default
  14847      template0  pg_default
      1      template1  pg_default
  14386           abce  pg_default
$ 

可以看到database 14386是數據庫abce

 

# SELECT relname FROM pg_class where oid=31042;
       relname        
----------------------
 habp
(1 row)

# 

可以查看到表名:habp

 

# select * from habp where ctid='(2129,23)';

結果為0行,可以知道對應的元組已經被修改了。
盡管ctid可以用來快速定位對應的行版本,但是對應的行如果被update了或被vacuum full操作過,就無法找到之前的元組了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM