yugabyte-db icon indicating copy to clipboard operation
yugabyte-db copied to clipboard

[YSQL] Spurious duplicate key constraint while creating unique index using online index backfill

Open deeps1991 opened this issue 2 years ago • 1 comments

Jira Link: DB-2962

Description

This error was noted while creating unique index using online index backfill:

person_core=# create unique index testidx on test(testid) include (profile_id, card_id, email_address);
ERROR:  Aborted: ERROR:  duplicate key value violates unique constraint "testidx"

However, no duplicate keys were found:

person_core=# select test_id from test group by test_id having count(test_id) > 1;

 test_id
--------------
(0 rows)


person_core=# select test_id, count(*) from test group by test_id having count(*) > 1;
 test_id | count
--------+-------
(0 rows)

Note that adding a nonconcurrent index succeeded without errors. Also note that there were concurrent INSERTs running while the DDL was happening.

deeps1991 avatar Jul 15 '22 17:07 deeps1991