Skip to content

Commit bbf0eba

Browse files
committed
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.
1 parent 2597056 commit bbf0eba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/backend/storage/buffer/freelist.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.44 2004/06/03 02:08:03 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.45 2004/06/11 17:20:39 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -709,6 +709,7 @@ StrategyInvalidateBuffer(BufferDesc *buf)
709709
*/
710710
CLEAR_BUFFERTAG(buf->tag);
711711
buf->flags &= ~(BM_VALID | BM_DIRTY);
712+
buf->cntxDirty = false;
712713
buf->bufNext = StrategyControl->listFreeBuffers;
713714
StrategyControl->listFreeBuffers = buf->buf_id;
714715
}
@@ -757,8 +758,7 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
757758
cdb_id_t1 = StrategyControl->listHead[STRAT_LIST_T1];
758759
cdb_id_t2 = StrategyControl->listHead[STRAT_LIST_T2];
759760

760-
while ((cdb_id_t1 >= 0 || cdb_id_t2 >= 0) &&
761-
num_buffer_dirty < max_buffers)
761+
while (cdb_id_t1 >= 0 || cdb_id_t2 >= 0)
762762
{
763763
if (cdb_id_t1 >= 0)
764764
{
@@ -772,6 +772,8 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
772772
buffers[num_buffer_dirty] = buf;
773773
buftags[num_buffer_dirty] = buf->tag;
774774
num_buffer_dirty++;
775+
if (num_buffer_dirty >= max_buffers)
776+
break;
775777
}
776778
}
777779

@@ -790,6 +792,8 @@ StrategyDirtyBufferList(BufferDesc **buffers, BufferTag *buftags,
790792
buffers[num_buffer_dirty] = buf;
791793
buftags[num_buffer_dirty] = buf->tag;
792794
num_buffer_dirty++;
795+
if (num_buffer_dirty >= max_buffers)
796+
break;
793797
}
794798
}
795799

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy