Skip to content

Commit

Permalink
store/tikv: support injecting customized failure to prewrite (#23432)
Browse files Browse the repository at this point in the history
  • Loading branch information
sticnarf authored Apr 15, 2021
1 parent 73dea07 commit 8498b2c
Showing 1 changed file with 9 additions and 11 deletions.
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

0 comments on commit 8498b2c

Please sign in to comment.