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 1rPf1X-00DCc9-IY for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jan 2024 08:42:20 +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 1rPf1W-002FRU-FF for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jan 2024 08:42:18 +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 1rPf1W-002FRL-4c for pgsql-hackers@lists.postgresql.org; Tue, 16 Jan 2024 08:42:18 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rPf1T-0025Oi-2i for pgsql-hackers@postgresql.org; Tue, 16 Jan 2024 08:42:17 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40e83823d17so4391585e9.1 for ; Tue, 16 Jan 2024 00:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705394534; x=1705999334; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=e5eIcOWPS394yqMKke3WIO61O0oXwWJQXkgXFqoGCGM=; b=hPgoI1wZmbaKn/wtcLVWSqFh7l3xjYSrzquxb1p2eO0KDBy0PwOacANAtULiVWMbx3 jSFA7g1ZjUmkI+sO5REMmj/+Rig5Bi6wDPvyBUe3RQVM9fC91ukNsWDZMbRNMiWh9Lls pVPYy8y2uYcOI9d8fL5i+Ak388kAN5g8DpDcLldri5Fwqpz3M93dF07lyMUoLrvlsdEV CiaTYz6cz0SMZR6OyRH8fYG9qaTlc0/fxIA+94jwj9klDT+PZSWvj6z9MAtTSFiW5h// 6MtDte+Hb510x2ts2ASlDAx7AYiAt4Dn/jIDOJdS7qeFmFR9ssii3VsCkBeUCB6sJlGi AAew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705394534; x=1705999334; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e5eIcOWPS394yqMKke3WIO61O0oXwWJQXkgXFqoGCGM=; b=RqTs2lklX3Z5obm41gh/jyBC6BaXILz1VTHg0tDNFuiuBz7828i1G0v7jlQCRmU6Hs iMqFOEFdbs+1S+rDmVMU+8Iy5IWKSBU6B4UUDksH8dG211DXBFsQjouB1pm80pxZT7fi fAl0cRaUXwbu7LX07D4WHx2hweyBZWZTPP96xiYgtR1fIb7F17cR22y0yF+jMiTv/sqS 8U6pitiU6WgFBm9iCVH9w3xQNneSTwFLEtfOMzTAFIK1yNYGcwQ00WKO3tONRkprIOry 0kazMgVu7QHh3R9vshBs7nY1Ht20APSAp1/j37jGS9xICGZnLWXlk6NlGpkMGU6Ao4HO 8Tvg== X-Gm-Message-State: AOJu0YwWl3CWhWr8GgMDh5PWS0dgggW6UbXYl/7rQKBaYjRfDp6L+Wn+ rZOtsmu+fNZ6EgXLJ/19OWQ= X-Google-Smtp-Source: AGHT+IEb/5m3NWpq0FlLXSP8+aoQsMsHKD9+HxRO11QTF2RF6NgoW5tR+7Vx50ZpVY9a8ME9PRWGKw== X-Received: by 2002:a05:600c:654f:b0:40e:477a:f36b with SMTP id dn15-20020a05600c654f00b0040e477af36bmr2172729wmb.353.1705394533425; Tue, 16 Jan 2024 00:42:13 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id h16-20020adfe990000000b003373ef060d5sm13957756wrm.113.2024.01.16.00.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 00:42:12 -0800 (PST) Date: Tue, 16 Jan 2024 08:42:11 +0000 From: Bertrand Drouvot To: Amit Kapila Cc: shveta malik , Masahiko Sawada , "Zhijie Hou (Fujitsu)" , Dilip Kumar , Peter Smith , Nisha Moond , "Hayato Kuroda (Fujitsu)" , Bharath Rupireddy , Peter Eisentraut , Bruce Momjian , Ashutosh Sharma , Andres Freund , pgsql-hackers , Ajin Cherian , Alvaro Herrera Subject: Re: Synchronizing slots from primary to standby Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Sat, Jan 13, 2024 at 12:53:50PM +0530, Amit Kapila wrote: > On Fri, Jan 12, 2024 at 5:50 PM shveta malik wrote: > > > > There are multiple approaches discussed and tried when it comes to > > starting a slot-sync worker. I am summarizing all here: > > > > 1) Make slotsync worker as an Auxiliary Process (like checkpointer, > > walwriter, walreceiver etc). The benefit this approach provides is, it > > can control begin and stop in a more flexible way as each auxiliary > > process could have different checks before starting and can have > > different stop conditions. But it needs code duplication for process > > management(start, stop, crash handling, signals etc) and currently it > > does not support db-connection smoothly (none of the auxiliary process > > has one so far) > > > > As slotsync worker needs to perform transactions and access syscache, > we can't make it an auxiliary process as that doesn't initialize the > required stuff like syscache. Also, see the comment "Auxiliary > processes don't run transactions ..." in AuxiliaryProcessMain() which > means this is not an option. > > > > > 2) Make slotsync worker as a 'special' process like AutoVacLauncher > > which is neither an Auxiliary process nor a bgworker one. It allows > > db-connection and also provides flexibility to have start and stop > > conditions for a process. > > > > Yeah, due to these reasons, I think this option is worth considering > and another plus point is that this allows us to make enable_syncslot > a PGC_SIGHUP GUC rather than a PGC_POSTMASTER. > > > > > 3) Make slotysnc worker a bgworker. Here we just need to register our > > process as a bgworker (RegisterBackgroundWorker()) by providing a > > relevant start_time and restart_time and then the process management > > is well taken care of. It does not need any code-duplication and > > allows db-connection smoothly in registered process. The only thing it > > lacks is that it does not provide flexibility of having > > start-condition which then makes us to have 'enable_syncslot' as > > PGC_POSTMASTER parameter rather than PGC_SIGHUP. Having said this, I > > feel enable_syncslot is something which will not be changed frequently > > and with the benefits provided by bgworker infra, it seems a > > reasonably good option to choose this approach. > > > > I agree but it may be better to make it a PGC_SIGHUP parameter. > > > 4) Another option is to have Logical Replication Launcher(or a new > > process) to launch slot-sync worker. But going by the current design > > where we have only 1 slotsync worker, it may be an overhead to have an > > additional manager process maintained. > > > > I don't see any good reason to have an additional launcher process here. > > > > > Thus weighing pros and cons of all these options, we have currently > > implemented the bgworker approach (approach 3). Any feedback is > > welcome. > > > > I vote to go for (2) unless we face difficulties in doing so but (3) > is also okay especially if others also think so. > Yeah, I think that (2) would be the "ideal" one but (3) is fine too. I think that if we think/see that (2) is too "complicated"/long to implement maybe we could do (3) initially and switch to (2) later. What I mean by that is that I don't think that not doing (2) should be a blocker. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com