Skip to content

Commit

Permalink
Merge pull request #135262 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.3.0-rc-135129

release-24.3.0-rc: kvserver: add logging if a lease {request, transfer} is not applied
  • Loading branch information
arulajmani authored Nov 15, 2024
2 parents c22e145 + 0385848 commit e77da9e
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 e77da9e

Please sign in to comment.