diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 046898c6190..acc3eb64e69 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -569,6 +569,13 @@ AssignTransactionId(TransactionState s)
 	if (!isSubXact)
 		RegisterPredicateLockingXid(s->transactionId);
 
+
+	(void) WaitLatch(MyLatch,
+			WL_LATCH_SET | WL_TIMEOUT,
+			30,
+			WAIT_EVENT_PG_SLEEP);
+	ResetLatch(MyLatch);
+
 	/*
 	 * Acquire lock on the transaction XID.  (We assume this cannot block.) We
 	 * have to ensure that the lock is assigned to the transaction's own
