Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
135129: kvserver: add logging if a lease {request, transfer} is not applied  r=tbg a=arulajmani

See individual commits for details.

Co-authored-by: Arul Ajmani <[email protected]>
  • Loading branch information
craig[bot] and arulajmani committed Nov 15, 2024
2 parents e6e86b7 + 68d7003 commit ad45b52
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/kv/kvserver/kvserverbase/forced_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/redact"
)

// ProposalRejectionType indicates how to handle a proposal that was
Expand Down Expand Up @@ -72,7 +73,22 @@ func CheckForcedErr(
raftCmd *kvserverpb.RaftCommand,
isLocal bool,
replicaState *kvserverpb.ReplicaState,
) ForcedErrResult {
) (res ForcedErrResult) {
isLeaseRequest := raftCmd.ReplicatedEvalResult.IsLeaseRequest

defer func() {
if res.ForcedError != nil &&
raftCmd.ReplicatedEvalResult.State != nil &&
raftCmd.ReplicatedEvalResult.State.Lease != nil {
op := redact.SafeString("transfer")
if isLeaseRequest {
op = "request"
}
log.Infof(ctx, "rejected lease %s %s; current lease %s; err: %s",
op, raftCmd.ReplicatedEvalResult.State.Lease, replicaState.Lease, res.ForcedError)
}
}()

if raftCmd.ReplicatedEvalResult.IsProbe {
// A Probe is handled by forcing an error during application (which
// avoids a separate "success" code path for this type of request)
Expand All @@ -84,7 +100,6 @@ func CheckForcedErr(
}
}
leaseIndex := replicaState.LeaseAppliedIndex
isLeaseRequest := raftCmd.ReplicatedEvalResult.IsLeaseRequest
var requestedLease roachpb.Lease
if isLeaseRequest {
requestedLease = *raftCmd.ReplicatedEvalResult.State.Lease
Expand Down

0 comments on commit ad45b52

Please sign in to comment.