Re: min_safe_lsn column in pg_replication_slots view

Поиск
Список
Период
Сортировка
От Fujii Masao
Тема Re: min_safe_lsn column in pg_replication_slots view
Дата
Msg-id c7821eb9-1ca6-1a4c-29a3-3dc1659d8f76@oss.nttdata.com
обсуждение исходный текст
Ответ на Re: min_safe_lsn column in pg_replication_slots view  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Ответы Re: min_safe_lsn column in pg_replication_slots view  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: min_safe_lsn column in pg_replication_slots view  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Re: min_safe_lsn column in pg_replication_slots view  (Amit Kapila <amit.kapila16@gmail.com>)
Список pgsql-hackers

On 2020/06/30 17:07, Fujii Masao wrote:
> 
> 
> On 2020/06/26 13:45, Amit Kapila wrote:
>> On Fri, Jun 26, 2020 at 4:54 AM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>>>
>>> On 2020-Jun-26, Michael Paquier wrote:
>>>
>>>> On Thu, Jun 25, 2020 at 11:24:27AM -0400, Alvaro Herrera wrote:
>>>>> I don't understand the proposal.  Michael posted a patch that adds
>>>>> pg_wal_oldest_lsn(), and you say we should apply the patch except the
>>>>> part that adds that function -- so what part would be applying?
>>>>
>>>> I have sent last week a patch about only the removal of min_safe_lsn:
>>>> https://www.postgresql.org/message-id/20200619121552.GH453547@paquier.xyz
>>>> So this applies to this part.
>>>
>>> Well, I oppose that because it leaves us with no way to monitor slot
>>> limits.  In his opening email, Masao-san proposed to simply change the
>>> value by adding 1.  How you go from adding 1 to a column to removing
>>> the column completely with no recourse, is beyond me.
>>>
>>> Let me summarize the situation and possible ways forward as I see them.
>>> If I'm mistaken, please correct me.
>>>
>>> Problems:
>>> i)  pg_replication_slot.min_safe_lsn has a weird definition in that all
>>>      replication slots show the same value
>>>
>>
>> It is also not clear how the user can make use of that value?
>>
>>> ii) min_safe_lsn cannot be used with pg_walfile_name, because it returns
>>>      the name of the previous segment.
>>>
>>> Proposed solutions:
>>>
>>> a) Do nothing -- keep the min_safe_lsn column as is.  Warn users that
>>>     pg_walfile_name should not be used with this column.
>>> b) Redefine min_safe_lsn to be lsn+1, so that pg_walfile_name can be used
>>>     and return a useful value.
>>> c) Remove min_safe_lsn; add functions that expose the same value
>>> d) Remove min_safe_lsn; add a new view that exposes the same value and
>>>     possibly others
>>>
>>> e) Replace min_safe_lsn with a "distance" column, which reports
>>>     restart_lsn - oldest valid LSN
>>>     (Note that you no longer have an LSN in this scenario, so you can't
>>>     call pg_walfile_name.)
> 
> I like (e).
> 
>>
>> Can we consider an option to "Remove min_safe_lsn; document how a user
>> can monitor the distance"?  We have a function to get current WAL
>> insert location and other things required are available either via
>> view or as guc variable values.  The reason I am thinking of this
>> option is that it might be better to get some more feedback on what is
>> the most appropriate value to display.  However, I am okay if we can
>> reach a consensus on one of the above options.
> 
> Yes, that's an idea. But it might not be easy to calculate that distance
> manually by subtracting max_slot_wal_keep_size from the current LSN.
> Because we've not supported -(pg_lsn, numeric) operator yet. I'm
> proposing that operator, but it's for v14.

Sorry this is not true. That distance can be calculated without those operators.
For example,

SELECT restart_lsn - pg_current_wal_lsn() + (SELECT setting::numeric * 1024 * 1024 FROM pg_settings WHERE name =
'max_slot_wal_keep_size')distance FROM pg_replication_slots;
 

If the calculated distance is small or negative value, which means that
we may lose some required WAL files. So in this case it's worth considering
to increase max_slot_wal_keep_size.

I still think it's better and more helpful to display something like
that distance in pg_replication_slots rather than making each user
calculate it...

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: warnings for invalid function casts
Следующее
От: Fujii Masao
Дата:
Сообщение: max_slot_wal_keep_size and wal_keep_segments