@@ -237,7 +237,7 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
237
237
{
238
238
int i ;
239
239
/* Check if the page is zeroed. */
240
- for (i = 0 ; i < BLCKSZ && page [i ] == 0 ; i ++ );
240
+ for (i = 0 ; i < BLCKSZ && page [i ] == 0 ; i ++ );
241
241
242
242
/* Page is zeroed. No need to check header and checksum. */
243
243
if (i == BLCKSZ )
@@ -271,9 +271,10 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
271
271
* should be a pointer to allocated BLCKSZ of bytes.
272
272
*
273
273
* Prints appropriate warnings/errors/etc into log.
274
- * Returns 0 if page was successfully retrieved
275
- * SkipCurrentPage(-3) if we need to skip this page
274
+ * Returns:
275
+ * PageIsOk(0) if page was successfully retrieved
276
276
* PageIsTruncated(-2) if the page was truncated
277
+ * SkipCurrentPage(-3) if we need to skip this page
277
278
* PageIsCorrupted(-4) if the page check mismatch
278
279
*/
279
280
static int32
@@ -312,9 +313,8 @@ prepare_page(ConnectionArgs *conn_arg,
312
313
switch (result )
313
314
{
314
315
case 2 :
315
- page_is_valid = true;
316
316
elog (VERBOSE , "File: \"%s\" blknum %u, empty page" , from_fullpath , blknum );
317
- break ;
317
+ return PageIsOk ;
318
318
319
319
case 1 :
320
320
page_is_valid = true;
@@ -393,6 +393,12 @@ prepare_page(ConnectionArgs *conn_arg,
393
393
}
394
394
}
395
395
396
+ /* Get page via ptrack interface from PostgreSQL shared buffer.
397
+ * We do this in following cases:
398
+ * 1. PTRACK backup of 1.x versions
399
+ * 2. During backup, regardless of backup mode, of PostgreSQL instance
400
+ * with ptrack support we encountered invalid page.
401
+ */
396
402
if ((backup_mode == BACKUP_MODE_DIFF_PTRACK
397
403
&& (ptrack_version_num >= 15 && ptrack_version_num < 20 ))
398
404
|| !page_is_valid )
@@ -434,7 +440,6 @@ prepare_page(ConnectionArgs *conn_arg,
434
440
!parse_page (page , & page_lsn ))
435
441
elog (ERROR , "Cannot parse page after pg_ptrack_get_block. "
436
442
"Possible risk of a memory corruption" );
437
-
438
443
}
439
444
440
445
if (page_is_truncated )
@@ -1260,22 +1265,18 @@ create_empty_file(fio_location from_location, const char *to_root,
1260
1265
/* open file for write */
1261
1266
join_path_components (to_path , to_root , file -> rel_path );
1262
1267
out = fio_fopen (to_path , PG_BINARY_W , to_location );
1268
+
1263
1269
if (out == NULL )
1264
- {
1265
- elog (ERROR , "cannot open destination file \"%s\": %s" ,
1270
+ elog (ERROR , "Cannot open destination file \"%s\": %s" ,
1266
1271
to_path , strerror (errno ));
1267
- }
1268
1272
1269
1273
/* update file permission */
1270
1274
if (fio_chmod (to_path , file -> mode , to_location ) == -1 )
1271
- {
1272
- fio_fclose (out );
1273
- elog (ERROR , "cannot change mode of \"%s\": %s" , to_path ,
1275
+ elog (ERROR , "Cannot change mode of \"%s\": %s" , to_path ,
1274
1276
strerror (errno ));
1275
- }
1276
1277
1277
1278
if (fio_fclose (out ))
1278
- elog (ERROR , "cannot close \"%s\": %s" , to_path , strerror (errno ));
1279
+ elog (ERROR , "Cannot close \"%s\": %s" , to_path , strerror (errno ));
1279
1280
1280
1281
return true;
1281
1282
}
0 commit comments