From 706f792fc525258803fc6444af05ce264b26acc8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 31 Jul 2012 14:37:08 -0400 Subject: Fix syslogger so that log_truncate_on_rotation works in the first rotation. In the original coding of the log rotation stuff, we did not bother to make the truncation logic work for the very first rotation after postmaster start (or after a syslogger crash and restart). It just always appended in that case. It did not seem terribly important at the time, but we've recently had two separate complaints from people who expected it to work unsurprisingly. (Both users tend to restart the postmaster about as often as a log rotation is configured to happen, which is maybe not typical use, but still...) Since the initial log file is opened in the postmaster, fixing this requires passing down some more state to the syslogger child process. It's always been like this, so back-patch to all supported branches. --- src/backend/postmaster/postmaster.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/backend/postmaster/postmaster.c') diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index ead51ee164e..5ae92d71400 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -436,6 +436,7 @@ typedef struct pid_t PostmasterPid; TimestampTz PgStartTime; TimestampTz PgReloadTime; + pg_time_t first_syslogger_file_time; bool redirection_done; #ifdef WIN32 HANDLE PostmasterHandle; @@ -4624,7 +4625,7 @@ MaxLivePostmasterChildren(void) /* * The following need to be available to the save/restore_backend_variables - * functions + * functions. They are marked NON_EXEC_STATIC in their home modules. */ extern slock_t *ShmemLock; extern LWLock *LWLockArray; @@ -4633,6 +4634,7 @@ extern PROC_HDR *ProcGlobal; extern PGPROC *AuxiliaryProcs; extern PMSignalData *PMSignalState; extern pgsocket pgStatSock; +extern pg_time_t first_syslogger_file_time; #ifndef WIN32 #define write_inheritable_socket(dest, src, childpid) ((*(dest) = (src)), true) @@ -4684,6 +4686,7 @@ save_backend_variables(BackendParameters * param, Port *port, param->PostmasterPid = PostmasterPid; param->PgStartTime = PgStartTime; param->PgReloadTime = PgReloadTime; + param->first_syslogger_file_time = first_syslogger_file_time; param->redirection_done = redirection_done; @@ -4902,6 +4905,7 @@ restore_backend_variables(BackendParameters * param, Port *port) PostmasterPid = param->PostmasterPid; PgStartTime = param->PgStartTime; PgReloadTime = param->PgReloadTime; + first_syslogger_file_time = param->first_syslogger_file_time; redirection_done = param->redirection_done; -- cgit v1.2.3