Re: logfile rotation

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: logfile rotation
Date: 2004-06-19 09:10:39
Message-ID: 40D4030F.2030407@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian wrote:

>Actually, this is the current state of this issue.
>
>

Right, please comment on this. To recall, it uses shared memory for a
"switch to next logfile name" flag, which can't cause harm in case of
shmem corruption, and a postmaster opened filehandle (kept open) to a
dummy file containing the actual file name (pseudo code below).

Regards,
Andreas

>---------------------------------------------------------------------------
>
>Andreas Pflug wrote:
>
>
>>Tom Lane wrote:
>>
>>
>>
>>>Andreas Pflug <pgadmin(at)pse-consulting(dot)de> writes:
>>>
>>>
>>>
>>>
>>>>>Answering my own question, the distribution of the current logfile
>>>>>name could be done trough a file handle.
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>>>>would you mind commenting on my suggestion so I can continue on that topic?
>>>>
>>>>
>>>>
>>>>
>>>There is no portable way to redistribute a file handle.
>>>
>>>
>>>
>>>
>>Seems I didn't make clear enough what I mean.
>>
>>I'd fopen a file handle in the postmaster, and all subsequent processes
>>will inherit that handle just as they do for stderr; no redistribution
>>required.
>>The log filename is written to that file when pg_logfile_rotate is called:
>>fseek(fh, 0, SEEK_SET);
>>fprintf(fh, "%s", newlogfilname);
>>fflush();
>>
>>and all subprocesses may retrieve the filename when required by
>>
>>char buf[MAXPGPATH];
>>fseek(fh, 0, SEEK_SET);
>>fread(buf, 1, MAXPGPATH, fh);
>>buf[MAXPGPATH-1]=0; // prevent buffer overflow
>>logfile=fopen(buf, "a+");
>>
>>Regards,
>>Andreas
>>
>>
>>
>>
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Devrim GUNDUZ 2004-06-19 09:11:42 Compilation failes in CVS tip
Previous Message Christopher Kings-Lynne 2004-06-19 08:29:19 Re: OWNER TO on all objects