Skip to content

Commit b592edd

Browse files
committed
kvclient: update error formatting in BatchResponse and improve test expectations in dist_sender_test
This commit modifies the error formatting in the BatchResponse's SafeFormat method to use a more concise representation. Additionally, it updates the expected output in the dist_sender_test to reflect changes in the string formatting, ensuring that the tests accurately validate the slow log messages. No functional changes were made to the logic. Epic: CRDB-37533 Part of: CRDB-44885 Release note: None
1 parent 5aac329 commit b592edd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/kv/kvclient/kvcoord/dist_sender_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,26 +4770,26 @@ func TestDistSenderSlowLogMessage(t *testing.T) {
47704770
br.Error = kvpb.NewError(errors.New("boom"))
47714771
desc := &roachpb.RangeDescriptor{RangeID: 9, StartKey: roachpb.RKey("x"), EndKey: roachpb.RKey("z")}
47724772
{
4773-
exp := `have been waiting 8.16s (120 attempts) for RPC Get(Shared,Unreplicated) ["a"] to` +
4774-
` r9:{x-z} [<no replicas>, next=0, gen=0]; resp: (err: boom)`
4773+
exp := `have been waiting 8.16s (120 attempts) for RPC Get(Shared,Unreplicated) ["a"] to` +
4774+
` r9:{‹x›-‹z›} [<no replicas>, next=0, gen=0]; resp: (err: boom)`
47754775
var s redact.StringBuilder
47764776
slowRangeRPCWarningStr(&s, ba, dur, attempts, desc, nil /* err */, br)
4777-
act := s.RedactableString().StripMarkers()
4777+
act := s.RedactableString()
47784778
require.EqualValues(t, exp, act)
47794779
}
47804780
{
47814781
exp := `slow RPC finished after 8.16s (120 attempts)`
47824782
var s redact.StringBuilder
47834783
slowRangeRPCReturnWarningStr(&s, dur, attempts)
4784-
act := s.RedactableString().StripMarkers()
4784+
act := s.RedactableString()
47854785
require.EqualValues(t, exp, act)
47864786
}
47874787
{
4788-
exp := `have been waiting 8.16s (120 attempts) for RPC Get(Shared,Unreplicated) ["a"] to` +
4788+
exp := `have been waiting 8.16s (120 attempts) for RPC Get(Shared,Unreplicated) ["a"] to` +
47894789
` replica (n2,s3):1; resp: (err: boom)`
47904790
var s redact.StringBuilder
47914791
slowReplicaRPCWarningStr(&s, ba, dur, attempts, nil /* err */, br)
4792-
act := s.RedactableString().StripMarkers()
4792+
act := s.RedactableString()
47934793
require.EqualValues(t, exp, act)
47944794
}
47954795
}

pkg/kv/kvpb/batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func (br *BatchResponse) String() string {
478478
func (br *BatchResponse) SafeFormat(s redact.SafePrinter, verb rune) {
479479
// Marking Error of BatchResponse as safe as Outside of the RPC boundaries,
480480
// this field is nil and must neither be checked nor populated
481-
s.Printf("(err: %s)", redact.Safe(br.Error.String()))
481+
s.Printf("(err: %v)", br.Error)
482482

483483
for count, union := range br.Responses {
484484
// Limit the strings to provide just a summary. Without this limit a log

0 commit comments

Comments
 (0)