From e1dd1f924e1990c604ce353c23fc6c0d2dc996a8 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Mon, 3 Nov 2025 12:57:09 -0800 Subject: [PATCH] Doc: cover index CONCURRENTLY causing errors in INSERT ... ON CONFLICT. Author: Mikhail Nikalayeu Reviewed-by: Noah Misch Discussion: https://postgr.es/m/CANtu0ojXmqjmEzp-=aJSxjsdE76iAsRgHBoK0QtYHimb_mEfsg@mail.gmail.com Backpatch-through: 13 --- doc/src/sgml/ref/insert.sgml | 9 +++++++++ src/backend/optimizer/util/plancat.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml index 6f0adee1a12..954ee3af3a1 100644 --- a/doc/src/sgml/ref/insert.sgml +++ b/doc/src/sgml/ref/insert.sgml @@ -556,6 +556,15 @@ INSERT INTO table_name [ AS + + + While CREATE INDEX CONCURRENTLY or REINDEX + CONCURRENTLY is running on a unique index, INSERT + ... ON CONFLICT statements on the same table may unexpectedly + fail with a unique violation. + + + diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 002cea0c116..b0eabeac058 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -637,6 +637,11 @@ get_relation_foreign_keys(PlannerInfo *root, RelOptInfo *rel, * the purposes of inference. If no opclass (or collation) is specified, then * all matching indexes (that may or may not match the default in terms of * each attribute opclass/collation) are used for inference. + * + * Note: during index CONCURRENTLY operations, different transactions may + * reference different sets of arbiter indexes. This can lead to false unique + * constraint violations that wouldn't occur during normal operations. For + * more information, see insert.sgml. */ List * infer_arbiter_indexes(PlannerInfo *root) -- 2.47.3