Skip to content

Commit 558347a

Browse files
committed
sql: don't store plan gist as FastValue in context
Given that in 67e45fd we introduced a different way to include plan gists into sentry reports, I don't think we need to include the plan gists into the context anymore, so we can free up the FastValue context slot for a better use. Release note: None
1 parent 99e7c38 commit 558347a

File tree

4 files changed

+3
-41
lines changed

4 files changed

+3
-41
lines changed

pkg/sql/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ go_library(
567567
"//pkg/util/collatedstring",
568568
"//pkg/util/ctxgroup",
569569
"//pkg/util/ctxlog",
570-
"//pkg/util/ctxutil",
571570
"//pkg/util/duration",
572571
"//pkg/util/encoding",
573572
"//pkg/util/encoding/csv",

pkg/sql/conn_executor.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ import (
7676
"github.com/cockroachdb/cockroach/pkg/util/buildutil"
7777
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker"
7878
"github.com/cockroachdb/cockroach/pkg/util/ctxlog"
79-
"github.com/cockroachdb/cockroach/pkg/util/ctxutil"
8079
"github.com/cockroachdb/cockroach/pkg/util/errorutil"
8180
"github.com/cockroachdb/cockroach/pkg/util/fsm"
8281
"github.com/cockroachdb/cockroach/pkg/util/hlc"
@@ -4938,28 +4937,3 @@ func (ex *connExecutor) WithAnonymizedStatementAndGist(err error) error {
49384937
}
49394938
return err
49404939
}
4941-
4942-
var contextPlanGistKey = ctxutil.RegisterFastValueKey()
4943-
4944-
func withPlanGist(ctx context.Context, gist string) context.Context {
4945-
if gist == "" {
4946-
return ctx
4947-
}
4948-
return ctxutil.WithFastValue(ctx, contextPlanGistKey, gist)
4949-
}
4950-
4951-
func planGistFromCtx(ctx context.Context) string {
4952-
val := ctxutil.FastValue(ctx, contextPlanGistKey)
4953-
if val != nil {
4954-
return val.(string)
4955-
}
4956-
return ""
4957-
}
4958-
4959-
func init() {
4960-
// Register a function to include the plan gist in crash reports.
4961-
logcrash.RegisterTagFn("gist", func(ctx context.Context) string {
4962-
return planGistFromCtx(ctx)
4963-
})
4964-
tree.PlanGistFromCtx = planGistFromCtx
4965-
}

pkg/sql/conn_executor_exec.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,6 @@ func (ex *connExecutor) makeExecPlan(
32783278
// Include gist in error reports.
32793279
ih := &planner.instrumentation
32803280
ex.curStmtPlanGist = redact.SafeString(ih.planGist.String())
3281-
ctx = withPlanGist(ctx, ih.planGist.String())
32823281
if buildutil.CrdbTestBuild && ih.planGist.String() != "" {
32833282
// Ensure that the gist can be decoded in test builds.
32843283
//

pkg/sql/sem/tree/datum.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5293,10 +5293,6 @@ func (d *DEnum) ResolvedType() *types.T {
52935293
return d.EnumTyp
52945294
}
52955295

5296-
// PlanGistFromCtx returns the plan gist if it is stored in the context. It is
5297-
// injected from the sql package to avoid import cycle.
5298-
var PlanGistFromCtx func(context.Context) string
5299-
53005296
// Compare implements the Datum interface.
53015297
func (d *DEnum) Compare(ctx context.Context, cmpCtx CompareContext, other Datum) (int, error) {
53025298
if other == DNull {
@@ -5314,16 +5310,10 @@ func (d *DEnum) Compare(ctx context.Context, cmpCtx CompareContext, other Datum)
53145310

53155311
// We should never be comparing two different versions of the same enum.
53165312
if v.EnumTyp.TypeMeta.Version != d.EnumTyp.TypeMeta.Version {
5317-
var gist redact.SafeString
5318-
if PlanGistFromCtx != nil {
5319-
// Plan gist, by construction, doesn't contain any PII, so it's a
5320-
// safe string.
5321-
gist = redact.SafeString(PlanGistFromCtx(ctx))
5322-
}
53235313
return 0, errors.AssertionFailedf(
5324-
"comparison of two different versions of enum %s oid %d: versions %d and %d, gist %q",
5325-
d.EnumTyp.SQLStringForError(), errors.Safe(d.EnumTyp.Oid()), d.EnumTyp.TypeMeta.Version,
5326-
v.EnumTyp.TypeMeta.Version, gist,
5314+
"comparison of two different versions of enum %s oid %d: versions %d and %d",
5315+
d.EnumTyp.SQLStringForError(), errors.Safe(d.EnumTyp.Oid()),
5316+
d.EnumTyp.TypeMeta.Version, v.EnumTyp.TypeMeta.Version,
53275317
)
53285318
}
53295319

0 commit comments

Comments
 (0)