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 1vaAvD-004hzR-2W for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Dec 2025 10:56:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vaAvC-00GXqz-0B for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Dec 2025 10:56:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaAvB-00GXqr-2O for pgsql-bugs@lists.postgresql.org; Mon, 29 Dec 2025 10:56:18 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vaAvA-003NzV-0K for pgsql-bugs@lists.postgresql.org; Mon, 29 Dec 2025 10:56:18 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-8035e31d834so6357906b3a.2 for ; Mon, 29 Dec 2025 02:56:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767005774; x=1767610574; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=LbDnyyO7w1r4F82BBuldcjk1kaxuKrxtUVsfOZamK4Y=; b=G2SMF0VKOqutajHrcIGnM01WDpr0nQoEuWb021UxBwPwVbSN1gGAdRV0zL/4L8c0iM 7nl2t8zAD87Mw56uz3vTVoEtq+R335mvcAni5kZlkDLB5O/O6iyoYJECeJBDCe19YOYQ BGvTSrfQEJ/9V9kydzMn9gsBRhrqM1YQkPjiiMg+ZN9NhvqsonsaIFZw2/+FOUY5bevP vQqEgXh4W5o0pP6Pozy1r5hoqn8wj2UcLVvuvyAvMOGEd3pVvaCymxcWxEMSaRV3TSEL waS5k6CB+h1/LHDgLY0rS06ZTbr5pOgZCYKYd1HJP7IY+mkt+nio1SAfnNIJrgPBUnil 0f2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767005774; x=1767610574; h=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=LbDnyyO7w1r4F82BBuldcjk1kaxuKrxtUVsfOZamK4Y=; b=Gskz4iIdxqS3GUCE4BrntcNu8lXffS5/MXqFC8x6ptp78q8wFfAU09NXGxnklFHQgd AX9huSHqJ1bIPJ2TDztdcn+Q1HoDWxH4zVdIdzIAu0UUgemCXNiUJlTcUeMEsBaLZcg4 CrhPKyhf1vKiCYOqycSRC6GCTJnLh2+WGoq7BQPR1WjeC7bo3YEdFYseUdA5coKeLsEQ 5htPwvHTGd3Jqk6mqa21a7H6e+dUsmdKlXiU7AfYWvvTkbrLe/+csJThJHmfhi5eHpxW gHHhXZy4v+5FnaB987AtoEHhDIjGOXO+CXj/IGZCek2uCVWu/5XVzdYX5DW4ZCh4qh6z Qw9A== X-Forwarded-Encrypted: i=1; AJvYcCUBM/qY+IMor98g+EVrG8iFTIDZuyZL/6wYqkQkQsxdx2bQQvAZBfkvjoJtQrZcZ5USrPRWtySG0gcZ@lists.postgresql.org X-Gm-Message-State: AOJu0YzPRavbgmSCLt3bl1f/pl+JGG6KqaqJNGuZFS2/KA251zFnNUAD yM+JURCdajX2Hkxk6tKYmqqOHwMGVERHqFT/fNeZb3V8Pa+UIyBKdqx4DwOvRmIVcB7D8K1+lXn 1ijMFPzB2D1Cob26l/ccJD0j+YqY3L+o= X-Gm-Gg: AY/fxX6S4cwqdZKGrniAgXPYmBIJsdym/f35eBEX8N5bIRjU3FEl9Tiwm/Y6d/Vfilb bPfw3LlTd4ZTtnhx0pkKbFoqJJkU+VuHtojtVFGOGKGee7PZxPdEJHhad/xf1cGeox7ChjMapOm LdWvVPo3mB9g4jOiTa4YKBVrVECLtDVchxzRFSTQzL45p+Yz8EbBDoUmKb4O39VtOAeTWrAYamY xPG6YyUhxv7o0F2n8FI5mjDGu5fyBPqAW3DnmS8PPD6xeqk+QXB3EehjTdCzqzpK7XylpTIGsVZ uO0CXaI6 X-Google-Smtp-Source: AGHT+IEOYyUVq0BDE0cFb10RYNNx9OsHHr9luxclHAOpyxaaP6+TX8g5nE4+whbHVutUNA+GH0JHK+/+ft3ajF3BsMY= X-Received: by 2002:a05:6a20:560a:b0:37b:98c3:4250 with SMTP id adf61e73a8af0-37b98c344d0mr13845840637.19.1767005773654; Mon, 29 Dec 2025 02:56:13 -0800 (PST) MIME-Version: 1.0 References: <19360-1952ab7afd799f70@postgresql.org> In-Reply-To: <19360-1952ab7afd799f70@postgresql.org> From: vignesh C Date: Mon, 29 Dec 2025 16:26:01 +0530 X-Gm-Features: AQt7F2q743bsJLwGbbs67AqDjbOhmHbMecZPsrBnd5_6rwBfMM3CM4wui0CK4dk Message-ID: Subject: Re: BUG #19360: Bug Report: Logical Replication initial sync fails with "conflict=update_origin_differs" PG12 toPG18 To: mostafaa.hasanzadeh@gmail.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 22 Dec 2025 at 19:00, PG Bug reporting form wrote: > > The following bug has been logged on the website: > > Bug reference: 19360 > Logged by: Mostafa Hassanzadeh > Email address: mostafaa.hasanzadeh@gmail.com > PostgreSQL version: 18.1 > Operating system: Ubuntu 24.04 > Description: > > Description: I am encountering a persistent issue during the initial > synchronization (Logical Replication) migrating from PostgreSQL 12 (Source) > to PostgreSQL 18 (Target/Devel). > > Despite ensuring a clean state (truncated tables, disabled triggers, dropped > indexes), the replication fails immediately after the initial COPY phase > when it tries to apply concurrent updates from WAL. The error indicates an > origin conflict, even though origin is set to none. > > It appears that the rows inserted during the initial COPY process in PG18 > are not being treated correctly regarding their origin status, causing a > conflict when the Apply Worker tries to update these rows with incoming WAL > entries. > > Environment: > > Publisher: PostgreSQL 12 > > Subscriber: PostgreSQL 18 (Development/Beta version) > > OS: Linux (Kernel > 5.10) > > Setup: High-volume data migration (~100GB tables) > > Steps to Reproduce: > > Publisher (PG12): Create a publication for tables with moderate write > traffic. > > Subscriber (PG18): > > DISABLE TRIGGER ALL on target tables. > > TRUNCATE target tables. > > Create a subscription with: > SQL > > CREATE SUBSCRIPTION sub_name > CONNECTION '...' > PUBLICATION pub_name > WITH (copy_data = true, origin = 'none', binary = false); > > Observation: > > The COPY phase starts and writes data to the disk. > > As soon as COPY finishes and the worker switches to streaming to > catch up, it crashes with the following error. > > Error Log: > > LOG: conflict detected on relation "public.player": > conflict=update_origin_differs > DETAIL: Updating the row that was modified by a non-existent origin in > transaction [TXID] at [TIMESTAMP]. > Existing local row (...); remote row (...); replica identity (id)=(...). > CONTEXT: processing remote data for replication origin "pg_..." during > message type "UPDATE" ... > > Analysis: I have verified that: > > There are no other active subscriptions writing to the target database. > > All triggers and foreign keys are disabled on the subscriber. > > The issue persists even after multiple cleanups (DROP SUBSCRIPTION / > TRUNCATE). > > Suspected Cause: It seems there is an incompatibility or regression in > PostgreSQL 18's logical replication handling. Specifically, tuples inserted > via the initial COPY protocol (from a PG12 source) might be tagged with a > local or null origin in a way that conflicts with the conflict_resolver or > origin checking logic in PG18, even when origin = 'none' is explicitly > configured. > > I suspect the COPY process does not correctly set the tuple origin state > that the WAL apply worker expects, leading it to believe the row was > modified locally by a third party. This can occur in the following scenario: commit timestamp tracking is enabled on the subscriber; the same table exists on both publisher and subscriber; a publication is created on the publisher with initial data; and a subscription is created on the subscriber with origin = none. During the initial table synchronization, the row is inserted using a tablesync replication origin, which is dropped once synchronization completes. If the row is updated on the publisher after the initial sync, the apply worker attempts to update a row that was inserted using a different replication origin(tablesync origin), resulting in an origin mismatch. The conflict is logged and logical replication continues normally. No crash occurs, and the log entry is informational rather than indicative of a failure. These messages can be safely ignored for now. We are currently evaluating possible improvements to handle this scenario more gracefully and to avoid reporting these conflicts in the future. Regards, Vignesh