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

Commita455ca4

Browse files
committed
Back-patch fix to ensure that VACUUM always calls FlushRelationBuffers.
1 parentc33ea1e commita455ca4

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.148 2000/05/1903:22:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.148.2.1 2000/09/1921:01:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -645,6 +645,19 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
645645
if (vacuum_pages.vpl_num_pages>0)/* Clean pages from
646646
* vacuum_pages list */
647647
vc_vacheap(vacrelstats,onerel,&vacuum_pages);
648+
else
649+
{
650+
/*
651+
* Flush dirty pages out to disk. We must do this even if we
652+
* didn't do anything else, because we want to ensure that all
653+
* tuples have correct on-row commit status on disk (see
654+
* bufmgr.c's comments for FlushRelationBuffers()).
655+
*/
656+
i=FlushRelationBuffers(onerel,vacrelstats->num_pages);
657+
if (i<0)
658+
elog(ERROR,"VACUUM (vc_vacone): FlushRelationBuffers returned %d",
659+
i);
660+
}
648661
}
649662
if (reindex)
650663
activate_indexes_of_a_table(relid, true);
@@ -1968,12 +1981,19 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
19681981
pfree(Nvpl.vpl_pagedesc);
19691982
}
19701983

1984+
/*
1985+
* Flush dirty pages out to disk. We do this unconditionally, even if
1986+
* we don't need to truncate, because we want to ensure that all tuples
1987+
* have correct on-row commit status on disk (see bufmgr.c's comments
1988+
* for FlushRelationBuffers()).
1989+
*/
1990+
i=FlushRelationBuffers(onerel,blkno);
1991+
if (i<0)
1992+
elog(ERROR,"VACUUM (vc_repair_frag): FlushRelationBuffers returned %d",i);
1993+
19711994
/* truncate relation, after flushing any dirty pages out to disk */
19721995
if (blkno<nblocks)
19731996
{
1974-
i=FlushRelationBuffers(onerel,blkno);
1975-
if (i<0)
1976-
elog(FATAL,"VACUUM (vc_repair_frag): FlushRelationBuffers returned %d",i);
19771997
blkno=smgrtruncate(DEFAULT_SMGR,onerel,blkno);
19781998
Assert(blkno >=0);
19791999
vacrelstats->num_pages=blkno;/* set new number of blocks */
@@ -2023,27 +2043,25 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList vacuum_pages)
20232043
}
20242044
}
20252045

2046+
/*
2047+
* Flush dirty pages out to disk. We do this unconditionally, even if
2048+
* we don't need to truncate, because we want to ensure that all tuples
2049+
* have correct on-row commit status on disk (see bufmgr.c's comments
2050+
* for FlushRelationBuffers()).
2051+
*/
2052+
Assert(vacrelstats->num_pages >=vacuum_pages->vpl_empty_end_pages);
2053+
nblocks=vacrelstats->num_pages-vacuum_pages->vpl_empty_end_pages;
2054+
2055+
i=FlushRelationBuffers(onerel,nblocks);
2056+
if (i<0)
2057+
elog(ERROR,"VACUUM (vc_vacheap): FlushRelationBuffers returned %d",i);
2058+
20262059
/* truncate relation if there are some empty end-pages */
20272060
if (vacuum_pages->vpl_empty_end_pages>0)
20282061
{
2029-
Assert(vacrelstats->num_pages >=vacuum_pages->vpl_empty_end_pages);
2030-
nblocks=vacrelstats->num_pages-vacuum_pages->vpl_empty_end_pages;
20312062
elog(MESSAGE_LEVEL,"Rel %s: Pages: %u --> %u.",
20322063
RelationGetRelationName(onerel),
20332064
vacrelstats->num_pages,nblocks);
2034-
2035-
/*
2036-
* We have to flush "empty" end-pages (if changed, but who knows
2037-
* it) before truncation
2038-
*
2039-
* XXX is FlushBufferPool() still needed here?
2040-
*/
2041-
FlushBufferPool();
2042-
2043-
i=FlushRelationBuffers(onerel,nblocks);
2044-
if (i<0)
2045-
elog(FATAL,"VACUUM (vc_vacheap): FlushRelationBuffers returned %d",i);
2046-
20472065
nblocks=smgrtruncate(DEFAULT_SMGR,onerel,nblocks);
20482066
Assert(nblocks >=0);
20492067
vacrelstats->num_pages=nblocks;/* set new number of

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp