@@ -858,6 +858,10 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
858858
859859 if (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 */
876880 if (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
880890 if (timeout > 0 && try_count > timeout )
881891 {
882892 if (file_exists )
883893 elog (ERROR , "WAL segment %s was archived, "
884894 "but target LSN %X/%X could not be archived in %d seconds" ,
885895 wal_segment , (uint32 ) (lsn >> 32 ), (uint32 ) lsn , timeout );
896+ /* If WAL segment doesn't exist or we wait for previous segment */
886897 else
887898 elog (ERROR ,
888899 "switched WAL segment %s could not be archived in %d seconds" ,
0 commit comments