Re: pgsql: Rename argument in pg_get_process_memory_contexts().

2025-04-10 Thread Daniel Gustafsson
> On 9 Apr 2025, at 06:02, Michael Paquier wrote: > > On Wed, Apr 09, 2025 at 12:49:52PM +1200, David Rowley wrote: >> On Wed, 9 Apr 2025 at 09:22, Daniel Gustafsson >> wrote: >>> Rename argument in pg_get_process_memory_contexts(). >> >>> src/include/catalog/pg_proc.dat | 2 +- >> >> I think t

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Fix race with synchronous_standby_names at startup

2025-04-10 Thread Michael Paquier
Fix race with synchronous_standby_names at startup synchronous_standby_names cannot be reloaded safely by backends, and the checkpointer is in charge of updating a state in shared memory if the GUC is enabled in WalSndCtl, to let the backends know if they should wait or not for a given LSN. This

pgsql: Add code comment explaining ins_since_vacuum and aborted inserts

2025-04-10 Thread David Rowley
Add code comment explaining ins_since_vacuum and aborted inserts Sami complained that there's a discrepancy between n_mod_since_analyze and n_ins_since_vacuum, as the former only accounts for committed changes and the latter tracks committed and aborted inserts. Nobody seemed overly concerned tha

pgsql: Fix fat fingering in 22cb6d28950

2025-04-10 Thread Andrew Dunstan
Fix fat fingering in 22cb6d28950 Per Rainier Vilela Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/39729ec01d25dbe12e0dd8322c68f242650235c9 Modified Files -- src/bin/pg_dump/pg_restore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

pgsql: Improve various new-to-v18 appendStringInfo calls

2025-04-10 Thread David Rowley
Improve various new-to-v18 appendStringInfo calls Similar to 8461424fd, here we adjust a few new locations which were not using the most suitable appendStringInfo* function for the intended purpose. Author: David Rowley https://postgr.es/m/CAApHDvqJnNjueb=eoj8k+8n0g7nj_acpwsicj5rnv4fdeja...@mail.

pgsql: Introduce file_copy_method setting.

2025-04-10 Thread Thomas Munro
Introduce file_copy_method setting. It can be set to either COPY (the default) or CLONE if the system supports it. CLONE causes callers of copydir(), currently CREATE DATABASE ... STRATEGY=FILE_COPY and ALTER DATABASE ... SET TABLESPACE = ..., to use copy_file_range (Linux, FreeBSD) or copyfile (

pgsql: Fix erroneous construction of functions' dependencies on transfo

2025-04-10 Thread Tom Lane
Fix erroneous construction of functions' dependencies on transforms. The list of transform objects that a function should use is specified in CREATE FUNCTION's TRANSFORM clause, and then represented indirectly in pg_proc.protrftypes. However, ProcedureCreate completely ignored that for purposes o

pgsql: Flush the IO statistics of active WAL senders more frequently

2025-04-10 Thread Michael Paquier
Flush the IO statistics of active WAL senders more frequently WAL senders do not flush their statistics until they exit, limiting the monitoring possible for live processes. This is penalizing when WAL senders are running for a long time, like in streaming or logical replication setups, because i

pgsql: Rename global variable backing DSA area

2025-04-10 Thread Daniel Gustafsson
Rename global variable backing DSA area The global variable backing the DSA area for Memory Context stats reporting had a too generic name, rename to be more descriptive. Independently reported by Peter and Laurenz. Author: Daniel Gustafsson Reported-by: Peter Eisentraut Reported-by: Laurenz Al

pgsql: Fix typo in docs.

2025-04-10 Thread Thomas Munro
Fix typo in docs. Typo in previous commit. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/7ea21f4ee2721be4239657e74c2ae8f88fb5a3ef Modified Files -- doc/src/sgml/ref/alter_database.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

pgsql: pg_buffercache: Change page_num type to bigint

2025-04-10 Thread Tomas Vondra
pg_buffercache: Change page_num type to bigint The page_num was defined as integer, which should be sufficient for the near future (with 4K pages it's 8TB). But it's virtually free to return bigint, and get a wider range. This was agreed on the thread, but I forgot to tweak this in ba2a3c2302f1.

pgsql: Cleanup of pg_numa.c

2025-04-10 Thread Tomas Vondra
Cleanup of pg_numa.c This moves/renames some of the functions defined in pg_numa.c: * pg_numa_get_pagesize() is renamed to pg_get_shmem_pagesize(), and moved to src/backend/storage/ipc/shmem.c. The new name better reflects that the page size is not related to NUMA, and it's specifically about

pgsql: Fix memory leak in pg_restore.c

2025-04-10 Thread Andrew Dunstan
Fix memory leak in pg_restore.c Oversight in 1495eff7bdb Author: Ranier Vilela Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/22cb6d289500ef22163a9d7cf2afa496f41b4d4c Modified Files -- src/bin/pg_dump/pg_restore.c | 2 ++ 1 file changed, 2 insertions(

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Doc: remove long-obsolete advice about generated constraint name

2025-04-10 Thread Tom Lane
Doc: remove long-obsolete advice about generated constraint names. It's been twenty years since we generated constraint names that look like "$N". So this advice about double-quoting such names is well past its sell-by date, and now it merely seems confusing. Reported-by: Yaroslav Saburov Autho

pgsql: Remove useless check for negative result of ip_addrsize().

2025-04-10 Thread Tom Lane
Remove useless check for negative result of ip_addrsize(). By inspection, ip_addrsize() can't return a negative result. (If it could, we'd have way bigger problems elsewhere.) So delete useless check in network_send(). Most C compilers are probably perfectly capable of removing this code by thems

pgsql: Flush the IO statistics of active WAL senders more frequently

2025-04-10 Thread Michael Paquier
Flush the IO statistics of active WAL senders more frequently WAL senders do not flush their statistics until they exit, limiting the monitoring possible for live processes. This is penalizing when WAL senders are running for a long time, like in streaming or logical replication setups, because i

pgsql: Flush the IO statistics of active WAL senders more frequently

2025-04-10 Thread Michael Paquier
Flush the IO statistics of active WAL senders more frequently WAL senders do not flush their statistics until they exit, limiting the monitoring possible for live processes. This is penalizing when WAL senders are running for a long time, like in streaming or logical replication setups, because i

pgsql: Fix test races between syscache-update-pruned.spec and autovacuu

2025-04-10 Thread Noah Misch
Fix test races between syscache-update-pruned.spec and autovacuum. This spec fails ~3% of my Valgrind runs, and the spec has failed on Valgrind buildfarm member skink at a similar rate. Two problems contributed to that: - A competing buffer pin triggered VACUUM's lazy_scan_noprune() path, causin

pgsql: Stabilize 035_standby_logical_decoding.pl.

2025-04-10 Thread Amit Kapila
Stabilize 035_standby_logical_decoding.pl. Some tests try to invalidate logical slots on the standby server by running VACUUM on the primary. The problem is that xl_running_xacts was getting generated and replayed before the VACUUM command, leading to the advancement of the active slot's catalog_x

Re: pgsql: Add support for basic NUMA awareness

2025-04-10 Thread Andres Freund
Hi, Walther, adding you because of the failure on buildfarm animal dogfish. The main issue is something unrelated to your animal (except it was the only one to catch it), but there's one oddity: On 2025-04-08 10:36:32 -0400, Tom Lane wrote: > Andres Freund writes: > > On April 8, 2025 10:05:48

pgsql: Further cleanup for directory creation on pg_dump/pg_dumpall

2025-04-10 Thread Andrew Dunstan
Further cleanup for directory creation on pg_dump/pg_dumpall Instead of two separate (and different) implementations, refactor to use a single common routine. Along the way, remove use of a hardcoded file permissions constant in favor of the common project setting for directory creation. Author:

Re: pgsql: Add function to get memory context stats for processes

2025-04-10 Thread Laurenz Albe
On Thu, 2025-04-10 at 14:46 +0200, Daniel Gustafsson wrote: > > On 10 Apr 2025, at 13:42, Laurenz Albe wrote: > > > +extern dsa_area *area; > > > > This commit causes problems for PostGIS, because the name "area" collides > > with a PostGIS object: > > Thanks for the report, I've already posted

Re: pgsql: Add function to get memory context stats for processes

2025-04-10 Thread Daniel Gustafsson
> On 10 Apr 2025, at 13:42, Laurenz Albe wrote: > On Tue, 2025-04-08 at 09:10 +, Daniel Gustafsson wrote: >> +extern dsa_area *area; > > This commit causes problems for PostGIS, because the name "area" collides > with a PostGIS object: Thanks for the report, I've already posted a patch [0]

Re: pgsql: Add function to get memory context stats for processes

2025-04-10 Thread Aleksander Alekseev
Hi, > Now one can take the position that PostGIS as dependent library hs to > adapt, but I think "area" is too generic a name. Could you envision > renaming the global variable to something like "shm_area"? > > Attached is a patch for this change. > I am not wedded to the name at all, it was just

Re: pgsql: Add function to get memory context stats for processes

2025-04-10 Thread Laurenz Albe
On Tue, 2025-04-08 at 09:10 +, Daniel Gustafsson wrote: > Add function to get memory context stats for processes > > This adds a function for retrieving memory context statistics > and information from backends as well as auxiliary processes. > The intended usecase is cluster debugging when un

pgsql: Fix data loss in logical replication.

2025-04-10 Thread Amit Kapila
Fix data loss in logical replication. Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ... or ALTER TYPE ... that don't take a strong lock on table happens concurrently to DMLs on the tables involved in the DDL. This happens because logical decoding doesn't distribute inval

Re: pgsql: Use extended stats for precise estimation of bucket size in hash

2025-04-10 Thread Alexander Korotkov
On Thu, Apr 10, 2025 at 3:37 AM Robins Tharakan wrote: > On Mon, 10 Mar 2025 at 22:18, Alexander Korotkov > wrote: > > > > Use extended stats for precise estimation of bucket size in hash join > > > After this commit, I see a recurrence of an error similar to the one fixed in > e28033fe1af8037e

pgsql: Fix data loss in logical replication.

2025-04-10 Thread Amit Kapila
Fix data loss in logical replication. Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ... or ALTER TYPE ... that don't take a strong lock on table happens concurrently to DMLs on the tables involved in the DDL. This happens because logical decoding doesn't distribute inval

pgsql: Fix data loss in logical replication.

2025-04-10 Thread Amit Kapila
Fix data loss in logical replication. Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ... or ALTER TYPE ... that don't take a strong lock on table happens concurrently to DMLs on the tables involved in the DDL. This happens because logical decoding doesn't distribute inval

pgsql: Fix data loss in logical replication.

2025-04-10 Thread Amit Kapila
Fix data loss in logical replication. Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ... or ALTER TYPE ... that don't take a strong lock on table happens concurrently to DMLs on the tables involved in the DDL. This happens because logical decoding doesn't distribute inval

pgsql: Fix data loss in logical replication.

2025-04-10 Thread Amit Kapila
Fix data loss in logical replication. Data loss can happen when the DDLs like ALTER PUBLICATION ... ADD TABLE ... or ALTER TYPE ... that don't take a strong lock on table happens concurrently to DMLs on the tables involved in the DDL. This happens because logical decoding doesn't distribute inval