Skip to content

Commit 9b36081

Browse files
committed
[Issue #228] various fixes and improvements
1 parent 29adb5b commit 9b36081

File tree

8 files changed

+547
-274
lines changed

8 files changed

+547
-274
lines changed

src/backup.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
664664

665665
for (i = 0; i < parray_num(backup_files_list); i++)
666666
{
667-
char to_fullpath[MAXPGPATH];
668-
pgFile *file = (pgFile *) parray_get(backup_files_list, i);
667+
char to_fullpath[MAXPGPATH];
668+
pgFile *file = (pgFile *) parray_get(backup_files_list, i);
669669

670670
/* TODO: sync directory ? */
671671
if (S_ISDIR(file->mode))
@@ -687,7 +687,21 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
687687
}
688688

689689
if (fio_sync(to_fullpath, FIO_BACKUP_HOST) != 0)
690-
elog(ERROR, "Failed to sync file \"%s\": %s", to_fullpath, strerror(errno));
690+
elog(ERROR, "Cannot sync file \"%s\": %s", to_fullpath, strerror(errno));
691+
692+
/* fsync header file */
693+
if (file->external_dir_num == 0 &&
694+
file->is_datafile && !file->is_cfs &&
695+
file->n_headers > 0)
696+
{
697+
char to_fullpath_hdr[MAXPGPATH];
698+
699+
snprintf(to_fullpath_hdr, MAXPGPATH, "%s_hdr", to_fullpath);
700+
701+
if (fio_sync(to_fullpath, FIO_BACKUP_HOST) != 0)
702+
elog(ERROR, "Cannot sync file \"%s\": %s", to_fullpath_hdr, strerror(errno));
703+
704+
}
691705
}
692706

693707
time(&end_time);
@@ -2131,7 +2145,7 @@ backup_files(void *arg)
21312145
/* backup file */
21322146
if (file->is_datafile && !file->is_cfs)
21332147
{
2134-
backup_data_file(&(arguments->conn_arg), file, from_fullpath, to_fullpath,
2148+
backup_data_file_new(&(arguments->conn_arg), file, from_fullpath, to_fullpath,
21352149
arguments->prev_start_lsn,
21362150
current.backup_mode,
21372151
instance_config.compress_alg,
@@ -2147,12 +2161,6 @@ backup_files(void *arg)
21472161
current.backup_mode, current.parent_backup, true);
21482162
}
21492163

2150-
/* No point in storing empty, missing or not changed files */
2151-
if (file->write_size <= 0)
2152-
unlink(to_fullpath);
2153-
// elog(ERROR, "Cannot remove file \"%s\": %s", to_fullpath,
2154-
// strerror(errno));
2155-
21562164
if (file->write_size == FILE_NOT_FOUND)
21572165
continue;
21582166

src/catalog.c

+5
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,12 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
19061906
len += sprintf(line+len, ",\"n_blocks\":\"%i\"", file->n_blocks);
19071907

19081908
if (file->n_headers > 0)
1909+
{
19091910
len += sprintf(line+len, ",\"n_headers\":\"%i\"", file->n_headers);
1911+
len += sprintf(line+len, ",\"hdr_crc\":\"%u\"", file->hdr_crc);
1912+
1913+
// elog(INFO, "CRC INT: %li, CRC UINT: %u", file->crc_hdr, file->crc_hdr);
1914+
}
19101915

19111916
sprintf(line+len, "}\n");
19121917

0 commit comments

Comments
 (0)