diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index db7d9930cb6517d03eee9ff277a63e0e191a5a99..19ef66b5f82fe9860126473a6ee2a70f01560c48 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -9411,16 +9411,14 @@ GetStandbyFlushRecPtr(void)
  * Get latest WAL insert pointer
  */
 XLogRecPtr
-GetXLogInsertRecPtr(bool needlock)
+GetXLogInsertRecPtr(void)
 {
 	XLogCtlInsert *Insert = &XLogCtl->Insert;
 	XLogRecPtr	current_recptr;
 
-	if (needlock)
-		LWLockAcquire(WALInsertLock, LW_SHARED);
+	LWLockAcquire(WALInsertLock, LW_SHARED);
 	INSERT_RECPTR(current_recptr, Insert, Insert->curridx);
-	if (needlock)
-		LWLockRelease(WALInsertLock);
+	LWLockRelease(WALInsertLock);
 
 	return current_recptr;
 }
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 1ca279de3ff78d94cacebe5e12ac190695c9b7e8..2e10d4d15f742cfa82ff1899cb364a659ba4143e 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -200,7 +200,7 @@ pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
 				 errmsg("recovery is in progress"),
 				 errhint("WAL control functions cannot be executed during recovery.")));
 
-	current_recptr = GetXLogInsertRecPtr(true);
+	current_recptr = GetXLogInsertRecPtr();
 
 	snprintf(location, sizeof(location), "%X/%X",
 			 current_recptr.xlogid, current_recptr.xrecoff);
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 93622c4d357027670ad9f32a53442f035fdc0f1a..1ddf4bf15f9a0c879551078018f2db6c4e1639c0 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -288,7 +288,7 @@ extern bool XLogInsertAllowed(void);
 extern void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream);
 extern XLogRecPtr GetXLogReplayRecPtr(XLogRecPtr *restoreLastRecPtr);
 extern XLogRecPtr GetStandbyFlushRecPtr(void);
-extern XLogRecPtr GetXLogInsertRecPtr(bool needlock);
+extern XLogRecPtr GetXLogInsertRecPtr(void);
 extern XLogRecPtr GetXLogWriteRecPtr(void);
 extern bool RecoveryIsPaused(void);
 extern void SetRecoveryPause(bool recoveryPause);