Skip to content

Commit

Permalink
kv: implement redact.SafeValue for PushTxnType
Browse files Browse the repository at this point in the history
This commit implements redact.SafeValue for PushTxnType with the goal of
displaying the PushTxnType on PushTxnRequest with the redacted format.

Fixes: #114475
Release note: None.
  • Loading branch information
lyang24 committed Dec 5, 2023
1 parent 07857a3 commit aa1af2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pkg/kv/kvpb/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2152,3 +2152,6 @@ type RangeFeedEventProducer interface {
// range needs to be restarted.
Recv() (*RangeFeedEvent, error)
}

// SafeValue implements the redact.SafeValue interface.
func (PushTxnType) SafeValue() {}
10 changes: 5 additions & 5 deletions pkg/kv/kvpb/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func TestAmbiguousResultError(t *testing.T) {

// Unit test the requests that implemented SafeFormatterRequest interface.
func TestRequestSafeFormat(t *testing.T) {
txn := roachpb.MakeTransaction("txn1", []byte("abc"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 6, 0)
txn := roachpb.MakeTransaction("txn1", []byte("abc"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 6, 0, false)
fixedUuid, _ := uuid.FromString("00fbff57-c1ee-48ce-966c-da568d50e425")
txn.ID = fixedUuid
pusherTxn := roachpb.MakeTransaction("txn2", []byte("123"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 1, 0)
pusheeTxn := roachpb.MakeTransaction("txn3", []byte("1234"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 1, 0)
pusherTxn := roachpb.MakeTransaction("txn2", []byte("123"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 1, 0, false)
pusheeTxn := roachpb.MakeTransaction("txn3", []byte("1234"), 0, 0, hlc.Timestamp{WallTime: 10}, 0, 1, 0, false)
fixedUuid2, _ := uuid.FromString("00fbff58-c1ee-48ce-966c-da568d50e425")
fixedUuid3, _ := uuid.FromString("00fbff59-c1ee-48ce-966c-da568d50e425")
pusherTxn.ID = fixedUuid2
Expand Down Expand Up @@ -180,8 +180,8 @@ func TestRequestSafeFormat(t *testing.T) {
PusherTxn: pusherTxn,
PusheeTxn: pusheeTxn.TxnMeta,
},
redactable: "PushTxn(PUSH_TIMESTAMP,00fbff58->00fbff59)",
redacted: "PushTxn(‹×›,00fbff58->00fbff59)",
redactable: "PushTxn(PUSH_TIMESTAMP,00fbff58->00fbff59)",
redacted: "PushTxn(PUSH_TIMESTAMP,00fbff58->00fbff59)",
},
}
for _, c := range testCases {
Expand Down
1 change: 1 addition & 0 deletions pkg/testutils/lint/passes/redactcheck/redactcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func runAnalyzer(pass *analysis.Pass) (interface{}, error) {
"LeaseAppliedIndex": {},
"RaftIndex": {},
"RaftTerm": {},
"PushTxnType": {},
},
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts/ctpb": {
"SeqNum": {},
Expand Down

0 comments on commit aa1af2f

Please sign in to comment.