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 1noVCF-0000Sd-WC for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 19:07:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1noVBG-0004o5-5r for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 19:05:58 +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 1noVBF-0004ng-EQ for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 19:05:57 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1noVBC-0003WH-Ov for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 19:05:56 +0000 Received: by mail-ej1-x630.google.com with SMTP id i19so34802716eja.11 for ; Tue, 10 May 2022 12:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=ccn8Gn+DjKbFFQnSU4NAqycY/4iobSOS0bxSzO5pVEQ=; b=WQNU7sqt+PTLbiHlTmyKqGPfEWRFIpVKvEciNXVmLpGs/xX3BFVzwoDMme8ta1qTXj S1eNDPoDsTKkEQBzjjl4ioSAJtOa8Ns8ujPVo82GBJsu2xbIE1BGkTiJjnP6Dov1uRKx YxR9YbzMOQrb1gicj7CdCqw8NgN97sAWU8kCn6XK9gVvGpKpMVhEiP4zyAUuIfzW9Prq MgSXm5xERr4U0uZy/Z0SXrwYXG3gVnAIWexb+GXpX5mgmV5uI/YL90B8wxpciLkWMfgU aw68dT4LEJx3FBiRScYRjVxf9HdQXpTLK34+RiMVXG0L3tGDB3t6UQjLwl1Lf75wuQPn 4ogg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=ccn8Gn+DjKbFFQnSU4NAqycY/4iobSOS0bxSzO5pVEQ=; b=ceVekpB633A/NFFvRktvdsv1g5hkeKNfHbXEBn5sfQLIOoDin4YKAR6oezcHPjEAPz Q0NmRXVtz0xDh6LimKPdOjWXpzkOfzWn3pMuA+Zu8+ronLWb623FomPO8oPch9lwrb9e y47qj7lDAv1oLCnVmBgYc87V5t/6EPW80n6hRfQlhtZzoUTV4fqFEoI73v3ehAyjMJuM bguiaNH7dUSYWuU3I44n3+eg6Nck/lZfelvbgBrMmQKnOed+TZFrjuau9hQpmmB9nTjl WGGfHEh3UhS6EnlOqIOHOVERzh0nRKW62L/2cQb9VRUXZS6v2YGWTA5Ti/7evUDY4ZmY fiNQ== X-Gm-Message-State: AOAM531vnCFDHFnJU4u2hPdVjKjrf3tUhG7ABgq2gNYy+NoNhQi1ErDk 2mu9M4GLbUk4J5aN/C85v36d3PYcFB3K0/uU/njZi58j3SFTSCuBob3FbaVi9X9EOe9Amd40N4h sPUrYZPEVwkRytFF/rAwsznn6eZq+SFRvTNdRotGSYdsez51iTNuaAqWih/PDDVMFmeSSzOi0DV Qr8/gnRncYlRTcuYwdyrKJq3CnMb9ASsGY85J04kXKa4vPT2LU4HSW X-Google-Smtp-Source: ABdhPJwfIeH3D9BtrH7Jpnom4tpiUsLsMYju/WgX5RKDF2Uui6B2Z9gHUwdLCfxOL7amJwrJtXRiYA== X-Received: by 2002:a17:907:1690:b0:6f5:40d:f4bb with SMTP id hc16-20020a170907169000b006f5040df4bbmr20606290ejc.495.1652209553353; Tue, 10 May 2022 12:05:53 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-250-165.net.upcbroadband.cz. [86.49.250.165]) by smtp.gmail.com with ESMTPSA id u5-20020a50d505000000b0042617ba63cdsm8021406edi.87.2022.05.10.12.05.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 May 2022 12:05:52 -0700 (PDT) Message-ID: Date: Tue, 10 May 2022 21:05:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: bogus: logical replication rows/cols combinations Content-Language: en-US To: Amit Kapila Cc: Alvaro Herrera , Peter Eisentraut , Pg Hackers References: <202205021144.zkbvyekn52v7@alvherre.pgsql> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/9/22 05:45, Amit Kapila wrote: > On Sun, May 8, 2022 at 11:41 PM Tomas Vondra > wrote: >> >> On 5/7/22 07:36, Amit Kapila wrote: >>> On Mon, May 2, 2022 at 6:11 PM Alvaro Herrera wrote: >>>> >>>> On 2022-May-02, Amit Kapila wrote: >>>> >>>> >>>>> I think it is possible to expose a list of publications for each >>>>> walsender as it is stored in each walsenders >>>>> LogicalDecodingContext->output_plugin_private. AFAIK, each walsender >>>>> can have one such LogicalDecodingContext and we can probably share it >>>>> via shared memory? >>>> >>>> I guess we need to create a DSM each time a walsender opens a >>>> connection, at START_REPLICATION time. Then ALTER PUBLICATION needs to >>>> connect to all DSMs of all running walsenders and see if they are >>>> reading from it. Is that what you have in mind? Alternatively, we >>>> could have one DSM per publication with a PID array of all walsenders >>>> that are sending it (each walsender needs to add its PID as it starts). >>>> The latter might be better. >>>> >>> >>> While thinking about using DSM here, I came across one of your commits >>> f2f9fcb303 which seems to indicate that it is not a good idea to rely >>> on it but I think you have changed dynamic shared memory to fixed >>> shared memory usage because that was more suitable rather than DSM is >>> not portable. Because I see a commit bcbd940806 where we have removed >>> the 'none' option of dynamic_shared_memory_type. So, I think it should >>> be okay to use DSM in this context. What do you think? >>> >> >> Why would any of this be needed? >> >> ALTER PUBLICATION will invalidate the RelationSyncEntry entries in all >> walsenders, no? So AFAICS it should be enough to enforce the limitations >> in get_rel_sync_entry, >> > > Yes, that should be sufficient to enforce limitations in > get_rel_sync_entry() but it will lead to the following behavior: > a. The Alter Publication command will be successful but later in the > logs, the error will be logged and the user needs to check it and take > appropriate action. Till that time the walsender will be in an error > loop which means it will restart and again lead to the same error till > the user takes some action. > b. As we use historic snapshots, so even after the user takes action > say by changing publication, it won't be reflected. So, the option for > the user would be to drop their subscription. > > Am, I missing something? If not, then are we okay with such behavior? > If yes, then I think it would be much easier implementation-wise and > probably advisable at this point. We can document it so that users are > careful and can take necessary action if they get into such a > situation. Any way we can improve this in future as you also suggested > earlier. > >> which is necessary anyway because the subscriber >> may not be connected when ALTER PUBLICATION gets executed. >> > > If we are not okay with the resultant behavior of detecting this in > get_rel_sync_entry(), then we can solve this in some other way as > Alvaro has indicated in one of his responses which is to detect that > at start replication time probably in the subscriber-side. > IMO that behavior is acceptable. We have to do that check anyway, and the subscription may start failing after ALTER PUBLICATION for a number of other reasons anyway so the user needs/should check the logs. And if needed, we can improve this and start doing the proactive-checks during ALTER PUBLICATION too. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company