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 1p5x0k-0008H4-Fw for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 22:47: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 1p5x0j-0005mi-8J for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 22:47: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 1p5x0i-0005jD-Mq for pgsql-hackers@lists.postgresql.org; Thu, 15 Dec 2022 22:47:28 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p5x0f-0005a0-Lo for pgsql-hackers@postgresql.org; Thu, 15 Dec 2022 22:47:27 +0000 Received: by mail-pj1-x1034.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so658588pjd.0 for ; Thu, 15 Dec 2022 14:47:25 -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=kz2vx1HfBw3fYaCpEUWWm3cKVnrJee8NXelXCbI0mp0=; b=mh0hrNIypdBt6H2/05dLFKtjwz/W9qOurAHR26JFwPzZf4TVJswQVgi2M72PLfJH23 REYpMZ2xxP40Pun1nqUTT0SNZuiAY7HMdY5g3PqZujLByYpa2Hz2DwkojhxRag3l17ZU eiQ99mP0rJQtCHy92P/vPkm2UFYfPZMHPb6YuJ3ZUmDvUqXmktE6Q/HeExlVA5c/Sgcr 4v1QsEtWBS7ubs58sFwPYQvDl39YbzRnY+XqYzaIgvr7Nq4gJclpw5kDejDPWezkamlU zo2GdyZqMWhu4el15dC4OQDKaouJGZ2buSYMIVFPSIy3mgDAo2uNssN/JlghorCmfTdt KPMw== 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=kz2vx1HfBw3fYaCpEUWWm3cKVnrJee8NXelXCbI0mp0=; b=Qx8u7oUaV7VprS8XxQCt/21/DXIkuDvZPB02BX+DojM9YMYSjdCieNgI6HQPSqUIS7 mmwRfBoLZoMuR0zRuveDpG6IRXogG9qoHDOA7LU95IvnGYeH//kf14xXfJyRuxcekTad vbGNhsnSmRDkeUEdEN5yYkx2RIcYoI6IK8gdp9FgWieztFoV2R809Yf78WfY6koxbkKS 14JUxrj5iiqSasa4B0k0AGMstbYQJLc1a3rFj7YfaHLrJ2URj70sarf8jx68INznPjAV fg6N7TLOJ2hbiYRsOKlBwTg+w041/c1sUEL6KVFa5dYQLQ5Do5R40D7GwCog2rfjcFbk upOA== X-Gm-Message-State: ANoB5pmMJXamx6fFkwf6FUP9z92AsOaP/i793VFYiyUvc/a21OczJGxg 6LjbJ8XqvySYggtVgHRaZ/Li6ooqO6Y= X-Google-Smtp-Source: AA0mqf6vP6p3ELVZ8Tmxx8ixp3JdhCrTwuQ9lG85B9Vo68PkLtfE9Ep15mg+qXI/OyfT3S9v4QyMBw== X-Received: by 2002:a17:902:a416:b0:188:f5de:8908 with SMTP id p22-20020a170902a41600b00188f5de8908mr26843934plq.65.1671144444436; Thu, 15 Dec 2022 14:47:24 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001894881842dsm146333plg.151.2022.12.15.14.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 14:47:23 -0800 (PST) Date: Thu, 15 Dec 2022 14:47:21 -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: <20221215224721.GA694065@nathanxps13> References: <20221214000145.GA638663@nathanxps13> <2561155.1670977214@sss.pgh.pa.us> <20221214004105.GA669835@nathanxps13> <20221214171023.GA689106@nathanxps13> <2707695.1671039752@sss.pgh.pa.us> <20221214174535.GA773264@nathanxps13> <2783450.1671042198@sss.pgh.pa.us> <20221214183759.GC773264@nathanxps13> <2787771.1671044578@sss.pgh.pa.us> <20221214231727.GA828014@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline In-Reply-To: <20221214231727.GA828014@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I tried setting wal_retrieve_retry_interval to 1ms for all TAP tests (similar to what was done in 2710ccd), and I noticed that the recovery tests consistently took much longer. Upon further inspection, it looks like the same (or a very similar) race condition described in e5d494d's commit message [0]. With some added debug logs, I see that all of the callers of MaybeStartWalReceiver() complete before SIGCHLD is processed, so ServerLoop() waits for a minute before starting the WAL receiver. A simple fix is to have DetermineSleepTime() take the WalReceiverRequested flag into consideration. The attached 0002 patch shortens the sleep time to 100ms if it looks like we are waiting on a SIGCHLD. I'm not certain this is the best approach, but it seems to fix the tests. On my machine, I see the following improvements in the tests (all units in seconds): HEAD patched (v9) check-world -j8 165 138 subscription 120 75 recovery 111 108 [0] https://postgr.es/m/21344.1498494720%40sss.pgh.pa.us -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --5mCyUwZo2JvN/JJP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0001-wake-up-logical-workers-as-needed-instead-of-rely.patch"