Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rac2,kvflowcontrol: fix redaction safety for a few types #137766

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ func (a AdmittedRaftLogEntries) SafeFormat(w redact.SafePrinter, _ rune) {
a.RangeID, a.StoreID, admissionpb.WorkPriority(a.AdmissionPriority), a.UpToRaftLogPosition)
}

func (a AdmittedResponseForRange) String() string {
return redact.StringWithoutMarkers(a)
}

func (a AdmittedResponseForRange) SafeFormat(w redact.SafePrinter, _ rune) {
w.Printf("admitted-response (s%s r%s %s)", a.LeaderStoreID, a.RangeID, a.Msg.String())
}

func (a AdmittedState) String() string {
return redact.StringWithoutMarkers(a)
}
Expand All @@ -71,5 +63,5 @@ func (a PiggybackedAdmittedState) String() string {

func (a PiggybackedAdmittedState) SafeFormat(w redact.SafePrinter, _ rune) {
w.Printf("[r%s,s%s,%d->%d] %s",
a.RangeID, a.ToStoreID, a.FromReplicaID, a.ToReplicaID, a.Admitted.String())
a.RangeID, a.ToStoreID, a.FromReplicaID, a.ToReplicaID, a.Admitted)
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,6 @@ message RaftLogPosition {
uint64 index = 2;
}

// AdmittedResponseForRange is only used in RACv2. It contains a MsgAppResp
// from a follower to a leader, that was generated to advance the admitted
// vector for that follower, maintained by the leader.
//
// TODO(pav-kv): remove this type and use PiggybackedAdmittedState.
message AdmittedResponseForRange {
option (gogoproto.goproto_stringer) = false;

// LeaderStoreID is used to route the request when this message is received
// at the leader node.
uint64 leader_store_id = 1 [(gogoproto.customname) = "LeaderStoreID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID"];

// RangeID of the raft group to which the MsgAppResp is directed. Used for
// routing at the leader node.
int64 range_id = 2 [(gogoproto.customname) = "RangeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.RangeID"];

// Msg is the MsgAppResp containing the admitted vector.
raftpb.Message msg = 3 [(gogoproto.nullable) = false];
}

// AdmittedState communicates a replica's vector of admitted log indices at
// different priorities to the leader of a range.
//
Expand Down
6 changes: 3 additions & 3 deletions pkg/kv/kvserver/kvflowcontrol/rac2/log_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func (av AdmittedVector) SafeFormat(w redact.SafePrinter, _ rune) {
buf.Printf("term:%d, admitted:[", av.Term)
for pri, index := range av.Admitted {
if pri > 0 {
buf.Printf(",")
buf.SafeRune(',')
}
buf.Printf("%s:%d", raftpb.Priority(pri), index)
}
buf.Printf("]")
w.Printf("%v", buf)
buf.SafeRune(']')
w.SafeString(redact.SafeString(buf.String()))
}

// LogTracker tracks the durable and logically admitted state of a raft log.
Expand Down
8 changes: 4 additions & 4 deletions pkg/raft/raftpb/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ func (p Priority) String() string {
func (p Priority) SafeFormat(w redact.SafePrinter, _ rune) {
switch p {
case LowPri:
w.Printf("LowPri")
w.SafeString("LowPri")
case NormalPri:
w.Printf("NormalPri")
w.SafeString("NormalPri")
case AboveNormalPri:
w.Printf("AboveNormalPri")
w.SafeString("AboveNormalPri")
case HighPri:
w.Printf("HighPri")
w.SafeString("HighPri")
default:
panic("invalid raft priority")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/util/admission/admissionpb/admissionpb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (w WorkPriority) String() string {
// SafeFormat implements the redact.SafeFormatter interface.
func (w WorkPriority) SafeFormat(p redact.SafePrinter, verb rune) {
if s, ok := WorkPriorityDict[w]; ok {
p.Print(s)
p.SafeString(redact.SafeString(s))
return
}
p.Printf("custom-pri=%d", int8(w))
Expand Down Expand Up @@ -232,11 +232,11 @@ func (w WorkClass) String() string {
func (w WorkClass) SafeFormat(p redact.SafePrinter, verb rune) {
switch w {
case RegularWorkClass:
p.Printf("regular")
p.SafeString("regular")
case ElasticWorkClass:
p.Printf("elastic")
p.SafeString("elastic")
default:
p.Printf("<unknown-class>")
p.SafeString("<unknown-class>")
}
}

Expand Down
Loading