RE: Newly created replication slot may be invalidated by checkpoint

Поиск
Список
Период
Сортировка
От Hayato Kuroda (Fujitsu)
Тема RE: Newly created replication slot may be invalidated by checkpoint
Дата
Msg-id OSCPR01MB14966FC74C1C617559345930BF51FA@OSCPR01MB14966.jpnprd01.prod.outlook.com
обсуждение исходный текст
Ответ на RE: Newly created replication slot may be invalidated by checkpoint  ("Vitaly Davydov" <v.davydov@postgrespro.ru>)
Ответы RE: Newly created replication slot may be invalidated by checkpoint
Список pgsql-hackers
Dear Vitaly,

> I propose to apply this patch and then to think how to resolve this race
> condition, which seems to take place in 18 and master as well.

No, I think this invalidation can't happen in PG18/HEAD.
This is because in CheckpointGuts()->CheckPointReplicationSlots()->
ReplicationSlotsComputeRequiredLSN(), slots are examined one by one to determine
whether their restart_lsn has advanced since the last check. If any slot has
advanced, protection is applied starting from the oldest restart_lsn.
Crucially, this check is performed before WAL removal. The function call was
introduced in commit ca307d5cec.
 
Further analysis shows that it is also safe if a slot is being created and WAL
advances after CheckpointGuts() but before the removal segments are determined.
In this case the restart_lsn points the CHECKPOINT_REDO generated by the current
CHECKPOINT. This and later records won't be discarded.

Best regards,
Hayato Kuroda
FUJITSU LIMITED


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