Skip to content

Commit

Permalink
cherry pick pingcap#33653 to release-6.0
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 36a9810 commit 7dd9c25
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 @@ -121,6 +121,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 @@ -1322,3 +1322,21 @@ func TestPlanCacheWithStaleReadByBinaryProto(t *testing.T) {
require.NoError(t, err)
tk.ResultSetToResult(rs, fmt.Sprintf("%v", rs)).Check(testkit.Rows("1 10"))
}

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 7dd9c25

Please sign in to comment.