通过transaction id找到对应的session

像之前遇到的分布式事务报错的问题,我们可能很想知道这个transaction对应的sql及user是什么,那怎么办呢?

我们先看看transaction id的组成:

4.10.878948

其中:4 = rbs#(回滚段编号) ,10 = slot#(事务槽编号), 878948 = wrap#(序号)


我们再看看v$transaction中的字段:

Column     Datatype      Description
———-  ———–    ——————-
XIDUSN    NUMBER        Undo segment number
XIDSLOT   NUMBER        Slot number
XIDSQN    NUMBER        Sequence number

这三个字段分别对应的就是transaction的第一,第二,第三个数字。那么我们就可以通过下面的语句查询到对应的sql及user:

  1. select e.sql_text, d.osuser,d.username
  2. from v$transaction c, v$session d, v$sqlarea e
  3. where d.taddr = c.addr and e.address = d.prev_sql_addr
  4. and c.xidusn = 4
  5. and c.xidslot =10
  6. and c.xidsqn = 878948;

当然前提是该transaction还能在v$transaction中查询到:)

  
« 【ZT】Oracle分布式事务故障处理            Home            Merry Xmas & Happy New Year »

No Comments

Be the first to comment on this entry.

Leave a comment

Name(required)
Mail (will not be published)(required)
Website

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://www.dbifan.com),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.

    搜索本站

    站点日历

    12月 2008
    « 11   1 »
    1234567
    891011121314
    15161718192021
    22232425262728
    293031  

    订阅本站

    文章分类

    最新日志

    热点文章

    日志存档

    常用标签