Hi all, Interesting bug!
The end-position calculation in v8 looks correct to me. The end of the switch record is already computed in ReserveXLogSwitch(), before the reservation is extended to the segment boundary. Could we keep that value rather than reconstruct it later? PFA an alternative based on v8, with the existing test included. It separates EndPos from ReservedEndPos. That needs a little more refactoring, but each variable keeps one meaning throughout XLogInsertRecord(), which I find easier to follow. WDYT? It's only an idea on how to do less bugs in future, I'm not wedded to this refactoring. Perhaps, for backpatching, v8 is preferable because the change is smaller. Thank you! Best regards, Andrey Borodin.
v9-0001-Keep-WAL-switch-record-and-reservation-ends-distinct.patch
Description: Binary data
