diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:18:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:18:04 +0000 |
commit | 1d82e40c4e30d4666490f7a02db711541b5bb77f (patch) | |
tree | dcc6d635e272e13637f4ffedb91a3756f4a54c9b /src/backend/commands/dbcommands.c | |
parent | Adding debian version 15.5-0+deb12u1. (diff) | |
download | postgresql-15-1d82e40c4e30d4666490f7a02db711541b5bb77f.tar.xz postgresql-15-1d82e40c4e30d4666490f7a02db711541b5bb77f.zip |
Merging upstream version 15.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 93f0c73..5ced6da 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -461,35 +461,12 @@ CreateDirAndVersionFile(char *dbpath, Oid dbid, Oid tsid, bool isRedo) char buf[16]; /* - * Prepare version data before starting a critical section. - * - * Note that we don't have to copy this from the source database; there's - * only one legal value. + * Note that we don't have to copy version data from the source database; + * there's only one legal value. */ sprintf(buf, "%s\n", PG_MAJORVERSION); nbytes = strlen(PG_MAJORVERSION) + 1; - /* If we are not in WAL replay then write the WAL. */ - if (!isRedo) - { - xl_dbase_create_wal_log_rec xlrec; - XLogRecPtr lsn; - - START_CRIT_SECTION(); - - xlrec.db_id = dbid; - xlrec.tablespace_id = tsid; - - XLogBeginInsert(); - XLogRegisterData((char *) (&xlrec), - sizeof(xl_dbase_create_wal_log_rec)); - - lsn = XLogInsert(RM_DBASE_ID, XLOG_DBASE_CREATE_WAL_LOG); - - /* As always, WAL must hit the disk before the data update does. */ - XLogFlush(lsn); - } - /* Create database directory. */ if (MakePGDirectory(dbpath) < 0) { @@ -530,12 +507,35 @@ CreateDirAndVersionFile(char *dbpath, Oid dbid, Oid tsid, bool isRedo) } pgstat_report_wait_end(); + pgstat_report_wait_start(WAIT_EVENT_VERSION_FILE_SYNC); + if (pg_fsync(fd) != 0) + ereport(data_sync_elevel(ERROR), + (errcode_for_file_access(), + errmsg("could not fsync file \"%s\": %m", versionfile))); + fsync_fname(dbpath, true); + pgstat_report_wait_end(); + /* Close the version file. */ CloseTransientFile(fd); - /* Critical section done. */ + /* If we are not in WAL replay then write the WAL. */ if (!isRedo) + { + xl_dbase_create_wal_log_rec xlrec; + + START_CRIT_SECTION(); + + xlrec.db_id = dbid; + xlrec.tablespace_id = tsid; + + XLogBeginInsert(); + XLogRegisterData((char *) (&xlrec), + sizeof(xl_dbase_create_wal_log_rec)); + + (void) XLogInsert(RM_DBASE_ID, XLOG_DBASE_CREATE_WAL_LOG); + END_CRIT_SECTION(); + } } /* |