Re: Column Filtering in Logical Replication
Amit Kapila <amit.kapila16@gmail.com>
On Tue, Sep 7, 2021 at 11:26 AM Dilip Kumar <dilipbalaut@gmail.com> wrote: > > On Tue, Sep 7, 2021 at 11:06 AM Amit Kapila <amit.kapila16@gmail.com> wrote: >> >> On Mon, Sep 6, 2021 at 11:21 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: >> > >> > On 2021-Sep-06, Rahila Syed wrote: >> > >> > > > > ... ugh. Since CASCADE is already defined to be a >> > > > > potentially-data-loss operation, then that may be acceptable >> > > > > behavior. For sure the default RESTRICT behavior shouldn't do it, >> > > > > though. >> > > > >> > > > That makes sense to me. >> > > >> > > However, the default (RESTRICT) behaviour of DROP TABLE allows >> > > removing the table from the publication. I have implemented the >> > > removal of table from publication on drop column (RESTRICT) on the >> > > same lines. >> > >> > But dropping the table is quite a different action from dropping a >> > column, isn't it? If you drop a table, it seems perfectly reasonable >> > that it has to be removed from the publication -- essentially, when the >> > user drops a table, she is saying "I don't care about this table >> > anymore". However, if you drop just one column, that doesn't >> > necessarily mean that the user wants to stop publishing the whole table. >> > Removing the table from the publication in ALTER TABLE DROP COLUMN seems >> > like an overreaction. (Except perhaps in the special case were the >> > column being dropped is the only one that was being published.) >> > >> > So let's discuss what should happen. If you drop a column, and the >> > column is filtered out, then it seems to me that the publication should >> > continue to have the table, and it should continue to filter out the >> > other columns that were being filtered out, regardless of CASCADE/RESTRICT. >> > >> >> Yeah, for this case we don't need to do anything and I am not sure if >> the patch is dropping tables in this case? >> >> > However, if the column is *included* in the publication, and you drop >> > it, ISTM there are two cases: >> > >> > 1. If it's DROP CASCADE, then the list of columns to replicate should >> > continue to have all columns it previously had, so just remove the >> > column that is being dropped. >> > >> >> Note that for a somewhat similar case in the index (where the index >> has an expression) we drop the index if one of the columns used in the >> index expression is dropped, so we might want to just remove the >> entire filter here instead of just removing the particular column or >> remove the entire table from publication as Rahila is proposing. >> >> I think removing just a particular column can break the replication >> for Updates and Deletes if the removed column is part of replica >> identity. > > > But how this is specific to this patch, I think the behavior should be the same as what is there now, I mean now also we can drop the columns which are part of replica identity right. > Sure, but we drop replica identity and corresponding index as well. The patch ensures that replica identity columns must be part of the column filter and now that restriction won't hold anymore. I think if we want to retain that restriction then it is better to either remove the entire filter or remove the entire table. Anyway, the main point was that if we can remove the index/replica identity, it seems like there should be the same treatment for column filter. Another related point that occurred to me is that if the user changes replica identity then probably we should ensure that the column filters for the table still holds the creteria or maybe we need to remove the filter in that case as well. I am not sure if the patch is already doing something about it and if not then isn't it better to do something about it? -- With Regards, Amit Kapila.
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Doc: Explain about Column List feature.
- f98d07424523 16.0 landed
- 25996a82a446 15.0 landed
-
Doc: fix column list vs. replica identity rules.
- 376af686111e 16.0 landed
- ab3131880d8a 15.0 landed
-
Prohibit combining publications with different column lists.
- fd0b9dcebda7 15.0 cited
-
Fix the check to limit sync workers.
- be46985bed8a 10.21 landed
- a90de822e483 11.16 landed
- 59348fbdeb7b 12.11 landed
- 82d4a17a1750 13.7 landed
- c9dea58e2702 14.3 landed
- dd4ab6fd6528 15.0 landed
-
Wait for subscription to sync in t/031_column_list.sql
- 404f49338fef 15.0 landed
-
Move prattrs to the pg_publication_rel section in docs
- 41b00f8e601f 15.0 landed
-
Allow specifying column lists for logical replication
- 923def9a533a 15.0 landed
-
Fix row filters with multiple publications
- 5a079662256e 15.0 landed
-
Fix publish_as_relid with multiple publications
- 27fafee72d17 13.7 landed
- 677a1dc0ca0f 14.3 landed
- c91f71b9dc91 15.0 landed
-
Add some additional tests for row filters in logical replication.
- ceb57afd3ce1 15.0 cited
-
Add index on pg_publication_rel.prpubid
- 025b920a3d45 15.0 landed
-
Avoid using DefElemAction in AlterPublicationStmt
- 9623d8999603 15.0 landed
-
Small cleanups related to PUBLICATION framework code
- c9105dd3660f 15.0 landed
-
Add PublicationTable and PublicationRelInfo structs
- 0c6828fa987b 15.0 landed
-
Fix various concurrency issues in logical replication worker launching
- de4389712206 10.0 cited