Skip to content

Commit

Permalink
raft: avoid log redaction on vote leasing decisions
Browse files Browse the repository at this point in the history
Improves debugging.

Epic: None
Release note: None
  • Loading branch information
nvanbenschoten committed Oct 22, 2024
1 parent 17abdb7 commit 7df2c5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/raft/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ go_library(
"//pkg/raft/tracker",
"//pkg/util/hlc",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_redact//:redact",
"@org_golang_x_exp//maps",
],
)
Expand Down
11 changes: 6 additions & 5 deletions pkg/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/raft/raftstoreliveness"
"github.com/cockroachdb/cockroach/pkg/raft/tracker"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/redact"
"golang.org/x/exp/maps"
)

Expand Down Expand Up @@ -1440,14 +1441,14 @@ func (r *raft) Step(m pb.Message) error {
// leader it does not update its term or grant its vote.
{
// Log why we're ignoring the Request{,Pre}Vote.
var inHeartbeatLeaseMsg string
var inFortifyLeaseMsg string
var sep string
var inHeartbeatLeaseMsg redact.RedactableString
var inFortifyLeaseMsg redact.RedactableString
var sep redact.SafeString
if inHeartbeatLease {
inHeartbeatLeaseMsg = fmt.Sprintf("recently received communication from leader (remaining ticks: %d)", r.electionTimeout-r.electionElapsed)
inHeartbeatLeaseMsg = redact.Sprintf("recently received communication from leader (remaining ticks: %d)", r.electionTimeout-r.electionElapsed)
}
if inFortifyLease {
inFortifyLeaseMsg = fmt.Sprintf("supporting fortified leader %d at epoch %d", r.lead, r.leadEpoch)
inFortifyLeaseMsg = redact.Sprintf("supporting fortified leader %d at epoch %d", r.lead, r.leadEpoch)
}
if inFortifyLease && inHeartbeatLease {
sep = " and "
Expand Down

0 comments on commit 7df2c5a

Please sign in to comment.