Re: Fsync (flush) all inserted WAL records

2024-08-20 Thread Vitaly Davydov
Dear All, I would propose a new function like GetXLogInsertRecPtr(), but with some modifications (please, see the attached patch). The result LSN can be passed to XLogFLush() safely. I believe, it will not raise an error in any case. XLogFlush(GetXLogLastInsertEndRecPtr()) will flush (fsync) a

Re: Fsync (flush) all inserted WAL records

2024-08-18 Thread Michael Paquier
On Wed, Aug 07, 2024 at 06:00:45PM +0300, Aleksander Alekseev wrote: > Assuming the function has value, as you claim, I see no reason not to > expose it similarly to pg_current_wal_*(). On top of that you will > have to test-cover it anyway. The easiest way to do it will be to have > an SQL-wrapper

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Aleksander Alekseev
Hi, > I use asynchronous commit (without XLogFlush/fsync at commit). At some moment > I would like to XLogFlush (fsync) all already asynchronously committed > transactions (inserted but not flushed/fsynced yet WAL records). Assume, that > there is no any active transactions at this moment, no a

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Vitaly Davydov
On Wednesday, August 07, 2024 16:55 MSK, Aleksander Alekseev wrote:   Perhaps you could give more context on the use cases for this function? The value of it is not quite clear. What people typically need is making sure if a given LSN was fsync'ed and/or replicated and/or applied on a replica. Y

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Aleksander Alekseev
Hi Vitaly, > 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; > SpinLockA

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Vitaly Davydov
Hi Aleksander, On Wednesday, August 07, 2024 12:19 MSK, Aleksander Alekseev wrote:  > Does pg_current_wal_flush_lsn() [1] return what you need? > > [1]: > https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL If not, take a look at its implementation and func

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Aleksander Alekseev
Hi, > > Could you please advice which way to go? > > Does pg_current_wal_flush_lsn() [1] return what you need? > > [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

Re: Fsync (flush) all inserted WAL records

2024-08-07 Thread Aleksander Alekseev
Hi, > I use async commits. At some moment, I would like to make sure that all > inserted WAL records are fsync-ed. I can use XLogFlush function but I have > some doubts which LSN to specify. There is a number of functions which return > write or insert LSNs but they are not applicable. > > I ca

Fsync (flush) all inserted WAL records

2024-08-05 Thread Vitaly Davydov
Hi Hackers, I use async commits. At some moment, I would like to make sure that all inserted WAL records are fsync-ed. I can use XLogFlush function but I have some doubts which LSN to specify. There is a number of functions which return write or insert LSNs but they are not applicable. I can'