diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 918bce6..e8905c1 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -324,6 +324,11 @@ SysLoggerMain(int argc, char *argv[])
 			/*
 			 * Ensure that additions to log_destination do not result in
 			 * writing out-of-date data to LOG_METAINFO_DATAFILE.
+			 * While it is tempting to do this only when we conditionally
+			 * call logfile_writename() immediately below, writing a new
+			 * csv logfile causes a logfile_writename() call so we must
+			 * test for the csv case unconditionally.  May as well do
+			 * stderr the same way.
 			 */
 			if (!(old_log_destination && LOG_DESTINATION_STDERR) &&
 				(Log_destination && LOG_DESTINATION_STDERR))
@@ -344,8 +349,14 @@ SysLoggerMain(int argc, char *argv[])
 			 * wait until the next logfile rotation, which could be some while
 			 * in the future.
 			 */
-			if (!rm_log_metainfo())
-				logfile_writename();
+			if (((old_log_destination && LOG_DESTINATION_STDERR) &&
+				 ! (Log_destination && LOG_DESTINATION_STDERR))
+				|| ((old_log_destination && LOG_DESTINATION_CSVLOG) &&
+					! (Log_destination && LOG_DESTINATION_CSVLOG)))
+			{
+				if (!rm_log_metainfo())
+					logfile_writename();
+			}
 
 			/*
 			 * Check if the log directory or filename pattern changed in
