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

Commit04dacea

Browse files
committed
various bugfixes and improvements for archiving and buffering
1 parent95825af commit04dacea

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

‎src/archive.c‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,11 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
587587
thread_num,from_fullpath,strerror(errno));
588588
}
589589

590-
if (read_len>0)
590+
if (read_len>0&&fio_write(out,buf,read_len)!=read_len)
591591
{
592-
if (fio_write(out,buf,read_len)!=read_len)
593-
{
594-
fio_unlink(to_fullpath_part,FIO_BACKUP_HOST);
595-
elog(ERROR,"Thread [%d]: Cannot write to destination temp file \"%s\": %s",
596-
thread_num,to_fullpath_part,strerror(errno));
597-
}
592+
fio_unlink(to_fullpath_part,FIO_BACKUP_HOST);
593+
elog(ERROR,"Thread [%d]: Cannot write to destination temp file \"%s\": %s",
594+
thread_num,to_fullpath_part,strerror(errno));
598595
}
599596

600597
if (feof(in))
@@ -832,14 +829,11 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
832829
thread_num,from_fullpath,strerror(errno));
833830
}
834831

835-
if (read_len>0)
832+
if (read_len>0&&fio_gzwrite(out,buf,read_len)!=read_len)
836833
{
837-
if (fio_gzwrite(out,buf,read_len)!=read_len)
838-
{
839-
fio_unlink(to_fullpath_gz_part,FIO_BACKUP_HOST);
840-
elog(ERROR,"Thread [%d]: Cannot write to compressed temp WAL file \"%s\": %s",
841-
thread_num,to_fullpath_gz_part,get_gz_error(out,errno));
842-
}
834+
fio_unlink(to_fullpath_gz_part,FIO_BACKUP_HOST);
835+
elog(ERROR,"Thread [%d]: Cannot write to compressed temp WAL file \"%s\": %s",
836+
thread_num,to_fullpath_gz_part,get_gz_error(out,errno));
843837
}
844838

845839
if (feof(in))

‎src/data.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ restore_data_file(parray *parent_chain, pgFile *dest_file, FILE *out, const char
855855
{
856856
inti;
857857
size_ttotal_write_len=0;
858-
char*in_buf;
858+
char*in_buf=pgut_malloc(STDIO_BUFSIZE);
859859

860860
for (i=parray_num(parent_chain)-1;i >=0;i--)
861861
{
@@ -902,7 +902,7 @@ restore_data_file(parray *parent_chain, pgFile *dest_file, FILE *out, const char
902902
elog(ERROR,"Cannot open backup file \"%s\": %s",from_fullpath,
903903
strerror(errno));
904904

905-
in_buf=pgut_malloc(STDIO_BUFSIZE);
905+
/* set stdio buffering for input data file */
906906
setvbuf(in,in_buf,_IOFBF,STDIO_BUFSIZE);
907907

908908
/*

‎src/merge.c‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,11 +1132,11 @@ merge_data_file(parray *parent_chain, pgBackup *full_backup,
11321132
pgBackup*dest_backup,pgFile*dest_file,pgFile*tmp_file,
11331133
constchar*full_database_dir)
11341134
{
1135-
FILE*out=NULL;
1136-
charto_fullpath[MAXPGPATH];
1137-
charto_fullpath_tmp1[MAXPGPATH];/* used for restore */
1138-
charto_fullpath_tmp2[MAXPGPATH];/* used forbackup */
1139-
charbuffer[STDIO_BUFSIZE];
1135+
FILE*out=NULL;
1136+
char*buffer=pgut_malloc(STDIO_BUFSIZE);
1137+
charto_fullpath[MAXPGPATH];
1138+
charto_fullpath_tmp1[MAXPGPATH];/* used forrestore */
1139+
charto_fullpath_tmp2[MAXPGPATH];/* used for backup */
11401140

11411141
/* The next possible optimization is copying "as is" the file
11421142
* from intermediate incremental backup, that didn`t changed in
@@ -1158,6 +1158,15 @@ merge_data_file(parray *parent_chain, pgBackup *full_backup,
11581158
/* restore file into temp file */
11591159
tmp_file->size=restore_data_file(parent_chain,dest_file,out,to_fullpath_tmp1);
11601160
fclose(out);
1161+
pg_free(buffer);
1162+
1163+
/* tmp_file->size is greedy, even if there is single 8KB block in file,
1164+
* that was overwritten twice during restore_data_file, we would assume that its size is
1165+
* 16KB.
1166+
* TODO: maybe we should just trust dest_file->n_blocks?
1167+
* No, we can`t, because current binary can be used to merge
1168+
* 2 backups of old versions, were n_blocks is missing.
1169+
*/
11611170

11621171
backup_data_file(NULL,tmp_file,to_fullpath_tmp1,to_fullpath_tmp2,
11631172
InvalidXLogRecPtr,BACKUP_MODE_FULL,

‎src/pg_probackup.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ extern int fio_send_pages(FILE* in, FILE* out, pgFile *file, XLogRecPtr horizonL
10161016
intcalg,intclevel,uint32checksum_version,
10171017
datapagemap_t*pagemap,BlockNumber*err_blknum,char**errormsg);
10181018
/* return codes for fio_send_pages */
1019-
#defineOUT_BUF_SIZE (1024 * 1024)
1019+
#defineOUT_BUF_SIZE (512 * 1024)
10201020
externintfio_send_file_gz(constchar*from_fullpath,constchar*to_fullpath,FILE*out,intthread_num);
10211021
externintfio_send_file(constchar*from_fullpath,constchar*to_fullpath,FILE*out,intthread_num);
10221022

‎src/restore.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ restore_files(void *arg)
859859
/* Restore destination file */
860860
if (dest_file->is_datafile&& !dest_file->is_cfs)
861861
{
862-
/* enable stdio buffering for local destination file */
862+
/* enable stdio buffering for local destinationnon-datafile */
863863
if (!fio_is_remote_file(out))
864864
setvbuf(out,out_buf,_IOFBF,STDIO_BUFSIZE);
865865
/* Destination file is data file */
@@ -868,7 +868,7 @@ restore_files(void *arg)
868868
}
869869
else
870870
{
871-
/* disable stdio buffering for local destination file */
871+
/* disable stdio buffering for local destinationdatafile */
872872
if (!fio_is_remote_file(out))
873873
setvbuf(out,NULL,_IONBF,BUFSIZ);
874874
/* Destination file is non-data file */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp