mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-05 13:20:31 +02:00
Fix overwriting of 0-sized postgresql.auto.conf in remote mode, restore nonedata files asynchronously
This commit is contained in:
parent
a758d11cbb
commit
807cc27ebe
@ -1145,7 +1145,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
|
||||
|
||||
if (read_len > 0)
|
||||
{
|
||||
if (fio_fwrite(out, buf, read_len) != read_len)
|
||||
if (fio_fwrite_async(out, buf, read_len) != read_len)
|
||||
elog(ERROR, "Cannot write to \"%s\": %s", to_fullpath,
|
||||
strerror(errno));
|
||||
}
|
||||
|
@ -1515,8 +1515,8 @@ update_recovery_options(pgBackup *backup,
|
||||
char postgres_auto_path[MAXPGPATH];
|
||||
char postgres_auto_path_tmp[MAXPGPATH];
|
||||
char path[MAXPGPATH];
|
||||
FILE *fp;
|
||||
FILE *fp_tmp;
|
||||
FILE *fp = NULL;
|
||||
FILE *fp_tmp = NULL;
|
||||
struct stat st;
|
||||
char current_time_str[100];
|
||||
/* postgresql.auto.conf parsing */
|
||||
@ -1540,9 +1540,13 @@ update_recovery_options(pgBackup *backup,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
fp = fio_open_stream(postgres_auto_path, FIO_DB_HOST);
|
||||
if (fp == NULL && errno != ENOENT)
|
||||
elog(ERROR, "cannot open \"%s\": %s", postgres_auto_path, strerror(errno));
|
||||
/* Kludge for 0-sized postgresql.auto.conf file. TODO: make something more intelligent */
|
||||
if (st.st_size > 0)
|
||||
{
|
||||
fp = fio_open_stream(postgres_auto_path, FIO_DB_HOST);
|
||||
if (fp == NULL && errno != ENOENT)
|
||||
elog(ERROR, "cannot open \"%s\": %s", postgres_auto_path, strerror(errno));
|
||||
}
|
||||
|
||||
sprintf(postgres_auto_path_tmp, "%s.tmp", postgres_auto_path);
|
||||
fp_tmp = fio_fopen(postgres_auto_path_tmp, "w", FIO_DB_HOST);
|
||||
@ -1582,9 +1586,11 @@ update_recovery_options(pgBackup *backup,
|
||||
if (fp)
|
||||
fio_close_stream(fp);
|
||||
|
||||
/* TODO: detect remote error */
|
||||
if (buf_len > 0)
|
||||
fio_fwrite(fp_tmp, buf, buf_len);
|
||||
/* Write data to postgresql.auto.conf.tmp */
|
||||
if (buf_len > 0 &&
|
||||
(fio_fwrite(fp_tmp, buf, buf_len) != buf_len))
|
||||
elog(ERROR, "Cannot write to \"%s\": %s",
|
||||
postgres_auto_path_tmp, strerror(errno));
|
||||
|
||||
if (fio_fflush(fp_tmp) != 0 ||
|
||||
fio_fclose(fp_tmp))
|
||||
|
Loading…
Reference in New Issue
Block a user