From: | "Vitaly Davydov" <v(dot)davydov(at)postgrespro(dot)ru> |
---|---|
To: | "Alexander Korotkov" <aekorotkov(at)gmail(dot)com> |
Cc: | "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>, "Masahiko Sawada" <sawada(dot)mshk(at)gmail(dot)com>, tomas(at)vondra(dot)me |
Subject: | Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly |
Date: | 2025-05-20 15:44:44 |
Message-ID: | 309f08-682ca380-25-139bf240@62751029 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Alexander,
Thank you very much for the review!
> The patchset doesn't seem to build after 371f2db8b0, which adjusted
> the signature of the INJECTION_POINT() macro. Could you, please,
> update the patchset accordingly.
I've updated the patch (see attached). Thanks.
> I see in 0004 patch we're calling XLogGetReplicationSlotMinimumLSN()
> before slots synchronization then use it for WAL truncation.
> Generally looks good. But what about the "if
> (InvalidateObsoleteReplicationSlots(...))" branch? It calls
> XLogGetReplicationSlotMinimumLSN() again. Why would the value
> obtained from the latter call reflect slots as they are synchronized
> to the disk?
In patch 0004 I call XLogGetReplicationSlotMinimumLSN() again to keep the old
behaviour - this function was called in KeepLogSeg prior to my change. I also
call CheckPointReplicationSlots at the next line to save the invalidated and
other dirty slots on disk again to make sure, the new oldest LSN is in sync.
The problem I tried to solve in this if-branch is to fix test
src/test/recovery/t/019_replslot_limit.pl which was failed because the WAL was
not truncated enought for the test to pass ok. In general, this branch is not
necessary and we may fix the test by calling checkpoint twice (please, see the
alternative.rej patch for this case). If you think, we should incorporate this
new change, I'm ok to do it. But the WAL will be truncating more lazily.
Furthermore, I think we can save slots on disk right after invalidation, not in
CheckPointGuts to avoid saving invalidated slots twice.
With best regards,
Vitaly
Attachment | Content-Type | Size |
---|---|---|
0002-Add-TAP-test-to-check-logical-repl-slot-advance-duri.v3.patch | text/x-patch | 8.0 KB |
0004-Keep-WAL-segments-by-slot-s-flushed-restart-LSN.v3.patch | text/x-patch | 6.0 KB |
alternative.rej | text/x-reject | 3.1 KB |
0003-Add-TAP-test-to-check-physical-repl-slot-advance-dur.v3.patch | text/x-patch | 6.1 KB |
0005-Remove-redundant-ReplicationSlotsComputeRequiredLSN-.v3.patch | text/x-patch | 6.3 KB |
0001-Add-injection-points-to-test-replication-slot-advanc.v3.patch | text/x-patch | 3.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2025-05-20 15:47:56 | Re: Suggestion: Update Copyright Year to 2025 in Recently Added Files |
Previous Message | Tom Lane | 2025-05-20 15:38:31 | Re: generic plans and "initial" pruning |