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

sentry: authorization.go:129: cannot use CheckPrivilege without a txn (1) assertion failure Wraps: (2) attached stack trace -- stack trace: | github.com/cockroachdb/cockroach/pkg/sql.(*planner).CheckPrivi... #82942

Closed
cockroach-teamcity opened this issue Jun 15, 2022 · 1 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.

Comments

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Jun 15, 2022

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

Panic message:

authorization.go:129: cannot use CheckPrivilege without a txn
(1) assertion failure
Wraps: (2) attached stack trace
-- stack trace:
| github.com/cockroachdb/cockroach/pkg/sql.(*planner).CheckPrivilegeForUser
| github.com/cockroachdb/cockroach/pkg/sql/authorization.go:129
| github.com/cockroachdb/cockroach/pkg/sql.(*planner).canResolveDescUnderSchema
| github.com/cockroachdb/cockroach/pkg/sql/authorization.go:743
| github.com/cockroachdb/cockroach/pkg/sql.(*optCatalog).ResolveDataSource
| github.com/cockroachdb/cockroach/pkg/sql/opt_catalog.go:214
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).resolveDataSource
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/util.go:606
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildDataSource
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:104
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildDataSource
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:60
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1155
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildFromTables
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1132
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildFrom
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1059
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectClause
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:980
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:928
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:901
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).processWiths
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:115
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:900
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmt
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:281
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildCTE
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:194
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildCTEs
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:139
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).processWiths
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:112
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:900
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmt
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:281
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:241
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).Build
| github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:215
| github.com/cockroachdb/cockroach/pkg/sql.(*optPlanningCtx).buildReusableMemo
| github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:399
| github.com/cockroachdb/cockroach/pkg/sql.(*planner).prepareUsingOptimizer
| github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:142
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).populatePrepared
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:278
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).prepare.func1
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:235
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).prepare
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:240
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).addPreparedStmt
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:102
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execPrepare
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:63
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1975
| github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1799
| github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn
| github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:747
Wraps: (3) cannot use CheckPrivilege without a txn
Error types: (1) *assert.withAssertionFailure (2) *withstack.withStack (3) *errutil.leafError
-- report composition:
*errutil.leafError: cannot use CheckPrivilege without a txn
authorization.go:129: *withstack.withStack (top exception)
*assert.withAssertionFailure

Stacktrace (expand for inline code snippets):

if p.txn == nil || !p.txn.IsOpen() {
return errors.AssertionFailedf("cannot use CheckPrivilege without a txn")
}
in pkg/sql.(*planner).CheckPrivilegeForUser
case catalog.SchemaUserDefined:
return p.CheckPrivilegeForUser(ctx, scDesc, privilege.USAGE, p.User())
default:
in pkg/sql.(*planner).canResolveDescUnderSchema
// Ensure that the current user can access the target schema.
if err := oc.planner.canResolveDescUnderSchema(ctx, prefix.Schema, desc); err != nil {
return nil, cat.DataSourceName{}, err
in pkg/sql.(*optCatalog).ResolveDataSource
}
ds, resName, err := b.catalog.ResolveDataSource(b.ctx, flags, tn)
if err != nil {
in pkg/sql/opt/optbuilder.(*Builder).resolveDataSource
ds, depName, resName := b.resolveDataSource(tn, privilege.SELECT)
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
}
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)
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)
outScope.expr = b.buildWiths(outScope.expr, correlatedCTEs)
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
if !isRecursive {
cteScope := b.buildStmt(cte.Stmt, nil /* desiredTypes */, inScope)
cteScope.removeHiddenCols()
in pkg/sql/opt/optbuilder.(*Builder).buildCTE
hasRecursive = hasRecursive || with.Recursive
cteExpr, cteCols, cteOrdering := b.buildCTE(cte, outScope, with.Recursive)
in pkg/sql/opt/optbuilder.(*Builder).buildCTEs
var correlatedCTEs cteSources
inScope, correlatedCTEs = 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
b.ctes = nil
outScope = b.buildStmt(stmt, desiredTypes, inScope)
// Build With operators for any CTEs hoisted to the top level.
in pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot
// and physical properties.
outScope := b.buildStmtAtRoot(b.stmt, nil /* desiredTypes */)
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
// and execute paths.
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, ex.state.mu.txn); err != nil && origin != PreparedStatementOriginSessionMigration {
return nil, err
in pkg/sql.(*connExecutor).prepare
// Prepare the query. This completes the typing of placeholders.
prepared, err := ex.prepare(ctx, stmt, placeholderHints, rawTypeHints, origin)
if err != nil {
in pkg/sql.(*connExecutor).addPreparedStmt
stmt := makeStatement(parseCmd.Statement, ex.generateID())
_, err := ex.addPreparedStmt(
ctx,
in pkg/sql.(*connExecutor).execPrepare
stmtCtx := withStatement(ctx, ex.curStmtAST)
ev, payload = ex.execPrepare(stmtCtx, tcmd)
case DescribeStmt:
in pkg/sql.(*connExecutor).execCmd
var err error
if err = ex.execCmd(); err != nil {
if errors.IsAny(err, io.EOF, errDrainingComplete) {
in pkg/sql.(*connExecutor).run
}()
return h.ex.run(ctx, s.pool, reserved, cancel)
}
in pkg/sql.(*Server).ServeConn

pkg/sql/authorization.go in pkg/sql.(*planner).CheckPrivilegeForUser at line 129
pkg/sql/authorization.go in pkg/sql.(*planner).canResolveDescUnderSchema at line 743
pkg/sql/opt_catalog.go in pkg/sql.(*optCatalog).ResolveDataSource at line 214
pkg/sql/opt/optbuilder/util.go in pkg/sql/opt/optbuilder.(*Builder).resolveDataSource at line 606
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildDataSource at line 104
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildDataSource at line 60
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFromTablesRightDeep at line 1155
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFromTables at line 1132
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildFrom at line 1059
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectClause at line 980
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens at line 928
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1 at line 901
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 115
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect at line 900
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 281
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).buildCTE at line 194
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).buildCTEs at line 139
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 112
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect at line 900
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 281
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot at line 241
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).Build at line 215
pkg/sql/plan_opt.go in pkg/sql.(*optPlanningCtx).buildReusableMemo at line 399
pkg/sql/plan_opt.go in pkg/sql.(*planner).prepareUsingOptimizer at line 142
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).populatePrepared at line 278
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare.func1 at line 235
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare at line 240
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).addPreparedStmt at line 102
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).execPrepare at line 63
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).execCmd at line 1975
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).run at line 1799
pkg/sql/conn_executor.go in pkg/sql.(*Server).ServeConn at line 747
Tag Value
Cockroach Release v22.1.0
Cockroach SHA: 5b78463
Platform linux amd64
Distribution CCL
Environment v22.1.0
Command server
Go Version ``
# of CPUs
# of Goroutines

Jira issue: CRDB-16744

@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 Jun 15, 2022
@rafiss
Copy link
Collaborator

rafiss commented Jun 28, 2022

dupe of #82034

@rafiss rafiss closed this as completed Jun 28, 2022
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

2 participants