Skip to content

Commit 118a936

Browse files
committed
scplan: unredact logs for unable to make progress error
We have seen this error in tests and Sentry reports. The details for the error do not show up when logs are redacted, so this change makes the details appear in the AssertionError itself. This also makes stageBuilder implement redact.SafeFormatter so that the error is formatted safely. Release note: None
1 parent a491fd9 commit 118a936

File tree

1 file changed

+16
-8
lines changed
  • pkg/sql/schemachanger/scplan/internal/scstage

1 file changed

+16
-8
lines changed

pkg/sql/schemachanger/scplan/internal/scstage/build.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ func buildPostCommitStages(bc buildContext, bs buildState) (stages []Stage) {
269269
var trace []string
270270
bs.trace = &trace
271271
sb = bc.makeStageBuilder(bs)
272-
panic(errors.WithDetailf(
273-
errors.AssertionFailedf("unable to make progress"),
274-
"terminal state:\n%s\nrule trace:\n%s", sb, strings.Join(trace, "\n")))
272+
panic(errors.AssertionFailedf(
273+
"unable to make progress\nterminal state:\n%v\nrule trace:\n%s",
274+
sb, redact.SafeString(strings.Join(trace, "\n")),
275+
))
275276
}
276277
build(sb)
277278
}
@@ -728,15 +729,22 @@ func (sb stageBuilder) hasAnyNonRevertibleOps() bool {
728729

729730
// String returns a string representation of the stageBuilder.
730731
func (sb stageBuilder) String() string {
731-
var str strings.Builder
732+
return redact.StringWithoutMarkers(sb)
733+
}
734+
735+
// SafeFormat implements redact.SafeFormatter.
736+
func (sb stageBuilder) SafeFormat(p redact.SafePrinter, verb rune) {
732737
for _, t := range sb.current {
733-
str.WriteString(" - ")
734-
str.WriteString(screl.NodeString(t.n))
735-
str.WriteString("\n")
738+
p.SafeString(" - ")
739+
if err := screl.FormatNode(p, t.n); err != nil {
740+
p.UnsafeString(screl.NodeString(t.n))
741+
}
742+
p.SafeString("\n")
736743
}
737-
return str.String()
738744
}
739745

746+
var _ redact.SafeFormatter = stageBuilder{}
747+
740748
// computeExtraOps generates extra operations to decorate a stage with.
741749
// These are typically job-related.
742750
//

0 commit comments

Comments
 (0)