|
15 | 15 | *
|
16 | 16 | *
|
17 | 17 | * IDENTIFICATION
|
18 |
| - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.160 2005/06/21 04:02:31 tgl Exp $ |
| 18 | + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.161 2005/06/25 22:47:29 tgl Exp $ |
19 | 19 | *
|
20 | 20 | *-------------------------------------------------------------------------
|
21 | 21 | */
|
@@ -514,6 +514,36 @@ createdb(const CreatedbStmt *stmt)
|
514 | 514 | /* Close pg_database, but keep exclusive lock till commit */
|
515 | 515 | heap_close(pg_database_rel, NoLock);
|
516 | 516 |
|
| 517 | + /* |
| 518 | + * We force a checkpoint before committing. This effectively means |
| 519 | + * that committed XLOG_DBASE_CREATE operations will never need to be |
| 520 | + * replayed (at least not in ordinary crash recovery; we still have |
| 521 | + * to make the XLOG entry for the benefit of PITR operations). |
| 522 | + * This avoids two nasty scenarios: |
| 523 | + * |
| 524 | + * #1: When PITR is off, we don't XLOG the contents of newly created |
| 525 | + * indexes; therefore the drop-and-recreate-whole-directory behavior |
| 526 | + * of DBASE_CREATE replay would lose such indexes. |
| 527 | + * |
| 528 | + * #2: Since we have to recopy the source database during DBASE_CREATE |
| 529 | + * replay, we run the risk of copying changes in it that were committed |
| 530 | + * after the original CREATE DATABASE command but before the system |
| 531 | + * crash that led to the replay. This is at least unexpected and at |
| 532 | + * worst could lead to inconsistencies, eg duplicate table names. |
| 533 | + * |
| 534 | + * (Both of these were real bugs in releases 8.0 through 8.0.3.) |
| 535 | + * |
| 536 | + * In PITR replay, the first of these isn't an issue, and the second |
| 537 | + * is only a risk if the CREATE DATABASE and subsequent template |
| 538 | + * database change both occur while a base backup is being taken. |
| 539 | + * There doesn't seem to be much we can do about that except document |
| 540 | + * it as a limitation. |
| 541 | + * |
| 542 | + * Perhaps if we ever implement CREATE DATABASE in a less cheesy |
| 543 | + * way, we can avoid this. |
| 544 | + */ |
| 545 | + RequestCheckpoint(true); |
| 546 | + |
517 | 547 | /*
|
518 | 548 | * Set flag to update flat database file at commit.
|
519 | 549 | */
|
|
0 commit comments