From df06247d10325c0b659f7fdcb8a6c6c32828ef82 Mon Sep 17 00:00:00 2001
From: Dilip Kumar <dilipkumar@localhost.localdomain>
Date: Thu, 21 Oct 2021 11:15:30 +0530
Subject: [PATCH] Code refactoring, move unwanted function out of the critical
 section

Move MarkCurrentTransactionIdLoggedIfAny out of the critical
section.
---
 src/backend/access/transam/xlog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index ee30315..28935e4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1168,10 +1168,10 @@ XLogInsertRecord(XLogRecData *rdata,
 	 */
 	WALInsertLockRelease();
 
-	MarkCurrentTransactionIdLoggedIfAny();
-
 	END_CRIT_SECTION();
 
+	MarkCurrentTransactionIdLoggedIfAny();
+
 	/*
 	 * Mark top transaction id is logged (if needed) so that we should not try
 	 * to log it again with the next WAL record in the current subtransaction.
-- 
1.8.3.1

