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.94.2) (envelope-from ) id 1qNmHJ-005vTQ-9O for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jul 2023 03:30:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qNmHH-007ONE-3G for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jul 2023 03:30:31 +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.94.2) (envelope-from ) id 1qNmHG-007ON6-NM for pgsql-hackers@lists.postgresql.org; Mon, 24 Jul 2023 03:30:30 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qNmHA-001R56-RC for pgsql-hackers@postgresql.org; Mon, 24 Jul 2023 03:30:30 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5634808e16eso2444031eaf.2 for ; Sun, 23 Jul 2023 20:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690169424; x=1690774224; 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=m4vhOioUZbh1QnVRGp26ziz8rZhhXwG7ULv36BDL7cI=; b=QqpTnR1TMBXEZiMfydVAJnKOlAG9TLipy3n+ScNM9yQGBxFNxu+Ou2NgtLExEAemRt wpXdLXvJhfoLz0UwftLtn9d0vuI4vfbDOHPn3qZVU+tSF/h0hAIN7fYBPVTb5BiOIj9l Gfep9/Cyhj/KhWrGJtPz/V+ct3odXrDo7iiDVj+hQGK2PS+QtXAehknuSKf2sGEihA9J klnDXzusHV6ZP3z2I14Pk/o2V9IUd9DuwB2PFcEKRQFjoIHlyOsId6AITKCaaUoQaaud jv1j/xcK1yWiL5V5eWddtLK4O8WwJ5JkunqJYAN6GmW+CAc2anLIVTtr5NdwpCkXCUa/ ZARg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690169424; x=1690774224; h=content-transfer-encoding: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=m4vhOioUZbh1QnVRGp26ziz8rZhhXwG7ULv36BDL7cI=; b=Idn4XfTPciQpkPm/tgZc+9q5scutQAso9yufiVSkmnNMdn8TZzVJHdAhSGOo1gDx3f 3a//Sd+tc5XY0S+PwhEuP8gT02rWf1CLwDm9hVTZ2rK1Qe7BkmlpmPbReLrjh4RAlG5b fLuI3wvYWEb/ELMIyfFQrq3gkYQKCFZgTSLi1wYZZG0YwahukyGaXUQ1bxOmkftF9Gl0 kGbR5n3egQoOnb6qJ/vN8dgD/M20Uow+ThanuY+v0iKy797Y6Pff3nzEdGId7i40SL4l ipl53eBExixMgezvPIRNJr+z0xaHFNXhFGAd06AeCa1f3ivvwARSwVtg/rh4c64LXdYI ocgg== X-Gm-Message-State: ABy/qLaS6g6/KxyC7ag6FQw2PlWpFrpjjsd6QSEYQoHXhya50Dxj2pHD BGcZ6xYjwkQhKx6FcJUbCxuxJ+LSXr2bLxQxP3s= X-Google-Smtp-Source: APBJJlFO/09krDg7ygMQemTCDPfYGtD50rLdeZmWthwaZ6BiBirS7KTGj76Py2P3Idkc+Zm3ysFcw3M4FYpZiLOkGvA= X-Received: by 2002:a4a:d1d9:0:b0:566:f052:696d with SMTP id a25-20020a4ad1d9000000b00566f052696dmr6827542oos.6.1690169423846; Sun, 23 Jul 2023 20:30:23 -0700 (PDT) MIME-Version: 1.0 References: <514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com> <18dbc929-a281-8552-4f1d-7e4d0e4eedba@enterprisedb.com> <646acd8d-9896-ed8d-2ab4-0bf11b3285d4@enterprisedb.com> <20220205195944.drwc3psrb5udt2cw@alap3.anarazel.de> <20220207203222.22aktwxrt3fcllru@alap3.anarazel.de> In-Reply-To: From: Amit Kapila Date: Mon, 24 Jul 2023 09:00:15 +0530 Message-ID: Subject: Re: Synchronizing slots from primary to standby To: Bharath Rupireddy Cc: shveta malik , "Drouvot, Bertrand" , Peter Eisentraut , Bruce Momjian , Ashutosh Sharma , Andres Freund , pgsql-hackers 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 Mon, Jul 24, 2023 at 8:03=E2=80=AFAM Bharath Rupireddy wrote: > > On Fri, Jul 21, 2023 at 5:16=E2=80=AFPM shveta malik wrote: > > > > Thanks Bharat for letting us know. It is okay to split the patch, it > > may definitely help to understand the modules better but shall we take > > a step back and try to reevaluate the design first before moving to > > other tasks? > > Agree that design comes first. FWIW, I'm attaching the v9 patch set > that I have with me. It can't be a perfect patch set unless the design > is finalized. > > > I analyzed more on the issues stated in [1] for replacing LIST_SLOTS > > with SELECT query. On rethinking, it might not be a good idea to > > replace this cmd with SELECT in Launcher code-path > > I think there are open fundamental design aspects, before optimizing > LIST_SLOTS, see below. I'm sure we can come back to this later. > > > Secondly, I was thinking if the design proposed in the patch is the > > best one. No doubt, it is the most simplistic design and thus may > > .......... Any feedback is appreciated. > > Here are my thoughts about this feature: > > Current design: > > 1. On primary, never allow walsenders associated with logical > replication slots to go ahead of physical standbys that are candidates > for future primary after failover. This enables subscribers to connect > to new primary after failover. > 2. On all candidate standbys, periodically sync logical slots from > primary (creating the slots if necessary) with one slot sync worker > per logical slot. > > Important considerations: > > 1. Does this design guarantee the row versions required by subscribers > aren't removed on candidate standbys as raised here - > https://www.postgresql.org/message-id/20220218222319.yozkbhren7vkjbi5%40a= lap3.anarazel.de? > > It seems safe with logical decoding on standbys feature. Also, a > test-case from upthread is already in patch sets (in v9 too) > https://www.postgresql.org/message-id/CAAaqYe9FdKODa1a9n%3Dqj%2Bw3NiB9gkw= vhRHhcJNginuYYRCnLrg%40mail.gmail.com. > However, we need to verify the use cases extensively. > Agreed. > 2. All candidate standbys will start one slot sync worker per logical > slot which might not be scalable. > Yeah, that doesn't sound like a good idea but IIRC, the proposed patch is using one worker per database (for all slots corresponding to a database). > Is having one (or a few more - not > necessarily one for each logical slot) worker for all logical slots > enough? > I guess for a large number of slots the is a possibility of a large gap in syncing the slots which probably means we need to retain corresponding WAL for a much longer time on the primary. If we can prove that the gap won't be large enough to matter then this would be probably worth considering otherwise, I think we should find a way to scale the number of workers to avoid the large gap. --=20 With Regards, Amit Kapila.