Skip to content

opt: v20.1.0-rc.2: assertion failed: estimated row count must be non-zero #49911

@cockroach-teamcity

Description

@cockroach-teamcity

This issue was autofiled by Sentry. It represents a crash or reported error on a live cluster with telemetry enabled.

Sentry link: https://sentry.io/organizations/cockroach-labs/issues/1711322401/?referrer=webhooks_plugin

Panic message:

*errors.errorString
*safedetails.withSafeDetails: estimated row count must be non-zero (1)
statistics_builder.go:2301: *withstack.withStack (2)
*assert.withAssertionFailure
(check the extra data payloads)

Stacktrace (expand for inline code snippets):

if s.RowCount <= 0 && relProps.Cardinality.Max > 0 {
panic(errors.AssertionFailedf("estimated row count must be non-zero"))
}
in pkg/sql/opt/memo.(*statisticsBuilder).finalizeFromCardinality
s.RowCount = inputStats.RowCount
sb.finalizeFromCardinality(relProps)
}
in pkg/sql/opt/memo.(*statisticsBuilder).buildWithScan
if !b.disableStats {
b.sb.buildWithScan(withScan, rel)
}
in pkg/sql/opt/memo.(*logicalPropsBuilder).buildWithScanProps
https://github.com/cockroachdb/cockroach/blob/c0f00d2a156295a1cb79ed960940c167cb03ccbc/pkg/sql/opt/memo/expr.og.go#L16550-L16552 in pkg/sql/opt/memo.(*Memo).MemoizeWithScan
https://github.com/cockroachdb/cockroach/blob/c0f00d2a156295a1cb79ed960940c167cb03ccbc/pkg/sql/opt/norm/factory.og.go#L8535-L8537 in pkg/sql/opt/norm.(*Factory).ConstructWithScan
outScope.expr = b.factory.ConstructWithScan(&memo.WithScanPrivate{
With: cte.id,
in pkg/sql/opt/optbuilder.(*Builder).buildDataSource
outScope = b.buildDataSource(source.Expr, indexFlags, locking, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildDataSource
) (outScope *scope) {
outScope = b.buildDataSource(tables[0], nil /* indexFlags */, locking, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep
}
tableScope := b.buildFromTablesRightDeep(tables, locking, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep
}
return b.buildFromTablesRightDeep(tables, locking, inScope)
}
in pkg/sql/opt/optbuilder.(*Builder).buildFromTables
if len(from.Tables) > 0 {
outScope = b.buildFromTables(from.Tables, locking, inScope)
} else {
in pkg/sql/opt/optbuilder.(*Builder).buildFrom
) (outScope *scope) {
fromScope := b.buildFrom(sel.From, locking, inScope)
b.processWindowDefs(sel, fromScope)
in pkg/sql/opt/optbuilder.(*Builder).buildSelectClause
case *tree.SelectClause:
outScope = b.buildSelectClause(t, orderBy, locking, desiredTypes, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens
return b.processWiths(with, inScope, func(inScope *scope) *scope {
return b.buildSelectStmtWithoutParens(
wrapped, orderBy, limit, locking, desiredTypes, inScope,
in pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1
inScope.atRoot = false
outScope := buildStmt(inScope)
inScope.atRoot = prevAtRoot
in pkg/sql/opt/optbuilder.(*Builder).processWiths
return b.processWiths(with, inScope, func(inScope *scope) *scope {
return b.buildSelectStmtWithoutParens(
in pkg/sql/opt/optbuilder.(*Builder).buildSelect
case *tree.Select:
return b.buildSelect(stmt, noRowLocking, desiredTypes, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildStmt
b.pushWithFrame()
recursiveScope := b.buildStmt(recursive, initialTypes /* desiredTypes */, cteScope)
b.popWithFrame(recursiveScope)
in pkg/sql/opt/optbuilder.(*Builder).buildCTE
hasRecursive = hasRecursive || with.Recursive
cteExpr, cteCols := b.buildCTE(cte, outScope, with.Recursive)
in pkg/sql/opt/optbuilder.(*Builder).buildCTEs
) *scope {
inScope = b.buildCTEs(with, inScope)
prevAtRoot := inScope.atRoot
in pkg/sql/opt/optbuilder.(*Builder).processWiths
return b.processWiths(with, inScope, func(inScope *scope) *scope {
return b.buildSelectStmtWithoutParens(
in pkg/sql/opt/optbuilder.(*Builder).buildSelect
case *tree.Select:
return b.buildSelect(stmt, noRowLocking, desiredTypes, inScope)
in pkg/sql/opt/optbuilder.(*Builder).buildStmt
return b.buildStmt(stmt, desiredTypes, inScope)
}
in pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot
// and physical properties.
outScope := b.buildStmtAtRoot(b.stmt, nil /* desiredTypes */, b.allocScope())
in pkg/sql/opt/optbuilder.(*Builder).Build
bld := optbuilder.New(ctx, &p.semaCtx, p.EvalContext(), &opc.catalog, f, opc.p.stmt.AST)
if err := bld.Build(); err != nil {
return nil, err
in pkg/sql.(*optPlanningCtx).buildExecMemo
execMemo, err := opc.buildExecMemo(ctx)
if err != nil {
in pkg/sql.(*planner).makeOptimizerPlan
if err := planner.makeOptimizerPlan(ctx); err != nil {
log.VEventf(ctx, 1, "optimizer plan failed: %v", err)
in pkg/sql.(*connExecutor).makeExecPlan
// between here and there needs to happen even if there's an error.
err := ex.makeExecPlan(ctx, planner)
// We'll be closing the plan manually below after execution; this
in pkg/sql.(*connExecutor).dispatchToExecutionEngine
p.autoCommit = os.ImplicitTxn.Get() && !ex.server.cfg.TestingKnobs.DisableAutoCommit
if err := ex.dispatchToExecutionEngine(ctx, p, res); err != nil {
return nil, nil, err
in pkg/sql.(*connExecutor).execStmtInOpenState
} else {
ev, payload, err = ex.execStmtInOpenState(ctx, stmt, res, pinfo)
}
in pkg/sql.(*connExecutor).execStmt
stmtCtx := withStatement(ctx, ex.curStmt)
ev, payload, err = ex.execStmt(stmtCtx, curStmt, stmtRes, nil /* pinfo */)
if err != nil {
in pkg/sql.(*connExecutor).execCmd
var err error
if err = ex.execCmd(ex.Ctx()); err != nil {
if err == io.EOF || err == errDrainingComplete {
in pkg/sql.(*connExecutor).run

pkg/sql/opt/memo/statistics_builder.go in pkg/sql/opt/memo.(*statisticsBuilder).finalizeFromCardinality at line 2301
pkg/sql/opt/memo/statistics_builder.go in pkg/sql/opt/memo.(*statisticsBuilder).buildWithScan at line 2136
pkg/sql/opt/memo/logical_props_builder.go in pkg/sql/opt/memo.(*logicalPropsBuilder).buildWithScanProps at line 800
pkg/sql/opt/memo/expr.og.go in pkg/sql/opt/memo.(*Memo).MemoizeWithScan at line 16551
pkg/sql/opt/norm/factory.og.go in pkg/sql/opt/norm.(*Factory).ConstructWithScan at line 8536
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildDataSource at line 96
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildDataSource at line 63
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep at line 1095
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep at line 1102
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFromTables at line 1072
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFrom at line 999
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectClause at line 921
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens at line 869
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1 at line 842
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 29
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect at line 841
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 253
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).buildCTE at line 158
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildCTEs at line 681
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 26
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect at line 841
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 253
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot at line 217
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).Build at line 188
pkg/sql/plan_opt.go in pkg/sql.(*optPlanningCtx).buildExecMemo at line 433
pkg/sql/plan_opt.go in pkg/sql.(*planner).makeOptimizerPlan at line 169
pkg/sql/conn_executor_exec.go in pkg/sql.(*connExecutor).makeExecPlan at line 801
pkg/sql/conn_executor_exec.go in pkg/sql.(*connExecutor).dispatchToExecutionEngine at line 691
pkg/sql/conn_executor_exec.go in pkg/sql.(*connExecutor).execStmtInOpenState at line 481
pkg/sql/conn_executor_exec.go in pkg/sql.(*connExecutor).execStmt at line 96
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).execCmd at line 1368
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).run at line 1297
Tag Value
Cockroach Release v20.1.0-rc.2
Cockroach SHA: c0f00d2
Platform linux amd64
Distribution CCL
Environment v20.1.0-rc.2
Command server
Go Version go1.13.9
# of CPUs 8
# of Goroutines 197

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-sentryOriginated from an in-the-wild panic report.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions