mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
StrategyDirtyBufferList wasn't being careful to honor max_buffers limit.
Bug is only latent given that sole caller is passing NBuffers, but it could bite someone in the rear someday.
This commit is contained in:
parent
2597056cc3
commit
bbf0ebadaf
@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.44 2004/06/03 02:08:03 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.45 2004/06/11 17:20:39 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -709,6 +709,7 @@ StrategyInvalidateBuffer(BufferDesc *buf)
|
|||||||
*/
|
*/
|
||||||
CLEAR_BUFFERTAG(buf->tag);
|
CLEAR_BUFFERTAG(buf->tag);
|
||||||
buf->flags &= ~(BM_VALID | BM_DIRTY);
|
buf->flags &= ~(BM_VALID | BM_DIRTY);
|
||||||
|
buf->cntxDirty = false;
|
||||||
buf->bufNext = StrategyControl->listFreeBuffers;
|
buf->bufNext = StrategyControl->listFreeBuffers;
|
||||||
StrategyControl->listFreeBuffers = buf->buf_id;
|
StrategyControl->listFreeBuffers = buf->buf_id;
|
||||||
}
|
}
|
||||||
@ -757,8 +758,7 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
|
|||||||
cdb_id_t1 = StrategyControl->listHead[STRAT_LIST_T1];
|
cdb_id_t1 = StrategyControl->listHead[STRAT_LIST_T1];
|
||||||
cdb_id_t2 = StrategyControl->listHead[STRAT_LIST_T2];
|
cdb_id_t2 = StrategyControl->listHead[STRAT_LIST_T2];
|
||||||
|
|
||||||
while ((cdb_id_t1 >= 0 || cdb_id_t2 >= 0) &&
|
while (cdb_id_t1 >= 0 || cdb_id_t2 >= 0)
|
||||||
num_buffer_dirty < max_buffers)
|
|
||||||
{
|
{
|
||||||
if (cdb_id_t1 >= 0)
|
if (cdb_id_t1 >= 0)
|
||||||
{
|
{
|
||||||
@ -772,6 +772,8 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
|
|||||||
buffers[num_buffer_dirty] = buf;
|
buffers[num_buffer_dirty] = buf;
|
||||||
buftags[num_buffer_dirty] = buf->tag;
|
buftags[num_buffer_dirty] = buf->tag;
|
||||||
num_buffer_dirty++;
|
num_buffer_dirty++;
|
||||||
|
if (num_buffer_dirty >= max_buffers)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,6 +792,8 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
|
|||||||
buffers[num_buffer_dirty] = buf;
|
buffers[num_buffer_dirty] = buf;
|
||||||
buftags[num_buffer_dirty] = buf->tag;
|
buftags[num_buffer_dirty] = buf->tag;
|
||||||
num_buffer_dirty++;
|
num_buffer_dirty++;
|
||||||
|
if (num_buffer_dirty >= max_buffers)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user