Re: Fsync (flush) all inserted WAL records
От | Vitaly Davydov |
---|---|
Тема | Re: Fsync (flush) all inserted WAL records |
Дата | |
Msg-id | ae3d1-66b37980-5-11516e80@151277688 обсуждение исходный текст |
Ответ на | Re: Fsync (flush) all inserted WAL records (Aleksander Alekseev <aleksander@timescale.com>) |
Ответы |
Re: Fsync (flush) all inserted WAL records
|
Список | pgsql-hackers |
Hi Aleksander,
On Wednesday, August 07, 2024 12:19 MSK, Aleksander Alekseev <aleksander@timescale.com> wrote:
I would propose a new function to fulfill my requirements like this (see below) but I prefer not to create new functions unreasonably:
XLogRecPtr
GetXLogLastInsertEndRecPtr(void)
{
XLogCtlInsert *Insert = &XLogCtl->Insert;
uint64 current_bytepos;
SpinLockAcquire(&Insert->insertpos_lck);
current_bytepos = Insert->CurrBytePos;
SpinLockRelease(&Insert->insertpos_lck);
return XLogBytePosToEndRecPtr(current_bytepos);
}
This function differs from the existing GetXLogInsertRecPtr() by calling XLogBytePosToEndRecPtr instead of XLogBytePosToRecPtr.
With best regards,
Vitaly
On Wednesday, August 07, 2024 12:19 MSK, Aleksander Alekseev <aleksander@timescale.com> wrote:
> Does pg_current_wal_flush_lsn() [1] return what you need?Thank you for the response. I need the LSN of the last inserted by not flushed WAL record. The function pg_current_wal_flush_lsn() doesn't help. It returns the current flush position. GetInsertRecPtr() doesn't help as well because it returns XLogCtl->LogwrtRqst.Write which is updated when the record crosses page boundary. I looked at the code and haven't found any suitable function except of GetLastImportantRecPtr() but it returns start LSN of the last inserted important record (but I need end lsn).
>
> [1]: https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL
If not, take a look at its implementation and functions around,
GetInsertRecPtr() and others. I believe you will find all you need for
the task.
I would propose a new function to fulfill my requirements like this (see below) but I prefer not to create new functions unreasonably:
XLogRecPtr
GetXLogLastInsertEndRecPtr(void)
{
XLogCtlInsert *Insert = &XLogCtl->Insert;
uint64 current_bytepos;
SpinLockAcquire(&Insert->insertpos_lck);
current_bytepos = Insert->CurrBytePos;
SpinLockRelease(&Insert->insertpos_lck);
return XLogBytePosToEndRecPtr(current_bytepos);
}
This function differs from the existing GetXLogInsertRecPtr() by calling XLogBytePosToEndRecPtr instead of XLogBytePosToRecPtr.
With best regards,
Vitaly
В списке pgsql-hackers по дате отправления: