本文为您介绍事务超时的相关报错及处理方式。
事务空闲超时
事务空闲超时指当事务两条语句执行间隔超过指定阈值。
报错:ORA-24761
错误码
OceanBase 错误码:6211
SQLSTATE:25000
报错信息
transaction rolled back
示例
开启事务后 120 秒内未操作。
obclient> CREATE TABLE t_insert(
id number NOT NULL PRIMARY KEY
, name varchar(10) NOT NULL
, value number
,gmt_create timestamp NOT NULL DEFAULT current_timestamp); //准备数据
Query OK, 0 rows affected
obclient> INSERT INTO t_insert(id, name, value, gmt_create) VALUES (1,'CN',10001, current_timestamp);
Query OK, 1 row affected
obclient> INSERT INTO t_insert(id, name, value) VALUES (2,'US', 10002);
Query OK, 1 rows affected
obclient> INSERT INTO t_insert(id, name, value) VALUES (3,'EN', 10003);
Query OK, 1 rows affected
obclient> BEGIN; //开启事务后 `120` 秒内未执行操作
Query OK, 0 rows affected
obclient> UPDATE t_insert SET t_insert.value = 10004 WHERE t_insert.id = 3;
ORA-24761: transaction rolled back: transaction needs rollback
处理方法
查看
ob_trx_idle_timeout参数值(单位:微秒),确认操作的超时时间是否超过了设置的值。obclient> SHOW variables like 'ob_trx_idle_timeout'; +---------------------+-----------+ | VARIABLE_NAME | VALUE | +---------------------+-----------+ | ob_trx_idle_timeout | 120000000 | +---------------------+-----------+ 1 row in set使用
ROLLBACK恢复操作。obclient> ROLLBACK; Query OK, 0 rows affected再次查询
t_insert表中的数据。obclient> SELECT sysdate, t.* FROM t_insert t; +-----------+----+------+-------+------------------------------+ | SYSDATE | ID | NAME | VALUE | GMT_CREATE | +-----------+----+------+-------+------------------------------+ | 05-SEP-22 | 1 | CN | 10001 | 05-SEP-22 04.34.37.145469 PM | | 05-SEP-22 | 2 | US | 10002 | 05-SEP-22 04.34.46.776463 PM | | 05-SEP-22 | 3 | EN | 10003 | 05-SEP-22 04.34.46.776463 PM | +-----------+----+------+-------+------------------------------+ 3 rows in set
事务未提交超时
事务未提交超时指当事务超过指定阈值后未提交或回滚。
报错:ORA-00600
报错信息
internal error code, arguments: -6210, Transaction is timeout
示例
200 秒内未提交事务或者回滚。
obclient> CREATE TABLE t_insert(
id number NOT NULL PRIMARY KEY
, name varchar(10) NOT NULL
, value number
,gmt_create timestamp NOT NULL DEFAULT current_timestamp); //准备数据
Query OK, 0 rows affected
obclient> INSERT INTO t_insert(id, name, value, gmt_create) VALUES (1,'CN',10001, current_timestamp);
Query OK, 1 row affected
obclient> INSERT INTO t_insert(id, name, value) VALUES (2,'US', 10002);
Query OK, 1 rows affected
obclient> INSERT INTO t_insert(id, name, value) VALUES (3,'EN', 10003);
Query OK, 1 rows affected
/* 等待 200 秒不操作*/
obclient> SELECT sysdate, t.* FROM t_insert t;
ORA-00600: internal error code, arguments: -6210, Transaction is timeout
obclient> COMMIT;
ORA-00600: internal error code, arguments: -6210, Transaction is timeout
处理方法
查看
ob_trx_timeout参数值(单位:微秒),确认事务超时时间是否超过了设置的值。obclient> SHOW variables like 'ob_trx_timeout'; +----------------+------------+ | Variable_name | Value | +----------------+------------+ | ob_trx_timeout | 200000000 | +----------------+------------+ 1 row in set使用
ROLLBACK恢复操作。obclient> ROLLBACK; Query OK, 0 rows affected再次
COMMIT。obclient> COMMIT; Query OK, 0 rows affected再次查询
t_insert表数据。obclient> SELECT sysdate, t.* FROM t_insert t; +-----------+----+------+-------+------------------------------+ | SYSDATE | ID | NAME | VALUE | GMT_CREATE | +-----------+----+------+-------+------------------------------+ | 05-SEP-22 | 1 | CN | 10001 | 05-SEP-22 04.34.37.145469 PM | | 05-SEP-22 | 2 | US | 10002 | 05-SEP-22 04.34.46.776463 PM | | 05-SEP-22 | 3 | EN | 10003 | 05-SEP-22 04.34.46.776463 PM | +-----------+----+------+-------+------------------------------+ 3 rows in set