Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: 锁冲突根因分析场景迭代 #327

Open
jingyd66 opened this issue Jul 15, 2024 · 1 comment
Open

[Enhancement]: 锁冲突根因分析场景迭代 #327

jingyd66 opened this issue Jul 15, 2024 · 1 comment
Assignees

Comments

@jingyd66
Copy link
Contributor

Description

版本:3.1.4 和4.2.1
租户级别
1.就是针对租户dml操作慢的场景,可以定位到有锁等待(ocp上面的重试信息);
2.能确认出我当前执行事务卡住的会话id,
3.根据我当前锁等待的行找到对应持锁事务的信息,如持锁的会话id;

确定好这两块等锁和拿锁会话id,知道拿锁的会话id执行了什么,等锁的会话id执行了什么;应用根据业务逻辑做出选择去杀哪个会话

因为生产环境锁等待的事务有多个,持锁事务也有多个,希望把锁冲突的rca用到生产环境排查问题中

希望内核同学能给下方案,我们这边有环境可复现,可以开发该功能

@YangEfei
Copy link

oceanbase/oceanbase@1196d9a
在本次提交中,在 OB_LOCKS 中新增了 session_id 列,表示当前请求锁的会话 id,同时调整了 ID1 / ID2 列,分别表示持锁事务 id / 持锁会话 id,对 type = 'TR' 类型的锁,即行锁,还会展示 ID3 列,形为 tablet_id - rowkey。

因此对于该 issue 内的问题,可以通过过滤 BLOCK = 1 AND TYPE = 'TR' 来过滤发生冲突的行锁,以此可以观察到行等待关系,并获取到持锁 / 等锁的事务 id 和会话 id,分别为 ID1 / trans_id 和 ID2 / session_id。

此外,需要注意的是,TR 类型的锁,即行锁,会在发生转储 / fast commit 后退化为 TX 类型的锁,即事务锁,此时若未发生冲突,只能观察到某事务持锁,但不知道其具体持有哪些锁。但是发生冲突时,仍能通过上面的过滤条件观察到冲突发生的行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants