Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tPanl-00DsI2-Cn for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Dec 2024 05:16:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tPank-007TTR-K0 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Dec 2024 05:16:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tPank-007TTI-A4 for pgsql-hackers@lists.postgresql.org; Mon, 23 Dec 2024 05:16:20 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tPanh-001AUF-D9 for pgsql-hackers@lists.postgresql.org; Mon, 23 Dec 2024 05:16:19 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id D782813801AD; Mon, 23 Dec 2024 00:16:15 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Mon, 23 Dec 2024 00:16:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1734930975; x=1735017375; bh=9Xa5gSBB92 4ss++wp7dF9E5Y4V6wMPYhYbmUfR7crng=; b=LQm9k2A9OyKNIufHwQglaCztUR DfhE4ZWtmfm3YRPRWH3eXeDxsxE0rPlqw/uSe/BVfFR6Udjswnkr3+kKDiWz8nyd nbAfsOIu9eK2Y/3P/8dPiiRTFXnRUMawbv8RO/X2zLPYoFg3ChY8484PUOyhUiYw GGEfB6VbgNiQxHaSKjSqJ7Vh6yyQgQcx75ohdURRErwWCWJbQzZCMzISKg6I/yJl HDIF0Cq5rUz/X3CMyQB6m8Rhy15jy57Xq5+C8p92w+lPWy6Qhh5ac/rbPTbpVp3V 5oHKg/IuspdmBZC8nsL7D7AUg20xByNUJErAPt4oKia0lBAZN27X5D+gp2ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1734930975; x=1735017375; bh=9Xa5gSBB924ss++wp7dF9E5Y4V6wMPYhYbm UfR7crng=; b=pkf7OXP1GO32yTrfrdSjqEiU17kGWoVsBBClUnoIU+KhkBRizB5 w3GNHPjIdlRJtxCG1CRbfEkmfUBc5Odgq6NxH9GKi3XOH0CS8uv+ahxV2yjXeOUS rqTI5Tp6xwbj3Tl/fqEEsqcinW0i57xbrisorETSptgHEYZCbBgJQmS+QuyrZ5Mv dqru5qu6FKoURat+vkf148oxRPiM3RzjTeY4dQCW+gSAT0+KkSxBbXz8Bfgn4/kr M0MjvlUitEUGaBCorveFapVyAcCqrFctX/PbsSngZ/06gZvO1pao77v/YEaZ3Sn1 pVnqmjJBFJQnG67xoXnb+qI0cw1+ljqSbug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtledgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhf gggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruc eomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteel ieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepmhgrhhgvnhgurhgrkhgrrhhfohhrphhgsehgmhgrihhlrdgtohhm pdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvg hsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Dec 2024 00:16:14 -0500 (EST) Date: Mon, 23 Dec 2024 14:16:01 +0900 From: Michael Paquier To: mahendrakar s Cc: PostgreSQL Hackers Subject: Re: Last removed wal segment file Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w9PlkCgGyLvBktEP" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --w9PlkCgGyLvBktEP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --w9PlkCgGyLvBktEP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmdo8hEACgkQnvQgOdby QH0Oeg/9GxpF29zKVA6fIId1J8Rez40ozB8nvAzfSbA6bjWcK16Byd1/cSVxLfQ8 9VcUATGHGjKNG4lzix10QBuLOwNolP6M/6A3qYdhTGlSaxaW4F3XWklakPzUCl+p MHn5S/ctOdT3wwpz+bip2zl3V5bKy206koUmCi9QIN12CSa2BmFJwvE3tuhaPjVy ELs2qh+U3D9yY4ZTq3dmQv8fg+Rw2qRNuFAMJoaXI8+xIovBa+t+4GwVhhNNIrDe ZxSqHWLeWAbZp4d4zgEipBoedccDSMy1EmR6Wi4sw+40PnKeaBvKCZkyplDdga1z wFnh7PFSKH11YO4DjB8tMZdXr+8v2PDbG31Jvk/t1vmTWUpu3VcgcgPrhiruy5cT z6tAuuRMwNCWXV0boDJE/Yb3YFaRsbXmKXVNECDe25K8owhNW7VSzu9pNzo0+EmS C/ZKDy5XuNnAkTJ06OO2ybe004w2t9/IjprmxUX9g1BMO5xVHmBJzHpljlTqSM22 LLyoaFrc1kR7NALYWCU8igjK+8u9P2zBM+QVkAenn/gGxV6/sgvAakS1BFmkluJl ZyQulAnnJf4OVXfexolLXfDpzu+GP4IQ0OqGowgUlEnyymoJf8/PGAg+Qa0sNGrK g/u5uqYx5rpZa0Q5PPIQdM01wtvThA1NowM5yv/EG88+opJLsgo= =bf3c -----END PGP SIGNATURE----- --w9PlkCgGyLvBktEP--