pg_basebackup and pg_switch_wal()

From: Fabrice Chapuis <fabrice636861(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_basebackup and pg_switch_wal()
Date: 2025-07-29 07:48:59
Message-ID: CAA5-nLAG8kPcQLS2a=EFCBy0+xaR4AAUc8G9C3b_O9mYTT0LbA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I read the doc concerning pg_basebackup

pg_basebackup cannot force the standby to switch to a new WAL file at the
end of backup.
When you are using -X none, if write activity on the primary is low,
pg_basebackup may need to wait a long time for the last WAL file required
for the backup to be switched and archived.
In this case, it may be useful to run pg_switch_wal on the primary in order
to trigger an immediate WAL file switch.

This is not the case also when the backup is made from the primary?

I didn't find any pg_switch_wal() call in the source code of the
pg_basebackup

~/GIT/postgres-18beta1/src/bin/pg_basebackup (master)$ grep
--include="*.c" "switch" *
astreamer_inject.c: switch (context)
pg_basebackup.c: switch (pg_check_dir(dirname))
pg_basebackup.c: switch (GetCopyDataByte(r, copybuf, &cursor))
pg_basebackup.c: switch (c)
pg_createsubscriber.c: pg_log_warning_hint("You can use
--enable-two-phase switch to enable two_phase.");
pg_createsubscriber.c: switch (c)
pg_createsubscriber.c: char *bad_switch = NULL;
pg_createsubscriber.c: bad_switch = "--database";
pg_createsubscriber.c: bad_switch = "--publication";
pg_createsubscriber.c: bad_switch = "--replication-slot";
pg_createsubscriber.c: bad_switch = "--subscription";
pg_createsubscriber.c: if (bad_switch)
pg_createsubscriber.c: pg_log_error("%s cannot be used
with -a/--all", bad_switch);
pg_receivewal.c: * timeline switch, xlogpos points to the beginning
of the segment because
pg_receivewal.c: pg_log_info("switched to timeline %u at
%X/%X",
pg_receivewal.c: switch (c)
pg_recvlogical.c: switch (c)
pg_recvlogical.c: switch (reason)

Thanks for your comment

Regards

Fabrice

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-07-29 08:08:56 Re: delimiter inconsistency in generate-wait_event_types.pl
Previous Message Lukas Fittl 2025-07-29 07:21:32 Re: Broken ./configure checks for __cpuid() and __cpuidex()