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: conn_executor.go:639: panic while executing 1 statements: UPSERT INTO _(_, _) VALUES ($1, $2), (__more4000__): caused by <redacted> #32834

Closed
tbg opened this issue Dec 4, 2018 · 10 comments · Fixed by #33245
Assignees
Labels
A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. 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. S-2-temp-unavailability Temp crashes or other availability problems. Can be worked around or resolved by restarting.

Comments

@tbg
Copy link
Member

tbg commented Dec 4, 2018

https://sentry.io/cockroach-labs/cockroachdb/issues/793275147/?referrer=webhooks_plugin

conn_executor.go:639: panic while executing 1 statements: UPSERT INTO (, _) VALUES ($1, $2), (more4000): caused by

github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1

stacktrace: {u'frames': [{u'function': u'func4', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl', u'in_app': True, u'lineno': 309, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go'}, {u'function': u'ServeConn', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*Server)', u'in_app': True, u'lineno': 389, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go'}, {u'function': u'run', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor)', u'in_app': True, u'lineno': 1169, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go'}, {u'function': u'execStmt', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor)', u'in_app': True, u'lineno': 96, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go'}, {u'function': u'execStmtInOpenState', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor)', u'in_app': True, u'lineno': 402, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go'}, {u'function': u'dispatchToExecutionEngine', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor)', u'in_app': True, u'lineno': 824, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go'}, {u'function': u'execWithDistSQLEngine', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor)', u'in_app': True, u'lineno': 982, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go'}, {u'function': u'PlanAndRun', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner)', u'in_app': True, u'lineno': 746, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go'}, {u'function': u'Run', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner)', u'in_app': True, u'lineno': 253, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go'}, {u'function': u'StartSync', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow)', u'in_app': True, u'lineno': 602, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go'}, {u'function': u'Run', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcessorBase)', u'in_app': True, u'lineno': 730, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go'}, {u'function': u'Start', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource)', u'in_app': True, u'lineno': 139, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go'}, {u'function': u'startExec', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql', u'in_app': True, u'lineno': 645, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/plan.go'}, {u'function': u'walkPlan', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql', u'in_app': True, u'lineno': 65, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/walk.go'}, {u'function': u'visit', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor)', u'in_app': True, u'lineno': 101, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/walk.go'}, {u'function': u'visitInternal', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor)', u'in_app': True, u'lineno': 543, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/walk.go'}, {u'function': u'func1', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal', u'in_app': True, u'lineno': 134, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/walk.go'}, {u'function': u'func2', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.startExec', u'in_app': True, u'lineno': 640, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/plan.go'}, {u'function': u'startExec', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*rowCountNode)', u'in_app': True, u'lineno': 173, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go'}, {u'function': u'BatchedNext', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/upsert.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*upsertNode)', u'in_app': True, u'lineno': 331, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/upsert.go'}, {u'function': u'atBatchEnd', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/tablewriter_upsert.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*tableUpserter)', u'in_app': True, u'lineno': 417, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/tablewriter_upsert.go'}, {u'function': u'panicslice', u'abs_path': u'/usr/local/go/src/runtime/panic.go', u'module': u'runtime', u'in_app': False, u'lineno': 35, u'filename': u'runtime/panic.go'}, {u'function': u'gopanic', u'abs_path': u'/usr/local/go/src/runtime/panic.go', u'module': u'runtime', u'in_app': False, u'lineno': 502, u'filename': u'runtime/panic.go'}, {u'function': u'call32', u'abs_path': u'/usr/local/go/src/runtime/asm_amd64.s', u'module': u'runtime', u'in_app': False, u'lineno': 573, u'filename': u'runtime/asm_amd64.s'}, {u'function': u'func1', u'abs_path': u'/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go', u'module': u'github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn', u'in_app': True, u'lineno': 387, u'filename': u'github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go'}]}
type: *log.safeError
value: conn_executor.go:639: panic while executing 1 statements: UPSERT INTO (, _) VALUES ($1, $2), (more4000): caused by

@tbg tbg 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 Dec 4, 2018
@blkerby
Copy link

blkerby commented Dec 4, 2018

Hi, I observed this crash. I was experimenting with CockroachDB in a Kubernetes cluster and was doing a bulk insert process when I saw two (out of three) CockroachDB pods had container restarts. Some context which may or may not be relevant: I had recently decreased the cluster size from 6 to 3 (which explains the failed connection attempts in the logs below), by scaling down the StatefulSet replicas one at a time and waiting for the Admin UI to show 0 under-replicated ranges before proceeding. I had also recently upgraded from 2.0.6 to 2.1.0 and then to 2.1.1. Please let me know if there's any additional context I could provide that might help. Here is the end of the log, for the one container:

E181204 21:07:25.050487 598393 sql/conn_executor.go:632 [n1,client=100.125.0.3:49916,user=uievent_pipeline] a SQL panic has occurred while executing "UPSERT INTO connection(id, close_ts) VALUES ($1, $2), ($3, $4), ($5, $6), ($7, $8), ($9, $10), ($11, $12), ($13, $14), ($15, $16), ($17, $18), ($19, $20), ($21, $22), ($23, $24), ($25, $26), ($27, $28), ($29, $30), ($31, $32), ($33, $34), ($35, $36), ($37, $38), ($39, $40), ($41, $42), ($43, $44), ($45, $46), ($47, $48), ($49, $50), ($51, $52), ($53, $54), ($55, $56), ($57, $58), ($59, $60), ($61, $62), ($63, $64), ($65, $66), ($67, $68), ($69, $70), ($71, $72), ($73, $74), ($75, $76), ($77, $78 [...]": runtime error: slice bounds out of range
E181204 21:07:25.062067 598393 util/log/crash_reporting.go:203 [n1,client=100.125.0.3:49916,user=uievent_pipeline] a panic has occurred!
W181204 21:07:25.442999 705940 vendor/google.golang.org/grpc/clientconn.go:1293 grpc: addrConn.createTransport failed to connect to {cockroachdb-4.cockroachdb-hs.cockroachdb.svc.cluster.local:26257 0 }. Err :connection error: desc = "transport: Error while dialing cannot reuse client connection". Reconnecting...
W181204 21:07:25.443066 705940 vendor/google.golang.org/grpc/clientconn.go:942 Failed to dial cockroachdb-4.cockroachdb-hs.cockroachdb.svc.cluster.local:26257: context canceled; please retry.
E181204 21:07:25.556333 598393 util/log/crash_reporting.go:477 [n1,client=100.125.0.3:49916,user=uievent_pipeline] Reported as error 720963f0cf764dea9d039c8da56de4e0
panic: runtime error: slice bounds out of range [recovered]
panic: panic while executing 1 statements: UPSERT INTO (, _) VALUES ($1, $2), (more4000); caused by runtime error: slice bounds out of range

goroutine 598393 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc4281eaa00, 0x3012380, 0xc4264b3bc0, 0x2754220, 0x4201da0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:646 +0x36f
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc4281eaa00, 0x3012380, 0xc4264b3bc0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:387 +0x61
panic(0x2754220, 0x4201da0)
/usr/local/go/src/runtime/panic.go:502 +0x229
github.com/cockroachdb/cockroach/pkg/sql.(*tableUpserter).atBatchEnd(0xc428b74000, 0x3012440, 0xc449fe93b0, 0xc4465c6300, 0xc4281eae18, 0xc425224200)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/tablewriter_upsert.go:417 +0x7e2
github.com/cockroachdb/cockroach/pkg/sql.(*upsertNode).BatchedNext(0xc4252350e0, 0x3012440, 0xc449fe93b0, 0xc4465c6380, 0xc4281eae18, 0x2879100, 0xc452fc1201, 0x7f5f5d26b4b8)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/upsert.go:331 +0x299
github.com/cockroachdb/cockroach/pkg/sql.(*rowCountNode).startExec(0xc434d81e20, 0x3012440, 0xc449fe93b0, 0xc4465c6380, 0xc4281eae18, 0x1, 0xc452fc1250)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go:173 +0xd0
github.com/cockroachdb/cockroach/pkg/sql.startExec.func2(0x2ab7b94, 0x5, 0x3005880, 0xc434d81e20, 0xc4288a5828, 0xc452fc1260)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:640 +0x90
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1(0xc4255a74a0, 0x2ab7b94, 0x5, 0x3005880, 0xc434d81e20)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:134 +0x5f
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal(0xc4255a74a0, 0x3005880, 0xc434d81e20, 0x2ab7b94, 0x5)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:543 +0x378
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit(0xc4255a74a0, 0x3005880, 0xc434d81e20, 0xc452fc1de8, 0x6c29f9)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:101 +0x8f
github.com/cockroachdb/cockroach/pkg/sql.walkPlan(0x3012440, 0xc449fe93b0, 0x3005880, 0xc434d81e20, 0x0, 0x2c12a80, 0x0, 0x0, 0xc449fe95f0, 0x3012380, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:65 +0x193
github.com/cockroachdb/cockroach/pkg/sql.startExec(0x3012440, 0xc449fe93b0, 0xc4465c6380, 0xc4281eae18, 0x3005880, 0xc434d81e20, 0xc42032b880, 0x3012440)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:645 +0x10e
github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start(0xc430194000, 0x3012440, 0xc449fe93b0, 0xc448596258, 0x266c1a0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:139 +0xe8
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcessorBase).Run(0xc430194000, 0x3012440, 0xc449fe93b0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:730 +0x58
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).StartSync(0xc4465c6700, 0x3012440, 0xc449fe93b0, 0x2c12298, 0xc4259681c0, 0x2fef500)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:602 +0x191
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc420819100, 0xc4346b4120, 0xc439320000, 0xc452fc28d8, 0xc425927900, 0xc4281eaeb0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:253 +0x879
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc420819100, 0x3012440, 0xc449fe8660, 0xc4281eaeb0, 0xc4346b4120, 0xc439320000, 0x3005880, 0xc434d81e20, 0xc425927900)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:746 +0x24c
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc4281eaa00, 0x3012440, 0xc449fe8660, 0xc4281eae18, 0x2, 0x7f5f5d243e98, 0xc4393205a0, 0x4823f00, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:982 +0x2d8
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc4281eaa00, 0x3012440, 0xc449fe8660, 0x3015480, 0xc440f359a0, 0x4823f00, 0x0, 0x0, 0xc42d6b8b40, 0x44, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:824 +0xa8a
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc4281eaa00, 0x3012440, 0xc449fe8660, 0x3015480, 0xc440f359a0, 0x4823f00, 0x0, 0x0, 0xc42d6b8b40, 0x44, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:402 +0xb3b
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc4281eaa00, 0x3012440, 0xc449fe8660, 0x3015480, 0xc440f359a0, 0x4823f00, 0x0, 0x0, 0xc42d6b8b40, 0x44, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:96 +0x341
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc4281eaa00, 0x3012380, 0xc4264b3bc0, 0xc420a02558, 0x5400, 0x15000, 0xc420a025f0, 0xc429ea6dd0, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1169 +0x1400
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc4207d3770, 0x3012380, 0xc4264b3bc0, 0xc4281eaa00, 0x5400, 0x15000, 0xc420a025f0, 0xc429ea6dd0, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:389 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl.func4(0xc4207d3770, 0x3012380, 0xc4264b3bc0, 0xc4281eaa00, 0x5400, 0x15000, 0xc420a025f0, 0xc429ea6dd0, 0xc429ea6de0, 0xc4203d1c40)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:309 +0x81
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:308 +0x107c

And for the other:

E181204 21:07:34.147599 399676 sql/conn_executor.go:632 [n2,client=100.125.0.3:50340,user=uievent_pipeline] a SQL panic has occurred while executing "UPSERT INTO connection(id, open_ts, stream_id, schema_id, open_data) VALUES ($1, $2, $3, $4, $5), ($6, $7, $8, $9, $10), ($11, $12, $13, $14, $15), ($16, $17, $18, $19, $20), ($21, $22, $23, $24, $25), ($26, $27, $28, $29, $30), ($31, $32, $33, $34, $35), ($36, $37, $38, $39, $40), ($41, $42, $43, $44, $45), ($46, $47, $48, $49, $50), ($51, $52, $53, $54, $55), ($56, $57, $58, $59, $60), ($61, $62, $63, $64, $65), ($66, $67, $68, $69, $70), ($71, $72, $73, $74, $75), ($76, $77, $78, $79, $80), ( [...]": runtime error: slice bounds out of range
E181204 21:07:34.175775 399676 util/log/crash_reporting.go:203 [n2,client=100.125.0.3:50340,user=uievent_pipeline] a panic has occurred!
W181204 21:07:34.286638 402518 vendor/google.golang.org/grpc/clientconn.go:1293 grpc: addrConn.createTransport failed to connect to {cockroachdb-3.cockroachdb-hs.cockroachdb.svc.cluster.local:26257 0 }. Err :connection error: desc = "transport: Error while dialing cannot reuse client connection". Reconnecting...
W181204 21:07:34.286733 402518 vendor/google.golang.org/grpc/clientconn.go:942 Failed to dial cockroachdb-3.cockroachdb-hs.cockroachdb.svc.cluster.local:26257: context canceled; please retry.
W181204 21:07:34.487341 402523 vendor/google.golang.org/grpc/clientconn.go:1293 grpc: addrConn.createTransport failed to connect to {cockroachdb-5.cockroachdb-hs.cockroachdb.svc.cluster.local:26257 0 }. Err :connection error: desc = "transport: Error while dialing cannot reuse client connection". Reconnecting...
W181204 21:07:34.487448 402523 vendor/google.golang.org/grpc/clientconn.go:942 Failed to dial cockroachdb-5.cockroachdb-hs.cockroachdb.svc.cluster.local:26257: context canceled; please retry.
W181204 21:07:34.490600 402534 vendor/google.golang.org/grpc/clientconn.go:1293 grpc: addrConn.createTransport failed to connect to {cockroachdb-4.cockroachdb-hs.cockroachdb.svc.cluster.local:26257 0 }. Err :connection error: desc = "transport: Error while dialing cannot reuse client connection". Reconnecting...
W181204 21:07:34.490657 402534 vendor/google.golang.org/grpc/clientconn.go:942 Failed to dial cockroachdb-4.cockroachdb-hs.cockroachdb.svc.cluster.local:26257: context canceled; please retry.
W181204 21:07:34.508977 402658 vendor/google.golang.org/grpc/clientconn.go:1293 grpc: addrConn.createTransport failed to connect to {cockroachdb-3.cockroachdb-hs.cockroachdb.svc.cluster.local:26257 0 }. Err :connection error: desc = "transport: Error while dialing dial tcp: lookup cockroachdb-3.cockroachdb-hs.cockroachdb.svc.cluster.local: no such host". Reconnecting...
E181204 21:07:34.640941 399676 util/log/crash_reporting.go:477 [n2,client=100.125.0.3:50340,user=uievent_pipeline] Reported as error f07eb7f662cb4d55910d91c71bd80f96
panic: runtime error: slice bounds out of range [recovered]
panic: panic while executing 1 statements: UPSERT INTO (, _, _, _, _) VALUES ($1, $2, more3), (more4000); caused by runtime error: slice bounds out of range

goroutine 399676 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc4288ec000, 0x3012380, 0xc4298e2080, 0x2754220, 0x4201da0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:646 +0x36f
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc4288ec000, 0x3012380, 0xc4298e2080)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:387 +0x61
panic(0x2754220, 0x4201da0)
/usr/local/go/src/runtime/panic.go:502 +0x229
github.com/cockroachdb/cockroach/pkg/sql.(*tableUpserter).atBatchEnd(0xc427033500, 0x3012440, 0xc435439380, 0xc42a801d00, 0xc4288ec418, 0xc436c5b100)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/tablewriter_upsert.go:417 +0x7e2
github.com/cockroachdb/cockroach/pkg/sql.(*upsertNode).BatchedNext(0xc42e21e2d0, 0x3012440, 0xc435439380, 0xc42a801dc0, 0xc4288ec418, 0x2879100, 0xc4288a5201, 0x7fee3c6d7998)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/upsert.go:331 +0x299
github.com/cockroachdb/cockroach/pkg/sql.(*rowCountNode).startExec(0xc44789da00, 0x3012440, 0xc435439380, 0xc42a801dc0, 0xc4288ec418, 0xc420062401, 0xc42eead250)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go:173 +0xd0
github.com/cockroachdb/cockroach/pkg/sql.startExec.func2(0x2ab7b94, 0x5, 0x3005880, 0xc44789da00, 0xc4271d2aa8, 0xc42eead260)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:640 +0x90
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1(0xc436c5b220, 0x2ab7b94, 0x5, 0x3005880, 0xc44789da00)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:134 +0x5f
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal(0xc436c5b220, 0x3005880, 0xc44789da00, 0x2ab7b94, 0x5)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:543 +0x378
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit(0xc436c5b220, 0x3005880, 0xc44789da00, 0xc4288a5de8, 0x6c2c0d)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:101 +0x8f
github.com/cockroachdb/cockroach/pkg/sql.walkPlan(0x3012440, 0xc435439380, 0x3005880, 0xc44789da00, 0x0, 0x2c12a80, 0x0, 0x0, 0xc435439470, 0x3012380, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:65 +0x193
github.com/cockroachdb/cockroach/pkg/sql.startExec(0x3012440, 0xc435439380, 0xc42a801dc0, 0xc4288ec418, 0x3005880, 0xc44789da00, 0xc420329880, 0x3012440)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:645 +0x10e
github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start(0xc42927a000, 0x3012440, 0xc435439380, 0xc43d6ca3c0, 0x266c1a0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:139 +0xe8
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcessorBase).Run(0xc42927a000, 0x3012440, 0xc435439380, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:730 +0x58
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).StartSync(0xc4402ac1c0, 0x3012440, 0xc435439380, 0x2c12298, 0xc4202940e0, 0x2fef500)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:602 +0x191
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc42093f100, 0xc44828ed80, 0xc427dc6480, 0xc4288a68d8, 0xc42bb04500, 0xc4288ec4b0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:253 +0x879
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc42093f100, 0x3012440, 0xc42aaf7cb0, 0xc4288ec4b0, 0xc44828ed80, 0xc427dc6480, 0x3005880, 0xc44789da00, 0xc42bb04500)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:746 +0x24c
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc4288ec000, 0x3012440, 0xc42aaf7cb0, 0xc4288ec418, 0x2, 0x7fee38c345b0, 0xc427dc65a0, 0x4823f00, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:982 +0x2d8
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc4288ec000, 0x3012440, 0xc42aaf7cb0, 0x3015480, 0xc4533f3770, 0x4823f00, 0x0, 0x0, 0xc42c5fe540, 0x6f, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:824 +0xa8a
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc4288ec000, 0x3012440, 0xc42aaf7cb0, 0x3015480, 0xc4533f3770, 0x4823f00, 0x0, 0x0, 0xc42c5fe540, 0x6f, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:402 +0xb3b
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc4288ec000, 0x3012440, 0xc42aaf7cb0, 0x3015480, 0xc4533f3770, 0x4823f00, 0x0, 0x0, 0xc42c5fe540, 0x6f, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:96 +0x341
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc4288ec000, 0x3012380, 0xc4298e2080, 0xc4209e69d8, 0x5400, 0x15000, 0xc4209e6a70, 0xc4519e62e0, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1169 +0x1400
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc420843770, 0x3012380, 0xc4298e2080, 0xc4288ec000, 0x5400, 0x15000, 0xc4209e6a70, 0xc4519e62e0, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:389 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl.func4(0xc420843770, 0x3012380, 0xc4298e2080, 0xc4288ec000, 0x5400, 0x15000, 0xc4209e6a70, 0xc4519e62e0, 0xc4519e62f0, 0xc42e5460e0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:309 +0x81
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).serveImpl
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:308 +0x107c

@jordanlewis
Copy link
Member

@knz can you PTAL?

@knz
Copy link
Contributor

knz commented Dec 6, 2018

I have the issue on the radar. Haven't found the root cause yet.

@knz knz added S-2-temp-unavailability Temp crashes or other availability problems. Can be worked around or resolved by restarting. A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. labels Dec 6, 2018
@blkerby
Copy link

blkerby commented Dec 10, 2018

I've explored this a little more. I found that the crashes occur more frequently if I bucket the data by ranges of keys (not the CockroachDB concept of ranges specifically). In this case it's more likely that duplicate keys could appear in a single UPSERT statement, so it led me to suspect that this could be what is triggering the crash (I noticed that in 2.0.0, this was not even allowed and would produce an error). Once a crash occurred, if I set up the client to retry, then I found it would consistently crash each of the CockroachDB nodes in turn, with availability only being restored for a moment before the next crash occurs; I saw 50+ crashes in a row this way without it making progress, so it appeared it might be a deterministic behavior.

I found that I can work around the issue by filtering the rows on the client side so that duplicate keys do not occur in the same statement. Since doing that, I have not observed the issue again.

I also found that this example reproduces the crash every time:

create table test_table4 (
  	id bigint primary key,
  	a bigint,
  	b bigint
);

insert into test_table4 (id, a) values
(123, 456),
(123, 456)
on conflict (id) do update set a = excluded.a

If I remove the "b bigint" from the CREATE TABLE statement, or if I modify the INSERT statement to include it, then the crash does not occur. So it appears it could have to do with this column implicitly being assigned a default value (of NULL).

@knz
Copy link
Contributor

knz commented Dec 10, 2018

Wow what a good analysis. Thank you so much!!! this will help us tremendously.

@knz knz removed their assignment Dec 14, 2018
@knz knz removed their assignment Dec 17, 2018
@BramGruneir BramGruneir self-assigned this Dec 17, 2018
@BramGruneir
Copy link
Member

Ok, I've been digging into this, and there's a disconnect between the tableupserter's existingRows (only 2 values) the columns in the fetchColByID (expecting 3 values).

I can get rid of the panic, but then we get hit by the difference. I'll keep digging into this.

Also, as a side note, postgres does not allow inserting and upserting a column in the same statement. By eliminating this ability, it would make the upsert logic much simpler and perhaps more efficient.

INSERT INTO test_table (id, a) VALUES
  (1234, 456), (1234, 4564)
  ON CONFLICT (id) DO UPDATE SET a = EXCLUDED.a;
ERROR:  ON CONFLICT DO UPDATE command cannot affect row a second time
HINT:  Ensure that no rows proposed for insertion within the same command have duplicate constrained values.

@ghost
Copy link

ghost commented Dec 17, 2018

CockroachDB used to give a similar error as Postgres. It appears that this pull request implemented the functionality which allows multiple changes to the same rows: #23698.

I do find the new functionality to be quite useful and would see a lot of benefit in keeping it if we can, but I can see there are tradeoffs here. One thing is the implication that the order of the rows matters, which could result in nondeterministic behavior, if for instance the inserted rows are supplied using a SELECT subquery without an ORDER BY clause. Of course, Postgres has other features which are non-deterministic (for instance, the order in which sequence ids are generated, e.g., if we're inserting into a table with a SERIAL column). We would just want to be sure that in case of an UPSERT with duplicate keys if an ordering is supplied then it is applied correctly (for instance, if ORDER BY is used in the subquery, or if VALUES is used); I'm not familiar with CockroachDB's internals, so I don't have a clear idea of how easy or hard that is to ensure.

@knz
Copy link
Contributor

knz commented Dec 17, 2018

@BramGruneir @BrentKerbySnap let us not get distracted from the bug at hand with a discussion on semantics.

Such a discussion is important and will be forthcoming when we revamp our mutations for performance in 2.2 and later releases, but for now we need to fix this bug which affects the 2.1 release.

BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Dec 18, 2018
There was an assumption that the row inserter and row updater had the same
columns in the same order and if that wasn't the case row inserter's columns
would be larger.

This assumption is incorrect, so to fix it, when storing the existing rows
(which are used to see if they conflicts with other rows further on in the
statement) instead of storing the row used for inputs, convert the rows
directly to those required by the row updater.

Fixes cockroachdb#32834.

Release note (bug fix): Fixed an issue in which if a nullable column wasn't
supplied in an INSERT ON CONFLICT DO UPDATE statement, it may cause a panic.
@BramGruneir
Copy link
Member

Just wanted to leave a comment here.

I've fixed the bug in #33245. When we rewrite our mutations, we'll have to consider this behaviour and decide if we want to keep it or not. I think we should try to keep it.

@knz
Copy link
Contributor

knz commented Dec 19, 2018

@BramGruneir thank you for the contribution! We need to find some way to provide the functionality to users, but the base behavior of INSERT ON CONFLICT is further constrained in a way I hadn't envisioned, related to #28842. I will prepare some notes that explain this in detail.

craig bot pushed a commit that referenced this issue Dec 20, 2018
33245: sql: fix panic in insert on conflict do update r=BramGruneir a=BramGruneir

There was an assumption that the row inserter and row updater had the same
columns in the same order and if that wasn't the case row inserter's columns
would be larger.

This assumption is incorrect, so to fix it, when storing the existing rows
(which are used to see if they conflicts with other rows further on in the
statement) instead of storing the row used for inputs, convert the rows
directly to those required by the row updater.

Fixes #32834.

Release note (bug fix): Fixed an issue in which if a nullable column wasn't
supplied in an INSERT ON CONFLICT DO UPDATE statement, it may cause a panic.

Co-authored-by: Bram Gruneir <[email protected]>
@craig craig bot closed this as completed in #33245 Dec 20, 2018
changangela pushed a commit to changangela/cockroach that referenced this issue Dec 20, 2018
There was an assumption that the row inserter and row updater had the same
columns in the same order and if that wasn't the case row inserter's columns
would be larger.

This assumption is incorrect, so to fix it, when storing the existing rows
(which are used to see if they conflicts with other rows further on in the
statement) instead of storing the row used for inputs, convert the rows
directly to those required by the row updater.

Fixes cockroachdb#32834.

Release note (bug fix): Fixed an issue in which if a nullable column wasn't
supplied in an INSERT ON CONFLICT DO UPDATE statement, it may cause a panic.
changangela pushed a commit to changangela/cockroach that referenced this issue Dec 20, 2018
There was an assumption that the row inserter and row updater had the same
columns in the same order and if that wasn't the case row inserter's columns
would be larger.

This assumption is incorrect, so to fix it, when storing the existing rows
(which are used to see if they conflicts with other rows further on in the
statement) instead of storing the row used for inputs, convert the rows
directly to those required by the row updater.

Fixes cockroachdb#32834.

Release note (bug fix): Fixed an issue in which if a nullable column wasn't
supplied in an INSERT ON CONFLICT DO UPDATE statement, it may cause a panic.
BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Jan 2, 2019
There was an assumption that the row inserter and row updater had the same
columns in the same order and if that wasn't the case row inserter's columns
would be larger.

This assumption is incorrect, so to fix it, when storing the existing rows
(which are used to see if they conflicts with other rows further on in the
statement) instead of storing the row used for inputs, convert the rows
directly to those required by the row updater.

Fixes cockroachdb#32834.

Release note (bug fix): Fixed an issue in which if a nullable column wasn't
supplied in an INSERT ON CONFLICT DO UPDATE statement, it may cause a panic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-mutations Mutation statements: UPDATE/INSERT/UPSERT/DELETE. 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. S-2-temp-unavailability Temp crashes or other availability problems. Can be worked around or resolved by restarting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants