Skip to content

Commit 69e0168

Browse files
authored
Merge pull request #151824 from rafiss/blathers/backport-release-25.3-151810
release-25.3: scplan: unredact logs for unable to make progress error
2 parents fbb8e4e + 6df271d commit 69e0168

File tree

1 file changed

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

1 file changed

+17
-8
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl"
2222
"github.com/cockroachdb/cockroach/pkg/util/iterutil"
2323
"github.com/cockroachdb/errors"
24+
"github.com/cockroachdb/redact"
2425
)
2526

2627
// BuildStages builds the plan's stages for this and all subsequent phases.
@@ -267,9 +268,10 @@ func buildPostCommitStages(bc buildContext, bs buildState) (stages []Stage) {
267268
var trace []string
268269
bs.trace = &trace
269270
sb = bc.makeStageBuilder(bs)
270-
panic(errors.WithDetailf(
271-
errors.AssertionFailedf("unable to make progress"),
272-
"terminal state:\n%s\nrule trace:\n%s", sb, strings.Join(trace, "\n")))
271+
panic(errors.AssertionFailedf(
272+
"unable to make progress\nterminal state:\n%v\nrule trace:\n%s",
273+
sb, redact.SafeString(strings.Join(trace, "\n")),
274+
))
273275
}
274276
build(sb)
275277
}
@@ -726,15 +728,22 @@ func (sb stageBuilder) hasAnyNonRevertibleOps() bool {
726728

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

745+
var _ redact.SafeFormatter = stageBuilder{}
746+
738747
// computeExtraOps generates extra operations to decorate a stage with.
739748
// These are typically job-related.
740749
//

0 commit comments

Comments
 (0)