Skip to content

Commit b5a19ba

Browse files
Merge pull request #11211 from cockroachdb/spencerkimball/fix-jepsen
kv: handle some additional cases where we need to signal ambiguous re…
2 parents 32a00c6 + 652f11e commit b5a19ba

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

pkg/storage/replica.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ const (
174174
// so if the retry does not succeed, care must be taken to correctly inform
175175
// the caller via an AmbiguousResultError.
176176
proposalReproposed
177+
// proposalErrorReproposing indicates that re-proposal
178+
// failed. Because the original proposal may have succeeded, an
179+
// AmbiguousResultError must be returned. The command should not be
180+
// retried.
181+
proposalErrorReproposing
182+
// proposalRangeNoLongerExists indicates the proposal was for a
183+
// range that no longer exists. Because the original proposal may
184+
// have succeeded, an AmbiguousResultError must be returned. The
185+
// command should not be retried.
186+
proposalRangeNoLongerExists
177187
)
178188

179189
// proposalResult indicates the result of a proposal. Exactly one of
@@ -1705,10 +1715,12 @@ func (r *Replica) addWriteCmd(
17051715
br, pErr, retry := r.tryAddWriteCmd(ctx, ba)
17061716
switch retry {
17071717
case proposalIllegalLeaseIndex:
1708-
continue
1718+
continue // retry
17091719
case proposalReproposed:
17101720
ambiguousResult = true
1711-
continue
1721+
continue // retry
1722+
case proposalRangeNoLongerExists, proposalErrorReproposing:
1723+
ambiguousResult = true
17121724
}
17131725
if pErr != nil {
17141726
// If this isn't an end transaction with commit=true, return
@@ -2836,7 +2848,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
28362848
log.Eventf(p.Local.ctx, "re-submitting command %x to Raft: %s", p.Local.idKey, reason)
28372849
if err := r.submitProposalLocked(p); err != nil {
28382850
delete(r.mu.proposals, p.Local.idKey)
2839-
p.Local.finish(proposalResult{Err: roachpb.NewError(err)})
2851+
p.Local.finish(proposalResult{Err: roachpb.NewError(err), ProposalRetry: proposalErrorReproposing})
28402852
}
28412853
}
28422854
}

pkg/storage/store.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,8 +2019,9 @@ func (s *Store) removeReplicaImpl(
20192019
// Clear the pending command queue.
20202020
if len(rep.mu.proposals) > 0 {
20212021
resp := proposalResult{
2022-
Reply: &roachpb.BatchResponse{},
2023-
Err: roachpb.NewError(roachpb.NewRangeNotFoundError(rep.RangeID)),
2022+
Reply: &roachpb.BatchResponse{},
2023+
Err: roachpb.NewError(roachpb.NewRangeNotFoundError(rep.RangeID)),
2024+
ProposalRetry: proposalRangeNoLongerExists,
20242025
}
20252026
for _, p := range rep.mu.proposals {
20262027
p.Local.finish(resp)

0 commit comments

Comments
 (0)