@@ -486,8 +486,6 @@ CreateDirAndVersionFile(char *dbpath, Oid dbid, Oid tsid, bool isRedo)
486
486
487
487
lsn = XLogInsert (RM_DBASE_ID , XLOG_DBASE_CREATE_WAL_LOG );
488
488
489
- SetLastWrittenLSNForDatabase (lsn );
490
-
491
489
/* As always, WAL must hit the disk before the data update does. */
492
490
XLogFlush (lsn );
493
491
}
@@ -615,7 +613,6 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
615
613
/* Record the filesystem change in XLOG */
616
614
{
617
615
xl_dbase_create_file_copy_rec xlrec ;
618
- XLogRecPtr lsn ;
619
616
620
617
xlrec .db_id = dst_dboid ;
621
618
xlrec .tablespace_id = dsttablespace ;
@@ -626,10 +623,8 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
626
623
XLogRegisterData ((char * ) & xlrec ,
627
624
sizeof (xl_dbase_create_file_copy_rec ));
628
625
629
- lsn = XLogInsert (RM_DBASE_ID ,
626
+ ( void ) XLogInsert (RM_DBASE_ID ,
630
627
XLOG_DBASE_CREATE_FILE_COPY | XLR_SPECIAL_REL_UPDATE );
631
-
632
- SetLastWrittenLSNForDatabase (lsn );
633
628
}
634
629
pfree (srcpath );
635
630
pfree (dstpath );
@@ -1403,6 +1398,11 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
1403
1398
CreateDatabaseUsingFileCopy (src_dboid , dboid , src_deftablespace ,
1404
1399
dst_deftablespace );
1405
1400
1401
+ /*
1402
+ * Update global last written LSN after wal-logging create database command
1403
+ */
1404
+ SetLastWrittenLSNForDatabase (XactLastRecEnd );
1405
+
1406
1406
/*
1407
1407
* Close pg_database, but keep lock till commit.
1408
1408
*/
0 commit comments