diff options
| author | Álvaro Herrera | 2025-12-11 19:56:37 +0000 |
|---|---|---|
| committer | Álvaro Herrera | 2025-12-11 19:56:37 +0000 |
| commit | 81f72115cf189b0a428d3efca2e4beb02b825111 (patch) | |
| tree | eeb97b0c6fd1f59768f0f2725bfc0d0e5bc9193a /src/backend/optimizer | |
| parent | b65f1ad9b12767dbd45d9588ce8ed2e593dbddbf (diff) | |
Fix infer_arbiter_index for partitioned tables
The fix for concurrent index operations in bc32a12e0db2 started
considering indexes that are not yet marked indisvalid as arbiters for
INSERT ON CONFLICT. For partitioned tables, this leads to including
indexes that may not exist in partitions, causing a trivially
reproducible "invalid arbiter index list" error to be thrown because of
failure to match the index. To fix, it suffices to ignore !indisvalid
indexes on partitioned tables. There should be no risk that the set of
indexes will change for concurrent transactions, because in order for
such an index to be marked valid, an ALTER INDEX ATTACH PARTITION must
run which requires AccessExclusiveLock.
Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/17622f79-117a-4a44-aa8e-0374e53faaf0%40gmail.com
Diffstat (limited to 'src/backend/optimizer')
| -rw-r--r-- | src/backend/optimizer/util/plancat.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index e553afb7f01..bf45c355b77 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -1000,6 +1000,15 @@ infer_arbiter_indexes(PlannerInfo *root) continue; /* + * Ignore invalid indexes for partitioned tables. It's possible that + * some partitions don't have the index (yet), and then we would not + * find a match during ExecInitPartitionInfo. + */ + if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && + !idxForm->indisvalid) + continue; + + /* * Note that we do not perform a check against indcheckxmin (like e.g. * get_relation_info()) here to eliminate candidates, because * uniqueness checking only cares about the most recently committed |
