Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSGxa-00032i-AX for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Feb 2023 12:32:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSGxZ-0005mM-5e for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Feb 2023 12:32:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSGxY-0005mC-R0 for pgsql-hackers@lists.postgresql.org; Wed, 15 Feb 2023 12:32:28 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSGxW-0004TD-GK for pgsql-hackers@postgresql.org; Wed, 15 Feb 2023 12:32:28 +0000 Received: by mail-pj1-x102e.google.com with SMTP id o13so18041277pjg.2 for ; Wed, 15 Feb 2023 04:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=r8CtGGTVruFIexi5PPnVCpg+CvG2JpyHHkxp3SfvP8Q=; b=ElhhS3lFKU8w20cldz1xjnnr8P1dM5qlu12bFK5TjEVZSO8tzDamFdWOBu+OzLFj4Z JAZaqrDrh4CMVpZv31ydORUKIhWyWmcIAgsA6nyrdgObTycqAcz/tjIGvVypY0Mjjkbw XubXNGGBVaPqahMDrH8h1t0LgrImSmkXt7V6Qr+jQIiivKq4sKBKtqa+SRHmwWQwX7zP nARqjfwD6/YBKvNVVhJsQyljqGTG6Ynuq5ffywsaapIFKDOH78X8fU0GiScmYjBbXs1i WLal87KwGutZLdFa13lQIUH3w4Bh03f4NlathFIJmEJS/qiTelvOJqBm5zO2pYdZ6quQ J9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=r8CtGGTVruFIexi5PPnVCpg+CvG2JpyHHkxp3SfvP8Q=; b=skU4FD3Lleu6Aw45768O0dsp99QA8bosovB3xcQIXbPuUydsK/Ag+GOr+EIS4Sajpe EFhw+1z+XAT7XEEwNZwDtzp7+Pvi/LKoUXYb7+yL1AO9idZ3WVAyfcwFKgYaXxAh0Eu4 +qf/J+t62ChPVm6/dO1pH3T2pWvY789ruL4jdbv1y1uPKwyo/BMfsl/AoDKVQiDIfDzb lL6FP8lv40L6f3dCHk/6DSXGsH4gIktZdqBMiANBEZEPgt7pUktjlq4jYrtduXjMsKQM LdJuoBDTNamGMki/rT2qgKEJLCOiNFMj1NlRPdvlLcyrolHwSWG/SunWjzFZzTi1BQRk AaEw== X-Gm-Message-State: AO0yUKWdyE1wlTmMg4B60oCIxZJEAn6qp3fqwts9R9wkTkoO30yEDyv2 4gPhONuniPnELVRLcA54AWlFYGxUBNwRGoon8po= X-Google-Smtp-Source: AK7set/k2K41BfxuDlTzCIxUFVdzAiPw0PS/KPddm1GMrC20A4Cl0pFZnchDSPh5cC73taPqvL0TGpbwS4Jywh38QrQ= X-Received: by 2002:a17:90b:2285:b0:233:ac84:ed33 with SMTP id kx5-20020a17090b228500b00233ac84ed33mr588795pjb.122.1676464343568; Wed, 15 Feb 2023 04:32:23 -0800 (PST) MIME-Version: 1.0 References: <1f2ad9fd-53ff-74cc-a602-72d45423bcab@gmail.com> <05c0c4f3-82eb-bc6d-c876-5a265c05927b@gmail.com> <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> <805540ba-b132-30f2-563d-cf9acc527008@gmail.com> <2d62f212-fce6-d639-b9eb-2a5bc4bec3b4@gmail.com> <20230112181630.lpqqty2vzuatgwcl@awork3.anarazel.de> In-Reply-To: <20230112181630.lpqqty2vzuatgwcl@awork3.anarazel.de> From: Ashutosh Sharma Date: Wed, 15 Feb 2023 18:02:11 +0530 Message-ID: Subject: Re: Minimal logical decoding on standbys To: Andres Freund Cc: "Drouvot, Bertrand" , Robert Haas , Thomas Munro , Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 12, 2023 at 11:46 PM Andres Freund wrote: > > Hi, > > On 2023-01-12 20:08:55 +0530, Ashutosh Sharma wrote: > > I previously participated in the discussion on "Synchronizing the > > logical replication slots from Primary to Standby" and one of the > > purposes of that project was to synchronize logical slots from primary > > to standby so that if failover occurs, it will not affect the logical > > subscribers of the old primary much. Can someone help me understand > > how we are going to solve this problem with this patch? Are we going > > to encourage users to do LR from standby instead of primary to get rid > > of such problems during failover? > > It only provides a building block towards that. The "Synchronizing the logical > replication slots from Primary to Standby" project IMO needs all of the > infrastructure in this patch. With the patch, a logical rep solution can > e.g. maintain one slot on the primary and one on the standby, and occasionally > forward the slot on the standby to the position of the slot on the primary. In > case of a failover it can just start consuming changes from the former > standby, all the necessary changes are guaranteed to be present. > > > > Also, one small observation: > > > > I just played around with the latest (v38) patch a bit and found that > > when a new logical subscriber of standby is created, it actually > > creates two logical replication slots for it on the standby server. > > May I know the reason for creating an extra replication slot other > > than the one created by create subscription command? See below: > > That's unrelated to this patch. There's no changes to the "higher level" > logical replication code dealing with pubs and subs, it's all on the "logical > decoding" level. > > I think this because logical rep wants to be able to concurrently perform > ongoing replication, and synchronize tables added to the replication set. The > pg_16399_sync_16392_7187728548042694423 slot should vanish after the initial > synchronization. > Thanks Andres. I have one more query (both for you and Bertrand). I don't know if this has already been answered somewhere in this mail thread, if yes, please let me know the mail that answers this query. Will there be a problem if we mandate the use of physical replication slots and hot_standby_feedback to support minimum LD on standby. I know people can do a physical replication setup without a replication slot or even with hot_standby_feedback turned off, but are we going to have any issue if we ask them to use a physical replication slot and turn on hot_standby_feedback for LD on standby. This will reduce the code changes required to do conflict handling for logical slots on standby which is being done by v50-0001 and v50-0002* patches currently. IMHO even in normal scenarios i.e. when we are not doing LD on standby, we should mandate the use of a physical replication slot. -- With Regards, Ashutosh Sharma.