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.98.2) (envelope-from ) id 1xTWAa-00000000NO5-0SKr for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Nov 2026 03:17:12 +0000 Received: from localhost ([127.0.0.1]:48486 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xTWAZ-00000008ao2-2ME1 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Nov 2026 03:17:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:48188) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xTWAZ-00000008anr-1787 for pgsql-hackers@lists.postgresql.org; Wed, 18 Nov 2026 03:17:11 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xTWAW-00000000H5D-2UgG for pgsql-hackers@lists.postgresql.org; Wed, 18 Nov 2026 03:17:10 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2ed2bfe3252so1982515ad.3 for ; Tue, 17 Nov 2026 19:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794971826; x=1795576626; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=S3NgpR9tVMnD79xqmJ0KVTIFxkoDP09Gne4JwgoDAyA=; b=eonKXvQ/nUKztWA6/8RufQy6naEnPPTftR9Qll8BnvwFsVVISKZfqsgMl4TYfG+rHg wGxLTQP6mQM462FDkgxMiRaCXOxKoAquZELJ8XfFssKKylWtpilcwUo9mCenv6PsPs4R FryoMN4cCJ4MRjCeQIaNuQOSNqCQdVlh8nCjcyUxHDYDhyzEv3Ygx7nflLVh2J1TkRx6 ietb0mOJ5QO9SG7k7JFOS8O2CIKwRQRxyAXsGcCIUUIU2lGsoOLY5zhB7yB9SCmZ1QPj /X9vHPYd2LXEUbbHno+z22SsxM5GB0t1DzInDab1AhlzInB/D+8wjq/tmWuc7SSql82Q PuKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794971826; x=1795576626; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=S3NgpR9tVMnD79xqmJ0KVTIFxkoDP09Gne4JwgoDAyA=; b=P0y70CzDtmrgu3eVOQfqr0PUT6+CUjUEnv78Kk6GVBFDkyZnnnbkhYhiqrSsk5kDmG 7GrSK6smpcAgPjflhQqXUnrgD9uL4kUMHQABXRR2Eeno7IjqdH4KTrf+Kj+1W6yVBjze JwI/IaySmixFYwETe36x5vuUuRmVOkF0Suhzlg8IJw0BxCL1ZTU/ZAfL8SzabFNKzs+T nSSwagHtgQqg7Kg+p9CbXYEzMfQXMvckqYDCThGcBKzc44OGhucxzNDTddvtLgN8foBi cP8ehmuijd5aoAi+j4pMGZn3j1V/WqMewx7ZghjUdp9WKXo5cYgIxw2F8n+0zX6EVd8B Zjwg== X-Gm-Message-State: APuU4Z+1Z8pM2T3au/DGs4uAy4ibsgbPViyHSAl9J0KpslG2ad0a0OAf tDDNjLdf9CGHjGsuO3Anx8wGIJX9nFZnaBjQm5TGZQKhmfifjWUyzLM8 X-Gm-Gg: AZFdTZeqJTg1kBnJXSA7gflxoN/BEcN++tLRbSHecQU+qCyunjgNl8Z5Eq8tGk3fyvK qmFZ+MNj4g488sTID9gtJH3HdYukrs7QtqlJmW37fjKSrav8jOmxfUYg+c9Pi0Oe1K9e8ScdQmQ 5vgB9lvCQBzZgljt+0VEat1Xb5WoSPZ0Q15mSioG2RzeSXHJc6Y8pOv1Nljyr2CF0e0Xu5J7zGv wp9H5T5okqaRPHqM8eROkcv16GhLsMbvKNCus2MFuBngw0RUmmePl+14b+Pq1ixRz40iJXEgdC8 Q7JH8aE1WDVhU6ClJ3Mzva5QmR60nOn0J33sej3EFHX1WgEc54IMoUDkqA09FmsXIkrNGHLxqQR lNovRPIYFpGJbYlVqQLpT//XEjBySCV345HcxrbzG1ZhezzqqEpdmpUh2fuK33V3FWPre4q4nlj 3kBEnjCXpjBKZgA7l14KX7ksUH/H4K11D9Nzw2JJxuSLhpC5cl20bd4SmEXg6cOctnPe1uHUShN cSh0XIiNew4JENRoRq1Ip4HGU8J8DzHe/1JW6kQEVycu//UWAM7imr1BU9DU83M7Ry4C8rooIgg 0wBSMYY8ZDd4bN4Rf9uPWwLEvU+19shhrlu2JNY= X-Received: by 2002:a17:902:ce88:b0:2e9:4175:3065 with SMTP id d9443c01a7336-2eff71f5106mr12928635ad.4.1794971826394; Tue, 17 Nov 2026 19:17:06 -0800 (PST) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2eff62e324dsm5072945ad.74.2026.11.17.19.17.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2026 19:17:05 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: pg_walinspect: add functions to locate and list WAL by time and LSN From: Chao Li In-Reply-To: Date: Wed, 18 Nov 2026 11:16:31 +0800 Cc: PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <80E9F0AD-CFC5-4BE5-81DE-D8FE35E10A1C@gmail.com> To: Bharath Rupireddy X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Nov 18, 2026, at 01:17, Bharath Rupireddy = wrote: >=20 > Hi, >=20 > On Thu, Sep 17, 2026 at 9:06=E2=80=AFPM Chao Li = wrote: >>=20 >> I'd like to propose adding two new SQL functions to pg_walinspect. >=20 > Thanks, and sorry for the delay. Thanks a lot for your feedback. >=20 >> During HOW2026 in Jinan this April, a DBA talked to me that PG lacks = an easy way to locate WAL files by time. >=20 > I think using the existing pg_walinspect functions, one can look up > the times using the transaction commit/abort time from the description > column, starting from the last checkpoint's redo LSN till the current > flush LSN. Isn't this helpful? It takes a bit of time to do so, but > that should be fine. I'm afraid that's not easy. As I implemented in the patch, I even chose = to use a binary search to find the start and end LSN boundaries for a = time range. I don't think this can be done easily with just a few SQL = statements, especially for ordinary DBAs. I've heard from many DBAs who = have requested such a function. Surya also agreed that this is a real = use case. >=20 >> He described a scenario where somebody had done something wrong in a = production database, for example accidentally deleting important data. = The administrator knew that the incident had happened at around 1am the = last night and wanted to confirm what had happened by analyzing WAL. >=20 > Isn't one expected to set up *some* kind of auditing or delayed > streaming standby or such in production if worried about such > accidental deletes/drops? We cannot imagine all users' operational models. I started talking to = DBAs last year. My main takeaway is that real-world use cases are = usually far more complicated than what I can imagine as a hacker writing = PostgreSQL code. I didn't come up with this feature myself; some DBAs = requested it. >=20 >> The problem was that, with thousands of WAL files in pg_wal, where = should he start? >=20 > WAL files are archived and renamed/reused/removed, so all the > thousands of files, one of which could be the interesting file > containing the accidental WAL records, are not guaranteed to be > available in the pg_wal dir anyway. 1000 WAL files come to around > 16GB, and I'm not sure if anyone really prefers to delay checkpoints > beyond that point (max_wal_size is also usually set up to trigger the > checkpoint). If needed, one can use pg_waldump and some scripts to do > the analysis independently of the database instance. I guess users would be more likely to set wal_keep_size to a large value = in order to retain more WAL files. Yes, users can write scripts to do whatever kind of analysis. But here, = users want a simple, native PG method. This patch is trying to address a = user requirement and make DBAs' lives a bit easier. Also, this patch doesn't touch the core, it just adds two new functions = to the pg_walinspect extension. >=20 > I'm not against enhancing pg_walinspect for more use cases. However, > I'm a bit worried about complicating it for this. Unless I'm missing > something here, the reported issue could have been solved with a bit > of SQL over the existing functions and/or with some scripting with > pg_waldump over pg_wal dir or the archived WAL. >=20 I don't feel this patch adds significant complexity to pg_walinspect. = This feature doesn't change the existing logic of pg_walinspect, it only = adds two new functions. And as explained above, what the new functions = do is not as easy to achieve with just a bit of SQL. Whenever possible, = we should try to improve the user experience. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/