From: | Torsten Förtsch <tfoertsch123(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Allowing pg_recvlogical to create temporary replication slots |
Date: | 2024-11-01 19:04:41 |
Message-ID: | CAKkG4_=tRpR9MKLfOxPeQHme55=Sp+hArQ2bmqUQ=ztOSPiczw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
This is another version of the patch. It now includes tests.
On Fri, Nov 1, 2024 at 1:42 PM Torsten Förtsch <tfoertsch123(at)gmail(dot)com>
wrote:
> On Wed, Oct 30, 2024 at 9:01 AM Peter Eisentraut <peter(at)eisentraut(dot)org>
> wrote:
>
>> On 27.10.24 13:37, Torsten Förtsch wrote:
>> > The attached patch enables pg_recvlogical to create a temporary slot.
>>
>> I think you should explain a bit why you want to do that, what use case
>> or scenario this is meant to address.
>>
>
> In my particular case I want to filter for messages sent by
> pg_logical_emit_message(). I don't care much about getting ALL the changes.
> If the replication slot disappears and a few changes are lost it does not
> matter. So, a temporary rep slot makes more sense than creating one and
> then having to make sure it is not retaining wal forever later.
>
> I can imagine this also as a tool to monitor changes for a while and then
> simply disconnect without the need to remove the slot.
>
> Why am I interested in pg_logical_emit_message()? We have an application
> with relatively complicated transactions involving multiple tables. Some of
> them use pg_notify(). We also have synchronous replication. Sometimes I see
> lock avalanches that can be traced to the "AccessExclusiveLock on object 0
> of class 1262 of database 0". This lock is taken during commit when the
> notification is inserted in the queue. After that the backend waits for the
> confirmation by the sync replica. So, this lock presses all the
> transactions sending notifications into a sequence.
>
> Now, if the application uses pg_logical_emit_message() instead, then I
> think there is no equivalent lock. I understand the semantics are a bit
> different (timing) but close enough for my use case. Another advantage of
> pg_logical_emit_message() is the ability to send them even if the
> transaction is aborted.
>
> I was in the process of experimenting with this idea and found that
> pg_recvlogical can:
> - only create the slot or
> - create the slot and immediately use it
> - try to create the slot and if the slot is already there use it
>
> So, why not also allow it to create a temporary slot?
>
Attachment | Content-Type | Size |
---|---|---|
pg_recvlogical-temp-slot-v2.patch | text/x-patch | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2024-11-01 19:19:27 | Re: Separate memory contexts for relcache and catcache |
Previous Message | Andres Freund | 2024-11-01 18:44:51 | Re: Adding NetBSD and OpenBSD to Postgres CI |