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

Appearance settings

Commit 4b4798e

Browse filesBrowse files
committed
Ensure that creation of an empty relfile is fsync'd at checkpoint.
If you create a table and don't insert any data into it, the relation file is never fsync'd. You don't lose data, because an empty table doesn't have any data to begin with, but if you crash and lose the file, subsequent operations on the table will fail with "could not open file" error. To fix, register an fsync request in mdcreate(), like we do for mdwrite(). Per discussion, we probably should also fsync the containing directory after creating a new file. But that's a separate and much wider issue. Backpatch to all supported versions. Reviewed-by: Andres Freund, Thomas Munro Discussion: https://www.postgresql.org/message-id/d47d8122-415e-425c-d0a2-e0160829702d%40iki.fi
1 parent 657f5f2 commit 4b4798e
Copy full SHA for 4b4798e

File tree

1 file changed

+3
-0
lines changed
Filter options
  • src/backend/storage/smgr

1 file changed

+3
-0
lines changed

‎src/backend/storage/smgr/md.c

Copy file name to clipboardExpand all lines: src/backend/storage/smgr/md.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
239239
mdfd = &reln->md_seg_fds[forknum][0];
240240
mdfd->mdfd_vfd = fd;
241241
mdfd->mdfd_segno = 0;
242+
243+
if (!SmgrIsTemp(reln))
244+
register_dirty_segment(reln, forknum, mdfd);
242245
}
243246

244247
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.