diff --git a/pkg/kv/kvclient/kvcoord/BUILD.bazel b/pkg/kv/kvclient/kvcoord/BUILD.bazel index ca63215d9630..12ce56996eb5 100644 --- a/pkg/kv/kvclient/kvcoord/BUILD.bazel +++ b/pkg/kv/kvclient/kvcoord/BUILD.bazel @@ -71,6 +71,7 @@ go_library( "//pkg/util/future", "//pkg/util/grpcutil", "//pkg/util/hlc", + "//pkg/util/humanizeutil", "//pkg/util/iterutil", "//pkg/util/limit", "//pkg/util/log", diff --git a/pkg/kv/kvclient/kvcoord/dist_sender.go b/pkg/kv/kvclient/kvcoord/dist_sender.go index 35526165c8a4..59242b1bc12c 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender.go @@ -2571,8 +2571,8 @@ func (ds *DistSender) sendToReplicas( case kvpb.RoutingPolicy_NEAREST: // Order by latency. - log.VEvent(ctx, 2, "routing to nearest replica; leaseholder not required") replicas.OptimizeReplicaOrder(ds.st, ds.nodeIDGetter(), ds.healthFunc, ds.latencyFunc, ds.locality) + log.VEventf(ctx, 2, "routing to nearest replica; leaseholder not required order=%v", replicas) default: log.Fatalf(ctx, "unknown routing policy: %s", ba.RoutingPolicy) diff --git a/pkg/kv/kvclient/kvcoord/replica_slice.go b/pkg/kv/kvclient/kvcoord/replica_slice.go index dcbfda6ec6d1..8fc8445f2a13 100644 --- a/pkg/kv/kvclient/kvcoord/replica_slice.go +++ b/pkg/kv/kvclient/kvcoord/replica_slice.go @@ -19,9 +19,11 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvclient" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/settings/cluster" + "github.com/cockroachdb/cockroach/pkg/util/humanizeutil" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/shuffle" "github.com/cockroachdb/errors" + "github.com/cockroachdb/redact" ) // ReplicaInfo extends the Replica structure with the associated node @@ -41,6 +43,25 @@ type ReplicaInfo struct { // A ReplicaSlice is a slice of ReplicaInfo. type ReplicaSlice []ReplicaInfo +func (rs ReplicaSlice) String() string { + return redact.StringWithoutMarkers(rs) +} + +// SafeFormat implements the redact.SafeFormatter interface. +func (rs ReplicaSlice) SafeFormat(w redact.SafePrinter, _ rune) { + var buf redact.StringBuilder + buf.Print("[") + for i, r := range rs { + if i > 0 { + buf.Print(",") + } + buf.Printf("%v(health=%v match=%d latency=%v)", + r, r.healthy, r.tierMatchLength, humanizeutil.Duration(r.latency)) + } + buf.Print("]") + w.Print(buf) +} + // ReplicaSliceFilter controls which kinds of replicas are to be included in // the slice for routing BatchRequests to. type ReplicaSliceFilter int