diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c255691918de23e61e26f9ca8080c8a7605e4820..b22e498f8b50a8d4c212f0637862e81cc92cd7e2 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6616,7 +6616,12 @@ StartupXLOG(void)
 		if (reachedStopPoint)	/* stopped because of stop request */
 			ereport(FATAL,
 					(errmsg("requested recovery stop point is before consistent recovery point")));
-		else	/* ran off end of WAL */
+		/* ran off end of WAL */
+		if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
+			ereport(FATAL,
+					(errmsg("WAL ends before end of online backup"),
+					 errhint("Online backup started with pg_start_backup() must be ended with pg_stop_backup(), and all WAL up to that point must be available at recovery.")));
+		else
 			ereport(FATAL,
 					(errmsg("WAL ends before consistent recovery point")));
 	}