@@ -109,7 +109,6 @@ static void pg_ptrack_clear(void);
109109static bool pg_ptrack_support (void );
110110static bool pg_ptrack_enable (void );
111111static bool pg_is_in_recovery (void );
112- static bool pg_archive_enabled (void );
113112static bool pg_ptrack_get_and_clear_db (Oid dbOid , Oid tblspcOid );
114113static char * pg_ptrack_get_and_clear (Oid tablespace_oid ,
115114 Oid db_oid ,
@@ -794,13 +793,6 @@ do_backup(time_t start_time)
794793 }
795794 }
796795
797- /* archiving check */
798- if (!current .stream && !pg_archive_enabled ())
799- elog (ERROR , "Archiving must be enabled for archive backup" );
800-
801- if (current .backup_mode == BACKUP_MODE_DIFF_PAGE && !pg_archive_enabled ())
802- elog (ERROR , "Archiving must be enabled for PAGE backup" );
803-
804796 if (from_replica )
805797 {
806798 /* Check master connection options */
@@ -1119,34 +1111,6 @@ pg_is_in_recovery(void)
11191111 return false;
11201112}
11211113
1122- /*
1123- * Check if archiving is enabled
1124- */
1125- static bool
1126- pg_archive_enabled (void )
1127- {
1128- PGresult * res_db ;
1129-
1130- res_db = pgut_execute (backup_conn , "show archive_mode" , 0 , NULL , true);
1131-
1132- if (strcmp (PQgetvalue (res_db , 0 , 0 ), "off" ) == 0 )
1133- {
1134- PQclear (res_db );
1135- return false;
1136- }
1137- PQclear (res_db );
1138-
1139- res_db = pgut_execute (backup_conn , "show archive_command" , 0 , NULL , true);
1140- if (strlen (PQgetvalue (res_db , 0 , 0 )) == 0 )
1141- {
1142- PQclear (res_db );
1143- return false;
1144- }
1145- PQclear (res_db );
1146-
1147- return true;
1148- }
1149-
11501114/* Clear ptrack files in all databases of the instance we connected to */
11511115static void
11521116pg_ptrack_clear (void )
@@ -1350,11 +1314,16 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13501314 TimeLineID tli ;
13511315 XLogSegNo targetSegNo ;
13521316 char wal_dir [MAXPGPATH ],
1353- wal_segment_full_path [MAXPGPATH ];
1317+ wal_segment_path [MAXPGPATH ];
13541318 char wal_segment [MAXFNAMELEN ];
1319+ bool file_exists = false;
13551320 uint32 try_count = 0 ,
13561321 timeout ;
13571322
1323+ #ifdef HAVE_LIBZ
1324+ char gz_wal_segment_path [MAXPGPATH ];
1325+ #endif
1326+
13581327 tli = get_current_timeline (false);
13591328
13601329 /* Compute the name of the WAL file containig requested LSN */
@@ -1367,14 +1336,14 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13671336 {
13681337 pgBackupGetPath2 (& current , wal_dir , lengthof (wal_dir ),
13691338 DATABASE_DIR , PG_XLOG_DIR );
1370- join_path_components (wal_segment_full_path , wal_dir , wal_segment );
1339+ join_path_components (wal_segment_path , wal_dir , wal_segment );
13711340
13721341 timeout = (uint32 ) checkpoint_timeout ();
13731342 timeout = timeout + timeout * 0.1 ;
13741343 }
13751344 else
13761345 {
1377- join_path_components (wal_segment_full_path , arclog_path , wal_segment );
1346+ join_path_components (wal_segment_path , arclog_path , wal_segment );
13781347 timeout = archive_timeout ;
13791348 }
13801349
@@ -1383,14 +1352,33 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
13831352 else
13841353 elog (LOG , "Looking for LSN: %X/%X in segment: %s" , (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment );
13851354
1355+ #ifdef HAVE_LIBZ
1356+ snprintf (gz_wal_segment_path , sizeof (gz_wal_segment_path ), "%s.gz" ,
1357+ wal_segment_path );
1358+ #endif
1359+
13861360 /* Wait until target LSN is archived or streamed */
13871361 while (true)
13881362 {
1389- bool file_exists = fileExists (wal_segment_full_path );
1363+ if (!file_exists )
1364+ {
1365+ file_exists = fileExists (wal_segment_path );
1366+
1367+ /* Try to find compressed WAL file */
1368+ if (!file_exists )
1369+ {
1370+ #ifdef HAVE_LIBZ
1371+ file_exists = fileExists (gz_wal_segment_path );
1372+ if (file_exists )
1373+ elog (LOG , "Found compressed WAL segment: %s" , wal_segment_path );
1374+ #endif
1375+ }
1376+ else
1377+ elog (LOG , "Found WAL segment: %s" , wal_segment_path );
1378+ }
13901379
13911380 if (file_exists )
13921381 {
1393- elog (LOG , "Found segment: %s" , wal_segment );
13941382 /* Do not check LSN for previous WAL segment */
13951383 if (wait_prev_segment )
13961384 return ;
@@ -1409,18 +1397,18 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14091397
14101398 sleep (1 );
14111399 if (interrupted )
1412- elog (ERROR , "interrupted during waiting for WAL archiving" );
1400+ elog (ERROR , "Interrupted during waiting for WAL archiving" );
14131401 try_count ++ ;
14141402
14151403 /* Inform user if WAL segment is absent in first attempt */
14161404 if (try_count == 1 )
14171405 {
14181406 if (wait_prev_segment )
1419- elog (INFO , "wait for WAL segment %s to be archived" ,
1420- wal_segment_full_path );
1407+ elog (INFO , "Wait for WAL segment %s to be archived" ,
1408+ wal_segment_path );
14211409 else
1422- elog (INFO , "wait for LSN %X/%X in archived WAL segment %s" ,
1423- (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment_full_path );
1410+ elog (INFO , "Wait for LSN %X/%X in archived WAL segment %s" ,
1411+ (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment_path );
14241412 }
14251413
14261414 if (timeout > 0 && try_count > timeout )
@@ -1432,7 +1420,7 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14321420 /* If WAL segment doesn't exist or we wait for previous segment */
14331421 else
14341422 elog (ERROR ,
1435- "switched WAL segment %s could not be archived in %d seconds" ,
1423+ "Switched WAL segment %s could not be archived in %d seconds" ,
14361424 wal_segment , timeout );
14371425 }
14381426 }
@@ -1843,22 +1831,6 @@ checkpoint_timeout(void)
18431831 return val_int ;
18441832}
18451833
1846- /*
1847- * Return true if the path is a existing regular file.
1848- */
1849- bool
1850- fileExists (const char * path )
1851- {
1852- struct stat buf ;
1853-
1854- if (stat (path , & buf ) == -1 && errno == ENOENT )
1855- return false;
1856- else if (!S_ISREG (buf .st_mode ))
1857- return false;
1858- else
1859- return true;
1860- }
1861-
18621834/*
18631835 * Notify end of backup to server when "backup_label" is in the root directory
18641836 * of the DB cluster.
0 commit comments