pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_ls_waldir does not work on standy
3+ messages / 2 participants
[nested] [flat]
* pg_ls_waldir does not work on standy
@ 2022-12-12 13:21 Nikhil Shetty <nikhil.dba04@gmail.com>
2022-12-12 16:22 ` Re: pg_ls_waldir does not work on standy Nikhil Shetty <nikhil.dba04@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Nikhil Shetty @ 2022-12-12 13:21 UTC (permalink / raw)
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Hi,
We see below error when running the function on a standby instance
postgres=# SELECT * FROM pg_ls_waldir()
postgres-# ;
ERROR: could not stat directory "pg_wal": No such file or directory
It works on a primary instance
Listing log directory works in both primary and standby
postgres=# select * from pg_ls_logdir();
name | size | modification
-------------------------+-----------+------------------------
postgresql-Fri.log | 274856244 | 2022-12-10 00:00:00+00
postgresql-Sat.log | 272873161 | 2022-12-11 00:00:00+00
postgresql-Thu.log | 274696376 | 2022-12-09 00:00:00+00
Thanks,
Nikhil
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_ls_waldir does not work on standy
2022-12-12 13:21 pg_ls_waldir does not work on standy Nikhil Shetty <nikhil.dba04@gmail.com>
@ 2022-12-12 16:22 ` Nikhil Shetty <nikhil.dba04@gmail.com>
2022-12-12 17:24 ` Re: pg_ls_waldir does not work on standy Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Nikhil Shetty @ 2022-12-12 16:22 UTC (permalink / raw)
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Postgres version is 10.12
On Mon, Dec 12, 2022 at 6:51 PM Nikhil Shetty <nikhil.dba04@gmail.com>
wrote:
> Hi,
>
> We see below error when running the function on a standby instance
>
> postgres=# SELECT * FROM pg_ls_waldir()
>
> postgres-# ;
>
> ERROR: could not stat directory "pg_wal": No such file or directory
>
>
> It works on a primary instance
>
>
>
> Listing log directory works in both primary and standby
>
>
> postgres=# select * from pg_ls_logdir();
>
> name | size | modification
>
> -------------------------+-----------+------------------------
>
> postgresql-Fri.log | 274856244 | 2022-12-10 00:00:00+00
>
> postgresql-Sat.log | 272873161 | 2022-12-11 00:00:00+00
>
> postgresql-Thu.log | 274696376 | 2022-12-09 00:00:00+00
>
>
>
> Thanks,
>
> Nikhil
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_ls_waldir does not work on standy
2022-12-12 13:21 pg_ls_waldir does not work on standy Nikhil Shetty <nikhil.dba04@gmail.com>
2022-12-12 16:22 ` Re: pg_ls_waldir does not work on standy Nikhil Shetty <nikhil.dba04@gmail.com>
@ 2022-12-12 17:24 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2022-12-12 17:24 UTC (permalink / raw)
To: Nikhil Shetty <nikhil.dba04@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Nikhil Shetty <nikhil.dba04@gmail.com> writes:
> Postgres version is 10.12
That's a couple years out of date. 10.13 and up have a probably-relevant
bug fix:
Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL_13_BR [085b6b667] 2020-03-11 15:27:59 -0400
Branch: REL_12_STABLE Release: REL_12_3 [3c8864fc1] 2020-03-11 15:27:59 -0400
Branch: REL_11_STABLE Release: REL_11_8 [63b51dfec] 2020-03-11 15:27:59 -0400
Branch: REL_10_STABLE Release: REL_10_13 [05283dd5b] 2020-03-11 15:28:00 -0400
Avoid holding a directory FD open across pg_ls_dir_files() calls.
This coding technique is undesirable because (a) it leaks the FD for
the rest of the transaction if the SRF is not run to completion, and
(b) allocated FDs are a scarce resource, but multiple interleaved
uses of the relevant functions could eat many such FDs.
In v11 and later, a query such as "SELECT pg_ls_waldir() LIMIT 1"
yields a warning about the leaked FD, and the only reason there's
no warning in earlier branches is that fd.c didn't whine about such
leaks before commit 9cb7db3f0. Even disregarding the warning, it
wouldn't be too hard to run a backend out of FDs with careless use
of these SQL functions.
Hence, rewrite the function so that it reads the directory within
a single call, returning the results as a tuplestore rather than
via value-per-call mode.
There are half a dozen other built-in SRFs with similar problems,
but let's fix this one to start with, just to see if the buildfarm
finds anything wrong with the code.
In passing, fix bogus error report for stat() failure: it was
whining about the directory when it should be fingering the
individual file. Doubtless a copy-and-paste error.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Back-patch to v10 where this function was added.
Justin Pryzby, with cosmetic tweaks and test cases by me
Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-12-12 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 13:21 pg_ls_waldir does not work on standy Nikhil Shetty <nikhil.dba04@gmail.com>
2022-12-12 16:22 ` Nikhil Shetty <nikhil.dba04@gmail.com>
2022-12-12 17:24 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox