@@ -858,6 +858,10 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
858858
859859if (file_exists )
860860{
861+ /* Do not check LSN for previous WAL segment */
862+ if (wait_prev_segment )
863+ return ;
864+
861865/*
862866 * A WAL segment found. Check LSN on it.
863867 */
@@ -874,15 +878,22 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
874878
875879/* Inform user if WAL segment is absent in first attempt */
876880if (try_count == 1 )
877- elog (INFO ,"wait for LSN %X/%X in archived WAL segment %s" ,
878- (uint32 ) (lsn >>32 ), (uint32 )lsn ,wal_segment_full_path );
881+ {
882+ if (wait_prev_segment )
883+ elog (INFO ,"wait for WAL segment %s to be archived" ,
884+ wal_segment_full_path );
885+ else
886+ elog (INFO ,"wait for LSN %X/%X in archived WAL segment %s" ,
887+ (uint32 ) (lsn >>32 ), (uint32 )lsn ,wal_segment_full_path );
888+ }
879889
880890if (timeout > 0 && try_count > timeout )
881891{
882892if (file_exists )
883893elog (ERROR ,"WAL segment %s was archived, "
884894"but target LSN %X/%X could not be archived in %d seconds" ,
885895wal_segment , (uint32 ) (lsn >>32 ), (uint32 )lsn ,timeout );
896+ /* If WAL segment doesn't exist or we wait for previous segment */
886897else
887898elog (ERROR ,
888899"switched WAL segment %s could not be archived in %d seconds" ,