@@ -149,6 +149,8 @@ func TestReplicaStateMachineChangeReplicas(t *testing.T) {
149
149
// should there be a command in the raft log (i.e. some errant lease request
150
150
// or whatnot) this will fire assertions because it will conflict with the
151
151
// log index that we pulled out of thin air above.
152
+ r .readOnlyCmdMu .Lock ()
153
+ defer r .readOnlyCmdMu .Unlock ()
152
154
r .mu .Lock ()
153
155
defer r .mu .Unlock ()
154
156
r .mu .destroyStatus .Set (errors .New ("test done" ), destroyReasonRemoved )
@@ -231,14 +233,16 @@ func TestReplicaStateMachineRaftLogTruncationStronglyCoupled(t *testing.T) {
231
233
_ , err = sm .ApplySideEffects (checkedCmd .Ctx (), checkedCmd )
232
234
require .NoError (t , err )
233
235
func () {
234
- r .mu .Lock ()
235
- defer r .mu .Unlock ()
236
236
// Set a destroyStatus to make sure there won't be any raft processing once
237
237
// we release raftMu. We applied a command but not one from the raft log, so
238
238
// should there be a command in the raft log (i.e. some errant lease request
239
239
// or whatnot) this will fire assertions because it will conflict with the
240
240
// log index that we pulled out of thin air above.
241
+ r .readOnlyCmdMu .Lock ()
242
+ r .mu .Lock ()
243
+ defer r .mu .Unlock ()
241
244
r .mu .destroyStatus .Set (errors .New ("test done" ), destroyReasonRemoved )
245
+ r .readOnlyCmdMu .Unlock ()
242
246
243
247
require .Equal (t , raftAppliedIndex + 1 , r .shMu .state .RaftAppliedIndex )
244
248
require .Equal (t , truncatedIndex + 1 , ls .shMu .trunc .Index )
@@ -427,7 +431,13 @@ func TestReplicaStateMachineEphemeralAppBatchRejection(t *testing.T) {
427
431
defer r .raftMu .Unlock ()
428
432
// Avoid additional raft processing after we're done with this replica because
429
433
// we've applied entries that aren't in the log.
430
- defer r .mu .destroyStatus .Set (errors .New ("boom" ), destroyReasonRemoved )
434
+ defer func () {
435
+ r .readOnlyCmdMu .Lock ()
436
+ defer r .readOnlyCmdMu .Unlock ()
437
+ r .mu .Lock ()
438
+ defer r .mu .Unlock ()
439
+ r .mu .destroyStatus .Set (errors .New ("boom" ), destroyReasonRemoved )
440
+ }()
431
441
432
442
sm := r .getStateMachine ()
433
443
0 commit comments