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 1pY8DP-0003oO-K8 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Mar 2023 16:25:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pY8DM-0001Rx-MR for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Mar 2023 16:25:00 +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 1pY8DM-0001Ro-D4 for pgsql-hackers@lists.postgresql.org; Fri, 03 Mar 2023 16:25:00 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pY8DJ-0007FT-9O for pgsql-hackers@postgresql.org; Fri, 03 Mar 2023 16:24:58 +0000 Received: by mail-wr1-x436.google.com with SMTP id v16so2889958wrn.0 for ; Fri, 03 Mar 2023 08:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677860696; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=OpDPGzKyAVk6xMlSXnvkMz9S2L2khcaqu3xL/vpmutE=; b=Ma5hsZ0eIQ/nWFbEgMx1JGSR0X0uumvzz0JyjnfqKWL9L/mSPRfRHHsiDBlXj+GgkV 8tQUsuIzHEdvYi7K3FxDQBnYmx755RScQD+ZRBGT4265tyIAdjurCPmMHTEusUnkzG/Z fdGPPyOLLRungnloONjz+62K5yXQStndeebwSieWxk5kR4qnElkrU7o0jdZHK2BjeGKR M+qWeX/12Tm/v/TqZiQFG4Lh9TM0UR6+iJFSFv/pnOK/Xm44RLxzjZutsGzgBlawy4aS ZmrXrq3wPHloeX08BkQgkV0JpCltmM4UyzCJrUF6PoZNWian1qg5ubIWLqI13PgTVVuQ hKKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677860696; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OpDPGzKyAVk6xMlSXnvkMz9S2L2khcaqu3xL/vpmutE=; b=JFXAMNMZv7qX/l7ks6u+qyOOIwNS02dGY0KnTrLXYODpdxiJtHNHUeBbd0VGLoiTqH YbcBPy/VzTFmySk5Tca0Dw0asZX3Ubk9yDZpYyu3iKSNagZpRMb3DKwdEJWB3oOa0Qu3 VzWn8NXPMEcqFmFlOqicbdHPUkYI8uWqhfiaUQwyAb0y6wWUXw7Mpk9BoqePhYFirfga yq9vqyrkWx++RTEAne692R57qVrDarBn1ly/imLl04141OQgg81L5PVDzR/JnRMJhS2f rjYgxIiFuqEI5daPnmIJHPK6yKD7XDkQ78jjlSQqDFdZiFiztFCx1y7uQohX8sPtQzj5 j64Q== X-Gm-Message-State: AO0yUKWouM0zHLS4zhTsl3ePFhTrCVVvkBq0FsCZdgK+qVntWXtogdd+ zZWnaXKx0YgaYigOKzJtpHU= X-Google-Smtp-Source: AK7set/pA3+B19wb2zNnU5YE5RCECQJNMb02G/j4FxCHzWB5ByDtReztQMEMpsTaWjzIzfg2vyFh9g== X-Received: by 2002:adf:ea08:0:b0:2c7:809:38f2 with SMTP id q8-20020adfea08000000b002c7080938f2mr1991114wrm.12.1677860695707; Fri, 03 Mar 2023 08:24:55 -0800 (PST) Received: from [192.168.2.139] ([54.239.6.189]) by smtp.gmail.com with ESMTPSA id v2-20020adfe282000000b002c7066a6f77sm2611861wri.31.2023.03.03.08.24.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Mar 2023 08:24:55 -0800 (PST) Message-ID: Date: Fri, 3 Mar 2023 17:23:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: "Drouvot, Bertrand" Subject: Re: Minimal logical decoding on standbys To: Jeff Davis , Andres Freund Cc: Robert Haas , Thomas Munro , Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers References: <1f2ad9fd-53ff-74cc-a602-72d45423bcab@gmail.com> <05c0c4f3-82eb-bc6d-c876-5a265c05927b@gmail.com> <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> <490206c5-bcde-e558-628a-dc67dae4d439@gmail.com> <20230119024617.jzsgpcrgjdc6ysge@awork3.anarazel.de> <94d9d47e-72f4-393a-246e-e3fe8db7b741@gmail.com> <2d314c22b9e03415aa1c7d8fd1f698dae60effa7.camel@j-davis.com> <061eeb26-156e-6011-02b6-b4b1422e2aa6@gmail.com> <8a7da0c2-b7fe-1c78-4e47-a16239bf4839@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 3/2/23 8:45 PM, Jeff Davis wrote: > On Thu, 2023-03-02 at 10:20 +0100, Drouvot, Bertrand wrote: >> Right, but in our case, right after the wakeup (the one due to the CV >> broadcast, >> aka the one that will remove it from the wait queue) we'll exit the >> loop due to: >> >> " >>          /* check whether we're done */ >>          if (loc <= RecentFlushPtr) >>              break; >> " >> >> as the CV broadcast means that a flush/replay occurred. > > But does it mean that the flush/replay advanced *enough* to be greater > than or equal to loc? > Yes I think so: loc is when we started waiting initially and RecentFlushPtr is >= to when the broadcast has been sent. >> - If it is awakened due to the CV broadcast, then we'll right after >> exit the loop (see above) > > ... > >> I think that's not needed as we'd exit the loop right after we are >> awakened by a CV broadcast. > > See the comment here: > WalSndWaitForWal > * If this process has been taken out of the wait list, then we know > * that it has been signaled by ConditionVariableSignal (or > * ConditionVariableBroadcast), so we should return to the caller. But > * that doesn't guarantee that the exit condition is met, only that we > * ought to check it. > > You seem to be arguing that in this case, it doesn't matter; that > walreceiver knows what walsender is waiting for, and will never wake it > up before it's ready. I don't think that's true, and even if it is, it > needs explanation. > What I think is that, in this particular case, we are sure that the loop exit condition is met as we know that loc <= RecentFlushPtr. >> >> I agree that's a good idea and that it should/would work too. I just >> wanted to highlight that in this particular >> case that might not be necessary to build this new API. > > In this case it looks easier to add the right API than to be sure about > whether it's needed or not. > What I meant is that of course I might be wrong. If we do not agree that the new API (in this particular case) is not needed then I agree that building the new API is the way to go ;-) (+ it offers the advantage to be able to be more precise while reporting the wait event). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com