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:04 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-07-31 14:37:04 -0400
commit118b941614cece1946d7eee31040061397102e05 (patch)
tree5c82977f262a4a431f95e93ded778363bd2215fe /src/backend/postmaster/postmaster.c
parent27394f76bf9a18a4e0337d3b3fb84a940e3555f5 (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 de012608e77..ea2784d6083 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;
bool IsBinaryUpgrade;
#ifdef WIN32
@@ -4696,7 +4697,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;
@@ -4705,6 +4706,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)
@@ -4756,6 +4758,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;
param->IsBinaryUpgrade = IsBinaryUpgrade;
@@ -4975,6 +4978,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;
IsBinaryUpgrade = param->IsBinaryUpgrade;