diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index ff1ee8689686ca3f7121a236214c7d8e618fc755..5a6b2a389e0d30d320d3aa337e80d6bbaa01fd62 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4877,8 +4877,11 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
 #endif
 
 	/* The history file can be archived immediately. */
-	TLHistoryFileName(histfname, newTLI);
-	XLogArchiveNotify(histfname);
+	if (XLogArchivingActive())
+	{
+		TLHistoryFileName(histfname, newTLI);
+		XLogArchiveNotify(histfname);
+	}
 }
 
 /*