@@ -1710,12 +1710,13 @@ GetXLogBuffer(XLogRecPtr ptr, TimeLineID tli)
17101710 * of bytes read successfully.
17111711 *
17121712 * Fewer than 'count' bytes may be read if some of the requested WAL data has
1713- * already been evicted from the WAL buffers, or if the caller requests data
1714- * that is not yet available.
1713+ * already been evicted.
17151714 *
17161715 * No locks are taken.
17171716 *
1718- * The 'tli' argument is only used as a convenient safety check so that
1717+ * Caller should ensure that it reads no further than LogwrtResult.Write
1718+ * (which should have been updated by the caller when determining how far to
1719+ * read). The 'tli' argument is only used as a convenient safety check so that
17191720 * callers do not read from WAL buffers on a historical timeline.
17201721 */
17211722Size
@@ -1724,26 +1725,13 @@ WALReadFromBuffers(char *dstbuf, XLogRecPtr startptr, Size count,
17241725{
17251726char * pdst = dstbuf ;
17261727XLogRecPtr recptr = startptr ;
1727- XLogRecPtr upto ;
1728- Size nbytes ;
1728+ Size nbytes = count ;
17291729
17301730if (RecoveryInProgress ()|| tli != GetWALInsertionTimeLine ())
17311731return 0 ;
17321732
17331733Assert (!XLogRecPtrIsInvalid (startptr ));
1734-
1735- /*
1736- * Don't read past the available WAL data.
1737- *
1738- * Check using local copy of LogwrtResult. Ordinarily it's been updated by
1739- * the caller when determining how far to read; but if not, it just means
1740- * we'll read less data.
1741- *
1742- * XXX: the available WAL could be extended to the WAL insert pointer by
1743- * calling WaitXLogInsertionsToFinish().
1744- */
1745- upto = Min (startptr + count ,LogwrtResult .Write );
1746- nbytes = upto - startptr ;
1734+ Assert (startptr + count <=LogwrtResult .Write );
17471735
17481736/*
17491737 * Loop through the buffers without a lock. For each buffer, atomically