Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vFhNu-00GrF3-Gw for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 23:21:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vFhNs-00EynC-NX for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 23:21:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vFhNs-00Eyn4-6i for pgsql-hackers@lists.postgresql.org; Sun, 02 Nov 2025 23:21:15 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vFhNl-0057O2-1L for pgsql-hackers@postgresql.org; Sun, 02 Nov 2025 23:21:13 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-28e7cd6dbc0so48257555ad.0 for ; Sun, 02 Nov 2025 15:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1762125668; x=1762730468; darn=postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=i4RB+/5lXKfifq1AXoz47IaMhwPzYf+fuWRZ3oLwWD4=; b=YwmIStSP/GXWLIRs411T1HCr1oDrVf6HO8D3PlmspvXv8HYBYZTPl6oaZhymPB3RtT eAKFsAkAvqpD4m7wkxPFylV6WztUeEOTm0W4NpjuR4MlcsL/J6xadsy17OXnPVUF4ZHn sz7mj7bxj1+40rfIPDIWSQsU4t7pUp5SEdyv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762125668; x=1762730468; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=i4RB+/5lXKfifq1AXoz47IaMhwPzYf+fuWRZ3oLwWD4=; b=jBTAYS54HjgEbZdAq6jxiq+Zzt8B2/e0jD7iuYVB2rzLJeSk1kgPfCwWsuJ1bU8fuK I6RYjwJ8xIhIrOqX0Dt9OZJTf5OcW91FmmtM0xzXSBvWcUIEMGM0VhfAcyoC1GGJja6E D54AlYXg6H974pXvFTnUGiUSXKeav1QFZms37lz56QBadc2DBJEwXB0VEuqRDrjbbLwx IwEAUABwDPvirOLIIKsMB+4iGh9KINQFOGQAn0/8q3LcFmx58ucj+aHi4uB5HYJoaEnt 5MdlF7Ic9EznWY3WL6xybUych+bhW8W4VWx07MypYCO0h0n0fPPgMU9msU8ElhGCpHtk 8dOQ== X-Forwarded-Encrypted: i=1; AJvYcCVm4mEgCXqNf7NUV9R2aqtuhLC9i/C5mlM3YsiIk4rAcvNc5y5zZISYLfOiBro/7wpzBZ9S+03A6ypWAuW8@postgresql.org X-Gm-Message-State: AOJu0Yw+zCifQwZmyrtdRt+hC6VVXz+BBKFo8T/rZSBWncWsrCPSx5Zp Wzvodv9dmttGpjy0NGdc0QpA5BX65agoaPfemacU6D9AFBA4nnT7YMvYu0zLZEx27g== X-Gm-Gg: ASbGnctjziw7aChG6fh+x13UswGHMTJhN8UO0tN/0TZEYKOxXYffTeZhjGXt/mWKmBs xoirQOfmDTqoF49V4aTqeHvpmX9oHc03bd6EtA0Wfonfx6eo2kHQHlea0tzH9xrkixNMTW+o9bu CzrLxBVhqZJv143B/We8bQz43yYmo5c5Y1SAOg+wLLI+qakAVGsWHEDb6Tmjl5LLJIkuH4s5zZX LsWeSKXuMP5ARYvSZdUqx+DnF/CblQorTNwSbA4gp/InS2oIuIGnAqrlmZUjd4ABczhSQ4dl7QA SEPP0X3sJlRNr55f2u/7QkhOBgU4r5LI3iihpkgPLqf1uWdIJEHJk9M2DTmNN3+qrEMOXdNOIMA QcwwEngGODYvEhp9UhF1BFf9osiLp389artRqd6A5YeAjAockty8SeR0qND/fXkChzmSccKn/+z OalI3vMd9J+fQNj68R1rAIPOc13LG2mhkBpJYNhc/xigfCLIw= X-Google-Smtp-Source: AGHT+IHU8WFA5A8+W3tg+PnOcfcbWl9xuaOYTqaOxlDef+KXjTTVCb2NyIuKe8vgHH3pNSz+Jw8imQ== X-Received: by 2002:a17:902:e88d:b0:295:8662:6a4e with SMTP id d9443c01a7336-29586627043mr50031455ad.47.1762125667720; Sun, 02 Nov 2025 15:21:07 -0800 (PST) Received: from rfd.leadboat.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-295688c68f0sm51694215ad.41.2025.11.02.15.21.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Nov 2025 15:21:06 -0800 (PST) Date: Sun, 2 Nov 2025 15:21:05 -0800 From: Noah Misch To: Mihail Nikalayeu Cc: Michael Paquier , PostgreSQL Hackers Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY Message-ID: <20251102232105.a3@rfd.leadboat.com> References: <20251027180606.f4.nmisch@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="huDzM1hR5qFLbvXI" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --huDzM1hR5qFLbvXI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Oct 28, 2025 at 02:19:00AM +0100, Mihail Nikalayeu wrote: > On Mon, Oct 27, 2025 at 7:06 PM Noah Misch wrote: > > Yes, I'm happy to push a patch documenting it. Would you like to propose the > > specific doc patch? I regret lacking the bandwidth to review the fix patches. > > Of course! > > First version in attachment, waiting for your comment. Thanks. Does "ON CONFLICT ON CONSTRAINT constraint_name" avoid the problem w/ concurrent REINDEX CONCURRENTLY? A search of the thread found no mention of "ON CONSTRAINT". It seems safe to assume that clause would avoid problems w/ CREATE INDEX CONCURRENTLY, but that's less certain for REINDEX. The attached version has these changes: - Mention ON CONSTRAINT as a workaround. Will remove if you find or suspect it's not effective. - Limit the doc change to ON CONFLICT. I think mentioning it at the INDEX commands is undue emphasis. - Use term "unique violation", a term used earlier on the same page, instead of "duplicate key ...". - Remove the internals-focused point about the brief window. - Remove some detail I considered insufficiently surprising, e.g. the point about "compatible with the index being built". --huDzM1hR5qFLbvXI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="doc-concurrently-on-conflict-v2nm.patch" From: Noah Misch 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 diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml index 3f13991..f88ea78 100644 --- a/doc/src/sgml/ref/insert.sgml +++ b/doc/src/sgml/ref/insert.sgml @@ -594,6 +594,17 @@ 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. Using ON CONFLICT ON + CONSTRAINT + constraint_name avoids this, by disabling inference. + + + --huDzM1hR5qFLbvXI--