Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 830bcfd

Browse files
committed
bugfixes:
- if block is invalid after 100 read attempts then throw an error - if block is invalid after first read attempt then instead of additional 99 atempts use pg_ptrack_get_block if ptrack is supported
1 parent 68e2742 commit 830bcfd

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/backup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static pthread_mutex_t start_stream_mut = PTHREAD_MUTEX_INITIALIZER;
5252
static pthread_t stream_thread;
5353

5454
static int is_ptrack_enable = false;
55+
bool is_ptrack_support = false;
5556
bool is_checksum_enabled = false;
5657

5758
/* Backup connections */
@@ -743,7 +744,6 @@ do_backup_instance(void)
743744
int
744745
do_backup(time_t start_time)
745746
{
746-
bool is_ptrack_support;
747747

748748
/* PGDATA and BACKUP_MODE are always required */
749749
if (pgdata == NULL)

src/data.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
190190
}
191191

192192
/* Verify checksum */
193-
if(current.checksum_version && is_checksum_enabled)
193+
if(current.checksum_version)
194194
{
195195
/*
196196
* If checksum is wrong, sleep a bit and then try again
@@ -266,10 +266,29 @@ backup_data_page(backup_files_args *arguments,
266266

267267
if (result == 1)
268268
page_is_valid = true;
269+
270+
/*
271+
* If ptrack support is available use it to get invalid block
272+
* instead of rereading it 99 times
273+
*/
274+
//elog(WARNING, "Checksum_Version: %i", current.checksum_version ? 1 : 0);
275+
276+
if (result == -1 && is_ptrack_support)
277+
{
278+
elog(WARNING, "File %s, block %u, try to fetch via SQL",
279+
file->path, blknum);
280+
break;
281+
}
269282
}
283+
/*
284+
* If page is not valid after 100 attempts to read it
285+
* throw an error.
286+
*/
287+
if(!page_is_valid && !is_ptrack_support)
288+
elog(ERROR, "Data file checksum mismatch, canceling backup");
270289
}
271290

272-
if (backup_mode == BACKUP_MODE_DIFF_PTRACK)
291+
if (backup_mode == BACKUP_MODE_DIFF_PTRACK || (!page_is_valid && is_ptrack_support))
273292
{
274293
size_t page_size = 0;
275294

src/pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ extern const char *master_port;
298298
extern const char *master_user;
299299
extern uint32 replica_timeout;
300300

301+
extern bool is_ptrack_support;
301302
extern bool is_checksum_enabled;
302303

303304
/* delete options */

0 commit comments

Comments
 (0)