Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: v20.1.12: estimated row count must be non-zero #61285

Closed
cockroach-teamcity opened this issue Mar 1, 2021 · 3 comments
Closed

opt: v20.1.12: estimated row count must be non-zero #61285

cockroach-teamcity opened this issue Mar 1, 2021 · 3 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-sentry Originated from an in-the-wild panic report.

Comments

@cockroach-teamcity
Copy link
Member

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/2245205023/?referrer=webhooks_plugin

Panic message:

*errors.errorString
*safedetails.withSafeDetails: estimated row count must be non-zero (1)
statistics_builder.go:2353: *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
sb.finalizeFromCardinality(relProps)
}
in pkg/sql/opt/memo.(*statisticsBuilder).buildSelect
if !b.disableStats {
b.sb.buildSelect(sel, rel)
}
in pkg/sql/opt/memo.(*logicalPropsBuilder).buildSelectProps
https://github.com/cockroachdb/cockroach/blob/871056016d8a32ff20921b716f103e0e3abdd6e2/pkg/sql/opt/memo/expr.og.go#L15692-L15694 in pkg/sql/opt/memo.(*Memo).MemoizeSelect
https://github.com/cockroachdb/cockroach/blob/871056016d8a32ff20921b716f103e0e3abdd6e2/pkg/sql/opt/norm/factory.og.go#L1036-L1038 in pkg/sql/opt/norm.(*Factory).ConstructSelect
https://github.com/cockroachdb/cockroach/blob/871056016d8a32ff20921b716f103e0e3abdd6e2/pkg/sql/opt/norm/factory.og.go#L385-L387 in pkg/sql/opt/norm.(*Factory).ConstructSelect
// Wrap the filter in a FiltersOp.
inScope.expr = b.factory.ConstructSelect(
inScope.expr.(memo.RelExpr),
in pkg/sql/opt/optbuilder.(*Builder).buildWhere
// WHERE
mb.b.buildWhere(where, mb.outScope)
in pkg/sql/opt/optbuilder.(*mutationBuilder).buildInputForUpdate
// All columns from the update table will be projected.
mb.buildInputForUpdate(inScope, upd.Table, upd.From, upd.Where, upd.Limit, upd.OrderBy)
in pkg/sql/opt/optbuilder.(*Builder).buildUpdate
return b.processWiths(stmt.With, inScope, func(inScope *scope) *scope {
return b.buildUpdate(stmt, inScope)
})
in pkg/sql/opt/optbuilder.(*Builder).buildStmt.func3
inScope.atRoot = false
outScope := buildStmt(inScope)
inScope.atRoot = prevAtRoot
in pkg/sql/opt/optbuilder.(*Builder).processWiths
case *tree.Update:
return b.processWiths(stmt.With, inScope, func(inScope *scope) *scope {
return b.buildUpdate(stmt, 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.KeepPlaceholders = true
if err := bld.Build(); err != nil {
return nil, err
in pkg/sql.(*optPlanningCtx).buildReusableMemo
memo, err := opc.buildReusableMemo(ctx)
if err != nil {
in pkg/sql.(*planner).prepareUsingOptimizer
// future.
flags, err := p.prepareUsingOptimizer(ctx)
if err != nil {
in pkg/sql.(*connExecutor).populatePrepared
p.semaCtx.Annotations = tree.MakeAnnotations(stmt.NumAnnotations)
flags, err = ex.populatePrepared(ctx, txn, placeholderHints, p)
return err
in pkg/sql.(*connExecutor).prepare.func1
// Use the existing transaction.
if err := prepare(ctx, txn); err != nil {
return nil, err
in pkg/sql.(*connExecutor).prepare
// Prepare the query. This completes the typing of placeholders.
prepared, err := ex.prepare(ctx, stmt, placeholderHints, origin)
if err != nil {
in pkg/sql.(*connExecutor).addPreparedStmt
ps, err := ex.addPreparedStmt(
ctx,
in pkg/sql.(*connExecutor).execPrepare
stmtCtx := withStatement(ctx, ex.curStmt)
ev, payload = ex.execPrepare(stmtCtx, tcmd)
case DescribeStmt:
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
}()
return h.ex.run(ctx, s.pool, reserved, cancel)
}
in pkg/sql.(*Server).ServeConn
reservedOwned = false // We're about to pass ownership away.
retErr = sqlServer.ServeConn(ctx, connHandler, reserved, cancelConn)
}()
in pkg/sql/pgwire.(*conn).processCommandsAsync.func1
/usr/local/go/src/runtime/asm_amd64.s#L1356-L1358 in runtime.goexit

pkg/sql/opt/memo/statistics_builder.go in pkg/sql/opt/memo.(*statisticsBuilder).finalizeFromCardinality at line 2353
pkg/sql/opt/memo/statistics_builder.go in pkg/sql/opt/memo.(*statisticsBuilder).buildSelect at line 763
pkg/sql/opt/memo/logical_props_builder.go in pkg/sql/opt/memo.(*logicalPropsBuilder).buildSelectProps at line 246
pkg/sql/opt/memo/expr.og.go in pkg/sql/opt/memo.(*Memo).MemoizeSelect at line 15693
pkg/sql/opt/norm/factory.og.go in pkg/sql/opt/norm.(*Factory).ConstructSelect at line 1037
pkg/sql/opt/norm/factory.og.go in pkg/sql/opt/norm.(*Factory).ConstructSelect at line 386
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildWhere at line 1048
pkg/sql/opt/optbuilder/mutation_builder.go in pkg/sql/opt/optbuilder.(*mutationBuilder).buildInputForUpdate at line 266
pkg/sql/opt/optbuilder/update.go in pkg/sql/opt/optbuilder.(*Builder).buildUpdate at line 98
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt.func3 at line 270
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 29
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 269
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).buildReusableMemo at line 312
pkg/sql/plan_opt.go in pkg/sql.(*planner).prepareUsingOptimizer at line 117
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).populatePrepared at line 238
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare.func1 at line 180
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare at line 186
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).addPreparedStmt at line 106
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).execPrepare at line 52
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).execCmd at line 1469
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).run at line 1335
pkg/sql/conn_executor.go in pkg/sql.(*Server).ServeConn at line 479
pkg/sql/pgwire/conn.go in pkg/sql/pgwire.(*conn).processCommandsAsync.func1 at line 582
/usr/local/go/src/runtime/asm_amd64.s in runtime.goexit at line 1357
Tag Value
Cockroach Release v20.1.12
Cockroach SHA: 8710560
Platform linux amd64
Distribution CCL
Environment v20.1.12
Command server
Go Version go1.13.9
# of CPUs 2
# of Goroutines 162
@cockroach-teamcity cockroach-teamcity added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-sentry Originated from an in-the-wild panic report. labels Mar 1, 2021
@rytaft
Copy link
Collaborator

rytaft commented Mar 1, 2021

This is odd... the statement in the sentry issue is BEGIN TRANSACTION

@yuzefovich yuzefovich changed the title sentry: *errors.errorString *safedetails.withSafeDetails: estimated row count must be non-zero (1) statistics_builder.go:2353: *withstack.withStack (2) *assert.withAssertionFailure (check the extra data payloads) opt: v20.1.12: estimated row count must be non-zero Mar 2, 2021
@yuzefovich
Copy link
Member

This looks like a dup of #53311 in which it was decided to not backport this fix to 20.1 branch.

@rytaft
Copy link
Collaborator

rytaft commented Mar 2, 2021

Yea, I think that's a good theory. And it's consistent with the fact that this error occurred inside buildSelect. I don't see how we can debug this further, so I'm going to close the issue.

@rytaft rytaft closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-sentry Originated from an in-the-wild panic report.
Projects
None yet
Development

No branches or pull requests

3 participants