On Sat, 2023-11-04 at 20:55 +0530, Bharath Rupireddy wrote:
> +             XLogRecPtr      EndPtr =
> pg_atomic_read_u64(&XLogCtl->xlblocks[curridx]);
> +
> +             /*
> +              * xlblocks value can be InvalidXLogRecPtr before
> the new WAL buffer
> +              * page gets initialized in AdvanceXLInsertBuffer.
> In such a case
> +              * re-read the xlblocks value under the lock to
> ensure the correct
> +              * value is read.
> +              */
> +             if (unlikely(XLogRecPtrIsInvalid(EndPtr)))
> +             {
> +                     LWLockAcquire(WALBufMappingLock,
> LW_EXCLUSIVE);
> +                     EndPtr = pg_atomic_read_u64(&XLogCtl-
> >xlblocks[curridx]);
> +                     LWLockRelease(WALBufMappingLock);
> +             }
> +
> +             Assert(!XLogRecPtrIsInvalid(EndPtr));

Can that really happen? If the EndPtr is invalid, that means the page
is in the process of being cleared, so the contents of the page are
undefined at that time, right?

Regards,
        Jeff Davis



Reply via email to