fsync pg_logical/mappings in CheckPointLogicalRewriteHeap().
authorAndres Freund <andres@anarazel.de>
Fri, 21 Jan 2022 19:22:55 +0000 (11:22 -0800)
committerAndres Freund <andres@anarazel.de>
Fri, 21 Jan 2022 19:22:55 +0000 (11:22 -0800)
While individual logical rewrite files were synced to disk, the directory was
not. On some filesystems that could lead to loosing directory entries after a
crash.

Reported-By: Tom Lane <tgl@sss.pgh.pa.us>
Author: Nathan Bossart <bossartn@amazon.com>
Discussion: https://postgr.es/m/867F2E29-2782-4869-970E-B984C6D35A8F@amazon.com
Backpatch: 10-

src/backend/access/heap/rewriteheap.c

index aa265edf6010e1120f6db6d9b328223484444f0a..2a53826736e80ed6677d1c653763b66f30e5c541 100644 (file)
@@ -1282,4 +1282,7 @@ CheckPointLogicalRewriteHeap(void)
                }
        }
        FreeDir(mappings_dir);
+
+       /* persist directory entries to disk */
+       fsync_fname("pg_logical/mappings", true);
 }