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

Commit836feed

Browse files
committed
Fix condition for whether end_heap_rewrite must fsync, per Heikki.
1 parent097a200 commit836feed

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/backend/access/heap/rewriteheap.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
* Portions Copyright (c) 1994-5, Regents of the University of California
9797
*
9898
* IDENTIFICATION
99-
* $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.2 2007/04/1720:49:39 tgl Exp $
99+
* $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.3 2007/04/1721:29:31 tgl Exp $
100100
*
101101
*-------------------------------------------------------------------------
102102
*/
@@ -272,10 +272,17 @@ end_heap_rewrite(RewriteState state)
272272
}
273273

274274
/*
275-
* Ifnot WAL-logging, must fsync before commit. We use heap_sync
275+
* Ifthe rel isn't temp, must fsync before commit. We use heap_sync
276276
* to ensure that the toast table gets fsync'd too.
277+
*
278+
* It's obvious that we must do this when not WAL-logging. It's less
279+
* obvious that we have to do it even if we did WAL-log the pages.
280+
* The reason is the same as in tablecmds.c's copy_relation_data():
281+
* we're writing data that's not in shared buffers, and so a CHECKPOINT
282+
* occurring during the rewriteheap operation won't have fsync'd data
283+
* we wrote before the checkpoint.
277284
*/
278-
if (!state->rs_use_wal)
285+
if (!state->rs_new_rel->rd_istemp)
279286
heap_sync(state->rs_new_rel);
280287

281288
/* Deleting the context frees everything */
@@ -584,7 +591,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
584591
/*
585592
* Now write the page. We say isTemp = true even if it's not a
586593
* temp table, because there's no need for smgr to schedule an
587-
* fsync for this write; we'll do it ourselvesbefore committing.
594+
* fsync for this write; we'll do it ourselvesin end_heap_rewrite.
588595
*/
589596
RelationOpenSmgr(state->rs_new_rel);
590597
smgrextend(state->rs_new_rel->rd_smgr,state->rs_blockno,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp