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.96) (envelope-from ) id 1wFOL5-005349-1V for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 03:33:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFOL3-00BXfV-2H for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 03:33:21 +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.96) (envelope-from ) id 1wFOL3-00BXfN-1L for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 03:33:21 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFOL1-00000002Bov-17R4 for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 03:33:20 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-35f9ab079bdso3114258a91.2 for ; Tue, 21 Apr 2026 20:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776828799; cv=none; d=google.com; s=arc-20240605; b=h5RRS18hXK44mXyno3mb4pLJE2LcF49Gpw3KXxjYvAacnRXW+NVja2FJ/hRnxExHOD KFmn1bA3x9wFUotg/nrb7Sq0ZWtZ2kIB4BDOoAKfTa9S1tHUCSBYaqW/y/aTbEtjETLI RdYf9esNf9wV3bP/46F2m6bSut6M6w8fX/6ZpfF+Nv4jyG1bzHr/VQ2oyzrpCPaUrbVr dqQdd9U6lT0GxzJEgI30C2o57ftCRPDkPJv6aVkVzkoZe9vcXlXWZuPTQIzgvc/CwNyi cgav10b2RkLYOhVb0cxEW9ubY9iCk6kjUx13uCkxmdR9ZS6zRv0hK1suVcalEqyJMj+7 6eyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=j+hv2Mr0oWGK8CEd2uGy021hktF7T++vk1V+YiSG0ok=; fh=dhFKMubU43L/Iyj67vWwIJh6c3oO3idgRqyHxJ874yA=; b=T4C28HF51YefVN8KGz3RiN7sGtMAUcGE0/penL3Q0ilch6TIEPMyT3zKkEQMPo9lNq 57JMpLLw3hSz2d2ewEYMiIqHNjvPhdgK914lnqqnLnMLtqqAzDeog7B2zbWhh3biNJab OsCt8UaiC35Y9E0EhONSGGSzrg92ruW3dTfuJQ2qSOCGNXXLwOspAs3C+fIwzaN8gPdR DWlNXsa3zIcV/scSyKzbWEQasj81SZcuy6wfh+nhX+eczXeifObXz/jojKVkf3vhmUJf R5cmzFQVHc7WZmx2SW2i7HpXUBO4jNYP524gJqmDN7yzDWYCjFKTslr/QJkENpREiGhv 8vCQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776828799; x=1777433599; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=j+hv2Mr0oWGK8CEd2uGy021hktF7T++vk1V+YiSG0ok=; b=cRbjseJkk61UOZWI0HZeXfH3qM4nuchSZ+tXOzNffQffiXk0UEGf09NZO/gI3XZL8e DF6Mkmc4RJxr2+/ZSh+BtKh6pGhYWvro2AERpd0oy6mVSYYtI0rkcjb13vRtbgA4yXWn l3Lb5QQij9aZ48gMHiwCzMgBj7lpN9oY4cIBNv5u1gT23EQaqahdZALm6ghOk11G3uLA WyG8HoV0Y4N9iiOFQG+bW/iF2ebVzuZfJbAks0askFVmXEbuB0zXBYcocmGP0gxb3IiF fR3sr3eypEd6tyqEZ31bIeax42WxD2EhAQAMXLTp6Yw/Bj6qcC50oJRVcwnj3ObJxjKV hcKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776828799; x=1777433599; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=j+hv2Mr0oWGK8CEd2uGy021hktF7T++vk1V+YiSG0ok=; b=QypGtk/riQ1Z5El/pnQLqcuhYVyz6jJJC5yQABAncbqqVwyM4M4HQ6Eabph3gVK273 7Exypq5Ob/M9Dita06FM1M/1BwDfHB6dldMbHyTd0+kIaOTvAKbYV/l3vVTCc4uWQ/OK +0OmaZNPFnWg2X8qNS4L4x5R0+TZn4UIrQcF3ABxtONCR+LqjasxMRiyEZZ0Mj1OQ6Bd tYG4vbWADGcQQXxXt9Kgg6pV5Vc+r8/qcebfsaewZkEq1yVN9tJ41Qk+ZrVMjxdxx+N3 zxeFGFY2KiZ6t1nQamBWEWK4G3MlZakWrtBxLnf2f/PuX8QnKy9RsfQYWagbc1eaegW3 OxXA== X-Gm-Message-State: AOJu0YxxkhKF8Gqp/HW4VW54LX6C+yDO8khQs3jZH0F0BXHgO+Evp/LP 3zfbigonmHZ3eyEG+o4dQgZjLB3+EAEkMAahIH5KjxBaw85fRvdMSVC+lGsUDdksqZ3CXqA5RSs Ev8lyX7zVDwJCDih6K08ugffe280mnSM= X-Gm-Gg: AeBDiesXwD4QxRB7U2x3bW1aGocvuNxkW4adFX5vF8AIVNcZOU+WHhOzNMyV3vXqi1R O3rbpiHkUDAkSi+5t2gyQYpABNZcWXUWF3jN7N4Vg4g6w0g21hCrFvqQ8HAApYL8prGKLW2Z18j 532gYqK7aKfHYaRCEIua6Q5tCrZUlE6VXHLzKwLSkPLVSOEFg9QVD6mGIjQr8KCegZzOsSRwORr 5Ia15e55+lb3/BDzxWkEoeOVo0q/gBJwil7bQMXziPhpfk0C40x1taSUuS80cdq8Ja5wrCx+/TC M8mxcT41EPBOXJ3qxB0FjUb8Tfnb7u+2pOEAdep5MjM1iA26Ns20HAeCyU/NOlav X-Received: by 2002:a17:90b:394e:b0:359:d54:846f with SMTP id 98e67ed59e1d1-361403f10f9mr20205339a91.7.1776828798547; Tue, 21 Apr 2026 20:33:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 22 Apr 2026 09:03:06 +0530 X-Gm-Features: AQROBzDy4JgwI0Pj2hg4qBWVye4kHYO2zC36ZF7yN6IbHi8pjFfCmkEUxMOyAgI Message-ID: Subject: Re: Warn on missing replica identity in CREATE/ALTER PUBLICATION To: =?UTF-8?B?5Y2X5ouT5byl?= Cc: pgsql-hackers@lists.postgresql.org, shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 21, 2026 at 11:06=E2=80=AFAM =E5=8D=97=E6=8B=93=E5=BC=A5 wrote: > > Hi hackers, > > CREATE PUBLICATION silently succeeds even when target tables lack a > usable replica identity, while the publication publishes UPDATE and/or > DELETE. The error only surfaces later at replication time: > > ERROR: cannot delete from table "foo" because it does not have a > replica identity and publishes deletes > > This gap has caused real production incidents =E2=80=94 in one case, a CD= C > pipeline using FOR TABLES IN SCHEMA included a table without a primary > key, and replication stalled for hours before the cause was found. > > I'd like to propose emitting a WARNING at publication creation/alter > time when this mismatch exists. The check would cover all paths: > > - CREATE PUBLICATION ... FOR TABLE / FOR TABLES IN SCHEMA / FOR ALL TABLE= S > - ALTER PUBLICATION ... ADD/SET TABLE / ADD/SET TABLES IN SCHEMA > - ALTER PUBLICATION ... SET (publish =3D 'update, delete') > > The approach I'm considering is a publication-level check that runs > after the final publication state is known, scanning the effective set > of published tables via GetIncludedPublicationRelations() / > GetAllSchemaPublicationRelations() / GetAllPublicationRelations() and > checking each table's replica identity. > > I have a working prototype for the FOR TABLE / ADD TABLE paths. A few > open questions before I post a full patch: > > 1. For FOR ALL TABLES, the check would scan pg_class. Acceptable for > a DDL operation, or too expensive? > > 2. Should we cap the number of warnings when many tables are affected? > > 3. Should this be controllable via a GUC, or is a simple WARNING > sufficient? > > Thoughts welcome. > Before we dive deeper into this idea, I=E2=80=99d like to highlight that there=E2=80=99s an ongoing thread addressing a similar issue. The proposed approach there is to implement a fallback RI in such scenarios to prevent replication-time errors caused by missing RI. Could you please review this ([1]) and confirm whether it meets your requirements? https://www.postgresql.org/message-id/flat/CAEoWx2mMorbMwjKbT4YCsjDyL3r9Mp%= 2Bz0bbK57VZ%2BOkJTgJQVQ%40mail.gmail.com thanks Shveta