Re: Add function to return backup_label and tablespace_map

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: Add function to return backup_label and tablespace_map
Дата
Msg-id CALj2ACVPV=3as7PW5Wj1pN_1gvO9Lrb-M_Q+4ggodRWaystA8w@mail.gmail.com
обсуждение исходный текст
Ответ на Add function to return backup_label and tablespace_map  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Ответы Re: Add function to return backup_label and tablespace_map  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Список pgsql-hackers
On Thu, Jul 7, 2022 at 10:14 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
>
> Hi,
>
> Since an exclusive backup method was dropped in v15, in v15 or later, we need to create backup_label and
tablespace_mapfiles from the result of pg_backup_stop() when taking a base backup using low level backup API. One issue
whendoing this is that; there is no simple way to create those files from two columns "labelfile" and "spcmapfile" that
pg_backup_stop()returns if we execute it via psql. Probaby we need to store those columns in a temporary file and run
someOS commands or script to separate that file into backup_label and tablespace_map. This is not simple way, and which
wouldprevent users from migrating their backup scripts using psql from an exclusive backup method to non-exclusive one,
I'mafraid. 
>
> To enable us to do that more easily, how about adding the pg_backup_label() function that returns backup_label and
tablespace_map?I'm thinking to make this function available just after pg_backup_start() finishes, also even after
pg_backup_stop()finishes. For example, this function allows us to take a backup using the following psql script file. 
>
> ------------------------------
> SELECT * FROM pg_backup_start('test');
> \! cp -a $PGDATA /backup
> SELECT * FROM pg_backup_stop();
>
> \pset tuples_only on
> \pset format unaligned
>
> \o /backup/data/backup_label
> SELECT labelfile FROM pg_backup_label();
>
> \o /backup/data/tablespace_map
> SELECT spcmapfile FROM pg_backup_label();
> ------------------------------
>
> Attached is the WIP patch to add pg_backup_label function. No tests nor docs have been added yet, but if we can
successfullyreach the consensus for adding the function, I will update the patch. 
>
> Thought?

+1 for making it easy for the user to create backup_label and
tablespace_map files. With the patch, the label_file and
tblspc_map_file contents are preserved until the lifecycle of the
session or the next run of pg_backup_start, I'm not sure if we need to
worry more about it.

Why can't we have functions like pg_create_backup_label() and
pg_create_tablespace_map() which create the 'backup_label' and
'tablespace_map' files respectively in the data directory and also
return the contents as output columns?

Also, we can let users run these create functions only once (perhaps
after the pg_backup_stop is called which is when the contents will be
consistent). If we allow these functions to read the label_file or
tblspc_map_file contents during the backup before stop backup, they
may not be consistent. We can have a new sessionBackupState something
like SESSION_BACKUP_READY_TO_COLLECT_INFO or SESSION_BACKUP_DONE and
after the new function calls sessionBackupState  goes to
SESSION_BACKUP_NONE) and the contents of label_file and
tblspc_map_file are freed up.

In the docs, it's good if we can clearly specify the steps to use all
of these functions.

Regards,
Bharath Rupireddy.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Aleksander Alekseev
Дата:
Сообщение: Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Re: Add function to return backup_label and tablespace_map