From 4a78cdeb6b598940e9d9adb92deca6494628802a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 1 Aug 2007 22:45:09 +0000 Subject: Support an optional asynchronous commit mode, in which we don't flush WAL before reporting a transaction committed. Data consistency is still guaranteed (unlike setting fsync = off), but a crash may lose the effects of the last few transactions. Patch by Simon, some editorialization by Tom. --- src/backend/commands/dbcommands.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/dbcommands.c') diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 4ceb962fb95..34b6da99df9 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.196 2007/06/28 00:02:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.197 2007/08/01 22:45:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -515,7 +515,11 @@ createdb(const CreatedbStmt *stmt) heap_close(pg_database_rel, NoLock); /* - * Set flag to update flat database file at commit. + * Set flag to update flat database file at commit. Note: this also + * forces synchronous commit, which minimizes the window between + * creation of the database files and commital of the transaction. + * If we crash before committing, we'll have a DB that's taking up + * disk space but is not in pg_database, which is not good. */ database_file_update_needed(); } @@ -675,7 +679,11 @@ dropdb(const char *dbname, bool missing_ok) heap_close(pgdbrel, NoLock); /* - * Set flag to update flat database file at commit. + * Set flag to update flat database file at commit. Note: this also + * forces synchronous commit, which minimizes the window between + * removal of the database files and commital of the transaction. + * If we crash before committing, we'll have a DB that's gone on disk + * but still there according to pg_database, which is not good. */ database_file_update_needed(); } -- cgit v1.2.3