问题现象
DML 语句执行卡住,长时间不能执行成功,甚至超时。
关键日志信息。
[2023-04-13 15:49:02.896797] WARN [STORAGE.TRANS] on_wlock_retry (ob_memtable_context.cpp:345) [83202][0][xxxxx-xxxxx-xxxxx-xxxxx] [lt=4] [dc=0] lock_for_write conflict(*this=alloc_type=0 ctx_descriptor=242543 min_table_version=1681371766732216 max_table_version=1681371766732216 is_safe_read=false read_snapshot=1681372142887131 start_version=-1 trans_version=9223372036854775807 commit_version=0 stmt_start_time=1681372142895986 abs_expired_time=1681372152796403 stmt_timeout=9900417 abs_lock_wait_timeout=1681372152796403 row_purge_version=0 lock_wait_start_ts=0 trx_lock_timeout=-1 end_code=0 is_readonly=false ref=2 pkey={tid:1100611139453786, partition_id:0, part_cnt:0} trans_id={hash:576748225754987808, inc:786467, addr:"xxx.xxx.xxx.xxx:xxx", t:1681372142895986} checksum_log_ts=0, key=table_id=1100611139453786 rowkey_object=[{"BIGINT UNSIGNED":1}] , conflict_ctx="alloc_type=0 ctx_descriptor=242522 min_table_version=1681371766732216 max_table_version=1681371766732216 is_safe_read=false read_snapshot=1681372141085659 start_version=-1 trans_version=9223372036854775807 commit_version=0 stmt_start_time=1681372141092544 abs_expired_time=1681372150989534 stmt_timeout=9896990 abs_lock_wait_timeout=1681372150989534 row_purge_version=0 lock_wait_start_ts=0 trx_lock_timeout=-1 end_code=0 is_readonly=false ref=0 pkey={tid:1100611139453786, partition_id:0, part_cnt:0} trans_id={hash:15363880101622890528, inc:786390, addr:"xxx.xxx.xxx.xxx:xxx", t:1681372141092544} checksum_log_ts=0")
问题原因
行锁导致 DML 不能执行成功。
问题的风险及影响
SQL 执行变慢甚至超时。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
适用版本
OceanBase 数据库 V3.x 版本。
解决方法及规避方式
解决方法:
需要找到持有锁的会话并 kill 掉。
规避方式:
锁冲突一般是业务逻辑导致,需要业务梳理正确的业务逻辑。