The following is an example of a transaction:
create table test (id1 int);
set @@ob_query_timeout=200 * 1000 * 1000;
set @@ob_trx_timeout = 200 * 1000 * 1000;
begin;
insert into test values(1);
// 150s interval in between
insert into test values(2); // This SQL will report Lost connection
select * from test; // This query returns empty, indicating that the transaction has been rolled back.
rollback;
When the second insert statement is executed, the client reports a Lost connection error. The reason is that if the interval between two SQL statements in a transaction exceeds a certain threshold, OceanBase Database forcibly kills the session, disconnects from the client, and rolls back the transaction.
This mechanism is used to address long transactions and hung transactions. The idle threshold is controlled by the tenant system variable ob_trx_idle_timeout, with a default value of 86400000000 microseconds, or 24 hours.