Open cockroach-sentry opened 9 months ago
Repro:
root@localhost:26257/defaultdb> set expect_and_ignore_not_visible_columns_in_copy=true;
SET
Time: 1ms total (execution 1ms / network 0ms)
root@localhost:26257/defaultdb> create table t (x int primary key, y int, index foo ((x + y)));
CREATE TABLE
Time: 26ms total (execution 26ms / network 0ms)
root@localhost:26257/defaultdb> alter table t add column z int not visible;
ALTER TABLE
Time: 259ms total (execution 259ms / network 0ms)
root@localhost:26257/defaultdb> copy t from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 1 2 3
>> \.
Result (server-side):
* ERROR: a panic has occurred!
* runtime error: slice bounds out of range [4:3]
* (1) attached stack trace
* -- stack trace:
* | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1
* | github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:965
* | [...repeated from below...]
* Wraps: (2) attached stack trace
* -- stack trace:
* | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1
* | github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:965
* | runtime.gopanic
* | GOROOT/src/runtime/panic.go:770
* | runtime.goPanicSliceB
* | GOROOT/src/runtime/panic.go:154
* | github.com/cockroachdb/cockroach/pkg/sql.(*copyMachine).maybeIgnoreHiddenColumnsBytes
* | github.com/cockroachdb/cockroach/pkg/sql/copy_from.go:1230
* | github.com/cockroachdb/cockroach/pkg/sql.(*copyMachine).readTextTuple
* | github.com/cockroachdb/cockroach/pkg/sql/copy_from.go:1240
* | github.com/cockroachdb/cockroach/pkg/sql.(*copyMachine).readTextData
The issue is that while we check that the supplied rows match up to visible
+ hidden
columns, some columns are not either of those things, which leads to the indexes in expectedHiddenColumnIdxs
being out of range for the input rows.
https://github.com/cockroachdb/cockroach/blob/d45a65e08d45383aade2bcffdcdbe72a0cc279b1/pkg/sql/copy_from.go#L832-L835
In the case of the repro above, the expression index adds an inaccessible
crdb_internal_idx_expr
column, which offsets the added hidden column by one.
This issue was auto filed by Sentry. It represents a crash or reported error on a live cluster with telemetry enabled.
Sentry Link: https://cockroach-labs.sentry.io/issues/5003119240/?referrer=webhooks_plugin
Panic Message:
Stacktrace (expand for inline code snippets):
[src/runtime/asm_arm64.s#L1171-L1173](src/runtime/asm_arm64.s#L1171-L1173) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/pgwire/conn.go#L309-L311](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/pgwire/conn.go#L309-L311) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L901-L903](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L901-L903) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L2104-L2106](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L2104-L2106) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L2363-L2365](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L2363-L2365) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L3152-L3154](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L3152-L3154) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor_exec.go#L3082-L3084](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor_exec.go#L3082-L3084) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L3165-L3167](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L3165-L3167) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L580-L582](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L580-L582) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L643-L645](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L643-L645) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L800-L802](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L800-L802) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L823-L825](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L823-L825) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L811-L813](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/copy_from.go#L811-L813) [GOROOT/src/runtime/panic.go#L138-L140](GOROOT/src/runtime/panic.go#L138-L140) [GOROOT/src/runtime/panic.go#L883-L885](GOROOT/src/runtime/panic.go#L883-L885) [https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L899-L901](https://github.com/cockroachdb/cockroach/blob/d7e9824b4cd6ebf7a8548156f2a772ae6648257d/pkg/sql/conn_executor.go#L899-L901)Tags
Jira issue: CRDB-36269