Skip to content

Commit 2f843a7

Browse files
committed
[Issue #227] Remove support of ptrack1.x, clean up redundant code in catchup
1 parent 2afa159 commit 2f843a7

File tree

3 files changed

+15
-91
lines changed

3 files changed

+15
-91
lines changed

src/catchup.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ do_catchup_instance(const char *source_pgdata, const char *dest_pgdata, PGconn *
9191
backup_mode == BACKUP_MODE_DIFF_DELTA))
9292
{
9393
dest_filelist = parray_new();
94-
dir_list_file(dest_filelist, dest_pgdata,
94+
dir_list_file(dest_filelist, dest_pgdata,
9595
true, true, false, backup_logs, true, 0, FIO_LOCAL_HOST);
9696

9797
sync_lsn = get_min_recovery_point(dest_pgdata);
@@ -268,18 +268,10 @@ do_catchup_instance(const char *source_pgdata, const char *dest_pgdata, PGconn *
268268
arg->nodeInfo = nodeInfo;
269269
arg->from_root = source_pgdata;
270270
arg->to_root = dest_pgdata;
271-
/* TODO разобраться */
272-
//arg->external_prefix = external_prefix;
273-
//arg->external_dirs = external_dirs;
274271
arg->source_filelist = source_filelist;
275-
/* TODO !!!! change to target file_list */
276272
arg->dest_filelist = dest_filelist;
277273
arg->sync_lsn = sync_lsn;
278274
arg->backup_mode = backup_mode;
279-
arg->conn_arg.conn = NULL;
280-
arg->conn_arg.cancel_conn = NULL;
281-
/* TODO !!!! */
282-
arg->hdr_map = &(current.hdr_map);
283275
arg->thread_num = i+1;
284276
/* By default there are some error */
285277
arg->ret = 1;
@@ -564,15 +556,15 @@ catchup_files(void *arg)
564556
/* Do actual work */
565557
if (file->is_datafile && !file->is_cfs)
566558
{
567-
catchup_data_file(&(arguments->conn_arg), file, from_fullpath, to_fullpath,
559+
catchup_data_file(file, from_fullpath, to_fullpath,
568560
arguments->sync_lsn,
569561
arguments->backup_mode,
570562
NONE_COMPRESS,
571563
0,
572564
arguments->nodeInfo->checksum_version,
573565
arguments->nodeInfo->ptrack_version_num,
574566
arguments->nodeInfo->ptrack_schema,
575-
arguments->hdr_map, false);
567+
false);
576568
}
577569
else
578570
{

src/data.c

+8-70
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ get_checksum_errormsg(Page page, char **errormsg, BlockNumber absolute_blkno)
276276
* return it to the caller
277277
*/
278278
static int32
279-
prepare_page(ConnectionArgs *conn_arg,
280-
pgFile *file, XLogRecPtr prev_backup_start_lsn,
279+
prepare_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
281280
BlockNumber blknum, FILE *in,
282281
BackupMode backup_mode,
283282
Page page, bool strict,
@@ -395,66 +394,6 @@ prepare_page(ConnectionArgs *conn_arg,
395394
return PageIsOk;
396395
}
397396

398-
/*
399-
* Get page via ptrack interface from PostgreSQL shared buffer.
400-
* We do this only in the cases of PTRACK 1.x versions backup
401-
*/
402-
if (backup_mode == BACKUP_MODE_DIFF_PTRACK
403-
&& (ptrack_version_num >= 15 && ptrack_version_num < 20))
404-
{
405-
int rc = 0;
406-
size_t page_size = 0;
407-
Page ptrack_page = NULL;
408-
ptrack_page = (Page) pg_ptrack_get_block(conn_arg, file->dbOid, file->tblspcOid,
409-
file->relOid, absolute_blknum, &page_size,
410-
ptrack_version_num, ptrack_schema);
411-
412-
if (ptrack_page == NULL)
413-
/* This block was truncated.*/
414-
return PageIsTruncated;
415-
416-
if (page_size != BLCKSZ)
417-
elog(ERROR, "File: \"%s\", block %u, expected block size %d, but read %zu",
418-
from_fullpath, blknum, BLCKSZ, page_size);
419-
420-
/*
421-
* We need to copy the page that was successfully
422-
* retrieved from ptrack into our output "page" parameter.
423-
*/
424-
memcpy(page, ptrack_page, BLCKSZ);
425-
pg_free(ptrack_page);
426-
427-
/*
428-
* UPD: It apprears that is possible to get zeroed page or page with invalid header
429-
* from shared buffer.
430-
* Note, that getting page with wrong checksumm from shared buffer is
431-
* acceptable.
432-
*/
433-
rc = validate_one_page(page, absolute_blknum,
434-
InvalidXLogRecPtr, page_st,
435-
checksum_version);
436-
437-
/* It is ok to get zeroed page */
438-
if (rc == PAGE_IS_ZEROED)
439-
return PageIsOk;
440-
441-
/* Getting page with invalid header from shared buffers is unacceptable */
442-
if (rc == PAGE_HEADER_IS_INVALID)
443-
{
444-
char *errormsg = NULL;
445-
get_header_errormsg(page, &errormsg);
446-
elog(ERROR, "Corruption detected in file \"%s\", block %u: %s",
447-
from_fullpath, blknum, errormsg);
448-
}
449-
450-
/*
451-
* We must set checksum here, because it is outdated
452-
* in the block recieved from shared buffers.
453-
*/
454-
if (checksum_version)
455-
page_st->checksum = ((PageHeader) page)->pd_checksum = pg_checksum_page(page, absolute_blknum);
456-
}
457-
458397
/*
459398
* Skip page if page lsn is less than START_LSN of parent backup.
460399
* Nullified pages must be copied by DELTA backup, just to be safe.
@@ -714,12 +653,11 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
714653
* backup with special header.
715654
*/
716655
void
717-
catchup_data_file(ConnectionArgs* conn_arg, pgFile *file,
718-
const char *from_fullpath, const char *to_fullpath,
656+
catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpath,
719657
XLogRecPtr prev_backup_start_lsn, BackupMode backup_mode,
720658
CompressAlg calg, int clevel, uint32 checksum_version,
721659
int ptrack_version_num, const char *ptrack_schema,
722-
HeaderMap *hdr_map, bool is_merge)
660+
bool is_merge)
723661
{
724662
int rc;
725663
bool use_pagemap;
@@ -796,7 +734,7 @@ catchup_data_file(ConnectionArgs* conn_arg, pgFile *file,
796734
else
797735
{
798736
/* TODO: stop handling errors internally */
799-
rc = copy_pages(conn_arg, to_fullpath, from_fullpath, file,
737+
rc = copy_pages(to_fullpath, from_fullpath, file,
800738
/* send prev backup START_LSN */
801739
backup_mode == BACKUP_MODE_DIFF_DELTA &&
802740
file->exists_in_prev ? prev_backup_start_lsn : InvalidXLogRecPtr,
@@ -1742,7 +1680,7 @@ check_data_file(ConnectionArgs *arguments, pgFile *file,
17421680
for (blknum = 0; blknum < nblocks; blknum++)
17431681
{
17441682
PageState page_st;
1745-
page_state = prepare_page(NULL, file, InvalidXLogRecPtr,
1683+
page_state = prepare_page(file, InvalidXLogRecPtr,
17461684
blknum, in, BACKUP_MODE_FULL,
17471685
curr_page, false, checksum_version,
17481686
0, NULL, from_fullpath, &page_st);
@@ -2228,7 +2166,7 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
22282166
while (blknum < file->n_blocks)
22292167
{
22302168
PageState page_st;
2231-
int rc = prepare_page(conn_arg, file, prev_backup_start_lsn,
2169+
int rc = prepare_page(file, prev_backup_start_lsn,
22322170
blknum, in, backup_mode, curr_page,
22332171
true, checksum_version,
22342172
ptrack_version_num, ptrack_schema,
@@ -2303,7 +2241,7 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
23032241

23042242
/* copy local file (взята из send_pages, но используется простое копирование странички, без добавления заголовков и компрессии) */
23052243
int
2306-
copy_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_fullpath,
2244+
copy_pages(const char *to_fullpath, const char *from_fullpath,
23072245
pgFile *file, XLogRecPtr prev_backup_start_lsn,
23082246
uint32 checksum_version, bool use_pagemap,
23092247
BackupMode backup_mode, int ptrack_version_num, const char *ptrack_schema)
@@ -2358,7 +2296,7 @@ copy_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
23582296
while (blknum < file->n_blocks)
23592297
{
23602298
PageState page_st;
2361-
int rc = prepare_page(conn_arg, file, prev_backup_start_lsn,
2299+
int rc = prepare_page(file, prev_backup_start_lsn,
23622300
blknum, in, backup_mode, curr_page,
23632301
true, checksum_version,
23642302
ptrack_version_num, ptrack_schema,

src/pg_probackup.h

+4-10
Original file line numberDiff line numberDiff line change
@@ -601,18 +601,13 @@ typedef struct
601601

602602
const char *from_root;
603603
const char *to_root;
604-
const char *external_prefix;
605604

606605
parray *source_filelist;
607606
parray *dest_filelist;
608-
/* TODO разобраться */
609-
//parray *external_dirs;
607+
610608
XLogRecPtr sync_lsn;
611609
BackupMode backup_mode;
612-
613-
ConnectionArgs conn_arg;
614610
int thread_num;
615-
HeaderMap *hdr_map;
616611

617612
/*
618613
* Return value from the thread.
@@ -1093,12 +1088,11 @@ extern void backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
10931088
CompressAlg calg, int clevel, uint32 checksum_version,
10941089
int ptrack_version_num, const char *ptrack_schema,
10951090
HeaderMap *hdr_map, bool missing_ok);
1096-
extern void catchup_data_file(ConnectionArgs* conn_arg, pgFile *file,
1097-
const char *from_fullpath, const char *to_fullpath,
1091+
extern void catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpath,
10981092
XLogRecPtr prev_backup_start_lsn, BackupMode backup_mode,
10991093
CompressAlg calg, int clevel, uint32 checksum_version,
11001094
int ptrack_version_num, const char *ptrack_schema,
1101-
HeaderMap *hdr_map, bool missing_ok);
1095+
bool missing_ok);
11021096
extern void backup_non_data_file(pgFile *file, pgFile *prev_file,
11031097
const char *from_fullpath, const char *to_fullpath,
11041098
BackupMode backup_mode, time_t parent_backup_time,
@@ -1226,7 +1220,7 @@ extern int send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const c
12261220
pgFile *file, XLogRecPtr prev_backup_start_lsn, CompressAlg calg, int clevel,
12271221
uint32 checksum_version, bool use_pagemap, BackupPageHeader2 **headers,
12281222
BackupMode backup_mode, int ptrack_version_num, const char *ptrack_schema);
1229-
extern int copy_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_fullpath,
1223+
extern int copy_pages(const char *to_fullpath, const char *from_fullpath,
12301224
pgFile *file, XLogRecPtr prev_backup_start_lsn,
12311225
uint32 checksum_version, bool use_pagemap,
12321226
BackupMode backup_mode, int ptrack_version_num, const char *ptrack_schema);

0 commit comments

Comments
 (0)