From 0b2717f70e45899d43049f16cb74c8381ab9e2ec Mon Sep 17 00:00:00 2001 From: Mikhail Nikalayeu Date: Tue, 28 Oct 2025 01:16:13 +0100 Subject: [PATCH v1] doc: Document potential failure scenarios for concurrent `INSERT ... ON CONFLICT` during CONCURRENTLY index operation on the same table. Author: Mikhail Nikalayeu Reviewed-by: Noah Misch Discussion: https://postgr.es/m/CANtu0ojXmqjmEzp-=aJSxjsdE76iAsRgHBoK0QtYHimb_mEfsg@mail.gmail.com --- doc/src/sgml/ref/create_index.sgml | 10 ++++++++++ doc/src/sgml/ref/insert.sgml | 17 +++++++++++++++++ doc/src/sgml/ref/reindex.sgml | 11 +++++++++++ 3 files changed, 38 insertions(+) diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml index b9c679c41e8..5ae7f1a1520 100644 --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -707,6 +707,16 @@ Indexes: partitioned index is a metadata only operation. + + + While CREATE INDEX CONCURRENTLY is running on a unique + index, concurrent INSERT ... ON CONFLICT statement on + the same table that uses an index compatible with the index being built + may unexpectedly fail with duplicate key constraint violation error. + See for more details. + + + diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml index 3f139917790..dc4b341ca3e 100644 --- a/doc/src/sgml/ref/insert.sgml +++ b/doc/src/sgml/ref/insert.sgml @@ -594,6 +594,23 @@ INSERT INTO table_name [ AS + + + If CREATE INDEX CONCURRENTLY or REINDEX + CONCURRENTLY is running on a unique index (or on a table + containing unique indexes), concurrent INSERT ... ON CONFLICT + statements on the same table may unexpectedly fail with duplicate key + constraint violation errors. This can occur when the statement uses an + index that is either compatible with the index being built or rebuilt, + or is itself being reindexed. Both DO UPDATE and + DO NOTHING conflict actions are affected. + + + These failures only occur during a brief window when the system catalogs + are being modified, not throughout the entire index build or rebuild process. + + + diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml index c4055397146..9b65b81615e 100644 --- a/doc/src/sgml/ref/reindex.sgml +++ b/doc/src/sgml/ref/reindex.sgml @@ -513,6 +513,17 @@ Indexes: in the pg_stat_progress_create_index view. See for details. + + + + While REINDEX CONCURRENTLY is running on a unique + index or on a table containing unique indexes, concurrent + INSERT ... ON CONFLICT statement on the same table + that uses an index compatible with any of the indexes being rebuilt + may unexpectedly fail with duplicate key constraint violation errors. + See for more details. + + -- 2.43.0