mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #14757 from ahrtr/add_failpoint_20221115
etcdserver: add failpoints for backend
This commit is contained in:
commit
39ca876f38
@ -634,7 +634,9 @@ func (b *backend) begin(write bool) *bolt.Tx {
|
||||
}
|
||||
|
||||
func (b *backend) unsafeBegin(write bool) *bolt.Tx {
|
||||
// gofail: var beforeStartDBTxn struct{}
|
||||
tx, err := b.db.Begin(write)
|
||||
// gofail: var afterStartDBTxn struct{}
|
||||
if err != nil {
|
||||
b.lg.Fatal("failed to begin tx", zap.Error(err))
|
||||
}
|
||||
|
@ -307,7 +307,9 @@ func newBatchTxBuffered(backend *backend) *batchTxBuffered {
|
||||
func (t *batchTxBuffered) Unlock() {
|
||||
if t.pending != 0 {
|
||||
t.backend.readTx.Lock() // blocks txReadBuffer for writing.
|
||||
// gofail: var beforeWritebackBuf struct{}
|
||||
t.buf.writeback(&t.backend.readTx.buf)
|
||||
// gofail: var afterWritebackBuf struct{}
|
||||
t.backend.readTx.Unlock()
|
||||
if t.pending >= t.backend.batchLimit {
|
||||
t.commit(false)
|
||||
|
@ -31,19 +31,25 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
KillFailpoint Failpoint = killFailpoint{}
|
||||
DefragBeforeCopyPanic Failpoint = goFailpoint{"backend/defragBeforeCopy", "panic", triggerDefrag}
|
||||
DefragBeforeRenamePanic Failpoint = goFailpoint{"backend/defragBeforeRename", "panic", triggerDefrag}
|
||||
BeforeCommitPanic Failpoint = goFailpoint{"backend/beforeCommit", "panic", nil}
|
||||
AfterCommitPanic Failpoint = goFailpoint{"backend/afterCommit", "panic", nil}
|
||||
RaftBeforeSavePanic Failpoint = goFailpoint{"etcdserver/raftBeforeSave", "panic", nil}
|
||||
RaftAfterSavePanic Failpoint = goFailpoint{"etcdserver/raftAfterSave", "panic", nil}
|
||||
CommitBeforePreCommitHookPanic Failpoint = goFailpoint{"backend/commitBeforePreCommitHook", "panic", nil}
|
||||
CommitAfterPreCommitHookPanic Failpoint = goFailpoint{"backend/commitAfterPreCommitHook", "panic", nil}
|
||||
RandomFailpoint Failpoint = randomFailpoint{[]Failpoint{
|
||||
KillFailpoint Failpoint = killFailpoint{}
|
||||
DefragBeforeCopyPanic Failpoint = goFailpoint{"backend/defragBeforeCopy", "panic", triggerDefrag}
|
||||
DefragBeforeRenamePanic Failpoint = goFailpoint{"backend/defragBeforeRename", "panic", triggerDefrag}
|
||||
BeforeCommitPanic Failpoint = goFailpoint{"backend/beforeCommit", "panic", nil}
|
||||
AfterCommitPanic Failpoint = goFailpoint{"backend/afterCommit", "panic", nil}
|
||||
RaftBeforeSavePanic Failpoint = goFailpoint{"etcdserver/raftBeforeSave", "panic", nil}
|
||||
RaftAfterSavePanic Failpoint = goFailpoint{"etcdserver/raftAfterSave", "panic", nil}
|
||||
BackendBeforePreCommitHookPanic Failpoint = goFailpoint{"backend/commitBeforePreCommitHook", "panic", nil}
|
||||
BackendAfterPreCommitHookPanic Failpoint = goFailpoint{"backend/commitAfterPreCommitHook", "panic", nil}
|
||||
BackendBeforeStartDBTxnPanic Failpoint = goFailpoint{"backend/beforeStartDBTxn", "panic", nil}
|
||||
BackendAfterStartDBTxnPanic Failpoint = goFailpoint{"backend/afterStartDBTxn", "panic", nil}
|
||||
BackendBeforeWritebackBufPanic Failpoint = goFailpoint{"backend/beforeWritebackBuf", "panic", nil}
|
||||
BackendAfterWritebackBufPanic Failpoint = goFailpoint{"backend/afterWritebackBuf", "panic", nil}
|
||||
RandomFailpoint Failpoint = randomFailpoint{[]Failpoint{
|
||||
KillFailpoint, BeforeCommitPanic, AfterCommitPanic, RaftBeforeSavePanic,
|
||||
RaftAfterSavePanic, DefragBeforeCopyPanic, DefragBeforeRenamePanic,
|
||||
CommitBeforePreCommitHookPanic, CommitAfterPreCommitHookPanic,
|
||||
BackendBeforePreCommitHookPanic, BackendAfterPreCommitHookPanic,
|
||||
BackendBeforeStartDBTxnPanic, BackendAfterStartDBTxnPanic,
|
||||
BackendBeforeWritebackBufPanic, BackendAfterWritebackBufPanic,
|
||||
}}
|
||||
// TODO: Figure out how to reliably trigger below failpoints and add them to RandomFailpoint
|
||||
raftBeforeLeaderSendPanic Failpoint = goFailpoint{"etcdserver/raftBeforeLeaderSend", "panic", nil}
|
||||
|
Loading…
x
Reference in New Issue
Block a user