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 1vXcE9-00GmCP-1G for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Dec 2025 09:29:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vXcE7-00DzTM-1k for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Dec 2025 09:29:16 +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 1vXcE7-00DzT4-0V for pgsql-hackers@lists.postgresql.org; Mon, 22 Dec 2025 09:29:16 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vXcE6-001wTe-1P for pgsql-hackers@lists.postgresql.org; Mon, 22 Dec 2025 09:29:15 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2a0a33d0585so34995785ad.1 for ; Mon, 22 Dec 2025 01:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766395753; x=1767000553; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vZevsF/SbWqHe3GWPKo1cmmI7g1CZSKq32r50ttgd8g=; b=K5v7wkv5XDF0DSxNAU43qNkDUS7UGJgcgKR2d1nB/JSovZYzYBsxXxosBSrPu0Rr9A U03JVx8LZMBBRtW9I1LI/XaW1n6I5dmWPI7qdoVFxd8Egs9/OWhLEniuH7PaDtc9KREm 4338N4wmai74ixzHkE0IzDxo17M8Ly8y3nr/iNccvKK5a98GRCQHpB6qfa+yz8gxfP9K 9zLqMBtVhGsBZl3s9bns99nlgfag1fC9OizeHIA/s5HqqHTGhL/kd+ErC3++Tkxpf7Ef 7YndkF3EyTbc1E4wAQBO9I2lWDOBtlmwzDutkv06WVYf70yJbYylcW6fcwOeYBa4hZni xf2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766395753; x=1767000553; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vZevsF/SbWqHe3GWPKo1cmmI7g1CZSKq32r50ttgd8g=; b=S+WSfxJKmTjPlceXyTdS3cEOC/IEPMni6anHh35jrvlpYWkH1yfFU0Tu1TaJjabkOi Sp/1V8QZpU1L9qX58PDLc2Aut5JCqQyx2T1cb6bwu8Mv+WIMa2VP+B7enG6whyC2EFDg Gjut+rQqSjmWEAkICRMOeze/k8VyER0ANKszbz5lTwkbA4ngMH0J83gEzvgv04knoL0m Vt6EUNKv9CUbvUohRCcTFAnC7LM9WYb9snCtkbRK0hQA0bhIQ6tc4G4purkdfK1dYT61 6A9t7x/pCsrGElkZvMghbVt+j4Cn9Bab9KnQnNIao8dWaG2seTpfW3SHJywBx/1oE28R IXFQ== X-Forwarded-Encrypted: i=1; AJvYcCXFgCioTXqL7jbTWc5QOk+ExTv0DHoTWXhf7NIRxEkW13sb7IImpnXLzqlCJHrizU6CnK/6cJ2bpItp2h0I@lists.postgresql.org X-Gm-Message-State: AOJu0YzomHpoPPY/DZ+LfD0ylVDcxsvcDw5xH2AxsMD6yni8EahoZv6V j8Aq3+W77Rvt54C0UqiEcWxxSUFjPnfPzukFocK5D/mtucThZzJMfZ0Y X-Gm-Gg: AY/fxX7tWepDGpR3nBWzW/oemsSIsEu3WVCZMhDEzhWUppQAwOCZRTL56l0H3qIDuZT X/MgjNirNlSBV3RxuzejF+ZSlXH5qxnC9ps+sy6TwJVoHU4pBCSF1d+7EoQ35AlMdheu2ThKRJh Bk+RH3kCd2A7FfwiIpfXvGMDpZMtS6huBPYWUqch4ciQZ+In04p2gYUJ5dZawnyJLC3cwkpXkSW w0g48xCPpPydRQ1RUnd+XkCpXuXlB75jZUGRLfvQCMP4g7jqRFerUxgwEaegffUhpCvFpAIm9ha YyNir821WVWFzzhLD0MDKvbsB2aQZfigWxcDPi6dvRdXywr3Dl+0fCbrxSWbzlWFTZd1dd80DPf SvoA9oDZ1SElyl3gwy3yYm0BvnNDH8DdOr2epobL0TWuy7vxAJI+51PzmgKE8IMKV6wfw0LutZl neNN8NTE1CKtkqQpeR+9Ru X-Google-Smtp-Source: AGHT+IFM/unShN3h0QqSICWRj0aQvc9AskR0Hj0S3f5WBfvHDIZVvQ58BM8jT2578UGl8yXGQBtOrg== X-Received: by 2002:a05:7022:428b:b0:119:e56b:91da with SMTP id a92af1059eb24-121722aae70mr13630498c88.11.1766395752941; Mon, 22 Dec 2025 01:29:12 -0800 (PST) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217253c23csm41328184c88.9.2025.12.22.01.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Dec 2025 01:29:12 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [bug fix] prepared transaction might be lost when max_prepared_transactions is zero on the subscriber From: Chao Li In-Reply-To: Date: Mon, 22 Dec 2025 17:28:37 +0800 Cc: Amit Kapila , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@lists.postgresql.org" , shveta malik Content-Transfer-Encoding: quoted-printable Message-Id: <0CE4BCB2-5C74-4A4F-88FF-60D8ED2622F9@gmail.com> References: To: "Zhijie Hou (Fujitsu)" X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Dec 22, 2025, at 17:01, Zhijie Hou (Fujitsu) = wrote: >=20 > Hi, >=20 > When reviewing some parallel apply related codes, I noticed a bug in = the > parallel apply worker, similar to the issue discussed in this thread. >=20 > The issue is that the logical replication parallel apply worker may = erroneously > advance the origin progress during an error or unsuccessful apply. = This can lead > to transaction loss, as these transactions will not be resent by the = server. > Commit 3f28b2fc addressed a similar issue in both the apply worker and = table > sync worker. >=20 > The original fix involved registering a before_shmem_exit callback to = reset the > origin information, preventing the worker from advancing it during = transaction > abortion on shutdown. The attached patch registers the same callback = for the > parallel apply worker, ensuring consistent behavior across all = workers. >=20 > Best Regards, > Hou zj > So, ParallelApplyWorkerMain() only calls InitializeLogRepWorker() but = SetupApplyOrSyncWorker(), by moving before_shmem_exit() into = InitializeLogRepWorker(), ParallelApplyWorkerMain()() gets the exit = callback. LGTM. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/