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 1mrfm3-0006Qc-DT for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Nov 2021 12:28:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mrfm2-0008FO-9i for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Nov 2021 12:28:46 +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 1mrfm1-0008FF-Uc for pgsql-hackers@lists.postgresql.org; Mon, 29 Nov 2021 12:28:46 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mrflw-0007AJ-CM for pgsql-hackers@postgresql.org; Mon, 29 Nov 2021 12:28:45 +0000 Received: by mail-pl1-x62c.google.com with SMTP id m24so12031463pls.10 for ; Mon, 29 Nov 2021 04:28:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TcI3nRzYQuXkW3H7yufn4DRo3Z+936s1yj+68oJjVbA=; b=B8aHhIS+1WlQg8C+c5LhBFOwaoKxxHRuaLlK73CnqfIdwD5RJbFcV6DcTy7s4Glbx0 XzozU9MuCqvxtB000KrWVpHocITx7st3QMDAj+5HTwO6zDB/VU0hkqSUwJHgtgPx9SZY jYZyMyO3qdnIZZ9QV3+Vw3Oawn7xDfGPPQiLtDnwPeQ5svjFCc5JK5LsSw8N7ceQExmx Q6XUhn5EOFo7vB4xDOzvZdlSBtbaUzKv+sHQbKWp6ns1P6a/dXp7uSJU0jkUW38u9zBn oDotMJtumC0trbIAxTMUL+ltHamxsRqIuN8NvZxKrthtTQa3sR23/4hQSq+sHKoC51ur WoDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TcI3nRzYQuXkW3H7yufn4DRo3Z+936s1yj+68oJjVbA=; b=aOgKz457LxC5b93FgKBBNJBCSZQLw3HgzZw2ZV2PkwSSwPrBx8DTG/JULZ5g+YbD5x +kbVtW7RajnWG22HlujzltYkhoCtXfsXKTF87yQ7nXEgaaLMl5Jw91mi0KQG3Qd53+UE 2CTdf+0hT7qZTMZeA/4JihIPAy6efPVMKDIZZ8DBuKUHuGNr057OGrDS3YvDrRrh1jlO VfTb4ws/pVmzqlBHYrjcRUIg2MozKutJEE0tckgPf8pVSDykPJ0dj0+RRyi6xOXBT9Cu c6pS+vhUfFo2DAdYnmDG2QK5cEg14oi+w6wBU7Aod6BU6KF0EQxyXLeM0JcUE97ToYio Jnjw== X-Gm-Message-State: AOAM531DkkQw+f6KVix+2zxQq2nEe5e/I9psnX3DL5RqaEcjvpwbTGKT +xjiPuULQVkOgoHGmW9aWRh9ZOPdYYXcH6NUKL0= X-Google-Smtp-Source: ABdhPJyDQoMkwAsWJSsU4TraWMvTi8JpOsiDQGUMaSqH9AF/iqM+NCZWiPcMLHLFwyiMSO9r5gWPHK4TF4jBLRR8tmo= X-Received: by 2002:a17:902:c7d5:b0:143:72b7:2ca5 with SMTP id r21-20020a170902c7d500b0014372b72ca5mr59922973pla.20.1638188917889; Mon, 29 Nov 2021 04:28:37 -0800 (PST) MIME-Version: 1.0 References: <514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com> In-Reply-To: From: Bharath Rupireddy Date: Mon, 29 Nov 2021 17:58:26 +0530 Message-ID: Subject: Re: Synchronizing slots from primary to standby To: Dilip Kumar Cc: SATYANARAYANA NARLAPURAM , Peter Eisentraut , 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, Nov 29, 2021 at 1:10 PM Dilip Kumar wrote: > > On Mon, Nov 29, 2021 at 12:19 PM Bharath Rupireddy > wrote: > > > > On Mon, Nov 29, 2021 at 11:14 AM Dilip Kumar wr= ote: > > > > > > On Mon, Nov 29, 2021 at 9:40 AM Bharath Rupireddy > > > wrote: > > > > > > > > On Mon, Nov 29, 2021 at 1:48 AM SATYANARAYANA NARLAPURAM > > > > wrote: > > > > > > > > > >> 3) Instead of the subscriber pulling the slot info, why can't th= e > > > > >> publisher (via the walsender or a new bg worker maybe?) push the > > > > >> latest slot info? I'm not sure we want to add more functionality= to > > > > >> the walsender, if yes, isn't it going to be much simpler? > > > > > > > > > > Standby pulling the information or at least making a first attemp= t to connect to the primary is a better design as primary doesn't need to = spend its cycles repeatedly connecting to an unreachable standby. In fact, = primary wouldn't even need to know the followers, for example followers / l= og shipping standbys > > > > > > > > My idea was to let the existing walsender from the primary/publishe= r > > > > to send the slot info (both logical and physical replication slots)= to > > > > the standby/subscriber, probably by piggybacking the slot info with > > > > the WAL currently it sends. Having said that, I don't know the > > > > feasibility of it. Anyways, I'm not in favour of having a new bg > > > > worker to just ship the slot info. The standby/subscriber, while > > > > making connection to primary/publisher, can choose to get the > > > > replication slot info. > > > > > > I think it is possible that the standby is restoring the WAL directly > > > from the archive location and there might not be any wal sender at > > > time. So I think the idea of standby pulling the WAL looks better to > > > me. > > > > My point was that why can't we let the walreceiver (of course users > > can configure it on the standby/subscriber) to choose whether or not > > to receive the replication (both physical and logical) slot info from > > the primary/publisher and if yes, the walsender(on the > > primary/publisher) sending it probably as a new WAL record or just > > piggybacking the replication slot info with any of the existing WAL > > records. > > Okay, I thought your point was that the primary pushing is better over > standby pulling the slot info, but now it seems that you also agree > that standby pulling is better right? Now it appears your point is > about whether we will use the same connection for pulling the slot > information which we are using for streaming the data or any other > connection? I mean in this patch also we are creating a replication > connection and pulling the slot information over there, just point is > we are starting a separate worker for pulling the slot information, > and I think that approach is better as this will not impact the > performance of the other replication connection which we are using for > communicating the data. The easiest way to implement this feature so far, is to use a common bg worker (as opposed to the bg worker proposed originally in this thread which, IIUC, works for logical replication) running on standby (in case of streaming replication with physical replication slots) or subscriber (in case of logical replication with logical replication slots) for getting both the physical and logical replication slots info from the primary or publisher. This bg worker requires at least two GUCs, 1) to enable/disable the worker 2) to define the slot sync interval (the bg worker gets the slots info after every sync interval of time). Thoughts? Regards, Bharath Rupireddy.