summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/postmaster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-07-31 14:37:08 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-07-31 14:37:08 -0400
commit706f792fc525258803fc6444af05ce264b26acc8 (patch)
treebee8a225b66054a6a3ecd915295e305e5d461b2d /src/backend/postmaster/postmaster.c
parent85509b9c646e2598b3d664b4d7afc16ea41ea708 (diff)
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.
Diffstat (limited to 'src/backend/postmaster/postmaster.c')
-rw-r--r--src/backend/postmaster/postmaster.c6
1 files changed, 5 insertions, 1 deletions
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;