Re: [Patch] add new parameter to pg_replication_origin_session_setup
| От | Amit Kapila |
|---|---|
| Тема | Re: [Patch] add new parameter to pg_replication_origin_session_setup |
| Дата | |
| Msg-id | CAA4eK1+sweRNinpkqjcP8T+9m1BY9xCbwEbWfM4tZD8923cqHQ@mail.gmail.com обсуждение исходный текст |
| Ответ на | RE: [Patch] add new parameter to pg_replication_origin_session_setup ("Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>) |
| Список | pgsql-hackers |
On Tue, Dec 23, 2025 at 2:24 PM Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com> wrote: > > When testing the new parameter in pg_replication_origin_session_setup(), I > noticed a bug allowing the origin in use to be dropped. The issue arises when > two backends set up the same origin; if the second backend resets the origin > first, it resets the acquired_by flag regardless of whether the first backend is > using it. This allows the origin to be dropped, enabling the slot in shared > memory to be reused, which is unintended. > > About the fix, simply adding a check for acquired_by field does not work, > because if the first backend resets the origin first, it still risks being > dropped while second backend uses it. > > To fully resolve this, I tried to add a reference count (refcount) for the > origin. The count is incremented when a backend sets up the origin and > decremented upon a reset. As a result, the replication origin is only dropped > when the reference count reaches zero. > > Thanks to Kuroda-San for discussing and reviewing this patch off-list. > Thanks to both of you for the report and patch. I'll look into it sometime during the next CF. -- With Regards, Amit Kapila.
В списке pgsql-hackers по дате отправления: