RE: logical replication restrictions - Mailing list pgsql-hackers

From kuroda.hayato@fujitsu.com
Subject RE: logical replication restrictions
Date
Msg-id TYAPR01MB586624683ACD766B967F87F2F5469@TYAPR01MB5866.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: logical replication restrictions  ("Euler Taveira" <euler@eulerto.com>)
Responses RE: logical replication restrictions
List pgsql-hackers
Dear Euler,

Thank you for making the patch! I'm also interested in the patch so I want to join the thread.

While testing your patch, I noticed that the 032_apply_delay.pl failed.
PSA logs that generated on my machine. This failure is same as reported by cfbot[1].

It seemed that the apply worker could not exit and starts WaitLatch() again even if the subscription had been disabled.
Followings are cited from attached log.

```
...
2022-09-14 09:44:30.489 UTC [14880] 032_apply_delay.pl LOG:  statement: ALTER SUBSCRIPTION tap_sub SET (min_apply_delay
=86460000) 
2022-09-14 09:44:30.525 UTC [14777] DEBUG:  sending feedback (force 0) to recv 0/1690220, write 0/1690220, flush
0/1690220
2022-09-14 09:44:30.526 UTC [14759] DEBUG:  server process (PID 14878) exited with exit code 0
2022-09-14 09:44:30.535 UTC [14777] DEBUG:  logical replication apply delay: 86460000 ms
2022-09-14 09:44:30.535 UTC [14777] CONTEXT:  processing remote data for replication origin "pg_16393" during "BEGIN"
intransaction 734 finished at 0/16902A8 
2022-09-14 09:44:30.576 UTC [14759] DEBUG:  forked new backend, pid=14884 socket=6
2022-09-14 09:44:30.578 UTC [14759] DEBUG:  server process (PID 14880) exited with exit code 0
2022-09-14 09:44:30.583 UTC [14884] 032_apply_delay.pl LOG:  statement: ALTER SUBSCRIPTION tap_sub DISABLE
2022-09-14 09:44:30.589 UTC [14777] DEBUG:  logical replication apply delay: 86459945 ms
2022-09-14 09:44:30.589 UTC [14777] CONTEXT:  processing remote data for replication origin "pg_16393" during "BEGIN"
intransaction 734 finished at 0/16902A8 
2022-09-14 09:44:30.608 UTC [14759] DEBUG:  forked new backend, pid=14886 socket=6
2022-09-14 09:44:30.632 UTC [14886] 032_apply_delay.pl LOG:  statement: SELECT count(1) = 0 FROM pg_stat_subscription
WHEREsubname = 'tap_sub' AND pid IS NOT NULL; 
2022-09-14 09:44:30.665 UTC [14759] DEBUG:  server process (PID 14884) exited with exit code 0
...
```

I think this may be caused because the delayed worker will not read the modified catalog even if ALTER SUBSCRIPTION ...
DISABLEDis called. 
I also attached the fix patch that can be applied after yours. It seems OK on my env.

[1]: https://cirrus-ci.com/task/4888001967816704

Best Regards,
Hayato Kuroda
FUJITSU LIMITED


Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Inconsistencies in error messages
Next
From: Önder Kalacı
Date:
Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher