Re: BUG #5741: syslog line length - Mailing list pgsql-bugs

From Noah Misch
Subject Re: BUG #5741: syslog line length
Date
Msg-id 20110805221811.GC419@tornado.leadboat.com
Whole thread Raw
In response to Re: BUG #5741: syslog line length  (Marc Cousin <cousinmarc@gmail.com>)
Responses Re: BUG #5741: syslog line length
Re: BUG #5741: syslog line length
List pgsql-bugs
On Fri, Jun 10, 2011 at 04:21:59PM +0200, Marc Cousin wrote:
> On 02/11/2010 17:17, heasley wrote:
> > The following bug has been logged online:
> >
> > Bug reference:      5741
> > Logged by:          heasley
> > Email address:      heas@shrubbery.net
> > PostgreSQL version: 8.4
> > Operating system:   solaris
> > Description:        syslog line length
> > Details:
> >
> > * Max string length to send to syslog().  Note that this doesn't count the
> >  * sequence-number prefix we add, and of course it doesn't count the prefix
> >  * added by syslog itself.      On many implementations it seems that the
> > hard
> >  * limit is approximately 2K bytes including both those prefixes.
> >  */
> > #ifndef PG_SYSLOG_LIMIT
> > #define PG_SYSLOG_LIMIT 1024
> > #endif
> >
> > solaris' syslogd limits the line length to 1024, with a
> > FQDN and it's silly "msg ID" quite a bit is dropped by
> > syslogd.
> >
> I've been having the exact same problem with CentOS 5.5 these days (and
> a customer's Red Hat 5.4).
>
> This same problem occurs with sysklogd, which has a
> #define MAXLINE         1024            /* maximum line length */

A PG_SYSLOG_LIMIT value that loses data to truncation on nearly every default
GNU/Linux installation makes for a poor default.  It seems we raised it from 128
to 1024 for version 8.4, on performance grounds:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=6b7eebc05e3bfd86757f5aa1f05bca463e92d7db

How about 896?  I reach that figure based on 1024 as a reasonable limit for the
total syslog line, including prefix, and these estimates for the prefix parts:

25 - fixed-length content
16 - syslog_ident [default is "postgres"]
10 - pid
32 - hostname [certainly not a limit, but frequently adequate]
10 - sequence number [ditto]
 3 - chunk number [ditto]
32 - facility/priority/message ID added by some syslog implementations
= 128

Perhaps, though, the default should be outright conservative, like 512.  We
could also have a compile-time fixed overhead and factor in actual lengths of
parts we know at runtime, but that smells like overkill.  Opinions?

--
Noah Misch                    http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

pgsql-bugs by date:

Previous
From: Christoph Anton Mitterer
Date:
Subject: Re: BUG #6152: possibly wrong display of pg_settings.enumvals for default_transaction_isolation
Next
From: Tom Lane
Date:
Subject: Re: BUG #5741: syslog line length