add a failpoint for sleep (#460)

Signed-off-by: ekexium <ekexium@gmail.com>

Co-authored-by: Yilin Chen <sticnarf@gmail.com>
Co-authored-by: disksing <i@disksing.com>
This commit is contained in:
Ziqian Qin 2022-04-11 21:34:25 +08:00 committed by GitHub
parent ec236b6435
commit e31ba21ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -190,6 +190,11 @@ func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *retry.B
return errors.New("injected error on prewriting secondary batch")
}
util.EvalFailpoint("prewriteSecondary") // for other failures like sleep or pause
// concurrent failpoint sleep doesn't work as expected. So we need a separate fail point.
// `1*sleep()` can block multiple concurrent threads that meet the failpoint.
if val, err := util.EvalFailpoint("prewriteSecondarySleep"); err == nil {
time.Sleep(time.Millisecond * time.Duration(val.(int)))
}
}
}