mirror of
https://github.com/postgres/postgres.git
synced 2025-05-22 00:02:02 -04:00
Add assert to WALReadFromBuffers().
Per suggestion from Andres. Discussion: https://postgr.es/m/20240214025508.6mcblauossthvaw3@awork3.anarazel.de
This commit is contained in:
parent
5497daf3aa
commit
9ecbf54075
@ -1710,12 +1710,13 @@ GetXLogBuffer(XLogRecPtr ptr, TimeLineID tli)
|
|||||||
* of bytes read successfully.
|
* of bytes read successfully.
|
||||||
*
|
*
|
||||||
* Fewer than 'count' bytes may be read if some of the requested WAL data has
|
* Fewer than 'count' bytes may be read if some of the requested WAL data has
|
||||||
* already been evicted from the WAL buffers, or if the caller requests data
|
* already been evicted.
|
||||||
* that is not yet available.
|
|
||||||
*
|
*
|
||||||
* No locks are taken.
|
* No locks are taken.
|
||||||
*
|
*
|
||||||
* The 'tli' argument is only used as a convenient safety check so that
|
* Caller should ensure that it reads no further than LogwrtResult.Write
|
||||||
|
* (which should have been updated by the caller when determining how far to
|
||||||
|
* read). The 'tli' argument is only used as a convenient safety check so that
|
||||||
* callers do not read from WAL buffers on a historical timeline.
|
* callers do not read from WAL buffers on a historical timeline.
|
||||||
*/
|
*/
|
||||||
Size
|
Size
|
||||||
@ -1724,26 +1725,13 @@ WALReadFromBuffers(char *dstbuf, XLogRecPtr startptr, Size count,
|
|||||||
{
|
{
|
||||||
char *pdst = dstbuf;
|
char *pdst = dstbuf;
|
||||||
XLogRecPtr recptr = startptr;
|
XLogRecPtr recptr = startptr;
|
||||||
XLogRecPtr upto;
|
Size nbytes = count;
|
||||||
Size nbytes;
|
|
||||||
|
|
||||||
if (RecoveryInProgress() || tli != GetWALInsertionTimeLine())
|
if (RecoveryInProgress() || tli != GetWALInsertionTimeLine())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Assert(!XLogRecPtrIsInvalid(startptr));
|
Assert(!XLogRecPtrIsInvalid(startptr));
|
||||||
|
Assert(startptr + count <= LogwrtResult.Write);
|
||||||
/*
|
|
||||||
* Don't read past the available WAL data.
|
|
||||||
*
|
|
||||||
* Check using local copy of LogwrtResult. Ordinarily it's been updated by
|
|
||||||
* the caller when determining how far to read; but if not, it just means
|
|
||||||
* we'll read less data.
|
|
||||||
*
|
|
||||||
* XXX: the available WAL could be extended to the WAL insert pointer by
|
|
||||||
* calling WaitXLogInsertionsToFinish().
|
|
||||||
*/
|
|
||||||
upto = Min(startptr + count, LogwrtResult.Write);
|
|
||||||
nbytes = upto - startptr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop through the buffers without a lock. For each buffer, atomically
|
* Loop through the buffers without a lock. For each buffer, atomically
|
||||||
|
Loading…
x
Reference in New Issue
Block a user