Skip to content

Commit 7f848cb

Browse files
Remove superfluous autoprewarm check
autoprewarm_database_main() prewarms blocks from the same database. It is passed an array of sorted BlockInfoRecords and a start and stop index into the array. The range represented should include only blocks belonging to global objects or blocks from a single database. Remove an unnecessary check that the current block is from the same database and add an assert to ensure this invariant remains. Doing so removes a special case that makes future refactoring to accommodate read streamifying autoprewarm easier. Noticed off-list by Andres Freund
1 parent b3f1a13 commit 7f848cb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

contrib/pg_prewarm/autoprewarm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,10 @@ autoprewarm_database_main(Datum main_arg)
463463
CHECK_FOR_INTERRUPTS();
464464

465465
/*
466-
* Quit if we've reached records for another database. If previous
467-
* blocks are of some global objects, then continue pre-warming.
466+
* All blocks between prewarm_start_idx and prewarm_stop_idx should
467+
* belong either to global objects or the same database.
468468
*/
469-
if (old_blk != NULL && old_blk->database != blk->database &&
470-
old_blk->database != 0)
471-
break;
469+
Assert(blk->database == apw_state->database || blk->database == 0);
472470

473471
/*
474472
* As soon as we encounter a block of a new relation, close the old

0 commit comments

Comments
 (0)