Skip to content

Commit

Permalink
Merge #53764
Browse files Browse the repository at this point in the history
53764: deps: bump cockroachdb/errors and cockroachdb/redact r=irfansharif a=knz

Fixes #53207
Needed for #53312 

This picks up improved support for `%T` in format strings,
as well as better support for `%w`.

Release justification: low risk, high benefit changes to existing functionality

Release note: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Sep 2, 2020
2 parents 0591183 + fea562b commit e04bc9a
Show file tree
Hide file tree
Showing 113 changed files with 1,548 additions and 1,540 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ require (
github.com/cockroachdb/cockroach-go v0.0.0-20200504194139-73ffeee90b62
github.com/cockroachdb/crlfmt v0.0.0-20200116191136-a78e1c207bc0
github.com/cockroachdb/datadriven v1.0.1-0.20200826112548-92602d883b11
github.com/cockroachdb/errors v1.7.3
github.com/cockroachdb/errors v1.7.4
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55
github.com/cockroachdb/gostdlib v1.13.0
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f
github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936
github.com/cockroachdb/redact v1.0.2
github.com/cockroachdb/redact v1.0.5
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2
github.com/cockroachdb/stress v0.0.0-20170808184505-29b5d31b4c3a
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ github.com/cockroachdb/datadriven v1.0.1-0.20200826112548-92602d883b11/go.mod h1
github.com/cockroachdb/errors v1.2.4 h1:Lap807SXTH5tri2TivECb/4abUkMZC9zRoLarvcKDqs=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
github.com/cockroachdb/errors v1.7.3 h1:3Vx4uIENFw44XbZe4Gnp/Soh4PlSowP7DaDu7INSKzE=
github.com/cockroachdb/errors v1.7.3/go.mod h1:pKPbzdh8tCRjLCJUFHEoRjfhT8HvwyW2cxImC+zVlMM=
github.com/cockroachdb/errors v1.7.4 h1:ZlMG24ZIxz6Yp00gR3KkJKsMEWWNyeOWiGyaUav5y8o=
github.com/cockroachdb/errors v1.7.4/go.mod h1:ngNOpuFdFU8EOjSsuVmCU9AODd7yp3XXEr0JUjbCN5U=
github.com/cockroachdb/etcd v0.4.7-0.20200615211340-a17df30d5955 h1:1ELogBFqZl2Cj/Rn0wWAU4z2/ghBlHzhXDlbT8RlrKU=
github.com/cockroachdb/etcd v0.4.7-0.20200615211340-a17df30d5955/go.mod h1:Vshs83p1UXI6fjU8eWVgqXeewFxRDP1fNVF5PHiSBm0=
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55 h1:YqzBA7tf8Gv8Oz0BbBsPenqkyjiohS7EUIwi7p1QJCU=
Expand All @@ -166,8 +166,8 @@ github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936 h1:MaPvrDBbbWMz
github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936/go.mod h1:hU7vhtrqonEphNF+xt8/lHdaBprxmV1h8BOGrd9XwmQ=
github.com/cockroachdb/redact v0.0.0-20200622112456-cd282804bbd3 h1:2+dpIJzYMSbLi0587YXpi8tOJT52qCOI/1I0UNThc/I=
github.com/cockroachdb/redact v0.0.0-20200622112456-cd282804bbd3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/redact v1.0.2 h1:bRktqHBXPqI+9bkOx0ikn9RS09G9k83oAdLx6rXRVTQ=
github.com/cockroachdb/redact v1.0.2/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/redact v1.0.5 h1:yxqIMS6G2Bvi6GiSHFmsrFGO3aP1rwt8cOm4pixw9eY=
github.com/cockroachdb/redact v1.0.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd h1:KFOt5I9nEKZgCnOSmy8r4Oykh8BYQO8bFOTgHDS8YZA=
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd/go.mod h1:AN708GD2FFeLgUHMbD58YPe4Nw8GG//3rwgyG4L9gR0=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
Expand Down
3 changes: 1 addition & 2 deletions pkg/ccl/changefeedccl/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package changefeedccl

import (
"encoding/json"
"fmt"
"math/big"
"time"

Expand Down Expand Up @@ -86,7 +85,7 @@ func avroUnionKey(t avroSchemaType) string {
case *avroRecord:
return s.Name
default:
panic(fmt.Sprintf(`unsupported type %T %v`, t, t))
panic(errors.AssertionFailedf(`unsupported type %T %v`, t, t))
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/col/coldataext/datum_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
package coldataext

import (
"fmt"

"github.com/cockroachdb/cockroach/pkg/col/coldata"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/colexecbase/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/util/encoding"
"github.com/cockroachdb/errors"
)

// Datum wraps a tree.Datum. This is the struct that datumVec.Get() returns.
Expand Down Expand Up @@ -175,7 +174,7 @@ func (dv *datumVec) assertValidDatum(datum tree.Datum) {
func (dv *datumVec) assertSameTypeFamily(t *types.T) {
if dv.t.Family() != t.Family() {
colexecerror.InternalError(
fmt.Sprintf("cannot use value of type %+v on a datumVec of type %+v", t, dv.t),
errors.AssertionFailedf("cannot use value of type %+v on a datumVec of type %+v", t, dv.t),
)
}
}
Expand All @@ -201,7 +200,7 @@ func maybeUnwrapDatum(v coldata.Datum) tree.Datum {
} else if datum, ok := v.(tree.Datum); ok {
return datum
}
colexecerror.InternalError(fmt.Sprintf("unexpected value: %v", v))
colexecerror.InternalError(errors.AssertionFailedf("unexpected value: %v", v))
// This code is unreachable, but the compiler cannot infer that.
return nil
}
6 changes: 3 additions & 3 deletions pkg/col/coldatatestutils/random_testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package coldatatestutils

import (
"context"
"fmt"
"math/rand"
"time"

Expand All @@ -25,6 +24,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/util/duration"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/errors"
)

// maxVarLen specifies a length limit for variable length types (e.g. byte slices).
Expand Down Expand Up @@ -228,7 +228,7 @@ func RandomBatch(
// less than batchSize.
func RandomSel(rng *rand.Rand, batchSize int, probOfOmitting float64) []int {
if probOfOmitting < 0 || probOfOmitting > 1 {
colexecerror.InternalError(fmt.Sprintf("probability of omitting a row is %f - outside of [0, 1] range", probOfOmitting))
colexecerror.InternalError(errors.AssertionFailedf("probability of omitting a row is %f - outside of [0, 1] range", probOfOmitting))
}
sel := make([]int, 0, batchSize)
for i := 0; i < batchSize; i++ {
Expand Down Expand Up @@ -396,7 +396,7 @@ func (o *RandomDataOp) ChildCount(verbose bool) int {

// Child implements the execinfra.OpNode interface.
func (o *RandomDataOp) Child(nth int, verbose bool) execinfra.OpNode {
colexecerror.InternalError(fmt.Sprintf("invalid index %d", nth))
colexecerror.InternalError(errors.AssertionFailedf("invalid index %d", nth))
// This code is unreachable, but the compiler cannot infer that.
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/jobs/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ func TestJobLifecycle(t *testing.T) {

t.Run("bad job details fail", func(t *testing.T) {
defer func() {
if r, ok := recover().(string); !ok || !strings.Contains(r, "unknown details type int") {
if r, ok := recover().(error); !ok || !strings.Contains(r.Error(), "unknown details type int") {
t.Fatalf("expected 'unknown details type int', but got: %v", r)
}
}()
Expand Down
8 changes: 4 additions & 4 deletions pkg/jobs/jobspb/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
package jobspb

import (
"fmt"
"strings"

"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
"github.com/cockroachdb/cockroach/pkg/sql/stats"
"github.com/cockroachdb/errors"
)

// Details is a marker interface for job details proto structs.
Expand Down Expand Up @@ -67,7 +67,7 @@ func DetailsType(d isPayload_Details) Type {
case *Payload_TypeSchemaChange:
return TypeTypeSchemaChange
default:
panic(fmt.Sprintf("Payload.Type called on a payload with an unknown details type: %T", d))
panic(errors.AssertionFailedf("Payload.Type called on a payload with an unknown details type: %T", d))
}
}

Expand Down Expand Up @@ -97,7 +97,7 @@ func WrapProgressDetails(details ProgressDetails) interface {
case TypeSchemaChangeProgress:
return &Progress_TypeSchemaChange{TypeSchemaChange: &d}
default:
panic(fmt.Sprintf("WrapProgressDetails: unknown details type %T", d))
panic(errors.AssertionFailedf("WrapProgressDetails: unknown details type %T", d))
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ func WrapPayloadDetails(details Details) interface {
case TypeSchemaChangeDetails:
return &Payload_TypeSchemaChange{TypeSchemaChange: &d}
default:
panic(fmt.Sprintf("jobs.WrapPayloadDetails: unknown details type %T", d))
panic(errors.AssertionFailedf("jobs.WrapPayloadDetails: unknown details type %T", d))
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (ds *DistSender) partialRangeFeed(
case errors.HasType(err, (*roachpb.RangeFeedRetryError)(nil)):
var t *roachpb.RangeFeedRetryError
if ok := errors.As(err, &t); !ok {
panic(fmt.Sprintf("wrong error type: %T", err))
panic(errors.AssertionFailedf("wrong error type: %T", err))
}
switch t.Reason {
case roachpb.RangeFeedRetryError_REASON_REPLICA_REMOVED,
Expand Down
3 changes: 2 additions & 1 deletion pkg/kv/kvserver/rangefeed/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/errors"
)

const (
Expand Down Expand Up @@ -561,7 +562,7 @@ func (p *Processor) consumeLogicalOps(ctx context.Context, ops []enginepb.MVCCLo
// No updates to publish.

default:
panic(fmt.Sprintf("unknown logical op %T", t))
panic(errors.AssertionFailedf("unknown logical op %T", t))
}

// Determine whether the operation caused the resolved timestamp to
Expand Down
3 changes: 2 additions & 1 deletion pkg/kv/kvserver/rangefeed/resolved_timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/errors"
)

// A rangefeed's "resolved timestamp" is defined as the timestamp at which no
Expand Down Expand Up @@ -205,7 +206,7 @@ func (rts *resolvedTimestamp) consumeLogicalOp(op enginepb.MVCCLogicalOp) bool {
return rts.intentQ.Del(t.TxnID)

default:
panic(fmt.Sprintf("unknown logical op %T", t))
panic(errors.AssertionFailedf("unknown logical op %T", t))
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/replica_rangefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (r *Replica) populatePrevValsInLogicalOpLogRaftMuLocked(
// Nothing to do.
continue
default:
panic(fmt.Sprintf("unknown logical op %T", t))
panic(errors.AssertionFailedf("unknown logical op %T", t))
}

// Don't read previous values from the reader for operations that are
Expand Down Expand Up @@ -538,7 +538,7 @@ func (r *Replica) handleLogicalOpLogRaftMuLocked(
// Nothing to do.
continue
default:
panic(fmt.Sprintf("unknown logical op %T", t))
panic(errors.AssertionFailedf("unknown logical op %T", t))
}

// Don't read values from the reader for operations that are not needed
Expand Down
12 changes: 4 additions & 8 deletions pkg/roachpb/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,7 @@ func CombineResponses(left, right Response) error {
if lOK && rOK {
return cLeft.combine(cRight)
} else if lOK != rOK {
// TODO(knz): Simplify to %T when
// https://github.com/cockroachdb/cockroach/issues/53207 is
// addressed.
return errors.Errorf("can not combine %s and %s",
errors.Safe(fmt.Sprintf("%T", left)), errors.Safe(fmt.Sprintf("%T", right)))
return errors.Errorf("can not combine %T and %T", left, right)
}
return nil
}
Expand Down Expand Up @@ -606,7 +602,7 @@ func (sr *ReverseScanResponse) Verify(req Request) error {
func (ru *RequestUnion) MustSetInner(args Request) {
ru.Reset()
if !ru.SetInner(args) {
panic(fmt.Sprintf("%T excludes %T", ru, args))
panic(errors.AssertionFailedf("%T excludes %T", ru, args))
}
}

Expand All @@ -616,7 +612,7 @@ func (ru *RequestUnion) MustSetInner(args Request) {
func (ru *ResponseUnion) MustSetInner(reply Response) {
ru.Reset()
if !ru.SetInner(reply) {
panic(fmt.Sprintf("%T excludes %T", ru, reply))
panic(errors.AssertionFailedf("%T excludes %T", ru, reply))
}
}

Expand Down Expand Up @@ -1360,7 +1356,7 @@ func (b *BulkOpSummary) Add(other BulkOpSummary) {
func (e *RangeFeedEvent) MustSetValue(value interface{}) {
e.Reset()
if !e.SetValue(value) {
panic(fmt.Sprintf("%T excludes %T", e, value))
panic(errors.AssertionFailedf("%T excludes %T", e, value))
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ func (l *Lease) Equal(that interface{}) bool {
if ok {
that1 = &that2
} else {
panic(fmt.Sprintf("attempting to compare lease to %T", that))
panic(errors.AssertionFailedf("attempting to compare lease to %T", that))
}
}
if that1 == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/roachpb/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type transactionRestartError interface {

// ErrorUnexpectedlySet creates a string to panic with when a response (typically
// a roachpb.BatchResponse) unexpectedly has Error set in its response header.
func ErrorUnexpectedlySet(culprit, response interface{}) string {
return fmt.Sprintf("error is unexpectedly set, culprit is %T:\n%+v", culprit, response)
func ErrorUnexpectedlySet(culprit, response interface{}) error {
return errors.AssertionFailedf("error is unexpectedly set, culprit is %T:\n%+v", culprit, response)
}

// ErrorPriority is used to rank errors such that the "best" one is chosen to be
Expand Down Expand Up @@ -271,7 +271,7 @@ func (e *Error) SetDetail(err error) {
if !e.Detail.SetInner(err) {
_, isInternalError := err.(*internalError)
if !isInternalError && e.TransactionRestart != TransactionRestart_NONE {
panic(fmt.Sprintf("transactionRestartError %T must be an ErrorDetail", err))
panic(errors.AssertionFailedf("transactionRestartError %T must be an ErrorDetail", err))
}
}
e.checkTxnStatusValid()
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/colcontainer/partitionedqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package colcontainer

import (
"context"
"fmt"

"github.com/cockroachdb/cockroach/pkg/col/coldata"
"github.com/cockroachdb/cockroach/pkg/sql/colexecbase/colexecerror"
Expand Down Expand Up @@ -144,7 +143,7 @@ func NewPartitionedDiskQueue(
// DiskQueues cannot serialize zero length schemas, so catch this error
// early.
// TODO(asubiotto): We could support this, but not sure we need to.
colexecerror.InternalError("zero length schema unsupported")
colexecerror.InternalError(errors.AssertionFailedf("zero length schema unsupported"))
}
return &PartitionedDiskQueue{
typs: typs,
Expand Down Expand Up @@ -175,7 +174,7 @@ func (p *PartitionedDiskQueue) closeWritePartition(
ctx context.Context, idx int, releaseFDOption closeWritePartitionArgument,
) error {
if p.partitions[idx].state != partitionStateWriting {
colexecerror.InternalError(fmt.Sprintf("illegal state change from %d to partitionStateClosedForWriting, only partitionStateWriting allowed", p.partitions[idx].state))
colexecerror.InternalError(errors.AssertionFailedf("illegal state change from %d to partitionStateClosedForWriting, only partitionStateWriting allowed", p.partitions[idx].state))
}
if err := p.partitions[idx].Enqueue(ctx, coldata.ZeroBatch); err != nil {
return err
Expand All @@ -190,7 +189,7 @@ func (p *PartitionedDiskQueue) closeWritePartition(

func (p *PartitionedDiskQueue) closeReadPartition(idx int) error {
if p.partitions[idx].state != partitionStateReading {
colexecerror.InternalError(fmt.Sprintf("illegal state change from %d to partitionStateClosedForReading, only partitionStateReading allowed", p.partitions[idx].state))
colexecerror.InternalError(errors.AssertionFailedf("illegal state change from %d to partitionStateClosedForReading, only partitionStateReading allowed", p.partitions[idx].state))
}
if err := p.partitions[idx].CloseRead(); err != nil {
return err
Expand Down Expand Up @@ -300,7 +299,7 @@ func (p *PartitionedDiskQueue) Dequeue(
case partitionStatePermanentlyClosed:
return errors.Errorf("partition at index %d permanently closed, cannot Dequeue", partitionIdx)
default:
colexecerror.InternalError(fmt.Sprintf("unhandled state %d", state))
colexecerror.InternalError(errors.AssertionFailedf("unhandled state %d", state))
}
notEmpty, err := p.partitions[idx].Dequeue(ctx, batch)
if err != nil {
Expand All @@ -317,7 +316,8 @@ func (p *PartitionedDiskQueue) Dequeue(
// Dequeue but more batches will be added in the future (i.e. a zero batch
// was never enqueued). Since we require partitions to be closed for writing
// before reading, this state is unexpected.
colexecerror.InternalError("DiskQueue unexpectedly returned that more data will be added")
colexecerror.InternalError(
errors.AssertionFailedf("DiskQueue unexpectedly returned that more data will be added"))
}
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/sql/colexec/aggregate_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/errors"
)

// isAggOptimized returns whether aggFn has an optimized implementation.
Expand Down Expand Up @@ -138,17 +139,17 @@ func (h *hashAggregateFuncBase) Reset() {
}

func (h *hashAggregateFuncBase) CurrentOutputIndex() int {
colexecerror.InternalError("CurrentOutputIndex called with hash aggregation")
colexecerror.InternalError(errors.AssertionFailedf("CurrentOutputIndex called with hash aggregation"))
// This code is unreachable, but the compiler cannot infer that.
return 0
}

func (h *hashAggregateFuncBase) SetOutputIndex(int) {
colexecerror.InternalError("SetOutputIndex called with hash aggregation")
colexecerror.InternalError(errors.AssertionFailedf("SetOutputIndex called with hash aggregation"))
}

func (h *hashAggregateFuncBase) HandleEmptyInputScalar() {
colexecerror.InternalError("HandleEmptyInputScalar called with hash aggregation")
colexecerror.InternalError(errors.AssertionFailedf("HandleEmptyInputScalar called with hash aggregation"))
}

// aggregateFuncAlloc is an aggregate function allocator that pools allocations
Expand Down
Loading

0 comments on commit e04bc9a

Please sign in to comment.