Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64e7fa4

Browse files
Fix autoprewarm neglect of tablespaces
While prewarming blocks from a dump file, autoprewarm_database_main()mistakenly ignored tablespace when detecting the beginning of the nextrelation to prewarm. Because RelFileNumbers are only unique within atablespace, autoprewarm could miss prewarming blocks from arelation with the same RelFileNumber in a different tablespace.Though this situation is likely rare in practice, it's best to make thecode correct. Do so by explicitly checking for the RelFileNumber whendetecting a new relation.Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>Discussion:https://postgr.es/m/97c36982-603b-494a-95f4-aaf2a12ac27e%40iki.fi
1 parent742317a commit64e7fa4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎contrib/pg_prewarm/autoprewarm.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,15 @@ autoprewarm_database_main(Datum main_arg)
472472

473473
/*
474474
* As soon as we encounter a block of a new relation, close the old
475-
* relation. Note that rel will be NULL if try_relation_open failed
476-
* previously; in that case, there is nothing to close.
475+
* relation. RelFileNumbers are only guaranteed to be unique within a
476+
* tablespace, so check that too.
477+
*
478+
* Note that rel will be NULL if try_relation_open failed previously;
479+
* in that case, there is nothing to close.
477480
*/
478-
if (old_blk!=NULL&&old_blk->filenumber!=blk->filenumber&&
481+
if (old_blk!=NULL&&
482+
(old_blk->tablespace!=blk->tablespace||
483+
old_blk->filenumber!=blk->filenumber)&&
479484
rel!=NULL)
480485
{
481486
relation_close(rel,AccessShareLock);
@@ -487,7 +492,9 @@ autoprewarm_database_main(Datum main_arg)
487492
* Try to open each new relation, but only once, when we first
488493
* encounter it. If it's been dropped, skip the associated blocks.
489494
*/
490-
if (old_blk==NULL||old_blk->filenumber!=blk->filenumber)
495+
if (old_blk==NULL||
496+
old_blk->tablespace!=blk->tablespace||
497+
old_blk->filenumber!=blk->filenumber)
491498
{
492499
Oidreloid;
493500

@@ -508,6 +515,7 @@ autoprewarm_database_main(Datum main_arg)
508515

509516
/* Once per fork, check for fork existence and size. */
510517
if (old_blk==NULL||
518+
old_blk->tablespace!=blk->tablespace||
511519
old_blk->filenumber!=blk->filenumber||
512520
old_blk->forknum!=blk->forknum)
513521
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp