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

sql: panic caused by DEALLOCATE ALL / DISCARD ALL inside of a prepared statement #52915

Closed
rafiss opened this issue Aug 17, 2020 · 0 comments · Fixed by #52940
Closed

sql: panic caused by DEALLOCATE ALL / DISCARD ALL inside of a prepared statement #52915

rafiss opened this issue Aug 17, 2020 · 0 comments · Fixed by #52940
Labels
A-sql-pgwire pgwire protocol issues. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked.

Comments

@rafiss
Copy link
Collaborator

rafiss commented Aug 17, 2020

The issue described below is caused by this PR: #48842. This PR was backported to release-19.2 (#52444) and is currently pending approval for backporting to release-20.1 (#52443).

Describe the problem

The PGJDBC test suite caused a panic in CockroachDB. View the PGJDBC artifacts here and look at the snippet below.

E200815 09:33:45.840902 9975344 sql/conn_executor.go:789  [n1,client=127.0.0.1:53762,hostnossl,user=root] a SQL panic has occurred while executing the following statement:
DEALLOCATE ALL
E200815 09:33:45.841067 9975344 util/log/crash_reporting.go:138  [n1,client=127.0.0.1:53762,hostnossl,user=root] a panic has occurred!
portal  doesn't exist
(1) attached stack trace
  | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:494
  | runtime.gopanic
  | 	/usr/local/go/src/runtime/panic.go:679
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).exhaustPortal
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:402
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execPortal
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:183
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1465
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1338
  | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:496
  | github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:580
Wraps: (2) 2 safe details enclosed
Wraps: (3) attached stack trace
  | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:494
  | runtime.gopanic
  | 	/usr/local/go/src/runtime/panic.go:679
  | [...repeated from below...]
Wraps: (4) assertion failure
Wraps: (5) attached stack trace
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).exhaustPortal
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:402
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execPortal
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:183
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1465
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1338
  | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:496
  | github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1
  | 	/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:580
  | runtime.goexit
  | 	/usr/local/go/src/runtime/asm_amd64.s:1357
Wraps: (6) 2 safe details enclosed
Wraps: (7) portal  doesn't exist

To Reproduce

This happened when qualifying v19.2.10. It also happens on the current master branch.

The following PGTest reproduces the issue.

send
Query {"String": "CREATE TABLE rollbacktest (a INT, str TEXT)"}
----

until
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"CREATE TABLE"}
{"Type":"ReadyForQuery","TxStatus":"I"}

# 80 = ASCII 'P' for Portal
send
Parse {"Name": "s1", "Query": "SELECT * FROM rollbacktest"}
Bind {"DestinationPortal": "p1", "PreparedStatement": "s1"}
Describe {"ObjectType": 80, "Name": "p1"}
Execute {"Portal": "p1"}
Sync
----

until
ReadyForQuery
----
{"Type":"ParseComplete"}
{"Type":"BindComplete"}
{"Type":"RowDescription","Fields":[{"Name":"a","TableOID":52,"TableAttributeNumber":1,"DataTypeOID":20,"DataTypeSize":8,"TypeModifier":-1,"Format":0},{"Name":"str","TableOID":52,"TableAttributeNumber":2,"DataTypeOID":25,"DataTypeSize":-1,"TypeModifier":-1,"Format":0}]}
{"Type":"CommandComplete","CommandTag":"SELECT 0"}
{"Type":"ReadyForQuery","TxStatus":"I"}


# 80 = ASCII 'P' for Portal
send
Parse {"Name": "s2", "Query": "DEALLOCATE ALL"}
Bind {"DestinationPortal": "p2", "PreparedStatement": "s2"}
Describe {"ObjectType": 80, "Name": "p2"}
Execute {"Portal": "p2"}
Sync
----

until
ReadyForQuery
----
{"Type":"ParseComplete"}
{"Type":"BindComplete"}
{"Type":"CommandComplete","CommandTag":"DEALLOCATE ALL"}
{"Type":"ReadyForQuery","TxStatus":"I"}
@rafiss rafiss added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-pgwire pgwire protocol issues. labels Aug 17, 2020
@rafiss rafiss mentioned this issue Aug 17, 2020
25 tasks
@rafiss rafiss added the release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked. label Aug 18, 2020
@craig craig bot closed this as completed in f41ff14 Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgwire pgwire protocol issues. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant