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 1p5VH4-0003Y6-GT for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Dec 2022 17:10: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 1p5VH3-00078w-C1 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Dec 2022 17:10:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5VH3-00078m-0v for pgsql-hackers@lists.postgresql.org; Wed, 14 Dec 2022 17:10:29 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p5VH0-00072G-Ns for pgsql-hackers@postgresql.org; Wed, 14 Dec 2022 17:10:28 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d15so3999190pls.6 for ; Wed, 14 Dec 2022 09:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AjTKpe9nPuVpO9O/a0L/MrnLX3Mpv4HT32TNIuI/46M=; b=A/adWU8fYYefOUqvStsGqKQWYJISXL4rZRiKuonulMmhSJX7XDJVEI0p+v4T89Dvv2 kdjrBJllLHffCj84s7ONV7rHD86G//I0kc3l2dEKe0PQ0oD+reqn3ietd/WFmMFccX0M OZRuyO8vCk5Dn1n/dVRsTb5VD792hdXuGjsaoG8Ahkci7D3AU7sjQYoyV9lv5msfO1KH NYcan8ztH1IXZgZbt5qbNgd5SnBayUi70iTaiCI2+A/20z2BD1J626spNQO2ieGj//3o brN4fWVepuZ7j7QtzFgfvT0f9feU/6o/rfqXKjZvouSxkp7lueR3+9OC0zo7j6EwkrW2 NBDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to: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=AjTKpe9nPuVpO9O/a0L/MrnLX3Mpv4HT32TNIuI/46M=; b=HPPhXs2Mkueb6FmF60kB3gjc8jOF4Kp340radyGkQdQINafDJCLFqIQAHlRKTZbn3l CINrDOpnkDYCUeT2ZOw29HB1NMuyM/V5ny1q40SIXwpiK6gRMPZjuhWByixEmARZSYZg qcscwx+QFz+ZM0gjPZ7XfBSf4fK6BN7vLT+kS4O4cx6p8Vf/Zn8Sy3lIJcdXjIIYVThK 8NrTqVin55QYjWwgCjyQrz4IZ6qeC4ZkHd4tiDv2o2M/mQrY8lckBq6W4MK2SCI9xYGY armAcNlY2gZd2SbqOPnUyWmKuqZcA41pyVVwSMQoAZdw5z3Ccxy1PareeBbM1K7Xo1Kd 0rLA== X-Gm-Message-State: ANoB5pmhbPMqF/9O80rB2Uwnx5cEWrfrPuS7dWgaBX/zdOESk2iH1mCn 4s/nj5jxlTA+Tx+1SbfAaQI= X-Google-Smtp-Source: AA0mqf4wxiaTP1fYsMWuooc5PhwZfWZ04cKLffJMJoxhKumxoZrI0DFyn3OoL4Su1JYiffcgkueKbg== X-Received: by 2002:a17:90a:b786:b0:212:cf2f:74ec with SMTP id m6-20020a17090ab78600b00212cf2f74ecmr25878681pjr.37.1671037825529; Wed, 14 Dec 2022 09:10:25 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id h3-20020a17090a648300b00219186abd7csm1668147pjj.16.2022.12.14.09.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 09:10:24 -0800 (PST) Date: Wed, 14 Dec 2022 09:10:23 -0800 From: Nathan Bossart To: Tom Lane Cc: Melih Mutlu , Thomas Munro , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@postgresql.org" Subject: Re: wake up logical workers after ALTER SUBSCRIPTION Message-ID: <20221214171023.GA689106@nathanxps13> References: <20221202192101.GB2277157@nathanxps13> <20221206192551.GA3078082@nathanxps13> <20221206212954.GA3403597@nathanxps13> <20221207181145.GA3698731@nathanxps13> <2550453.1670974328@sss.pgh.pa.us> <20221214000145.GA638663@nathanxps13> <2561155.1670977214@sss.pgh.pa.us> <20221214004105.GA669835@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221214004105.GA669835@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Dec 13, 2022 at 04:41:05PM -0800, Nathan Bossart wrote: > On Tue, Dec 13, 2022 at 07:20:14PM -0500, Tom Lane wrote: >> I certainly don't think that "wake the apply launcher every 1ms" >> is a sane configuration. Unless I'm missing something basic about >> its responsibilities, it should seldom need to wake at all in >> normal operation. > > This parameter appears to control how often the apply launcher starts new > workers. If it starts new workers in a loop iteration, it updates its > last_start_time variable, and it won't start any more workers until another > wal_retrieve_retry_interval has elapsed. If no new workers need to be > started, it only wakes up every 3 minutes. Looking closer, I see that wal_retrieve_retry_interval is used for three purposes. It's main purpose seems to be preventing busy-waiting in WaitForWALToBecomeAvailable(), as that's what's documented. But it's also used for logical replication. The apply launcher uses it as I've describe above, and the apply workers use it when launching sync workers. Unlike the apply launcher, the apply workers store the last start time for each table's sync worker and use that to determine whether to start a new one. My first thought is that the latter two uses should be moved to a new parameter, and the apply launcher should store the last start time for each apply worker like the apply workers do for the table-sync workers. In any case, it probably makes sense to lower this parameter's value for testing so that tests that restart these workers frequently aren't waiting for so long. I can put a patch together if this seems like a reasonable direction to go. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com