Skip to content

Commit

Permalink
deps: update cockroachdb/errors
Browse files Browse the repository at this point in the history
This upgrades to v1.9.0 and enhances Sentry reports as requested by
the SQL queries team.

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

Release note: None
  • Loading branch information
knz committed Mar 11, 2022
1 parent 0069e98 commit a3934f8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 62 deletions.
6 changes: 3 additions & 3 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1252,10 +1252,10 @@ def go_deps():
patches = [
"@cockroach//build/patches:com_github_cockroachdb_errors.patch",
],
sha256 = "65cad26bfd3df564cfcbdc99f14b72b1a62d53d71956f60499a51801518e1fc3",
strip_prefix = "github.com/cockroachdb/errors@v1.8.9",
sha256 = "ff3814544271799c80da14dadfe408efc4f66e02cbdf17b73e81614ed9f7ae43",
strip_prefix = "github.com/cockroachdb/errors@v1.9.0",
urls = [
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/errors/com_github_cockroachdb_errors-v1.8.9.zip",
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/errors/com_github_cockroachdb_errors-v1.9.0.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/cockroachdb/cockroach-go/v2 v2.2.6
github.com/cockroachdb/crlfmt v0.0.0-20210128092314-b3eff0b87c79
github.com/cockroachdb/datadriven v1.0.1
github.com/cockroachdb/errors v1.8.9
github.com/cockroachdb/errors v1.9.0
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-20211118104740-dabe8e521a4f
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac=
github.com/cockroachdb/errors v1.8.8/go.mod h1:z6VnEL3hZ/2ONZEvG7S5Ym0bU2AqPcEKnIiA1wbsSu0=
github.com/cockroachdb/errors v1.8.9 h1:eqUxTOUOduHP4D3f3wJ0kiyoNjDf6wLCso/4n7rBA4U=
github.com/cockroachdb/errors v1.8.9/go.mod h1:vaNcEYYqbIqB5JhKBhFV9CneUqeuEbB2OYJBK4GBNYQ=
github.com/cockroachdb/errors v1.9.0 h1:B48dYem5SlAY7iU8AKsgedb4gH6mo+bDkbtLIvM/a88=
github.com/cockroachdb/errors v1.9.0/go.mod h1:vaNcEYYqbIqB5JhKBhFV9CneUqeuEbB2OYJBK4GBNYQ=
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55 h1:YqzBA7tf8Gv8Oz0BbBsPenqkyjiohS7EUIwi7p1QJCU=
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55/go.mod h1:QqVqNIiRhLqJXif5C9wbM4JydBhrAF2WDMxkv5xkyxQ=
github.com/cockroachdb/gostdlib v1.13.0 h1:TzSEPYgkKDNei3gbLc0rrHu4iHyBp7/+NxPOFmcXGaw=
Expand Down
98 changes: 42 additions & 56 deletions pkg/util/log/logcrash/crash_reporting_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ func TestCrashReportingPacket(t *testing.T) {
expectations := []struct {
serverID *regexp.Regexp
tagCount int
message string
extra []extraPair
title string
message *regexp.Regexp
}{
{regexp.MustCompile(`^$`), 7, func() string {
message := prefix
Expand All @@ -125,9 +125,9 @@ func TestCrashReportingPacket(t *testing.T) {
}
message += " (TestCrashReportingPacket)"
return message
}(), []extraPair{
{"1: details", "panic: " + panicPre},
}},
}(),
regexp.MustCompile(`crash_reporting_packet_test.go:\d+: panic: boom`),
},
{regexp.MustCompile(`^[a-z0-9]{8}-1$`), 12, func() string {
message := prefix
// gccgo stack traces are different in the presence of function literals.
Expand All @@ -138,9 +138,9 @@ func TestCrashReportingPacket(t *testing.T) {
}
message += " (TestCrashReportingPacket)"
return message
}(), []extraPair{
{"1: details", "panic: " + panicPost},
}},
}(),
regexp.MustCompile(`crash_reporting_packet_test.go:\d+: panic: baam`),
},
}

if e, a := len(expectations), len(packets); e != a {
Expand All @@ -151,6 +151,8 @@ func TestCrashReportingPacket(t *testing.T) {
p := packets[0]
packets = packets[1:]
t.Run("", func(t *testing.T) {
t.Logf("message: %q", p.Message)

if !logcrash.ReportSensitiveDetails {
e, a := "<redacted>", p.ServerName
if e != a {
Expand All @@ -167,12 +169,14 @@ func TestCrashReportingPacket(t *testing.T) {
t.Errorf("expected server_id '%s' to match %s", serverID, exp.serverID)
}

assert.Regexp(t, exp.message, p.Message)

if len(p.Exception) < 1 {
t.Error("expected some exception in packet, got none")
} else {
if p.Exception[0].Type != exp.message {
if p.Exception[0].Type != exp.title {
t.Errorf("expected %q in exception type, got %q",
exp.message, p.Exception[0].Type)
exp.title, p.Exception[0].Type)
}

lastFrame := p.Exception[0].Stacktrace.Frames[len(p.Exception[0].Stacktrace.Frames)-1]
Expand All @@ -183,20 +187,6 @@ func TestCrashReportingPacket(t *testing.T) {
t.Errorf("last frame filename: expected crash_reporting_packet_test.go, got %q", lastFrame.Filename)
}
}

for _, ex := range exp.extra {
data, ok := p.Extra[ex.key]
if !ok {
t.Errorf("expected detail %q in extras, was not found", ex.key)
continue
}
sdata, ok := data.(string)
if !ok {
t.Errorf("expected detail %q of type string, found %T (%q)", ex.key, data, data)
continue
}
assert.Regexp(t, ex.reVal, sdata)
}
})
}
}
Expand Down Expand Up @@ -248,43 +238,39 @@ func TestInternalErrorReporting(t *testing.T) {
// the redaction markers are removed.
rm := string(redact.RedactableBytes(redact.RedactedMarker()).StripMarkers())

assert.Regexp(t, `builtins\.go:\d+: crdb_internal.force_assertion_error\(\): `+rm+`\n`+
`--\n`+
`\*errutil.leafError: `+rm+` \(1\)\n`+
`builtins.go:\d+: \*withstack.withStack \(top exception\)\n`+
`\*assert.withAssertionFailure\n`+
`\*errutil.withPrefix: crdb_internal.force_assertion_error\(\) \(2\)\n`+
`eval.go:\d+: \*withstack.withStack \(3\)\n`+
`\*telemetrykeys.withTelemetry: crdb_internal.force_assertion_error\(\) \(4\)\n`+
`\*colexecerror.notInternalError\n`+
`\(check the extra data payloads\)`, p.Message)

expectedExtra := []struct {
key string
reVal string
}{
{"1: details", rm},
{"2: details", `crdb_internal\.force_assertion_error\(\)`},
{"4: details", `crdb_internal\.force_assertion_error\(\)`},
}
for _, ex := range expectedExtra {
data, ok := p.Extra[ex.key]
if !ok {
t.Errorf("expected detail %q in extras, was not found", ex.key)
continue
}
sdata, ok := data.(string)
if !ok {
t.Errorf("expected detail %q of type string, found %T (%q)", ex.key, data, data)
continue
}
assert.Regexp(t, ex.reVal, sdata)
assert.Regexp(t, `builtins\.go:\d+: crdb_internal.force_assertion_error\(\): `+rm+`\n`, p.Message)
idx := strings.Index(p.Message, "-- report composition:\n")
assert.GreaterOrEqual(t, idx, 1)
if idx > 0 {
assert.Regexp(t,
`-- report composition:\n`+
`\*errutil.leafError: `+rm+`\n`+
`builtins.go:\d+: \*withstack.withStack \(top exception\)\n`+
`\*assert.withAssertionFailure\n`+
`\*errutil.withPrefix: crdb_internal.force_assertion_error\(\)\n`+
`eval.go:\d+: \*withstack.withStack \(1\)\n`+
`\*telemetrykeys.withTelemetry: crdb_internal.force_assertion_error\(\)\n`+
`\*colexecerror.notInternalError\n`+
`\(check the extra data payloads\)`, p.Message[idx:])
}

if len(p.Exception) < 2 {
t.Fatalf("expected 2 stacktraces, got %d", len(p.Exception))
}

extra, ok := p.Extra["error types"]
assert.True(t, ok)
if ok {
assert.Equal(t, "github.com/cockroachdb/errors/errutil/*errutil.leafError (*::)\n"+
"github.com/cockroachdb/errors/withstack/*withstack.withStack (*::)\n"+
"github.com/cockroachdb/errors/assert/*assert.withAssertionFailure (*::)\n"+
"github.com/cockroachdb/errors/errutil/*errutil.withPrefix (*::)\n"+
"github.com/cockroachdb/errors/withstack/*withstack.withStack (*::)\n"+
"github.com/cockroachdb/errors/telemetrykeys/*telemetrykeys.withTelemetry (*::)\n"+
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror/*colexecerror.notInternalError (*::)\n",
extra)
}

// The innermost stack trace (and main exception object) is the last
// one in the Sentry event.
assert.Regexp(t, `^builtins.go:\d+ \(.*\)$`, p.Exception[1].Type)
Expand All @@ -293,7 +279,7 @@ func TestInternalErrorReporting(t *testing.T) {
assert.Regexp(t, `.*/builtins.go`, fr[len(fr)-1].Filename)
assert.Regexp(t, `.*/eval.go`, fr[len(fr)-2].Filename)

assert.Regexp(t, `^\(3\) eval.go:\d+ \(MaybeWrapError\)$`, p.Exception[0].Type)
assert.Regexp(t, `^\(1\) eval.go:\d+ \(MaybeWrapError\)$`, p.Exception[0].Type)
assert.Regexp(t, `^\*withstack\.withStack$`, p.Exception[0].Value)
fr = p.Exception[0].Stacktrace.Frames
assert.Regexp(t, `.*/eval.go`, fr[len(fr)-1].Filename)
Expand Down
2 changes: 1 addition & 1 deletion vendor

0 comments on commit a3934f8

Please sign in to comment.