Re: Column Filtering in Logical Replication
Masahiko Sawada <sawada.mshk@gmail.com>
( On Wed, Apr 13, 2022 at 6:45 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > On Wed, Apr 13, 2022 at 1:41 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > > > I've looked at this issue and had the same analysis. Also, I could > > reproduce this issue with the steps shared by Amit. > > > > As I mentioned in another thread[1], the fact that the tablesync > > worker doesn't check the return value from > > wait_for_worker_state_change() seems a bug to me. So my initial > > thought of the solution is that we can have the tablesync worker check > > the return value and exit if it's false. That way, the apply worker > > can restart and request to launch the tablesync worker again. What do > > you think? > > > > I think that will fix this symptom but I am not sure if that would be > the best way to deal with this because we have a mechanism where the > sync worker can continue even if we don't do anything as a result of > wait_for_worker_state_change() provided apply worker restarts. I think we can think this is a separate issue. That is, if tablesync worker can start streaming changes even without waiting for the apply worker to set SUBREL_STATE_CATCHUP, do we really need the wait? I'm not sure it's really safe. If it's safe, the tablesync worker will no longer need to wait there. > > The other part of the puzzle is the below check in the code: > /* > * If we reached the sync worker limit per subscription, just exit > * silently as we might get here because of an otherwise harmless race > * condition. > */ > if (nsyncworkers >= max_sync_workers_per_subscription) > > It is not clear to me why this check is there, if this wouldn't be > there, the user would have got either a WARNING to increase the > max_logical_replication_workers or the apply worker would have been > restarted. Do you have any idea about this? Yeah, I'm also puzzled with this check. It seems that this function doesn't work well when the apply worker is not running and some tablesync workers are running. I initially thought that the apply worker calls to this function as many as tables that needs to be synced, but it checks the max_sync_workers_per_subscription limit before calling to logicalrep_worker_launch(). So I'm not really sure we need this check. > > Yet another option is that we ensure that before launching sync > workers (say in process_syncing_tables_for_apply->FetchTableStates, > when we have to start a new transaction) we again call > maybe_reread_subscription(), which should also fix this symptom. But > again, I am not sure why it should be compulsory to call > maybe_reread_subscription() in such a situation, there are no comments > which suggest it, Yes, it will fix this issue. > > Now, the reason why it appeared recently in commit c91f71b9dc is that > I think we have increased the number of initial table syncs in that > test, and probably increasing > max_sync_workers_per_subscription/max_logical_replication_workers > should fix that test. I think so too. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/
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