public inbox for [email protected]
help / color / mirror / Atom feedFrom: Michael Paquier <[email protected]>
To: mahendrakar s <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Last removed wal segment file
Date: Mon, 23 Dec 2024 14:16:01 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <CABkiuWo_7Py0_RCbGKW=oEod4PFrFBM716qytdO3e-PK68DE9A@mail.gmail.com>
References: <CABkiuWo_7Py0_RCbGKW=oEod4PFrFBM716qytdO3e-PK68DE9A@mail.gmail.com>
On Mon, Dec 23, 2024 at 09:22:06AM +0530, mahendrakar s wrote:
> Is there any psql utility function that returns the last removed wal
> segment file?
> I see there is a method: XLogGetLastRemovedSegno in xlog.c.
> Would be happy to add a new psql function around it (similar to:
> pg_walfile_name, pg_last_wal_replay_lsn, etc other utility functions
> we have).
What's your use-case for it? I have to admit that finding out this
information can be a bit annoying as it requires checking the state of
archiving and the replication slots from which you would get a LSN
(not a segment name). Of course, one can use pg_ls_waldir() these
days and it would also work based on timeline number and even partial
segments which are not removed by the checkpointer. That's more
expensive than looking at a single counter in shmem.
If you wrap a SQL function around that, the segment number would not
be enough to guess which segment is removed: the timeline of the file
removed should also be added. Hence XLogCtlData should be extended
with a kind of lastRemovedSegTLI or equivalent to be able to rebuild
the file name from the data in shared memory. Note that
UpdateLastRemovedPtr() extracts the timeline number, does not store
it.
Also, note that UpdateLastRemovedPtr() has a small race condition when
it comes to monitoring: it is called before the file is physically
removed in RemoveOldXlogFiles(). It would not really matter much in
practice, I guess..
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
download
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Last removed wal segment file
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox