You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some times in a uint test, we want to "pause" a session manually and then "resume" it to run some other codes between them. For example, if we want to test the retry operation when it has a key conflict , we need to:
Execute "update t set v=v+1 where id=1" in session1, PAUSE this session after it updated the record in memory before committed to TiKV.
Create a new session2, and update the same record.
RESUME the session1 to continue the commit works. At this time, we expect a conflict error from TiKV. The session1 retries then, and finally write the right value.
However, the current MustExec or MustQuery will block the execute goroutine and will not return util the whole statement is finished, so we need other utils to make the pause and resume semantics. It looks like the below codes:
// initial value for table t is (1, 10)
tk1 := testkit.NewTestKit(t, store)
task := CreateExecTask("update t set v=v+1 where id=1")
// Create a sql task and start it and pause it before commit
task.Start().CheckStopAt("before commit")
// Then tk1 update the record to construct the conflict
tk1.MustExec("update t set v=v+1 where id=1")
// Continue the task and check it stop at commit retry because of error
task.Continue().CheckStopAt("commit retry")
// Then continue again the task to done
task.Continue().CheckDone()
// Check the final value is 12 not 11
tk1.MustQuery("select v from t where id=1").Check(testkit.Rows("1 12"))
The text was updated successfully, but these errors were encountered:
Enhancement
Some times in a uint test, we want to "pause" a session manually and then "resume" it to run some other codes between them. For example, if we want to test the retry operation when it has a key conflict , we need to:
However, the current
MustExec
orMustQuery
will block the execute goroutine and will not return util the whole statement is finished, so we need other utils to make the pause and resume semantics. It looks like the below codes:The text was updated successfully, but these errors were encountered: