cockroachdb / cockroachdb/cockroach

import: IMPORT INTO on an empty table fails on a checkForKeyCollisions error

Open
#97,219 4 comments 0 reactions 0 assignees View on GitHub
A-import branch-master C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

In the [linked](https://github.com/cockroachlabs/support/issues/2051) escalation, we confirmed that an IMPORT INTO job which loaded around 5 billion rows into a table failed on a `CheckForKeyCollisions` error. Notably, the table was **empty** and had a non visible primary key generated by `gen_random_uuid()`. This failure implies that we generated identical keys for two _different_ imported rows (different values). We're not yet sure why, but it likely related to how import overrides the unique ID generation process, described [here](https://github.com/cockroachdb/cockroach/blob/6d22e25358435e4aa9e065c7c8a31fdfdb91c6ee/pkg/sql/row/expr_walker.go#L217). Note, to generate _uuid_'s import seeds uuid generation with a `unique_rowid`. The codepath is described [here.](https://cockroachlabs.slack.com/archives/C0168LW5THS/p1675966988684039?thread_ts=1675796933.385789&cid=C0168LW5THS)

We understand the root cause of a related error where a `CheckForKeyCollisions` error fails the second of _two_ sequential imports on a table, described [here](https://github.com/cockroachdb/cockroach/issues/96885).

Accompanying slack [thread](https://cockroachlabs.slack.com/archives/C0168LW5THS/p1675796933385789).

gz#15706

Jira issue: CRDB-24616

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.