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

Commitdb31add

Browse files
committed
Force a checkpoint in CREATE DATABASE before starting to copy the files,
to process any pending unlinks for the source database.Before, if you dropped a relation in the template database just beforeCREATE DATABASE, and a checkpoint happened during copydir(), the checkpointmight delete a file that we're just about to copy, causing lstat() incopydir() to fail with ENOENT.Backpatch to 8.3, where the pending unlinks were introduced.Per report by Matthew Wakeling and analysis by Tom Lane.
1 parent3437286 commitdb31add

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.213 2008/09/30 10:52:12 heikki Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.214 2008/10/09 10:34:06 heikki Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -539,10 +539,15 @@ createdb(const CreatedbStmt *stmt)
539539
copyTemplateDependencies(src_dboid,dboid);
540540

541541
/*
542-
* Force dirty buffers out to disk, to ensure source database is
543-
* up-to-date for the copy.
542+
* Force a checkpoint before starting the copy. This will force dirty
543+
* buffers out to disk, to ensure source database is up-to-date on disk
544+
* for the copy. FlushDatabaseBuffers() would suffice for that, but we
545+
* also want to process any pending unlink requests. Otherwise, if a
546+
* checkpoint happened while we're copying files, a file might be deleted
547+
* just when we're about to copy it, causing the lstat() call in copydir()
548+
* to fail with ENOENT.
544549
*/
545-
FlushDatabaseBuffers(src_dboid);
550+
RequestCheckpoint(CHECKPOINT_IMMEDIATE |CHECKPOINT_FORCE |CHECKPOINT_WAIT);
546551

547552
/*
548553
* Once we start copying subdirectories, we need to be able to clean 'em

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp