Content-Length: 310179 | pFad | http://github.com/postgrespro/postgres/commit/836feeda9ca93e977224910cb79ec826b06e6e9e

D1 Fix condition for whether end_heap_rewrite must fsync, per Heikki. · postgrespro/postgres@836feed · GitHub
Skip to content

Commit 836feed

Browse files
committed
Fix condition for whether end_heap_rewrite must fsync, per Heikki.
1 parent 097a200 commit 836feed

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/17 20:49:39 tgl Exp $
99+
* $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.3 2007/04/17 21:29:31 tgl Exp $
100100
*
101101
*-------------------------------------------------------------------------
102102
*/
@@ -272,10 +272,17 @@ end_heap_rewrite(RewriteState state)
272272
}
273273

274274
/*
275-
* If not WAL-logging, must fsync before commit. We use heap_sync
275+
* If the 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 ourselves before committing.
594+
* fsync for this write; we'll do it ourselves in 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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/836feeda9ca93e977224910cb79ec826b06e6e9e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy