Skip to content

Commit 6e984e8

Browse files
author
Commitfest Bot
committed
[CF 5928] v14 - Remove freelist and the buffer_strategy_lock
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5928 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/[email protected] Author(s): Greg Burd
2 parents 317c117 + d3c8d26 commit 6e984e8

File tree

11 files changed

+463
-223
lines changed

11 files changed

+463
-223
lines changed

contrib/pg_prewarm/autoprewarm.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,16 @@ apw_load_buffers(void)
370370
apw_state->prewarm_start_idx = apw_state->prewarm_stop_idx = 0;
371371
apw_state->prewarmed_blocks = 0;
372372

373+
374+
/* Don't prewarm more than we can fit. */
375+
if (num_elements > NBuffers)
376+
{
377+
num_elements = NBuffers;
378+
ereport(LOG,
379+
(errmsg("autoprewarm: capping prewarmed blocks to %d (shared_buffers size)",
380+
NBuffers)));
381+
}
382+
373383
/* Get the info position of the first block of the next database. */
374384
while (apw_state->prewarm_start_idx < num_elements)
375385
{
@@ -410,10 +420,6 @@ apw_load_buffers(void)
410420
apw_state->database = current_db;
411421
Assert(apw_state->prewarm_start_idx < apw_state->prewarm_stop_idx);
412422

413-
/* If we've run out of free buffers, don't launch another worker. */
414-
if (!have_free_buffer())
415-
break;
416-
417423
/*
418424
* Likewise, don't launch if we've already been told to shut down.
419425
* (The launch would fail anyway, but we might as well skip it.)
@@ -462,12 +468,6 @@ apw_read_stream_next_block(ReadStream *stream,
462468
{
463469
BlockInfoRecord blk = p->block_info[p->pos];
464470

465-
if (!have_free_buffer())
466-
{
467-
p->pos = apw_state->prewarm_stop_idx;
468-
return InvalidBlockNumber;
469-
}
470-
471471
if (blk.tablespace != p->tablespace)
472472
return InvalidBlockNumber;
473473

@@ -523,10 +523,10 @@ autoprewarm_database_main(Datum main_arg)
523523
blk = block_info[i];
524524

525525
/*
526-
* Loop until we run out of blocks to prewarm or until we run out of free
526+
* Loop until we run out of blocks to prewarm or until we run out of
527527
* buffers.
528528
*/
529-
while (i < apw_state->prewarm_stop_idx && have_free_buffer())
529+
while (i < apw_state->prewarm_stop_idx)
530530
{
531531
Oid tablespace = blk.tablespace;
532532
RelFileNumber filenumber = blk.filenumber;
@@ -568,14 +568,13 @@ autoprewarm_database_main(Datum main_arg)
568568

569569
/*
570570
* We have a relation; now let's loop until we find a valid fork of
571-
* the relation or we run out of free buffers. Once we've read from
572-
* all valid forks or run out of options, we'll close the relation and
571+
* the relation or we run out of buffers. Once we've read from all
572+
* valid forks or run out of options, we'll close the relation and
573573
* move on.
574574
*/
575575
while (i < apw_state->prewarm_stop_idx &&
576576
blk.tablespace == tablespace &&
577-
blk.filenumber == filenumber &&
578-
have_free_buffer())
577+
blk.filenumber == filenumber)
579578
{
580579
ForkNumber forknum = blk.forknum;
581580
BlockNumber nblocks;

0 commit comments

Comments
 (0)