Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit807cc27

Browse files
committed
Fix overwriting of 0-sized postgresql.auto.conf in remote mode, restore nonedata files asynchronously
1 parenta758d11 commit807cc27

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

‎src/data.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
11451145

11461146
if (read_len>0)
11471147
{
1148-
if (fio_fwrite(out,buf,read_len)!=read_len)
1148+
if (fio_fwrite_async(out,buf,read_len)!=read_len)
11491149
elog(ERROR,"Cannot write to \"%s\": %s",to_fullpath,
11501150
strerror(errno));
11511151
}

‎src/restore.c‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ update_recovery_options(pgBackup *backup,
15151515
charpostgres_auto_path[MAXPGPATH];
15161516
charpostgres_auto_path_tmp[MAXPGPATH];
15171517
charpath[MAXPGPATH];
1518-
FILE*fp;
1519-
FILE*fp_tmp;
1518+
FILE*fp=NULL;
1519+
FILE*fp_tmp=NULL;
15201520
structstatst;
15211521
charcurrent_time_str[100];
15221522
/* postgresql.auto.conf parsing */
@@ -1540,9 +1540,13 @@ update_recovery_options(pgBackup *backup,
15401540
strerror(errno));
15411541
}
15421542

1543-
fp=fio_open_stream(postgres_auto_path,FIO_DB_HOST);
1544-
if (fp==NULL&&errno!=ENOENT)
1545-
elog(ERROR,"cannot open \"%s\": %s",postgres_auto_path,strerror(errno));
1543+
/* Kludge for 0-sized postgresql.auto.conf file. TODO: make something more intelligent */
1544+
if (st.st_size>0)
1545+
{
1546+
fp=fio_open_stream(postgres_auto_path,FIO_DB_HOST);
1547+
if (fp==NULL&&errno!=ENOENT)
1548+
elog(ERROR,"cannot open \"%s\": %s",postgres_auto_path,strerror(errno));
1549+
}
15461550

15471551
sprintf(postgres_auto_path_tmp,"%s.tmp",postgres_auto_path);
15481552
fp_tmp=fio_fopen(postgres_auto_path_tmp,"w",FIO_DB_HOST);
@@ -1582,9 +1586,11 @@ update_recovery_options(pgBackup *backup,
15821586
if (fp)
15831587
fio_close_stream(fp);
15841588

1585-
/* TODO: detect remote error */
1586-
if (buf_len>0)
1587-
fio_fwrite(fp_tmp,buf,buf_len);
1589+
/* Write data to postgresql.auto.conf.tmp */
1590+
if (buf_len>0&&
1591+
(fio_fwrite(fp_tmp,buf,buf_len)!=buf_len))
1592+
elog(ERROR,"Cannot write to \"%s\": %s",
1593+
postgres_auto_path_tmp,strerror(errno));
15881594

15891595
if (fio_fflush(fp_tmp)!=0||
15901596
fio_fclose(fp_tmp))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp