rac ora-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 3502669
  • 博文数量: 718
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7790
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(718)

文章存档

2024年(4)

2023年(74)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

最近访客
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2022-08-29 21:19:27

死锁是两个或多个用户等待数据相互锁定的情况。死锁会阻止某些事务继续工作。

oracle 数据库会自动检测死锁,并通过回滚死锁中涉及的一条语句,释放一组冲突的行锁来解决死锁。数据库向经历语句级回滚的事务返回相应的消息。回滚的语句属于检测死锁的事务。通常,应显式回滚已发出信号的事务,但它可以在等待后重试回滚语句。

模拟


发生死锁后应用端收到报错ora-00060

00060, 00000, "deadlock detected while waiting for resource"
// *cause:  transactions deadlocked one another while waiting for resources.
// *action: look at the trace file to see the transactions and resources
//          involved. retry if necessary.

告警日志中也会有异常

  1. 2022-08-29t10:27:13.24392008:00
  2. global enqueue services deadlock detected (did = 4_0_172). more information in file
  3.  /oracle/app/oracle/diag/rdbms/orclp/orcl1/trace/orcl1_lmd0_38295.trc.
  4. 2022-08-29t10:27:23.69119408:00
  5. global enqueue services deadlock detected (did = 4_1_202). more information in file
  6.  /oracle/app/oracle/diag/rdbms/orclp/orcl2/trace/orcl2_lmd0_53074.trc on instance 2.
  7. 2022-08-29t11:05:10.78298508:00
  8. thread 1 advanced to log sequence 588 (lgwr switch), current scn: 24798531
  9.   current log# 2 seq# 588 mem# 0: datadg/orclp/onlinelog/group_2.258.1111942287
  10.   current log# 2 seq# 588 mem# 1: archdg/orclp/onlinelog/group_2.259.1111942289
  11. 2022-08-29t11:05:10.95631208:00
  12. arc5 (pid:39189): archived log entry 1944 added for t-1.s-587 id 0xaf1a0265 lad:1
  13. 2022-08-29t11:05:13.82702808:00
  14. thread 1 advanced to log sequence 589 (lgwr switch), current scn: 24799636
  15.   current log# 3 seq# 589 mem# 0: datadg/orclp/onlinelog/group_3.265.1111942289
  16.   current log# 3 seq# 589 mem# 1: archdg/orclp/onlinelog/group_3.260.1111942291
  17. 2022-08-29t11:10:13.55474208:00
  18. global enqueue services deadlock detected (did = 4_0_173). more information in file
  19.  /oracle/app/oracle/diag/rdbms/orclp/orcl1/trace/orcl1_lmd0_38295.trc.
  20. 2022-08-29t11:10:18.68093408:00
  21. global enqueue services deadlock detected (did = 4_0_174). more information in file
  22.  /oracle/app/oracle/diag/rdbms/orclp/orcl1/trace/orcl1_lmd0_38295.trc.
rac环境中由lmd进程每10秒检测一次死锁,发现后进行回滚,记录到trc文件中,部分信息可能记录在另一个节点上。

lmd进程的trc文件头部信息
  1. trace file /oracle/app/oracle/diag/rdbms/orclp/orcl1/trace/orcl1_lmd0_38295.trc trace文件名称及路径
  2. oracle database 19c enterprise edition release 19.0.0.0.0 - production 数据库版本
  3. version 19.14.0.0.0   数据库补丁版本
  4. build label: rdbms_19.14.0.0.0dbru_linux.x64_211224.3 补丁编译信息
  5. oracle_home: /oracle/app/oracle/product/19.3.0/db_1   oracle_home路径
  6. system name:    linux 操作系统类型
  7. node name:    db1     主机名
  8. release:    3.10.0-957.el7.x86_64              操作系统内核
  9. version:    #1 smp thu oct 4 20:48:51 utc 2018 操作系统版本
  10. machine:    x86_64    主机架构
  11. instance name: orcl1  实例名
  12. redo thread mounted by this instance: 0 <none> 线程序号
  13. oracle process number: 23     oracle内部进程号(lmd进程
  14. unix process pid: 38295, image: oracle@db1 (lmd0) 操作系统进程号及名称


  15. *** 2022-08-11t10:40:30.89123408:00                  trace文件生成日期
  16. *** client id:() 2022-08-11t10:40:30.89125908:00     客户端id
  17. *** service name:() 2022-08-11t10:40:30.89126308:00  服务名
  18. *** module name:() 2022-08-11t10:40:30.89126708:00   模块
  19. *** action name:() 2022-08-11t10:40:30.89127008:00   行为
  20. *** client driver:() 2022-08-11t10:40:30.89127308:00 客户端驱动


  dlm resource hashmasks initialised
  *** 2022-08-11 10:40:30.891298 [krsa.c:2949]
  acquiring krso process latch [krso.c:553] ix0
  *** 2022-08-11 10:40:30.891313 [krsa.c:2972]
  successfully acquired krso process latch ix

trc文件下面会有很多信息,摘取部分主要的


  1. *** 2022-08-24t10:10:15.039249 08:00  其中一个死锁的开始时间,通常会有多个类似的
    global blockers dump start:---------------------------------
    2022-08-24 10:10:15.038*:kjdggblkrdmp(): dump local blocker/holder: block level 5 res [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]

    输出本地阻塞者/持有者信息 
    [0xa001e][0x19f9e]是事务id,下面会看到事务详细内容 
    [tx]代表死锁类型,主要有几种:
    tx block level 5 说明是独占事务锁
    tx in share 这种情况下应该会看到block level 3,共享事务锁
    tm 全表锁 一般是缺少外键
    iv instance validation 实例有效性 应该很少见,一般是bug
    lb library cache lock 类库缓存,应该很少见,与外部表统计信息bug相关

    ----------resource 0x1bc5160020----------------------
    resname       : [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
    lmdid         : 0
    rht group     : 0
    rht ptr       : 0x1be5b8cc68
    rht bucket idx: 14775
    hp            : 0x1c284685b0
    domain ptr    : 0x167fd71f00
    hash mask     : x7
    local inst    : 1  本地实例号
    dir_inst      : 1
    master_inst   : 1
    hv idx        : 16 hv = hash value
    hv last r.inc : 4
    current inc   : 4
    hv status     : 0
    hv master inst: 2
    open options  : deadlock detection=y, cached=n, varvblk=n, slock=n
    held mode     : kjusernl   持有模型  kj=kernel lock 内部锁模块, user=用户, nl=null 没有锁,详见下面
    cvt mode      : kjusernl   转换模型  cvt=convert 转换
    next cvt mode : kjusernl
    msg_seq       : 0x0
    res_seq       : 1 (0x1)
    grant_bits    : kjusernl kjuserex ex=excluve 独占锁,详见下面
    grant mode    : kjusernl  kjusercr  kjusercw  kjuserpr  kjuserpw  kjuserex 持有模型

  2.  kjusernl=null          空锁           例如select语句
  3.  kjusercr=row-s (ss)    行级共享锁      只能查select for update、lock for update、lock row share 
  4.  kjusercw=row-x (sx)    行级独占锁      在提交前不允许做dml操作insert、update、delete、lock row share
     kjuserpr=share         共享锁          create index、lock share
     kjuserpw=s/row-x (ssx) 共享行级排他锁   lock share row exclusive
     kjuserex=exclusive     独占锁  alter table、drop table、drop index、truncate table、lock exclusive

  5. count         : 5         0         0         0         0         1 持有模型计数,空锁5个,独占锁1个
    val_state     : kjuservs_novalue
    valblk        : 0xd88a6da71b0000001205020000000000 .m
    access_inst   : 1
    vbreq_state   : 0
    state         : x0
    resp          : 0x1bc5160020
    entry         : dir=y, master=y
    on scan_q?    : n
    on cache?     : n
    on remote_q?  : y
    frozen        : 0
    total accesses: 35
    imm.  accesses: 32
    granted_locks : 1 
    cvting_locks  : 5 
    reqing_locks  : none 
    value_block:  d8 8a 6d a7 1b 00 00 00 12 05 02 00 00 00 00 00
    granted_q: 持有序列
    lp 0x1c467ceca0 gl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c623b8080 possible pid 51602 xid cf000-0001-7ffd0000020b rseq 1 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > loc_ast
      open opt kjuserdeadlock  flags 0x1 sec since mv2grq 10
    convert_q: 转换序列
    lp 0x1c0794e7e0 gl kjusernl rl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1be1f12598 possible pid 50879 xid 147000-0001-0000000f rseq 1 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1c2a083de0 gl kjusernl rl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c6259c480 possible pid 50850 xid 12d000-0001-0000000c rseq 1 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x173b013c08 gl kjusernl rl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 owner 2 rseq 1 mseq 0x1 bast armed
      history none > none > none > none > none > ref_res > rem_ast > gr2cvt > msgsent
      convert opt kjusergetvalue  flags 0x4
    lp 0x1c29861908 gl kjusernl rl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1ba20acbd0 possible pid 33412 xid 106000-0001-0000013b rseq 1 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1c669c4db0 gl kjusernl rl kjuserex rp 0x1bc5160020 [0xa001e][0x19f9e],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c61f25500 possible pid 33415 xid 14c000-0001-00000081 rseq 1 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    ----------enqueue 0x1c467ceca0------------------------
    lock version     : 10007
    owner inst       : 1
    grant_level      : kjuserex
    req_level        : kjuserex
    bast_level       : kjusernl
    notify_func      : none
    resp             : 0x1bc5160020
    procp            : 0x1c64b5dd90
    pid              : 50879   进程id,下面多次涉及此pid
    proc version     : 14
    oprocp           : (nil)
    opid             : 50879
    group lock owner : 0x1c623b8080
    possible pid     : 51602  可能的阻塞进程id
    xid              : cf000-0001-0000020b
    dd_time          : 0.0 secs
    dd_count         : 0
    timeout          : 0.0 secs
    on_timer_q?      : n
    on_dd_q?         : n
    sec since mv2grq : 10
    lock_state       : granted 锁状态:已经持有tx
    ast_flag         : 0x0
    flags            : 0x1
    open options     : kjuserdeadlock 
    convert options  : kjusernoqueue kjusernodeadlockwait 
    history          : free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > loc_ast
    msg_seq          : 0x0
    res_seq          : 1
    valblk           : 0xfc82de1cb3300febfc82f47df02ef514 .0}.
    user session for deadlock lock 0x1c467ceca0
      sid: 4467 ser: 12694 audsid: 62289 user: 105/scott
        flags: (0x41) usr/- flags2: (0x40009) -/-/inc
        flags_idl: (0x1) status: bsy/-/-/- kill: -/-/-/-
      pid: 207 o/s info: user: grid, term: unknown, ospid: 51602
        image: oracle@db1
      client details:
        o/s info: user: scott, term: unknown, ospid: 1234
        machine: db1 program: jdbc thin client
        application name: jdbc thin client, hash value=2546894660
      current sql:  当前sql
      update act_hist
         set stat = :1 ,
                proc_def_sn = :2 ,
                assignee_ = :3  
        where sn = :4 
        and stat = :5 
    2022-08-24 10:10:15.039*:kjdglblkrdmpint(): dump local blocker: initiate state dump for deadlock
      possible owner[207.51602] on resource tx-000a001e-00019f9e-00000000-00000000
    2022-08-24 10:10:15.039 :kjzddmp(): submitting asynchronized dump request [1c]. summary=[ges process stack dump (kjdglblkrdm1)].
    ----------enqueue 0x1c0794e7e0------------------------
    lock version     : 32121
    owner inst       : 1
    grant_level      : kjusernl
    req_level        : kjuserex
    bast_level       : kjusernl
    notify_func      : none
    resp             : 0x1bc5160020
    procp            : 0x1c64b5dd90
    pid              : 50879
    proc version     : 14
    oprocp           : (nil)
    opid             : 50879
    group lock owner : 0x1be1f12598
    possible pid     : 50879
    xid              : 147000-0001-0000000f
    dd_time          : 10.0 secs  死锁时间,来自隐含参数_lm_dd_interval
    dd_count         : 1 死锁次数
    timeout          : 0.0 secs
    on_timer_q?      : n
    on_dd_q?         : y
    sec since mv2grq : n/a
    lock_state       : opening converting 
    ast_flag         : 0x0
    flags            : 0x0
    open options     : kjuserdeadlock 
    convert options  : kjusergetvalue 
    history          : free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
    msg_seq          : 0x0
    res_seq          : 1
    valblk           : 0xbb527488a57f00000180adfbfd7f0000 .rt
    user session for deadlock lock 0x1c0794e7e0
      sid: 671 ser: 20082 audsid: 62167 user: 105/scott 用户信息
        flags: (0x41) usr/- flags2: (0x40009) -/-/inc
        flags_idl: (0x1) status: bsy/-/-/- kill: -/-/-/-
      pid: 327 o/s info: user: grid, term: unknown, ospid: 50879
        image: oracle@db1
      client details:
        o/s info: user: scott, term: unknown, ospid: 1234
        machine: db2 program: jdbc thin client
        application name: jdbc thin client, hash value=2546894660
      current sql: 当前sql
      update task_info_table
           set stat = :1 ,
          assignee_ = :2 ,
          claim_time_ = :3 ,
          last_updated_time_ = :4  
        where sn = :5 
        and stat = :6 
    2022-08-24 10:10:15.039*:kjdglblkrdmpint(): dump local blocker: initiate state dump for deadlock
      possible owner[327.50879] on resource tx-000a001e-00019f9e-00000000-00000000
    2022-08-24 10:10:15.039 :kjzddmp(): submitting asynchronized dump request [1c]. summary=[ges process stack dump (kjdglblkrdm1)].
    2022-08-24 10:10:15.039*:kjdggblkrdmp(): dump local blocker/holder: block level 5 res [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
    ----------resource 0x1799a4cc68----------------------
    resname       : [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
    lmdid         : 1
    rht group     : 0
    rht ptr       : 0x1bc4d61300
    rht bucket idx: 13506
    hp            : 0x1be618c960
    domain ptr    : 0x167fd71f00
    hash mask     : x7
    local inst    : 1
    dir_inst      : 1
    master_inst   : 1
    hv idx        : 96
    hv last r.inc : 4
    current inc   : 4
    hv status     : 0
    hv master inst: 2
    open options  : deadlock detection=y, cached=n, varvblk=n, slock=n
    held mode     : kjusernl
    cvt mode      : kjusernl
    next cvt mode : kjusernl
    msg_seq       : 0x0
    res_seq       : 3 (0x3)
    grant_bits    : kjusernl kjuserex 
    grant mode    : kjusernl  kjusercr  kjusercw  kjuserpr  kjuserpw  kjuserex
    count         : 12         0         0         0         0         1
    val_state     : kjuservs_novalue
    valblk        : 0x00000000000000000100000000000000 .
    access_inst   : 1
    vbreq_state   : 0
    state         : x0
    resp          : 0x1799a4cc68
    entry         : dir=y, master=y
    on scan_q?    : n
    on cache?     : n
    on remote_q?  : y
    frozen        : 0
    total accesses: 63
    imm.  accesses: 60
    granted_locks : 1 
    cvting_locks  : 12 
    reqing_locks  : none 
    value_block:  00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
    granted_q: 持有列表
    lp 0x1c294e5600 gl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1be1f12598 possible pid 50879 xid 147000-0001-7ffd0000000f rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > loc_ast
      open opt kjuserdeadlock  flags 0x1 sec since mv2grq 10
    convert_q: 转换列表,有12条
    lp 0x16bd727c50 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 owner 2 rseq 2 mseq 0x1 bast armed
      history none > none > none > none > none > ref_res > rem_ast > gr2cvt > msgsent
      convert opt kjusergetvalue  flags 0x4
    lp 0x1be76c3900 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c623b8080 possible pid 51602 xid cf000-0001-0000020b rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1ba9512280 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1ba26408c0 possible pid 51606 xid e0000-0001-000000ab rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1ba8f432c8 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1ba1fc7158 possible pid 17602 xid 5f000-0001-00000169 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1ba95125f8 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1ba2639108 possible pid 3861 xid 130000-0001-00000054 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1bc5e27b30 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c624aa280 possible pid 81797 xid 126000-0001-00000012 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1c468f7f98 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c02480568 possible pid 74897 xid 124000-0001-0000004f rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1bc5f51338 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c21fcbed0 possible pid 33418 xid 154000-0001-00000088 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1be721e678 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1ba219edd0 possible pid 33428 xid 15d000-0001-00000041 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1be70f45e8 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1bc24fad60 possible pid 33525 xid 16e000-0001-0000001b rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1c29739048 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1c02390b50 possible pid 33523 xid 16d000-0001-00000016 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    lp 0x1c0712cd40 gl kjusernl rl kjuserex rp 0x1799a4cc68 [0x90016][0x2df6],[tx][ext 0x0,0x0][domid 0x0]
      master 1 gl owner 0x1be2589518 possible pid 33600 xid 178000-0001-00000025 rseq 3 mseq 0 bast none
      history free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > gr2cvt
      convert opt kjusergetvalue  flags 0x0
    ----------enqueue 0x1c294e5600------------------------
    lock version     : 195
    owner inst       : 1
    grant_level      : kjuserex
    req_level        : kjuserex
    bast_level       : kjusernl
    notify_func      : none
    resp             : 0x1799a4cc68
    procp            : 0x1c64af1040
    pid              : 38344
    proc version     : 0
    oprocp           : (nil)
    opid             : 38344
    group lock owner : 0x1be1f12598
    possible pid     : 50879
    xid              : 147000-0001-0000000f
    dd_time          : 0.0 secs
    dd_count         : 0
    timeout          : 0.0 secs
    on_timer_q?      : n
    on_dd_q?         : n
    sec since mv2grq : 10
    lock_state       : granted
    ast_flag         : 0x0
    flags            : 0x1
    open options     : kjuserdeadlock 
    convert options  : kjusernoqueue kjusernodeadlockwait 
    history          : free > kjlalc > ref_res > loc_ast > close > free > kjlalc > ref_res > loc_ast
    msg_seq          : 0x0
    res_seq          : 3
    valblk           : 0x36d47f12000000000200000000000000 6
    user session for deadlock lock 0x1c294e5600
      sid: 671 ser: 20082 audsid: 62167 user: 105/scott
        flags: (0x41) usr/- flags2: (0x40009) -/-/inc
        flags_idl: (0x1) status: bsy/-/-/- kill: -/-/-/-
      pid: 327 o/s info: user: grid, term: unknown, ospid: 50879
        image: oracle@db1
      client details:
        o/s info: user: scott, term: unknown, ospid: 1234
        machine: db2 program: jdbc thin client
        application name: jdbc thin client, hash value=2546894660
      current sql:
      update task_info_table
           set stat = :1 ,
          assignee_ = :2 ,
          claim_time_ = :3 ,
          last_updated_time_ = :4  
        where sn = :5 
        and stat = :6 
    2022-08-24 10:10:15.039*:kjdglblkrdmpint(): dump local blocker: initiate state dump for deadlock
      possible owner[327.50879] on resource tx-00090016-00002df6-00000000-00000000
    2022-08-24 10:10:15.040 :kjzddmp(): submitting asynchronized dump request [1c]. summary=[ges process stack dump (kjdglblkrdm1)].
    local hanganalyze find 1 local blockers blocking this session (pid=50879 sid=671).
    dumping blocker#0 (pid=51602 sid=4467)
    2022-08-24 10:10:15.040*:kjdglblkrdmpint(): dump local blocker: initiate state dump for deadlock
      possible owner[207.51602] on resource tx-00090016-00002df6-00000000-00000000
    2022-08-24 10:10:15.040 :kjzddmp(): submitting asynchronized dump request [1c]. summary=[ges process stack dump (kjdglblkrdm1)].
    ----------enqueue 0x16bd727c50------------------------
    lock version     : 1
    owner inst       : 2
    grant_level      : kjusernl
    req_level        : kjuserex
    bast_level       : kjusernl
    notify_func      : armed
    resp             : 0x1799a4cc68
    procp            : (nil)
    pid              : 0
    proc version     : 0
    oprocp           : (nil)
    opid             : 0
    group lock owner : (nil)
    xid              : 0000-0000-00000000
    dd_time          : 0.0 secs
    dd_count         : 0
    timeout          : 0.0 secs
    on_timer_q?      : n
    on_dd_q?         : n
    sec since mv2grq : n/a
    lock_state       : granted
    ast_flag         : 0x4
    flags            : 0x4
    open options     :  kjuserno_xid
    convert options  : kjusergetvalue 
    history          : none > none > none > none > none > ref_res > rem_ast > gr2cvt > msgsent
    msg_seq          : 0x1
    res_seq          : 2
    valblk           : 0xbb527488a57f00000180adfbfd7f0000 .rt
    global blockers dump end:-----------------------------------


    ========================================================================
      global wait-for-graph(wfg) for ges deadlock id=[4_0_1]   全局等待图
    ------------------------------------------------------------------------
                           victim : (instance=1, lock=0x1c0794e7e0) 受害者来自实例1 
          start (master) instance : 1   发起位置:实例1
         number of locks involved : 4   涉及的锁4个
      number of sessions involved : 2   涉及的会话2个


    user session identified by:     用户会话信息
    {
                user name : scott   用户名
             user machine : db2     主机名
         os terminal name : unknown 终端名
            os process id : 12349   操作系统进程号
          os program name : jdbc thin client1 程序
         application name : jdbc thin client  应用
              action name : flush ksxm hash table actionask actionave flush 行为
              current sql : 当前sql(最重要的信息!)
           update task_info_table 
             set stat = :1 ,    
          assignee_ = :2 ,
          claim_time_ = :3 ,
          last_updated_time_ = :4  
             where sn = :5 and stat = :6 
           session number : 671    会话id
    session serial number : 20082  会话序号
    server process orapid : 327    oracle进程号
    server process ospid : 50879  操作系统进程号
                 instance : 1      会话所在实例号
    }
    waiting for lock 0x1c0794e7e0 (transaction):等待锁定的对象
    {
            lock level : kjuserex
         resource name : tx 0xa001e.0x19f9e(ext 0x0,0x0) 资源名(事务id)
    ges transaction id : 147000-0001-0000000f 全局事务id
    }
    which is blocked by lock 0x1c467ceca0 (transaction): 上述对象被哪个事务锁住
    {
            lock level : kjuserex
         resource name : tx 0xa001e.0x19f9e(ext 0x0,0x0)
    ges transaction id : cf000-0001-0000020b
    }
    owned by the
    user session identified by:  持有者信息
    {
                user name : scott  持有者用户
             user machine : db1    持有者主机
         os terminal name : unknown
            os process id : 12342
          os program name : jdbc thin client1
         application name : jdbc thin client(tns v1-v3)v3)
              action name : 0000014 finished129o next slotesactionave
              current sql : 
        update act_hist
         set stat = :1 ,        
                proc_def_sn = :2 ,
                assignee_ = :3  
         where sn = :4 and stat = :5 
           session number : 4467    持有者会话id
    session serial number : 12694   持有者会话序号
    server process orapid : 207     持有者oracle进程号
    server process ospid : 51602   持有者操作系统进程号
                 instance : 1       持有者进程所在实例号
    }
    waiting for lock 0x1be76c3900 (transaction):
    {
            lock level : kjuserex
         resource name : tx 0x90016.0x2df6(ext 0x0,0x0)
    ges transaction id : cf000-0001-0000020b
    }
    which is blocked by lock 0x1c294e5600 (transaction):
    {
            lock level : kjuserex
         resource name : tx 0x90016.0x2df6(ext 0x0,0x0)
    ges transaction id : 147000-0001-0000000f
    }
    owned by the first user session of the wfg.
    ------------------------------------------------------------------------
          end of global wfg for ges deadlock id=[4_0_1]
    ========================================================================

50879进程执行的update被51602进程执行的update阻塞了。
快捷分析定位方法:在lmd的trc中直接搜wfg

检查锁状态:

  1. select dl.inst_id,
  2.          s.sid,
  3.          p.spid,
  4.          dl.resource_name1,
  5.          decode(substr(dl.grant_level, 1, 8),
  6.         'kjusernl','null','kjusercr','row-s (ss)',
  7.         'kjusercw','row-x (sx)',
  8.         'kjuserpr','share',
  9.         'kjuserpw','s/row-x (ssx)',
  10.         'kjuserex','exclusive',
  11.         request_level) as grant_level,
  12.         decode(substr(dl.request_level,1,8),
  13.         'kjusernl','null',
  14.         'kjusercr','row-s (ss)',
  15.         'kjusercw','row-x (sx)',
  16.         'kjuserpr','share',
  17.         'kjuserpw','s/row-x (ssx)',
  18.         'kjuserex','exclusive',request_level) as request_level,
  19.         decode(substr(dl.state,1,8),'kjusergr','granted','kjuserop','opening',
  20.         'kjuserca','canceling','kjusercv','converting') as state,
  21.         s.sid, sw.event, sw.seconds_in_wait sec
  22. from gv$ges_enqueue dl, gv$process p, gv$session s, gv$session_wait sw
  23. where blocker = 1
  24.         and (dl.inst_id = p.inst_id
  25.         and dl.pid = p.spid)
  26.         and (p.inst_id = s.inst_id
  27.         and p.addr = s.paddr)
  28.         and (s.inst_id = sw.inst_id
  29.         and s.sid = sw.sid)
  30. order by sw.seconds_in_wait desc;


lock table命令(很少用)


模式说明

参考:

  1. https://docs.oracle.com/en/database/oracle/oracle-database/21/cncpt/data-concurrency-and-consistency.html#guid-c1971e9b-849a-4634-9575-4f8fad697750

  http://what-when-how.com/tutorial/topic-108718ku082/expert-oracle-rac-12c-348.html

  troubleshooting "global enqueue services deadlock detected" (doc id 1443482.1)


阅读(681) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图