Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaAJc-0000qT-Vp for pgsql-bugs@postgresql.org; Sun, 18 Nov 2012 19:14:01 +0000 Received: from moutng.kundenserver.de ([212.227.126.186]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaAJa-0000O1-4F for pgsql-bugs@postgresql.org; Sun, 18 Nov 2012 19:14:00 +0000 Received: from anarazel.de (p5DDC7C56.dip.t-dialin.net [93.220.124.86]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Lgw8E-1SyJ3I3BVW-00ncqK; Sun, 18 Nov 2012 20:13:50 +0100 Received: by anarazel.de (Postfix, from userid 1000) id EB8401C00E5; Sun, 18 Nov 2012 20:13:49 +0100 (CET) Date: Sun, 18 Nov 2012 20:13:49 +0100 From: Andres Freund To: Tom Lane Cc: Igor , pgsql-bugs@postgresql.org Subject: Re: BUG #7670: BUG #7545: Unresponsive server with error log reporting: "poll() failed: Invalid argument" Message-ID: <20121118191349.GB1325@awork2.anarazel.de> References: <20121118162852.GB14145@awork2.anarazel.de> <3078.1353259769@sss.pgh.pa.us> <3366.1353260695@sss.pgh.pa.us> <20121118180654.GB30822@awork2.anarazel.de> <4024.1353262722@sss.pgh.pa.us> <20121118185102.GA1325@awork2.anarazel.de> <4924.1353265657@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4924.1353265657@sss.pgh.pa.us> X-Provags-ID: V02:K0:/SdJU9VD3xuAXgVyqV862u+zPfS52eANbB4VXlvMjef 4Ky/saAJ3D71xmBWaWxIeUUlA6Jz2JsPXfY6PMn+7L6MN5mgsO Zt0qtY+xzZ0gaUiLwj8lgn3rE46DfoG1Z9M5Rj95hXuSFW8iCY 8mUjbkLbh9eKfEMLWxcj3Y1abNgT2Rq/zNXJfumbUcxZJoJ66Y nEm2Fc8yqanTJYMj+zKrlliMB7tdhmYw8ZYU85Os0FTmk/xBi0 OXpzDl2GOFDQ3InXt88bxFfGZtzM8siyOgTuQ3GHNI8WDc7Ojf rEWIANupie0ztNUcDwDcrLUYCgsxI9qTevkNu4ri2gZu52OxmN csHqPrz71T9ALDQOhwsvUeX+g/cBtf8pm3SUcUiFQ X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201211/139 X-Sequence-Number: 34697 On 2012-11-18 14:07:37 -0500, Tom Lane wrote: > Andres Freund writes: > > On 2012-11-18 13:18:42 -0500, Tom Lane wrote: > >> Well, we have two reports of people trying such values (assuming that > >> #7545 actually is the same thing), and it didn't work for either of > >> them. I don't think it's a problem to restrict the value to something > >> that will work rather than fail. > > > Thats a good point. But #7545 was on OSX so its not really that much > > evidence a larger value doesn't work on non-bsdish systems. > > > In fact, a setting of 32 days seems not to cause any immediate problems > > here on linux, even when choosing the timeout in a way it results in a > > negative timeout value for poll. Not sure what its waiting for, but it > > doesn't crash. > > If you look closely at what's happening in syslogger.c, you'll realize > that it's a phase of the moon kind of behavior, because the > next_rotation_time is rounded off to a multiple of the specified > log_rotation_age. Then you'll get an overflow (or not) depending on > whether now() is within 2^31 msec of that target time. So for example > with a 30-day log_rotation_age, you'd be seeing failures during the > first five days of every "month", where a month is defined as > exactly-30-day intervals since the epoch. And I think there's a > timezone correction in there too, which would shift the trouble > intervals around for different people. I verified with strace that I calculated correctly and got a negative value: poll([{fd=10, events=POLLIN}, {fd=3, events=POLLIN}], 2, -1033055888) = 1 ([{fd=10, revents=POLLIN}]) (that poll finished was due to a SIGHUP) > Anyway, even if Linux for some reason doesn't reject negative values, > I think we need to limit the GUC's range so we don't try to use them. > Maybe you'd get sane behavior and maybe you wouldn't. I notice that > the Single Unix Spec doesn't specify EINVAL for negative timeout > values, but it also doesn't define what happens for a negative value > other than -1. So this is basically an unspecified case and it's > incumbent on us to not do it if we want portable behavior. I aggree that we need to do something. I just think it might be enough to clamp the timeout value passed to WaitLatchOrSocket to the maximum valid value. The rest of SysLoggerMain seems to work correctly in that case. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services