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 1w2lZJ-000aBO-2E for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 07:43:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2lZI-008SHK-0H for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 07:43:52 +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 1w2lZH-008SHC-2S for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 07:43:51 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2lZF-00000000tO4-149E for pgsql-hackers@postgresql.org; Wed, 18 Mar 2026 07:43:51 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-66174cf4549so1322717a12.0 for ; Wed, 18 Mar 2026 00:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773819828; cv=none; d=google.com; s=arc-20240605; b=ShoLLOUWPVfxroaDlqMYdkJFmvoXgZ+5MjknE4YwpJj+ryR4vzDsXodic/HPSjufJ5 3tXfKPblCmuFhJzSH/ffIdlxolIuAAHdh8EnoVmogq5v47H5DFVBfzsvw2ffQ4qJ5UAF 7mCjWbw5M5SBNBfBt1Yl2+JiORtXJZbSGmkW1lzYos9ixkP6rxQY4Wtb/LoUIpNJWrlp h55tNAH+qhgUyYFzy7xNl0JooC077WD99u3IRN98OS+ValU0GHYJzwB28KCafuhCWwFM 1UxQm1KAKCCfdJ7d1jgV1laoyutsz1bKUde6sr6GyK0RW933ro+VI0k/Mna6ioBA4wCi M2Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Bojto2dRuwBmaUljszENXUgCAsxGoAtGHJt6KB6qiK4=; fh=KHppo21YSmgQ+nqk/UX9SuorGKx7zz0ZlcSsAPuNtC8=; b=Dg/R9+LDbM+VtfoUG7RkpMip2cbs8sBJOR248M2PKK/O2NpPUEMZAzLjCGux+LaDCt b8KFV9Ea5W/zQwtgwYS5oE2na2kitHmZ7asgklzQu1u5kUFjRhdpm5mHxecaiCKAsRyt Sw4tu04up7u+tzTrJwQb8MdwAiZN0J0Xp6VFMNkIzN9bmXVRQJMWMd/0mj8ozqF0yfWc P/DbndxkCVzewsLomBRrz/qeuRqVgKushJp6j9UYtVxC2U6BMulyMGRTBpd/27/nnoOU m4SFc9q9eKcwSF2UqnZ6BaYPmgtAc51QNgpoTuejGHAaFQKFdzhTlXDWz7hIcROYh/xJ rdMg==; darn=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=20230601; t=1773819828; x=1774424628; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Bojto2dRuwBmaUljszENXUgCAsxGoAtGHJt6KB6qiK4=; b=T6JpC1g+bWaTl2JqhohwCgyiinDE/+aE8wiTfw+suxOJbsLM/xMsjdYuG6z5Y1yMM0 0GrH2qjDlYV8N3nzPNn1z6KOOD5OJh2PlM+UZqcbLFxN5vEyJ3X9YcBMYqPdTDZkX2/B m+VIGrzlmN95Pcdua87pIR/oQZxwGx4z/DJeAqG6K4XORsRnUGk0QocW7M1YA4torCA5 OKnxMBBRMoLdiHiwzHoYob2UziArJxyG8qQK8tWlDYig6W1CJMhsdfaYzVNOfYqQElFX v2+5D3n25iRP03UcN5IB8Xell2kpu2N3VfFxRf9V6kpjFlwYTiTfU1zR2HO5jRNVa59S /CVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773819828; x=1774424628; h=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=Bojto2dRuwBmaUljszENXUgCAsxGoAtGHJt6KB6qiK4=; b=XU1vFnVCM/AFtX6zEuNtcLNSvP8YUvBpWtukXySk5OztCyL1uWf1LX1KDVSFnTy6hz jGQVV+Q8eobezJEzh9tGbxpBECwfqcGg4xFh7CeFlxdgF+ONPnBRMY7OvP32daSF2KZG D3bVu5zdtSW2F/J7FyeIxosbzAud53buSCZsINEMtGKsUvKPyISdscjXfocc6gNI/w4Q kDnN2FUe+JQLzzVNdMmsqwXBhY5QqXoQlHHI4vB+R/nwFCfpkQgqf6l7HLfoSlkL2vt1 Veetadv7kyL7RqZLneKpQmIZxTHRy1FGyVGer8Mk8SY/wsFvD7p+B7or6ozgg9Nk3FmS L1TQ== X-Forwarded-Encrypted: i=1; AJvYcCWBixyyZ1dOWmlFTnD4fa0BIddJo/kyVwIEyv0dh0GPBfDxU9k7Z9AMVYGwkVxRcxVPfiScewaWeJGHiiVb@postgresql.org X-Gm-Message-State: AOJu0Ywgj0she/g3X8148Rs9f/eQ/OOuHwZSY8idnyZBtKXtwWv508Do bZi26C1ht6tVYVFbN8YMdQAqjAosi7u5V+4rH5XrSChOVcxPVElb6cjbn9dfSTdRu9fKP0vjM+M T1NgVkOiVjs7ub9Jkaw9NbBHQE0d96Fc= X-Gm-Gg: ATEYQzwpLiXVojhE4AJYiQcen4BPmw4845vuPPvQ/yO2dsnA/HDlk2hoJ4H2oNzTOjc nA8FN07EH7cVakBwpqHzpAwAKv255WlEv2FpEaESiJ9b0477JnmFweCPGoMIBmSHrftDOmvUkFJ SsxW2PcRNgNhIfd+tOjq78MrP5EbeUWZ9cUdmBRZ/DjoqZ+0OsnOXBG6XW2XW9KpuDhlEL6Q2dS 861oagu7oa7Ts6rlaM0xFLCRY/yHVjrtAockK70UnnLZSEd2rRRPN8xEDYn4bqhIgR5KSBuEkr2 UoEodw== X-Received: by 2002:a05:6402:84f:b0:665:3400:faa8 with SMTP id 4fb4d7f45d1cf-667b2343fe3mr1501662a12.5.1773819828367; Wed, 18 Mar 2026 00:43:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Imran Zaheer Date: Wed, 18 Mar 2026 12:43:37 +0500 X-Gm-Features: AaiRm5264IS1rL5v7LWVd3jKjB-N2edje-mhnLhd2nly_KNDGNtS_vwJKamaIec Message-ID: Subject: Re: [WIP] Pipelined Recovery To: Zsolt Parragi Cc: "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: multipart/alternative; boundary="000000000000c3f42f064d479cee" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c3f42f064d479cee Content-Type: text/plain; charset="UTF-8" Hi Zsolt. Thanks alot for the review and pointing out the bugs. I have fixed the bugs you mentioned in my new patch set. But patchset mail is held for moderation for some reason. > > if (reachedRecoveryTarget) > { > + if (wal_pipeline_enabled) > + WalPipeline_Stop(); > > What if we didn't reach the recovery target, shouldn't we stop the > pipelines then? > I have fixed the bugs shutdown logic. As we already know we will exist the recovery redo loop in `PerformWalRecovery()` only in two cases 1: Recovery target reached: In this case consumers will call to stop the pipeline. @@ -1807,6 +1931,9 @@ PerformWalRecovery(void) if (reachedRecoveryTarget) { + if (wal_pipeline_enabled) + WalPipeline_Stop(); + 2: Available pg_wal is consumed and now more wal to read. In this case pipeline producers will send the shutdown msg to the consumer. Consumer will detect this message and then call ` WalPipeline_Stop`. This is the case where we cannot read more records and the while loop will break here. + if (decoded_record) + { + record = &decoded_record->header; + return record; + } + else + { + /* + * We will end up here only when pipeline couldn't read more + * records and have sent a shutdown msg. We will acknowldge this + * and will trigger request to stop the pipeline workers. + */ + WalPipeline_Stop(); + return NULL; + } Hope this makes sense. Once again thanks for reporting the bugs. You will receive the new patchset mail soon once it is cleared from the moderation. Looking forward to your reviews, comments, etc. Regards, Imran Zaheer --000000000000c3f42f064d479cee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Zsolt.

Thanks alot for = the review and pointing out the bugs. I have fixed the bugs you mentioned i= n my new patch set. But
patchset mail is held for moderation for some re= ason.

>
> =C2=A0 if (reachedRecoveryTarget)
> =C2=A0 = {
> + if (wal_pipeline_enabled)
> + WalPipeline_Stop();
>=
> What if we didn't reach the recovery target, shouldn't we = stop the
> pipelines then?
>

I have fixed the bugs= shutdown logic.

As we already know we will exist the recovery= redo loop in `PerformWalRecovery()` only in two cases

1: Reco= very target reached:
In this case consumers will call to stop= the pipeline.

@@ -1807,6 +1931,9 @@ PerformWalRecovery(void)
=C2= =A0
=C2=A0 if (reachedRecoveryTarget)
=C2=A0 {
+ if (wal_pipel= ine_enabled)
+ WalPipeline_Stop();
+

2: Availa= ble pg_wal is consumed and now more wal to read.
In this case pip= eline producers will send the shutdown msg to the consumer. Consumer will
detect this message=C2=A0and then call ` WalPipeline_Stop`. This= is the case where we cannot read
more records and the while=C2= =A0loop will break here.

+ if (decoded_record)
+ {
+ recor= d =3D &decoded_record->header;
+ return record;
+ }
+ e= lse
+ {
+ /*
+ * We will end up here only when pipeline coul= dn't read more
+ * records and have sent a shutdown msg. We will = acknowldge this
+ * and will trigger request to stop the pipeline wor= kers.
+ */
+ WalPipeline_Stop();
+ return NULL;
+ }
=

Hope this makes sense.=C2=A0

Once agai= n thanks for reporting the bugs. You will receive the new patchset mail soo= n once it is cleared=C2=A0from
the moderation.

Look= ing forward to your reviews, comments, etc.

Regards,
Imran Zaheer
--000000000000c3f42f064d479cee--