Skip to content

Commit

Permalink
cherry pick pingcap#33653 to release-5.4
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
lcwangchao authored and ti-srebot committed Apr 2, 2022
1 parent b1c5a67 commit dfadd62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func newExecutorBuilder(ctx sessionctx.Context, is infoschema.InfoSchema, ti *Te
ctx: ctx,
is: is,
Ti: ti,
snapshotTSCached: isStaleness,
snapshotTS: snapshotTS,
isStaleness: isStaleness,
readReplicaScope: replicaReadScope,
Expand Down
18 changes: 18 additions & 0 deletions executor/stale_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1245,3 +1245,21 @@ func (s *testStaleTxnSerialSuite) TestStaleReadNoExtraTSORequest(c *C) {
tk.MustQuery("select * from t")
failpoint.Disable("github.com/pingcap/tidb/session/assertTSONotRequest")
}

func TestIssue30872(t *testing.T) {
store, _, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_txn_mode='pessimistic'")
tk.MustExec("set tx_isolation = 'READ-COMMITTED'")
tk.MustExec("create table t1 (id int primary key, v int)")
tk.MustExec("insert into t1 values(1, 10)")
time.Sleep(time.Millisecond * 100)
tk.MustExec("set @a=now(6)")
time.Sleep(time.Millisecond * 100)
tk.MustExec("update t1 set v=100 where id=1")
tk.MustExec("set autocommit=0")
tk.MustQuery("select * from t1 as of timestamp @a").Check(testkit.Rows("1 10"))
}

0 comments on commit dfadd62

Please sign in to comment.