Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store/tikv: support injecting customized failure to prewrite #23432

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions store/tikv/prewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,25 @@ func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *Backoff
// checked there.

if c.sessionID > 0 {
failpoint.Inject("beforePrewrite", func() {})

failpoint.Inject("prewritePrimaryFail", func() {
if batch.isPrimary {
if batch.isPrimary {
failpoint.Inject("prewritePrimaryFail", func() {
// Delay to avoid cancelling other normally ongoing prewrite requests.
time.Sleep(time.Millisecond * 50)
logutil.Logger(bo.ctx).Info("[failpoint] injected error on prewriting primary batch",
zap.Uint64("txnStartTS", c.startTS))
failpoint.Return(errors.New("injected error on prewriting primary batch"))
}
})

failpoint.Inject("prewriteSecondaryFail", func() {
if !batch.isPrimary {
})
failpoint.Inject("prewritePrimary", nil) // for other failures like sleep or pause
} else {
failpoint.Inject("prewriteSecondaryFail", func() {
// Delay to avoid cancelling other normally ongoing prewrite requests.
time.Sleep(time.Millisecond * 50)
logutil.Logger(bo.ctx).Info("[failpoint] injected error on prewriting secondary batch",
zap.Uint64("txnStartTS", c.startTS))
failpoint.Return(errors.New("injected error on prewriting secondary batch"))
}
})
})
failpoint.Inject("prewriteSecondary", nil) // for other failures like sleep or pause
}
}

txnSize := uint64(c.regionTxnSize[batch.region.id])
Expand Down