1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-22 11:44:34 +02:00

[Issue #169] fix merge of 0 sized files

This commit is contained in:
Grigory Smolkin 2020-02-20 17:50:15 +03:00
parent 2d3f19e622
commit 0b16fc0576
2 changed files with 23 additions and 6 deletions

View File

@ -646,6 +646,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
if (file->pagemap.bitmapsize == PageBitmapIsEmpty ||
file->pagemap_isabsent || !file->exists_in_prev)
{
/* remote FULL and DELTA */
if (fio_is_remote_file(in))
{
int rc = fio_send_pages(in, out, file,
@ -669,6 +670,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
}
else
{
/* local FULL and DELTA */
RetryUsingPtrack:
for (blknum = 0; blknum < nblocks; blknum++)
{
@ -689,7 +691,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
page_state, curr_page, calg, clevel,
from_fullpath, to_fullpath);
else
elog(ERROR, "Illegal page state: %i, file: %s, blknum %i",
elog(ERROR, "Invalid page state: %i, file: %s, blknum %i",
page_state, file->rel_path, blknum);
n_blocks_read++;
@ -718,6 +720,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
if (page_state == PageIsTruncated)
break;
/* TODO: PAGE and PTRACK should never get SkipCurrentPage */
else if (page_state == SkipCurrentPage)
n_blocks_skipped++;
@ -726,7 +729,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
page_state, curr_page, calg, clevel,
from_fullpath, to_fullpath);
else
elog(ERROR, "Illegal page state: %i, file: %s, blknum %i",
elog(ERROR, "Invalid page state: %i, file: %s, blknum %i",
page_state, file->rel_path, blknum);
n_blocks_read++;

View File

@ -849,7 +849,7 @@ merge_files(void *arg)
goto done;
if (progress)
elog(INFO, "Progress: (%d/%lu). Process file \"%s\"",
elog(INFO, "Progress: (%d/%lu). Merging file \"%s\"",
i + 1, (unsigned long) parray_num(arguments->dest_backup->files), dest_file->rel_path);
if (dest_file->is_datafile && !dest_file->is_cfs)
@ -1111,14 +1111,28 @@ merge_data_file(parray *parent_chain, pgBackup *full_backup,
dest_backup->compress_alg, dest_backup->compress_level,
dest_backup->checksum_version, 0, NULL, false);
/* drop restored temp file */
if (unlink(to_fullpath_tmp1) == -1)
elog(ERROR, "Cannot remove file \"%s\": %s", to_fullpath_tmp1,
strerror(errno));
/*
* In old (=<2.2.7) versions of pg_probackup n_blocks attribute of files
* in PAGE and PTRACK wasn`t filled.
*/
// Assert(tmp_file->n_blocks == dest_file->n_blocks);
//Assert(tmp_file->n_blocks == dest_file->n_blocks);
/* Backward compatibility kludge:
* When merging old backups, it is possible that
* to_fullpath_tmp2 size will be 0, and so it will be
* truncated in backup_data_file().
* TODO: remove in 3.0.0
*/
if (tmp_file->write_size == 0)
return;
if (fio_sync(to_fullpath_tmp2, FIO_BACKUP_HOST) != 0)
elog(ERROR, "Cannot fsync merge temp file \"%s\": %s",
elog(ERROR, "Cannot sync merge temp file \"%s\": %s",
to_fullpath_tmp2, strerror(errno));
/* Do atomic rename from second temp file to destination file */
@ -1223,7 +1237,7 @@ merge_non_data_file(parray *parent_chain, pgBackup *full_backup,
/* TODO: --no-sync support */
if (fio_sync(to_fullpath_tmp, FIO_BACKUP_HOST) != 0)
elog(ERROR, "Cannot fsync merge temp file \"%s\": %s",
elog(ERROR, "Cannot sync merge temp file \"%s\": %s",
to_fullpath_tmp, strerror(errno));
/* Do atomic rename from second temp file to destination file */