tidb: An immediate read after two UPDATE transactions does not pick up the change in the other transaction

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?

I run the following script which consists of two transactions. After both transactions commit, a first SELECT cannot see the UPDATE by the other session. However if I run the same SELECT again, it picks up the UPDATE by the other session.

create table test (id int primary key, value int);
insert into test (id, value) values (1, 10), (2, 20);

begin; -- T1
begin; -- T2

update test set value = 11 where id = 1; -- T1
update test set value = 19 where id = 2; -- T1
update test set value = 12 where id = 1; -- T2. Blocked
commit; -- T1. This unblocks T2
update test set value = 18 where id = 2; -- T2
commit; -- T2

select * from test; -- T1. Shows 1 => 11, 2 => 19 (caching problem?)
select * from test; -- T1. Shows 1 => 12, 2 => 18 (correct result)

2. What did you expect to see?

The last two SELECT should return same result.

3. What did you see instead?

The next to last SELECT returns a result that does not reflect the change by T2.

4. What version of TiDB are you using? (tidb-server -V or run select tidb_version(); on TiDB)

v3.0.12

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 38 (24 by maintainers)

Most upvoted comments

Sorry @yanmingcao , feedback@pingcap.com did not previously have permission to receive out-of-company mail. If we missed your contact information, please send it again. Thank you!