Re: persist logical slots to disk during shutdown checkpoint

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: persist logical slots to disk during shutdown checkpoint
Date: 2023-08-20 03:03:46
Message-ID: CAA4eK1KYO6cuPxY-yiR+Fd2U8=BH+G-PX=de5vGbBeoQRXrS7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 19, 2023 at 12:46 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
>
> On Sat, 19 Aug 2023, 14:16 Amit Kapila, <amit(dot)kapila16(at)gmail(dot)com> wrote:
>>
>
>> The idea discussed in the thread [1] is to always persist logical
>> slots to disk during the shutdown checkpoint. I have extracted the
>> patch to achieve the same from that thread and attached it here. This
>> could lead to some overhead during shutdown (checkpoint) if there are
>> many slots but it is probably a one-time work.
>>
>> I couldn't think of better ideas but another possibility is to mark
>> the slot as dirty when we update the confirm_flush LSN (see
>> LogicalConfirmReceivedLocation()). However, that would be a bigger
>> overhead in the running server as it could be a frequent operation and
>> could lead to more writes.
>
>
> Yeah I didn't find any better option either at that time. I still think that forcing persistence on shutdown is the best compromise. If we tried to always mark the slot as dirty, we would be sure to add regular overhead but we would probably end up persisting the slot on disk on shutdown anyway most of the time, so I don't think it would be a good compromise.
>

The other possibility is that we introduce yet another dirty flag for
slots, say dirty_for_shutdown_checkpoint which will be set when we
update confirmed_flush LSN. The flag will be cleared each time we
persist the slot but we won't persist if only this flag is set. We can
then use it during the shutdown checkpoint to decide whether to
persist the slot.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-08-20 08:07:26 Re: WIP: new system catalog pg_wait_event
Previous Message jian he 2023-08-20 02:18:23 Re: PostgreSQL 16 release announcement draft