diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index f0819d15ab7..c587278e0f6 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -44,6 +44,8 @@
 #include "catalog/pg_tablespace.h"
 #include "commands/comment.h"
 #include "commands/dbcommands.h"
+#include "commands/sequence.h"
+#include "commands/sequence_xlog.h"
 #include "commands/dbcommands_xlog.h"
 #include "commands/defrem.h"
 #include "commands/seclabel.h"
@@ -109,6 +111,7 @@ typedef struct CreateDBRelInfo
 	RelFileLocator rlocator;	/* physical relation identifier */
 	Oid			reloid;			/* relation oid */
 	bool		permanent;		/* relation is permanent or unlogged */
+	char		relkind;		/* relation kind */
 } CreateDBRelInfo;
 
 
@@ -129,6 +132,7 @@ static bool check_db_file_conflict(Oid db_id);
 static int	errdetail_busy_db(int notherbackends, int npreparedxacts);
 static void CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
 									  Oid dst_tsid);
+static void ResetSequenceLogCnt(RelFileLocator rlocator, bool permanent);
 static List *ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath);
 static List *ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid,
 										   Oid dbid, char *srcpath,
@@ -218,6 +222,10 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
 		/* Copy relation storage from source to the destination. */
 		CreateAndCopyRelationData(srcrlocator, dstrlocator, relinfo->permanent);
 
+		/* Reset log_cnt for sequences to ensure WAL on first nextval() */
+		if (relinfo->relkind == RELKIND_SEQUENCE)
+			ResetSequenceLogCnt(dstrlocator, relinfo->permanent);
+
 		/* Release the relation locks. */
 		UnlockRelationId(&srcrelid, AccessShareLock);
 		UnlockRelationId(&dstrelid, AccessShareLock);
@@ -228,6 +236,58 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
 	list_free_deep(rlocatorlist);
 }
 
+/*
+ * Reset log_cnt of a sequence to zero, ensuring the next nextval() call
+ * will emit a WAL record. This is needed after copying a sequence via
+ * the WAL_LOG strategy for CREATE DATABASE.
+ */
+static void
+ResetSequenceLogCnt(RelFileLocator rlocator, bool permanent)
+{
+	Buffer		buf;
+	Page		page;
+	ItemId		lp;
+	HeapTupleData seqtuple;
+	Form_pg_sequence_data seq;
+
+	buf = ReadBufferWithoutRelcache(rlocator, MAIN_FORKNUM, 0,
+									RBM_NORMAL, NULL, permanent);
+	LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
+	page = BufferGetPage(buf);
+	lp = PageGetItemId(page, FirstOffsetNumber);
+	Assert(ItemIdIsNormal(lp));
+
+	seqtuple.t_data = (HeapTupleHeader) PageGetItem(page, lp);
+	seqtuple.t_len = ItemIdGetLength(lp);
+	seq = (Form_pg_sequence_data) GETSTRUCT(&seqtuple);
+
+	if (seq->log_cnt != 0)
+	{
+		START_CRIT_SECTION();
+		seq->log_cnt = 0;
+		MarkBufferDirty(buf);
+
+		if (permanent)
+		{
+			xl_seq_rec	xlrec;
+			XLogRecPtr	recptr;
+
+			XLogBeginInsert();
+			XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
+
+			xlrec.locator = rlocator;
+			XLogRegisterData(&xlrec, sizeof(xl_seq_rec));
+			XLogRegisterData((char *) seqtuple.t_data, seqtuple.t_len);
+
+			recptr = XLogInsert(RM_SEQ_ID, XLOG_SEQ_LOG);
+
+			PageSetLSN(page, recptr);
+		}
+		END_CRIT_SECTION();
+	}
+	UnlockReleaseBuffer(buf);
+}
+
 /*
  * Scan the pg_class table in the source database to identify the relations
  * that need to be copied to the destination database.
@@ -442,6 +502,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
 	relinfo->rlocator.dbOid = dbid;
 	relinfo->rlocator.relNumber = relfilenumber;
 	relinfo->reloid = classForm->oid;
+	relinfo->relkind = classForm->relkind;
 
 	/* Temporary relations were rejected above. */
 	Assert(classForm->relpersistence != RELPERSISTENCE_TEMP);
