From 6cfb3f799550a1d23684bd185a34fb9bab4aa14a Mon Sep 17 00:00:00 2001 From: Arseny Kositsin Date: Mon, 28 Oct 2024 18:08:38 +0300 Subject: [PATCH] Fixed creation of an empty .log file When logs are rotated, if the log_destination = 'csvlog', besides .csv file, an empty .log file was created. In order to correct this behavior, an additional check has been added to the log file_rotate() function. --- src/backend/postmaster/syslogger.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index 50c2edec1f61..8f5e7f2629ae 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -1377,22 +1377,25 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for) fntime = time(NULL); /* file rotation for stderr */ - if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, - LOG_DESTINATION_STDERR, &last_sys_file_name, - &syslogFile)) - return; + if ((Log_destination & LOG_DESTINATION_STDERR) != 0) + if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, + LOG_DESTINATION_STDERR, &last_sys_file_name, + &syslogFile)) + return; /* file rotation for csvlog */ - if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, - LOG_DESTINATION_CSVLOG, &last_csv_file_name, - &csvlogFile)) - return; + if ((Log_destination & LOG_DESTINATION_CSVLOG) != 0) + if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, + LOG_DESTINATION_CSVLOG, &last_csv_file_name, + &csvlogFile)) + return; /* file rotation for jsonlog */ - if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, - LOG_DESTINATION_JSONLOG, &last_json_file_name, - &jsonlogFile)) - return; + if ((Log_destination & LOG_DESTINATION_JSONLOG) != 0) + if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime, + LOG_DESTINATION_JSONLOG, &last_json_file_name, + &jsonlogFile)) + return; update_metainfo_datafile();