diff options
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index a850582b872..022f907f6d5 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -523,15 +523,17 @@ createdb(const CreatedbStmt *stmt) InvokeObjectAccessHook(OAT_POST_CREATE, DatabaseRelationId, dboid, 0); /* - * Force a checkpoint before starting the copy. This will force dirty - * buffers out to disk, to ensure source database is up-to-date on disk - * for the copy. FlushDatabaseBuffers() would suffice for that, but we - * also want to process any pending unlink requests. Otherwise, if a - * checkpoint happened while we're copying files, a file might be deleted - * just when we're about to copy it, causing the lstat() call in copydir() - * to fail with ENOENT. + * Force a checkpoint before starting the copy. This will force all dirty + * buffers, including those of unlogged tables, out to disk, to ensure + * source database is up-to-date on disk for the copy. + * FlushDatabaseBuffers() would suffice for that, but we also want + * to process any pending unlink requests. Otherwise, if a checkpoint + * happened while we're copying files, a file might be deleted just when + * we're about to copy it, causing the lstat() call in copydir() to fail + * with ENOENT. */ - RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT); + RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT + | CHECKPOINT_FLUSH_ALL); /* * Take an MVCC snapshot to use while scanning through pg_tablespace. For @@ -1111,8 +1113,9 @@ movedb(const char *dbname, const char *tblspcname) dst_dbpath = GetDatabasePath(db_id, dst_tblspcoid); /* - * Force a checkpoint before proceeding. This will force dirty buffers out - * to disk, to ensure source database is up-to-date on disk for the copy. + * Force a checkpoint before proceeding. This will force all dirty + * buffers, including those of unlogged tables, out to disk, to ensure + * source database is up-to-date on disk for the copy. * FlushDatabaseBuffers() would suffice for that, but we also want to * process any pending unlink requests. Otherwise, the check for existing * files in the target directory might fail unnecessarily, not to mention @@ -1120,7 +1123,8 @@ movedb(const char *dbname, const char *tblspcname) * On Windows, this also ensures that the bgwriter doesn't hold any open * files, which would cause rmdir() to fail. */ - RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT); + RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT + | CHECKPOINT_FLUSH_ALL); /* * Check for existence of files in the target directory, i.e., objects of |