Re: Disabled logical replication origin session causes primary key errors
От | Masahiko Sawada |
---|---|
Тема | Re: Disabled logical replication origin session causes primary key errors |
Дата | |
Msg-id | CAD21AoA1K8pD-90B-KW_8ifRRQU7_nOBZTo3We6ENpu+uCSdUw@mail.gmail.com обсуждение исходный текст |
Ответ на | Disabled logical replication origin session causes primary key errors (Shawn McCoy <shawn.the.mccoy@gmail.com>) |
Ответы |
Re: Disabled logical replication origin session causes primary key errors
|
Список | pgsql-bugs |
Hi, Thank you for the report and sharing the reproducers. On Fri, Apr 18, 2025 at 2:22 PM Shawn McCoy <shawn.the.mccoy@gmail.com> wrote: > > Hello, > > We have discovered a recent regression in the Origin handling of logical replication apply workers. We have found the causeof the issue was due to the worker resetting its local origin session information during the processing of an errorthat is > silently handled allowing the worker to continue. We suspect this is caused by the recent change made in the followingthread, https://www.postgresql.org/message-id/TYAPR01MB5692FAC23BE40C69DA8ED4AFF5B92@TYAPR01MB5692.jpnprd01.prod.outlook.com. > > The logical replication apply worker will originally setup the origin correctly. However, on the first insert will callinto the trigger which will raise an exception. This exception will execute the error callback that resets the originsession state. The exception will then be silently handled, returning execution back to the apply worker. In the secondreproduction, a function based index is used with the same result. > > At this point, the apply worker can continue to commit these changes, but has cleared all local origin session state. Asa result, we will not update our remote to local LSN mapping of the origin. Allowing for duplicate data to be applied. I agree with your analysis. When the subscriber restarts the logical replication, changes that happened since the last acknowledged LSN would be replicated again. With commit 3f28b2fcac33f, we reset the replication origin in apply_error_callback() but I guess moving it to the PG_CATCH() block in start_apply() might work. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com
В списке pgsql-bugs по дате отправления: