etcdserver: add two failpoints for backend

1. before and after create boltDB transaction;
2. before and after writebuf back to read buffer;

Signed-off-by: Benjamin Wang <wachao@vmware.com>
dependabot/go_modules/go.uber.org/atomic-1.10.0
Benjamin Wang 2022-11-15 08:09:05 +08:00
parent efa144a66a
commit 4f824336ad
2 changed files with 4 additions and 0 deletions

View File

@ -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))
}

View File

@ -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)