# Technical Advisory 71553

Publication date: November 8, 2021

## Description

Secondary unique indexes that are created as a result of running two `ALTER PRIMARY KEY` statements on the same table can be misinterpreted by the vectorized engine, potentially creating incorrect results. Precisely, if you create a new primary key with `ALTER PRIMARY KEY`, and then edit the primary key again with a second `ALTER PRIMARY KEY`, the secondary unique index that was the primary key created by the first `ALTER PRIMARY KEY` statement will be affected by this issue.

CockroachDB versions 20.2 and 21.1 are affected by this bug, until maintenance versions 20.2.18 and 21.1.12.

## Statement

This bug was resolved in CockroachDB by PR 71545, which corrects the bug in the vectorized engine that caused the database to return incorrect results when reading unique secondary indexes that were created as a result of an `ALTER PRIMARY KEY`.

The fix has been applied to maintenance versions 20.2.18 and 21.1.12 of CockroachDB.

This public issue is tracked by issue 71553.

## Mitigation

Users of CockroachDB are encouraged to upgrade to a maintenance version with the fix applied.

To work around the issue without upgrading, you can:

- Rebuild any unique secondary indexes created as a result of an `ALTER PRIMARY KEY` statement, using `DROP INDEX` and `CREATE INDEX`.
- Temporarily disable the vectorized engine by running `SET CLUSTER SETTING sql.defaults.vectorize = off`.

## Impact

SQL statements that used secondary unique indexes that were created as a result of an `ALTER PRIMARY KEY` statement can return incorrect results.

Please reach out to the support team if you need more information or assistance.