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 1pk2Uw-0002PC-5v for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2023 12:44:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pk2Uu-00072r-Si for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2023 12:44:20 +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 1pk2Uu-00072i-Hc for pgsql-hackers@lists.postgresql.org; Wed, 05 Apr 2023 12:44:20 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pk2Un-0004EA-UG for pgsql-hackers@postgresql.org; Wed, 05 Apr 2023 12:44:19 +0000 Received: by mail-wm1-x329.google.com with SMTP id n9-20020a05600c4f8900b003f05f617f3cso2760064wmq.2 for ; Wed, 05 Apr 2023 05:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680698652; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1pa47ExiYcS7ORlTnzaRtfJJePSGDQi/BD5ZoNYjQ8I=; b=Hq9Csr9seP5HnGIV6gWFD+rVMElQG4IDEi369yQ7StQN/fCUZZwmd55OEmIfsr6Vub PpyYKhFVzGsA7NhHjrLu6fO3QBvszLHmoHU8V9SG4HVi4JT8fYPv9GKISns1qlnCzJux +7jBIEclmGopKgcVS/geeqYA5/9rEy+BvcRSQsLVALrDBq5asH5S2QMeN8eP5ZvszF+X ez2R1rfpb3LlfpBAt2ThcPSJvDyoaJDwFj/t2VPB2j6kj9XoDMLgF0F+X7WsRo8v+Dre 3KAe+BdCcOTIsOS35e6ondpj4noKqHtxNpXb98yZblBg753a5ERxmhzY4nCy8hNOLX8a 98lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680698652; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1pa47ExiYcS7ORlTnzaRtfJJePSGDQi/BD5ZoNYjQ8I=; b=r4JYBn7YBJtpITE9uXoNDvpEDaH+RCG2qUcFuC4YrXDG3PToVFLUG/EaX++fET4dee LdDHFFXFlgO4eDFU/Je/NEI6jhzi/4kYMpM9HthsrTsA247NZ1++DgXkfh7UT0fAE2gs b/cRSijXp2WaSm6gLkGvS4eEzzFnRilcbW/anrEH4KDXNJwbIxZY1QrhcfKdZizZAyeV a1IWx/jMauQkSMPKlrp2b0+IcTBjAN2ATCcyzNqfOTnJczds25p6Y/ihWwF9+mR0h3/e gRqd/rSXeH1RlUNTKeZguDrbLRjKxlA6K2WMNgE7rHleUwHuQfX+FQej2JA3ny/zY/Rs V33A== X-Gm-Message-State: AAQBX9caCKWVLx93cNUzuPPTbY08XRSwik+HNzVkgdWbJHJ3qLoQFKwI mGiPYH/nGuYEFhhzxHQD4ZE= X-Google-Smtp-Source: AKy350Y3oOy+VDKvWA7bvwXcqx0h3yNbv2zZ9WAws37n6cA9WYCeF/f80gOKjlR+DZLCJs0n3XqMlg== X-Received: by 2002:a1c:f013:0:b0:3ed:29d9:56ae with SMTP id a19-20020a1cf013000000b003ed29d956aemr4416982wmb.6.1680698651902; Wed, 05 Apr 2023 05:44:11 -0700 (PDT) Received: from [192.168.16.194] ([54.239.6.187]) by smtp.gmail.com with ESMTPSA id g6-20020a05600c4ec600b003edc4788fa0sm2221730wmq.2.2023.04.05.05.44.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Apr 2023 05:44:11 -0700 (PDT) Message-ID: Date: Wed, 5 Apr 2023 14:44:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: Minimal logical decoding on standbys Content-Language: en-US To: Amit Kapila Cc: Alvaro Herrera , Jeff Davis , Andres Freund , Robert Haas , Thomas Munro , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers References: <20230330095449.47yz2q4mn27t6xgl@alvherre.pgsql> <68a47e4c-f4bb-45ae-28be-938af60b203c@gmail.com> From: "Drouvot, Bertrand" 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 4/5/23 12:28 PM, Amit Kapila wrote: > On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand > wrote: >> Maybe we could change the doc with something among those lines instead? >> >> " >> Existing logical slots on standby also get invalidated if wal_level on primary is reduced to >> less than 'logical'. This is done as soon as the standby detects such a change in the WAL stream. >> >> It means, that for walsenders that are lagging (if any), some WAL records up to the parameter change on the >> primary won't be decoded". >> >> I don't know whether this is what one would expect but that should be less of a surprise if documented. >> >> What do you think? >> > > Yeah, I think it is better to document to avoid any surprises if > nobody else sees any problem with it. Ack. > BTW, another thought that > crosses my mind is that let's not invalidate the slots when the > standby startup process processes parameter_change record and rather > do it when walsender decodes the parameter_change record, if we think > that is safe. I have shared this as this crosses my mind while > thinking about this part of the patch and wanted to validate my > thoughts, we don't need to change even if the idea is valid. > I think this is a valid idea but I think I do prefer the current one (where the startup process triggers the invalidations) because: - I think this is better to invalidate as soon as possible. In case of inactive logical replication slot (walsenders stopped) it could take time to get "notified". While with the current approach you'd get notified in the logfile and pg_replication_slots even if walsenders are stopped. - This is not a "slot" dependent invalidation (as opposed to the xid invalidations case) - This is "somehow" the same behavior as on the primary: if one change the wal_level to be < logical then the engine will not start (if logical slot in place). Then what has been decoded is until the time the engine has been stopped. So if there is walsender lag, you'd not see some records. > minor nitpick: > + > + /* Intentional fall through to session cancel */ > + /* FALLTHROUGH */ > > Do we need to repeat fall through twice in different ways? > Do you mean, you'd prefer what was done in v52/0002? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com