@@ -1350,11 +1350,16 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13501350 TimeLineID tli ;
13511351 XLogSegNo targetSegNo ;
13521352 char wal_dir [MAXPGPATH ],
1353- wal_segment_full_path [MAXPGPATH ];
1353+ wal_segment_path [MAXPGPATH ];
13541354 char wal_segment [MAXFNAMELEN ];
1355+ bool file_exists = false;
13551356 uint32 try_count = 0 ,
13561357 timeout ;
13571358
1359+ #ifdef HAVE_LIBZ
1360+ char gz_wal_segment_path [MAXPGPATH ];
1361+ #endif
1362+
13581363 tli = get_current_timeline (false);
13591364
13601365 /* Compute the name of the WAL file containig requested LSN */
@@ -1367,14 +1372,14 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13671372 {
13681373 pgBackupGetPath2 (& current , wal_dir , lengthof (wal_dir ),
13691374 DATABASE_DIR , PG_XLOG_DIR );
1370- join_path_components (wal_segment_full_path , wal_dir , wal_segment );
1375+ join_path_components (wal_segment_path , wal_dir , wal_segment );
13711376
13721377 timeout = (uint32 ) checkpoint_timeout ();
13731378 timeout = timeout + timeout * 0.1 ;
13741379 }
13751380 else
13761381 {
1377- join_path_components (wal_segment_full_path , arclog_path , wal_segment );
1382+ join_path_components (wal_segment_path , arclog_path , wal_segment );
13781383 timeout = archive_timeout ;
13791384 }
13801385
@@ -1383,14 +1388,33 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13831388 else
13841389 elog (LOG , "Looking for LSN: %X/%X in segment: %s" , (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment );
13851390
1391+ #ifdef HAVE_LIBZ
1392+ snprintf (gz_wal_segment_path , sizeof (gz_wal_segment_path ), "%s.gz" ,
1393+ wal_segment_path );
1394+ #endif
1395+
13861396 /* Wait until target LSN is archived or streamed */
13871397 while (true)
13881398 {
1389- bool file_exists = fileExists (wal_segment_full_path );
1399+ if (!file_exists )
1400+ {
1401+ file_exists = fileExists (wal_segment_path );
1402+
1403+ /* Try to find compressed WAL file */
1404+ if (!file_exists )
1405+ {
1406+ #ifdef HAVE_LIBZ
1407+ file_exists = fileExists (gz_wal_segment_path );
1408+ if (file_exists )
1409+ elog (LOG , "Found compressed WAL segment: %s" , wal_segment_path );
1410+ #endif
1411+ }
1412+ else
1413+ elog (LOG , "Found WAL segment: %s" , wal_segment_path );
1414+ }
13901415
13911416 if (file_exists )
13921417 {
1393- elog (LOG , "Found segment: %s" , wal_segment );
13941418 /* Do not check LSN for previous WAL segment */
13951419 if (wait_prev_segment )
13961420 return ;
@@ -1409,18 +1433,18 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14091433
14101434 sleep (1 );
14111435 if (interrupted )
1412- elog (ERROR , "interrupted during waiting for WAL archiving" );
1436+ elog (ERROR , "Interrupted during waiting for WAL archiving" );
14131437 try_count ++ ;
14141438
14151439 /* Inform user if WAL segment is absent in first attempt */
14161440 if (try_count == 1 )
14171441 {
14181442 if (wait_prev_segment )
1419- elog (INFO , "wait for WAL segment %s to be archived" ,
1420- wal_segment_full_path );
1443+ elog (INFO , "Wait for WAL segment %s to be archived" ,
1444+ wal_segment_path );
14211445 else
1422- elog (INFO , "wait for LSN %X/%X in archived WAL segment %s" ,
1423- (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment_full_path );
1446+ elog (INFO , "Wait for LSN %X/%X in archived WAL segment %s" ,
1447+ (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment_path );
14241448 }
14251449
14261450 if (timeout > 0 && try_count > timeout )
@@ -1432,7 +1456,7 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14321456 /* If WAL segment doesn't exist or we wait for previous segment */
14331457 else
14341458 elog (ERROR ,
1435- "switched WAL segment %s could not be archived in %d seconds" ,
1459+ "Switched WAL segment %s could not be archived in %d seconds" ,
14361460 wal_segment , timeout );
14371461 }
14381462 }
0 commit comments