runtime error : slice bounds out of range [recovered]

Please, can you include more details? What was the stack trace? What is your schema? Thanks.
I'm seeing this too. I'm trying to migrate data from cassandra to cockroach. I'm trying to do a substring on a column that has nulls (but shouldn't). Easy fix on my end by scrubbing the data before importing it but perhaps it helps you guys figure things out.
E190108 16:36:09.579106 307 sql/conn_executor.go:636 [n2,client=192.168.223.57:37158,user=root] a SQL panic has occurred while executing
"INSERT INTO chatmessages(spotname, id, iv, fromuser, fromversion, touser, toversion, datetime, data, mimetype, datasize, shareable, hashe
d, deleted) SELECT spotname, id, iv, fromuser, fromversion, touser, toversion, CAST(concat(substring(datetime, 1, 22), ':00') AS TIMESTAMP
TZ), data, mimetype, datasize, shareable, hashed, true FROM chatmessagesimport WHERE datetime IS NOT NULL ON CONFLICT (spotname, id) DO UP
DATE SET deleted = false": runtime error: slice bounds out of range
E190108 16:36:09.580144 307 util/log/crash_reporting.go:203 [n2,client=192.168.223.57:37158,user=root] a panic has occurred!
E190108 16:36:09.965921 307 util/log/crash_reporting.go:477 [n2,client=192.168.223.57:37158,user=root] Reported as error 6fa82140e131431596ca992857192e77
panic: runtime error: slice bounds out of range [recovered]
panic: panic while executing 1 statements: INSERT INTO _(_, _, _, _, _, _, _, _, _, _, _, _, _, _) SELECT _, _, _, _, _, _, _, CAST(concat(substring(_, _, _), _) AS TIMESTAMPTZ), _, _, _, _, _, _ FROM _ WHERE _ IS NOT _ ON CONFLICT (_, _) DO UPDATE SET _ = _; caused by runtime error: slice bounds out of range
goroutine 307 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc425da6000, 0x3032640, 0xc4289d3f00, 0x2770200, 0x4231d80)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:650 +0x36f
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc425da6000, 0x3032640, 0xc4289d3f00)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:387 +0x61
panic(0x2770200, 0x4231d80)
/usr/local/go/src/runtime/panic.go:502 +0x229
github.com/cockroachdb/cockroach/pkg/sql.(*tableUpserter).atBatchEnd(0xc428dc7500, 0x3032700, 0xc428dc2cf0, 0xc4280d3a00, 0xc425da6418, 0xc428d82700)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/tablewriter_upsert.go:417 +0x7e2
github.com/cockroachdb/cockroach/pkg/sql.(*upsertNode).BatchedNext(0xc426c025a0, 0x3032700, 0xc428dc2cf0, 0xc4280d3a40, 0xc425da6418, 0x2895e01, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/upsert.go:331 +0x299
github.com/cockroachdb/cockroach/pkg/sql.(*rowCountNode).startExec(0xc428d89d40, 0x3032700, 0xc428dc2cf0, 0xc4280d3a40, 0xc425da6418, 0x1, 0xc428e11250)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go:173 +0xd0
github.com/cockroachdb/cockroach/pkg/sql.startExec.func2(0x2ad5c1f, 0x5, 0x3025780, 0xc428d89d40, 0xc425b31228, 0xc428e11260)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:640 +0x90
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1(0xc428da5040, 0x2ad5c1f, 0x5, 0x3025780, 0xc428d89d40)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:134 +0x5f
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal(0xc428da5040, 0x3025780, 0xc428d89d40, 0x2ad5c1f, 0x5)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:543 +0x378
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit(0xc428da5040, 0x3025780, 0xc428d89d40, 0xc428075de8, 0x6c4069)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:101 +0x8f
github.com/cockroachdb/cockroach/pkg/sql.walkPlan(0x3032700, 0xc428dc2cf0, 0x3025780, 0xc428d89d40, 0x0, 0x2c316f8, 0x0, 0x0, 0xc428dee030, 0x3032640, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:65 +0x193
github.com/cockroachdb/cockroach/pkg/sql.startExec(0x3032700, 0xc428dc2cf0, 0xc4280d3a40, 0xc425da6418, 0x3025780, 0xc428d89d40, 0xc4209fca80, 0x3032700)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:645 +0x10e
github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start(0xc428d90a00, 0x3032700, 0xc428dc2cf0, 0xc426057b38, 0x2687c40)
/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(0xc428d90a00, 0x3032700, 0xc428dc2cf0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:730 +0x58
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).StartSync(0xc4280d3dc0, 0x3032700, 0xc428dc2cf0, 0x2c30f10, 0xc428d82540, 0x300f380)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:607 +0x191
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc4207eec00, 0xc428db49c0, 0xc4280f5ef0, 0xc4280768d8, 0xc428dac280, 0xc425da64b0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:253 +0x879
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc4207eec00, 0x3032700, 0xc428d84330, 0xc425da64b0, 0xc428db49c0, 0xc4280f5ef0, 0x3025780, 0xc428d89d40, 0xc428dac280)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:758 +0x24c
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc425da6000, 0x3032700, 0xc428d84330, 0xc425da6418, 0x2, 0x7f184bc40428, 0xc428d8a000, 0x0, 0x0, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:982 +0x2d8
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc425da6000, 0x3032700, 0xc428d84330, 0x3035740, 0xc428d869b0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:824 +0xa8a
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc425da6000, 0x3032700, 0xc428d84330, 0x3035740, 0xc428d869b0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:402 +0xb3b
@2fours thanks - this is helpful. What version are you on? And could you please include SHOW CREATE TABLE for both of those tables as well?
I'm on 2.1.3.
IMPORT TABLE chatmessagesimport (
username STRING,
spotname STRING,
id INT,
iv STRING,
fromuser STRING,
fromversion STRING,
touser STRING,
toversion STRING,
datetime STRING,
data STRING,
mimetype STRING,
datasize int,
shareable BOOL,
hashed BOOL,
PRIMARY KEY (username, spotname, id)
) CSV DATA ('nodelocal:///chatmessages.csv.gz') with nullif='';
CREATE TABLE chatmessages (
spotname STRING,
id INT,
iv STRING,
fromuser STRING,
fromversion STRING,
touser STRING,
toversion STRING,
datetime TIMESTAMPTZ,
data STRING,
mimetype STRING,
datasize int,
shareable BOOL,
hashed BOOL,
deleted BOOL,
sig STRING,
PRIMARY KEY (spotname, id)
);
[email protected]:26257/surespot> show create chatmessagesimport;
table_name | create_statement
+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
chatmessagesimport | CREATE TABLE chatmessagesimport (
| username STRING NOT NULL,
| spotname STRING NOT NULL,
| id INT NOT NULL,
| iv STRING NULL,
| fromuser STRING NULL,
| fromversion STRING NULL,
| touser STRING NULL,
| toversion STRING NULL,
| datetime STRING NULL,
| data STRING NULL,
| mimetype STRING NULL,
| datasize INT NULL,
| shareable BOOL NULL,
| hashed BOOL NULL,
| CONSTRAINT "primary" PRIMARY KEY (username ASC, spotname ASC, id ASC),
| FAMILY "primary" (username, spotname, id, iv, fromuser, fromversion, touser, toversion, datetime, data, mimetype, datasize, shareable, hashed)
| )
(1 row)
Time: 9.994664ms
[email protected]:26257/surespot> show create chatmessages;
table_name | create_statement
+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
chatmessages | CREATE TABLE chatmessages (
| spotname STRING NOT NULL,
| id INT NOT NULL,
| iv STRING NULL,
| fromuser STRING NULL,
| fromversion STRING NULL,
| touser STRING NULL,
| toversion STRING NULL,
| datetime TIMESTAMPTZ NULL,
| data STRING NULL,
| mimetype STRING NULL,
| datasize INT NULL,
| shareable BOOL NULL,
| hashed BOOL NULL,
| deleted BOOL NULL,
| sig STRING NULL,
| CONSTRAINT "primary" PRIMARY KEY (spotname ASC, id ASC),
| FAMILY "primary" (spotname, id, iv, fromuser, fromversion, touser, toversion, datetime, data, mimetype, datasize, shareable, hashed, deleted, sig)
| )
(1 row)
Time: 9.612316ms
I'm still getting the same error even though I've deleted rows with null datetime from the import table so not sure what's going on.
If I change the query to use on conflict do nothing instead I don't get the error, but this sort of hampers my migration.
@knz please take a look when you've got the chance - the panic is on line 417 of this snippet.
https://github.com/cockroachdb/cockroach/blob/0c87b11cb99ba5c677c95ded55dcba385928474e/pkg/sql/tablewriter_upsert.go#L416-L421
I think dup with https://github.com/cockroachdb/cockroach/issues/32834#issuecomment-445865612 and I solve this problem
we would like to keep the issue open if that's OK with you
I have rewritten this part of the code a few times since. I believe this issue has been addressed.