Skip to content

Commit

Permalink
server: fix unstable test-case TestInternalSessionTxnStartTS (#42392)
Browse files Browse the repository at this point in the history
close #42269
  • Loading branch information
TonsnakeLin authored Mar 20, 2023
1 parent ad6b795 commit 0fe2637
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
13 changes: 0 additions & 13 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,19 +553,6 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
pi.SetProcessInfo(sql, time.Now(), cmd, maxExecutionTime)
}

failpoint.Inject("mockDelayInnerSessionExecute", func() {
var curTxnStartTS uint64
if cmd != mysql.ComSleep || sctx.GetSessionVars().InTxn() {
curTxnStartTS = sctx.GetSessionVars().TxnCtx.StartTS
}
if sctx.GetSessionVars().SnapshotTS != 0 {
curTxnStartTS = sctx.GetSessionVars().SnapshotTS
}
logutil.BgLogger().Info("Enable mockDelayInnerSessionExecute when execute statement",
zap.Uint64("startTS", curTxnStartTS))
time.Sleep(200 * time.Millisecond)
})

isPessimistic := sctx.GetSessionVars().TxnCtx.IsPessimistic

// Special handle for "select for update statement" in pessimistic transaction.
Expand Down
6 changes: 0 additions & 6 deletions server/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ func TestInternalSessionTxnStartTS(t *testing.T) {
}
// Test an issue that sysSessionPool doesn't call session's Close, cause
// asyncGetTSWorker goroutine leak.
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/executor/mockDelayInnerSessionExecute", "return"))
var wg util.WaitGroupWrapper
for i := 0; i < count; i++ {
s := stmts[i]
Expand All @@ -912,11 +911,6 @@ func TestInternalSessionTxnStartTS(t *testing.T) {
require.NoError(t, err)
})
}
time.Sleep(100 * time.Millisecond)
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/executor/mockDelayInnerSessionExecute"))

lst := ts.domain.InfoSyncer().GetSessionManager().GetInternalSessionStartTSList()
require.Equal(t, len(lst), 10)

wg.Wait()
}
Expand Down

0 comments on commit 0fe2637

Please sign in to comment.