Skip to content

Prevent SELECT ... AS OF TIMESTAMP from being used during implicit txn with autocommit = 0. #65957

@wfxr

Description

@wfxr

Enhancement

According to the description in Stale Read Product Design, SELECT ... AS OF TIMESTAMP

  • Only used in the implicit transaction with autocommit = 1.

However, we can still successfully execute the SELECT ... AS OF TIMESTAMP statement even with autocommit = 0.

drop table if exists t;
create table t (id int primary key, v int);
insert into t values (1, 10);
select sleep(0.1);

set @ts1 = now(6);
select sleep(0.1);

update t set v = 20 where id = 1;

set @ts2 = now(6);
select sleep(0.1);

update t set v = 30 where id = 1;

select sleep(1);

set @@tidb_read_staleness = -1;
set @@autocommit = 0;

-- should report error but sometimes it doesn't
select * from t as of timestamp @ts1 where id = 1;
select * from t as of timestamp @ts2 where id = 1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions