Description
In a multi-region database, callingIMPORT INTO on a REGIONAL BY ROW table could violate UNIQUE constraints, including PRIMARY KEY constraints, resulting in duplicate keys.
Affected versions: v21.2.0 to v21.2.7
Statement
The fix was applied in the maintenance release of .Mitigation
Users of CockroachDB v21.2.0 to v21.2.7 who have usedIMPORT INTO must audit their REGIONAL BY ROW tables with UNIQUE constraints to ensure these tables do not contain UNIQUE constraint violations.
Users should also upgrade to v21.2.8 or a later version.
v21.2.6 or later
Users of CockroachDB v21.2.6 and later have access to the following built-in functions, which can be used to easily validateUNIQUE constraints:
SELECT crdb_internal.revalidate_unique_constraints_in_all_tables();SELECT crdb_internal.revalidate_unique_constraints_in_table('table_name');SELECT crdb_internal.revalidate_unique_constraint('table_name', 'constraint_name');
Prior to v21.2.6
Users of CockroachDB releases prior to v21.2.6 may audit the table for duplicate keys by running a query of the following form, for eachUNIQUE constraint that may have been affected:
UNIQUE constraint violations. To fix the violations, update all but one of the duplicate keys with a different value.
Impact
REGIONAL BY ROW tables spanning multiple regions could contain non-unique data in unique columns if IMPORT INTO was used to import data with duplicate keys. Versions affected include v21.2.0 to v21.2.7, v22.1.0-alpha.1 to v22.1.0-alpha.5, and v22.1.0-beta.1.
Please reach out to the support team for more information.
