Skip to content

Commit df1e658

Browse files
committed
Merge branch 'master' into release_2_4
2 parents f2d2bab + 963f20f commit df1e658

13 files changed

+83
-28
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp
5454

5555
## Current release
5656

57-
[2.3.3](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.3)
57+
[2.3.4](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.4)
5858

5959
## Documentation
6060

src/archive.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ setup_push_filelist(const char *archive_status_dir, const char *first_file,
944944

945945
/* get list of files from archive_status */
946946
status_files = parray_new();
947-
dir_list_file(status_files, archive_status_dir, false, false, false, false, 0, FIO_DB_HOST);
947+
dir_list_file(status_files, archive_status_dir, false, false, false, false, true, 0, FIO_DB_HOST);
948948
parray_qsort(status_files, pgFileCompareName);
949949

950950
for (i = 0; i < parray_num(status_files); i++)

src/backup.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
333333
/* list files with the logical path. omit $PGDATA */
334334
if (fio_is_remote(FIO_DB_HOST))
335335
fio_list_dir(backup_files_list, instance_config.pgdata,
336-
true, true, false, backup_logs, 0);
336+
true, true, false, backup_logs, true, 0);
337337
else
338338
dir_list_file(backup_files_list, instance_config.pgdata,
339-
true, true, false, backup_logs, 0, FIO_LOCAL_HOST);
339+
true, true, false, backup_logs, true, 0, FIO_LOCAL_HOST);
340340

341341
/*
342342
* Get database_map (name to oid) for use in partial restore feature.
@@ -356,10 +356,10 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
356356
* 0 value is not external dir */
357357
if (fio_is_remote(FIO_DB_HOST))
358358
fio_list_dir(backup_files_list, parray_get(external_dirs, i),
359-
false, true, false, false, i+1);
359+
false, true, false, false, true, i+1);
360360
else
361361
dir_list_file(backup_files_list, parray_get(external_dirs, i),
362-
false, true, false, false, i+1, FIO_LOCAL_HOST);
362+
false, true, false, false, true, i+1, FIO_LOCAL_HOST);
363363
}
364364
}
365365

@@ -615,7 +615,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
615615
/* Scan backup PG_XLOG_DIR */
616616
xlog_files_list = parray_new();
617617
join_path_components(pg_xlog_path, database_path, PG_XLOG_DIR);
618-
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, false, 0,
618+
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, false, true, 0,
619619
FIO_BACKUP_HOST);
620620

621621
/* TODO: Drop streamed WAL segments greater than stop_lsn */

src/catalog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ catalog_get_timelines(InstanceConfig *instance)
878878

879879
/* read all xlog files that belong to this archive */
880880
sprintf(arclog_path, "%s/%s/%s", backup_path, "wal", instance->name);
881-
dir_list_file(xlog_files_list, arclog_path, false, false, false, false, 0, FIO_BACKUP_HOST);
881+
dir_list_file(xlog_files_list, arclog_path, false, false, false, false, true, 0, FIO_BACKUP_HOST);
882882
parray_qsort(xlog_files_list, pgFileCompareName);
883883

884884
timelineinfos = parray_new();

src/checkdb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ do_block_validation(char *pgdata, uint32 checksum_version)
208208

209209
/* list files with the logical path. omit $PGDATA */
210210
dir_list_file(files_list, pgdata, true, true,
211-
false, false, 0, FIO_DB_HOST);
211+
false, false, true, 0, FIO_DB_HOST);
212212

213213
/*
214214
* Sort pathname ascending.

src/delete.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ delete_backup_files(pgBackup *backup)
750750

751751
/* list files to be deleted */
752752
files = parray_new();
753-
dir_list_file(files, backup->root_dir, false, false, true, false, 0, FIO_LOCAL_HOST);
753+
dir_list_file(files, backup->root_dir, false, false, true, false, false, 0, FIO_BACKUP_HOST);
754754

755755
/* delete leaf node first */
756756
parray_qsort(files, pgFileCompareRelPathWithExternalDesc);

src/dir.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ typedef struct TablespaceCreatedList
124124
static int pgCompareString(const void *str1, const void *str2);
125125

126126
static char dir_check_file(pgFile *file);
127+
127128
static void dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
128-
bool exclude, bool follow_symlink,
129+
bool exclude, bool follow_symlink, bool skip_hidden,
129130
int external_dir_num, fio_location location);
130131
static void opt_path_map(ConfigOption *opt, const char *arg,
131132
TablespaceList *list, const char *type);
@@ -513,7 +514,8 @@ db_map_entry_free(void *entry)
513514
*/
514515
void
515516
dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink,
516-
bool add_root, bool backup_logs, int external_dir_num, fio_location location)
517+
bool add_root, bool backup_logs, bool skip_hidden, int external_dir_num,
518+
fio_location location)
517519
{
518520
pgFile *file;
519521

@@ -551,7 +553,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
551553
parray_append(files, file);
552554

553555
dir_list_file_internal(files, file, root, exclude, follow_symlink,
554-
external_dir_num, location);
556+
skip_hidden, external_dir_num, location);
555557

556558
if (!add_root)
557559
pgFileFree(file);
@@ -773,7 +775,7 @@ dir_check_file(pgFile *file)
773775
*/
774776
static void
775777
dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
776-
bool exclude, bool follow_symlink,
778+
bool exclude, bool follow_symlink, bool skip_hidden,
777779
int external_dir_num, fio_location location)
778780
{
779781
DIR *dir;
@@ -820,7 +822,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
820822
}
821823

822824
/* skip hidden files and directories */
823-
if (file->name[0] == '.')
825+
if (skip_hidden && file->name[0] == '.')
824826
{
825827
elog(WARNING, "Skip hidden file: '%s'", child);
826828
pgFileFree(file);
@@ -863,7 +865,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
863865
*/
864866
if (S_ISDIR(file->mode))
865867
dir_list_file_internal(files, file, child, exclude, follow_symlink,
866-
external_dir_num, location);
868+
skip_hidden, external_dir_num, location);
867869
}
868870

869871
if (errno && errno != ENOENT)

src/merge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ remove_dir_with_files(const char *path)
10621062
int i;
10631063
char full_path[MAXPGPATH];
10641064

1065-
dir_list_file(files, path, false, false, true, false, 0, FIO_LOCAL_HOST);
1065+
dir_list_file(files, path, false, false, true, false, false, 0, FIO_LOCAL_HOST);
10661066
parray_qsort(files, pgFileCompareRelPathWithExternalDesc);
10671067
for (i = 0; i < parray_num(files); i++)
10681068
{

src/pg_probackup.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,18 @@ main(int argc, char *argv[])
561561
setMyLocation();
562562
}
563563

564-
/* disable logging into file for archive-push and archive-get */
565-
if (backup_subcmd == ARCHIVE_GET_CMD ||
566-
backup_subcmd == ARCHIVE_PUSH_CMD)
564+
/*
565+
* Disable logging into file for archive-push and archive-get.
566+
* Note, that we should NOT use fio_is_remote() here,
567+
* because it will launch ssh connection and we do not
568+
* want it, because it will kill archive-get prefetch
569+
* performance.
570+
*
571+
* TODO: make logging into file possible via ssh
572+
*/
573+
if (fio_is_remote_simple(FIO_BACKUP_HOST) &&
574+
(backup_subcmd == ARCHIVE_GET_CMD ||
575+
backup_subcmd == ARCHIVE_PUSH_CMD))
567576
{
568577
instance_config.logger.log_level_file = LOG_OFF;
569578
}

src/pg_probackup.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ typedef enum ShowFormat
241241
#define BYTES_INVALID (-1) /* file didn`t changed since previous backup, DELTA backup do not rely on it */
242242
#define FILE_NOT_FOUND (-2) /* file disappeared during backup */
243243
#define BLOCKNUM_INVALID (-1)
244-
#define PROGRAM_VERSION "2.3.3"
245-
#define AGENT_PROTOCOL_VERSION 20303
244+
#define PROGRAM_VERSION "2.3.4"
245+
#define AGENT_PROTOCOL_VERSION 20304
246246

247247

248248
typedef struct ConnectionOptions
@@ -860,7 +860,7 @@ extern const char* deparse_compress_alg(int alg);
860860
/* in dir.c */
861861
extern void dir_list_file(parray *files, const char *root, bool exclude,
862862
bool follow_symlink, bool add_root, bool backup_logs,
863-
int external_dir_num, fio_location location);
863+
bool skip_hidden, int external_dir_num, fio_location location);
864864

865865
extern void create_data_directories(parray *dest_files,
866866
const char *data_dir,
@@ -1036,7 +1036,7 @@ extern int fio_send_file(const char *from_fullpath, const char *to_fullpath, FIL
10361036
pgFile *file, char **errormsg);
10371037

10381038
extern void fio_list_dir(parray *files, const char *root, bool exclude, bool follow_symlink,
1039-
bool add_root, bool backup_logs, int external_dir_num);
1039+
bool add_root, bool backup_logs, bool skip_hidden, int external_dir_num);
10401040

10411041
extern bool pgut_rmtree(const char *path, bool rmtopdir, bool strict);
10421042

@@ -1052,6 +1052,7 @@ extern bool pgut_rmtree(const char *path, bool rmtopdir, bool strict);
10521052

10531053
/* Check if specified location is local for current node */
10541054
extern bool fio_is_remote(fio_location location);
1055+
extern bool fio_is_remote_simple(fio_location location);
10551056

10561057
extern void get_header_errormsg(Page page, char **errormsg);
10571058
extern void get_checksum_errormsg(Page page, char **errormsg,

src/utils/file.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typedef struct
4444
bool add_root;
4545
bool backup_logs;
4646
bool exclusive_backup;
47+
bool skip_hidden;
4748
int external_dir_num;
4849
} fio_list_dir_request;
4950

@@ -175,6 +176,15 @@ bool fio_is_remote(fio_location location)
175176
return is_remote;
176177
}
177178

179+
/* Check if specified location is local for current node */
180+
bool fio_is_remote_simple(fio_location location)
181+
{
182+
bool is_remote = MyLocation != FIO_LOCAL_HOST
183+
&& location != FIO_LOCAL_HOST
184+
&& location != MyLocation;
185+
return is_remote;
186+
}
187+
178188
/* Try to read specified amount of bytes unless error or EOF are encountered */
179189
static ssize_t fio_read_all(int fd, void* buf, size_t size)
180190
{
@@ -1536,7 +1546,7 @@ static void fio_send_pages_impl(int out, char* buf)
15361546
hdr.arg = OPEN_FAILED;
15371547
errormsg = pgut_malloc(ERRMSG_MAX_LEN);
15381548
/* Construct the error message */
1539-
snprintf(errormsg, ERRMSG_MAX_LEN, "Cannot open source file '%s': %s",
1549+
snprintf(errormsg, ERRMSG_MAX_LEN, "Cannot open file \"%s\": %s",
15401550
from_fullpath, strerror(errno));
15411551
hdr.size = strlen(errormsg) + 1;
15421552
}
@@ -2065,7 +2075,8 @@ static void fio_send_file_impl(int out, char const* path)
20652075

20662076
/* Compile the array of files located on remote machine in directory root */
20672077
void fio_list_dir(parray *files, const char *root, bool exclude,
2068-
bool follow_symlink, bool add_root, bool backup_logs, int external_dir_num)
2078+
bool follow_symlink, bool add_root, bool backup_logs,
2079+
bool skip_hidden, int external_dir_num)
20692080
{
20702081
fio_header hdr;
20712082
fio_list_dir_request req;
@@ -2078,6 +2089,7 @@ void fio_list_dir(parray *files, const char *root, bool exclude,
20782089
req.add_root = add_root;
20792090
req.backup_logs = backup_logs;
20802091
req.exclusive_backup = exclusive_backup;
2092+
req.skip_hidden = skip_hidden;
20812093
req.external_dir_num = external_dir_num;
20822094

20832095
hdr.cop = FIO_LIST_DIR;
@@ -2172,7 +2184,8 @@ static void fio_list_dir_impl(int out, char* buf)
21722184
exclusive_backup = req->exclusive_backup;
21732185

21742186
dir_list_file(file_files, req->path, req->exclude, req->follow_symlink,
2175-
req->add_root, req->backup_logs, req->external_dir_num, FIO_LOCAL_HOST);
2187+
req->add_root, req->backup_logs, req->skip_hidden,
2188+
req->external_dir_num, FIO_LOCAL_HOST);
21762189

21772190
/* send information about files to the main process */
21782191
for (i = 0; i < parray_num(file_files); i++)

tests/compatibility.py

+30
Original file line numberDiff line numberDiff line change
@@ -958,3 +958,33 @@ def test_page_vacuum_truncate_compression(self):
958958

959959
# Clean after yourself
960960
self.del_test_dir(module_name, fname)
961+
962+
# @unittest.skip("skip")
963+
def test_hidden_files(self):
964+
"""
965+
old_version should be < 2.3.0
966+
Create hidden file in pgdata, take backup
967+
with old binary, then try to delete backup
968+
with new binary
969+
"""
970+
fname = self.id().split('.')[3]
971+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
972+
node = self.make_simple_node(
973+
base_dir=os.path.join(module_name, fname, 'node'),
974+
set_replication=True,
975+
initdb_params=['--data-checksums'],
976+
pg_options={'autovacuum': 'off'})
977+
978+
self.init_pb(backup_dir, old_binary=True)
979+
self.add_instance(backup_dir, 'node', node, old_binary=True)
980+
node.slow_start()
981+
982+
open(os.path.join(node.data_dir, ".hidden_stuff"), 'a').close()
983+
984+
backup_id = self.backup_node(
985+
backup_dir, 'node',node, old_binary=True, options=['--stream'])
986+
987+
self.delete_pb(backup_dir, 'node', backup_id)
988+
989+
# Clean after yourself
990+
self.del_test_dir(module_name, fname)

tests/expected/option_version.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pg_probackup 2.3.3
1+
pg_probackup 2.3.4

0 commit comments

Comments
 (0)