Skip to content

Commit 9226670

Browse files
committed
back port gofail comments to release-3.5
Signed Signed-off-by: Gang Li <[email protected]>
1 parent e230ade commit 9226670

File tree

9 files changed

+17
-1
lines changed

9 files changed

+17
-1
lines changed

contrib/raftexample/raft.go

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (rc *raftNode) saveSnap(snap raftpb.Snapshot) error {
127127
if err := rc.snapshotter.SaveSnap(snap); err != nil {
128128
return err
129129
}
130+
// gofail: var raftBeforeWALSaveSnaphot struct{}
130131
if err := rc.wal.SaveSnapshot(walSnap); err != nil {
131132
return err
132133
}

server/etcdserver/api/membership/cluster.go

+1
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ func (c *RaftCluster) IsMemberExist(id types.ID) bool {
903903
c.Lock()
904904
defer c.Unlock()
905905
_, ok := c.members[id]
906+
// gofail: var afterIsMemberExist struct{}
906907
return ok
907908
}
908909

server/etcdserver/api/v3rpc/watch.go

+1
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ func (sws *serverWatchStream) sendLoop() {
453453
sws.mu.RUnlock()
454454

455455
var serr error
456+
// gofail: var beforeSendWatchResponse struct{}
456457
if !fragmented && !ok {
457458
serr = sws.gRPCStream.Send(wr)
458459
} else {

server/etcdserver/raft.go

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ func (r *raftNode) start(rh *raftReadyHandler) {
334334
notifyc <- struct{}{}
335335
}
336336

337+
// gofail: var raftBeforeAdvance struct{}
337338
r.Advance()
338339
case <-r.stopped:
339340
return

server/etcdserver/server.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,7 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
13321332
// wait for raftNode to persist snapshot onto the disk
13331333
<-apply.notifyc
13341334

1335+
// gofail: var applyBeforeOpenSnapshot struct{}
13351336
newbe, err := openSnapshotBackend(s.Cfg, s.snapshotter, apply.snapshot, s.beHooks)
13361337
if err != nil {
13371338
lg.Panic("failed to open snapshot backend", zap.Error(err))
@@ -2064,6 +2065,7 @@ func (s *EtcdServer) publishV3(timeout time.Duration) {
20642065
ClientUrls: s.attributes.ClientURLs,
20652066
},
20662067
}
2068+
// gofail: var beforePublishing struct{}
20672069
lg := s.Logger()
20682070
for {
20692071
select {
@@ -2242,7 +2244,7 @@ func (s *EtcdServer) apply(
22422244
s.consistIndex.SetConsistentApplyingIndex(e.Index, e.Term)
22432245
shouldApplyV3 = membership.ApplyBoth
22442246
}
2245-
2247+
// gofail: var beforeApplyOneConfChange struct{}
22462248
var cc raftpb.ConfChange
22472249
pbutil.MustUnmarshal(&cc, e.Data)
22482250
removedSelf, err := s.applyConfChange(cc, confState, shouldApplyV3)

server/mvcc/backend/backend.go

+2
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,9 @@ func (b *backend) begin(write bool) *bolt.Tx {
669669
}
670670

671671
func (b *backend) unsafeBegin(write bool) *bolt.Tx {
672+
// gofail: var beforeStartDBTxn struct{}
672673
tx, err := b.db.Begin(write)
674+
// gofail: var afterStartDBTxn struct{}
673675
if err != nil {
674676
b.lg.Fatal("failed to begin tx", zap.Error(err))
675677
}

server/mvcc/backend/batch_tx.go

+3
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ func (t *batchTxBuffered) Unlock() {
310310
t.backend.readTx.Lock() // blocks txReadBuffer for writing.
311311
// gofail: var beforeWritebackBuf struct{}
312312
t.buf.writeback(&t.backend.readTx.buf)
313+
// gofail: var afterWritebackBuf struct{}
313314
t.backend.readTx.Unlock()
314315
// We commit the transaction when the number of pending operations
315316
// reaches the configured limit(batchLimit) to prevent it from
@@ -359,7 +360,9 @@ func (t *batchTxBuffered) commit(stop bool) {
359360

360361
func (t *batchTxBuffered) unsafeCommit(stop bool) {
361362
if t.backend.hooks != nil {
363+
// gofail: var commitBeforePreCommitHook struct{}
362364
t.backend.hooks.OnPreCommitUnsafe(t)
365+
// gofail: var commitAfterPreCommitHook struct{}
363366
}
364367
if t.backend.readTx.tx != nil {
365368
// wait all store read transactions using the current boltdb tx to finish,

server/mvcc/kvstore.go

+2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ func (s *store) updateCompactRev(rev int64) (<-chan struct{}, int64, error) {
225225
tx.UnsafePut(buckets.Meta, scheduledCompactKeyName, rbytes)
226226
tx.Unlock()
227227
// ensure that desired compaction is persisted
228+
// gofail: var compactBeforeCommitScheduledCompact struct{}
228229
s.b.ForceCommit()
230+
// gofail: var compactAfterCommitScheduledCompact struct{}
229231

230232
s.revMu.Unlock()
231233

server/mvcc/kvstore_compaction.go

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (s *store) scheduleCompaction(compactMainRev, prevCompactRev int64) (KeyVal
6565
revToBytes(revision{main: compactMainRev}, rbytes)
6666
tx.UnsafePut(buckets.Meta, finishedCompactKeyName, rbytes)
6767
tx.Unlock()
68+
// gofail: var compactAfterSetFinishedCompact struct{}
6869
hash := h.Hash()
6970
size, sizeInUse := s.b.Size(), s.b.SizeInUse()
7071
s.lg.Info(
@@ -84,7 +85,9 @@ func (s *store) scheduleCompaction(compactMainRev, prevCompactRev int64) (KeyVal
8485
revToBytes(revision{main: rev.main, sub: rev.sub + 1}, last)
8586
tx.Unlock()
8687
// Immediately commit the compaction deletes instead of letting them accumulate in the write buffer
88+
// gofail: var compactBeforeCommitBatch struct{}
8789
s.b.ForceCommit()
90+
// gofail: var compactAfterCommitBatch struct{}
8891
dbCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
8992

9093
select {

0 commit comments

Comments
 (0)