Re: more contrib: log rotator - Mailing list pgsql-hackers

From Tom Lane
Subject Re: more contrib: log rotator
Date
Msg-id 10790.1049502178@sss.pgh.pa.us
Whole thread Raw
In response to Re: more contrib: log rotator  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: more contrib: log rotator  (Jon Jensen <jon@endpoint.com>)
Re: more contrib: log rotator  (Peter Eisentraut <peter_e@gmx.net>)
Re: more contrib: log rotator  (Giles Lean <giles@nemeton.com.au>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> AFAICS, the only practical way to do this is to have a single process
>> collecting the stdout/stderr from the postmaster and all its children.

> I think not.  It's a little tricky handling it directly in the child
> processes, but it's been done before.

A "little" tricky?  Thanks, but no thanks ... for one thing, there'd be
no easy way to know when all the children had switched over to writing
the new file.  Also, at least for not-too-long messages, writing on a
single pipe gives atomicity guarantees that AFAIK do not exist when
writing a file through multiple independently opened descriptors.  In
the latter case I think we'd have lots of trouble with interleaving of
messages from different backends.

>> If someone can offer a better alternative than Andrew's, great, let's
>> see it.

> How about the attached one, which I floated a while ago but which didn't
> generate much interest.

Seems like a good bare-bones file writer; but how about all those
frammishes that people ask for like generating date-based filenames,
switching every so many bytes, etc?  Also, it'd be nice not to be
dependent on a cron job to tickle the switchover.

I do think there's an efficiency argument for having the log writer
coded in C, so starting with what you have here and building up might
be a better idea than starting with Andrew's perl script.  But the
important thing in my mind is to get something in there.

We should also take a look at Apache's rotator to see if there's any need
to reinvent the wheel at all.  I have not seen it, am not even sure what
it's written in...
        regards, tom lane



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: more contrib: log rotator
Next
From: Kevin Brown
Date:
Subject: Re: Detecting corrupted pages earlier