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 1qEP05-0007vf-16 for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jun 2023 06:50:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qEP03-0001hi-Kr for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jun 2023 06:49:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qEP03-0001gs-B5 for pgsql-hackers@lists.postgresql.org; Wed, 28 Jun 2023 06:49:59 +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 1qEOzz-000vDv-VH for pgsql-hackers@postgresql.org; Wed, 28 Jun 2023 06:49:58 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fa8cd4a113so33303175e9.2 for ; Tue, 27 Jun 2023 23:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687934994; x=1690526994; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uwaGWabSnReTYOAAt1AJmOhSpZKlShBE3Wlmx621dY4=; b=MQyRLyKb7D3XjoqaybdXT/W0+f9CVxvmkuU6Z75anf2wVeR2MzL9C/2/YEOy8m/Inm 707xW4lIDgNJBgnb6Btc0KWcyAiC49wvUQ5oh8LOUMAMT8U2010/YlCGe3mS+K6Amg07 JN1XJdvOXYAQf9jaMXlJ4hxYPpwoWsMssCZ5rIyJo7S8Ufod/9VhstfozcaV5K6pou1L OyZp3/DlWDgYCZYzx9iGTWAhkYQzO8omhrdKJfhBcGQ8b54inZgu0KaxeEutyn28xsaR oWjzDvwlPH7OOgPUfZP18Bf8ctqCl71ria/NvS/aVBzhMThVdiNNbLTDx5TNbe7gqYXv bmfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687934994; x=1690526994; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uwaGWabSnReTYOAAt1AJmOhSpZKlShBE3Wlmx621dY4=; b=Cf0RtcJWP/sOpha0uYtqwMS/oIUW/XedlFngLgy1onpIAGez3hfXKzLRUX96aBGjfd s7gnY9kzcy39axOhjCtKbS3HIL2KOP4A9nJ4BUFNlXBVL6IcOT+OVrgNNxzhnF9S55gd nCA0YEseDVpbf6ZDoGlCAfaiVWM/nKtDCpnHgLMIiNaf+Zr9CZjZ2VIsu53btyfIpyr8 z7LtGhFjN1O5CFUSp1kukHXgVNSsJmca2dfY2NaV+lbAZxynvfDmTNwIHTYzOU9hW1+e LTuMRuRLZHykkALngnfoB6p7uJIQ2OK/Y5wsmxZ0K/eoz35JWDYTig743Ft5JY3H9kJI HzdQ== X-Gm-Message-State: AC+VfDwbDAwEiP1Nl48i9JJuBVMCV0DMHU4e1YmfTuZ4uOHqWsqd/8wa k9v905r6JhE2waMBLuylEr0= X-Google-Smtp-Source: ACHHUZ64kJSI3HOsru2Di+vhuhF9M263x8AFUY1kYoBjuCa8x3IAzyIQI3xRTn7inmJXIUw6nzMxrQ== X-Received: by 2002:a1c:ed08:0:b0:3f4:27ff:7d48 with SMTP id l8-20020a1ced08000000b003f427ff7d48mr23493589wmh.19.1687934994198; Tue, 27 Jun 2023 23:49:54 -0700 (PDT) Received: from ?IPV6:2a01:cb11:55e:1700:f55a:f896:9f78:691c? ([2a01:cb11:55e:1700:f55a:f896:9f78:691c]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b003f90ab2fff9sm12806813wmi.9.2023.06.27.23.49.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jun 2023 23:49:53 -0700 (PDT) Message-ID: <6932a919-df8a-8127-9f92-227aed8e62bf@gmail.com> Date: Wed, 28 Jun 2023 08:49:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: Synchronizing slots from primary to standby To: Amit Kapila Cc: Peter Eisentraut , Bruce Momjian , Ashutosh Sharma , Andres Freund , pgsql-hackers References: <514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com> <20220205195944.drwc3psrb5udt2cw@alap3.anarazel.de> <20220207203222.22aktwxrt3fcllru@alap3.anarazel.de> <0c44c106-b5f7-d293-dcbc-04903046313f@gmail.com> Content-Language: en-US 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 6/26/23 12:34 PM, Amit Kapila wrote: > On Mon, Jun 26, 2023 at 11:15 AM Drouvot, Bertrand > wrote: >> >> On 6/20/23 12:22 PM, Amit Kapila wrote: >>> On Mon, Jun 19, 2023 at 9:56 PM Drouvot, Bertrand >>> wrote: >> >>>> In such a case (slot valid on the primary but invalidated on the standby) then I think we >>>> could drop and recreate the invalidated slot on the standby. >>>> >>> >>> Will it be safe? Because after recreating the slot, it will reserve >>> the new WAL location and build the snapshot based on that which might >>> miss some important information in the snapshot. For example, to >>> update the slot's position with new information from the primary, the >>> patch uses pg_logical_replication_slot_advance() which means it will >>> process all records and update the snapshot via >>> DecodeCommit->SnapBuildCommitTxn(). >> >> Your concern is that the slot could have been consumed on the standby? >> >> I mean, if we suppose the "synchronized" slot can't be consumed on the standby then >> drop/recreate such an invalidated slot would be ok? >> > > That also may not be sufficient because as soon as the slot is > invalidated/dropped, the required WAL could be removed on standby. > Yeah, I think once the slot is dropped we just have to wait for the slot to be re-created on the standby according to the new synchronize_slot_names GUC. Assuming the initial slot "creation" on the standby (coming from the synchronize_slot_names usage) is working "correctly" then it should also work "correctly" once the slot is dropped. If we agree that a synchronized slot can not/should not be consumed (will implement this behavior) then I think the proposed scenario above should make sense, do you agree? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com