Unnecessary limit on max_standby_streaming_delay

Lists: pgsql-hackers
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Unnecessary limit on max_standby_streaming_delay
Date: 2010-12-17 11:57:48
Message-ID: AANLkTik_x=n=BfQAcds9DAyY5LQLVCQhXxNZ93N-UuwC@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The limit on max_standby_streaming_delay is currently 35 minutes
(around) - or you have to set it to unlimited. This is because the GUC
is limited to MAX_INT/1000, unit milliseconds.

Is there a reason for the /1000, or is it just an oversight thinking
the unit was in seconds?

If we can get rid of the /1000, it would make the limit over three
weeks, which seems much more reasonable. Or if we made it a 64-bit
counter it would go away completely.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unnecessary limit on max_standby_streaming_delay
Date: 2010-12-17 12:18:07
Message-ID: 4D0B54FF.7020708@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander wrote:
> The limit on max_standby_streaming_delay is currently 35 minutes
> (around) - or you have to set it to unlimited. This is because the GUC
> is limited to MAX_INT/1000, unit milliseconds.
>
> Is there a reason for the /1000, or is it just an oversight thinking
> the unit was in seconds?
>
> If we can get rid of the /1000, it would make the limit over three
> weeks, which seems much more reasonable. Or if we made it a 64-bit
> counter it would go away completely.
>

The code for this uses TimestampTzPlusMilliseconds to determine its
deadline:

return TimestampTzPlusMilliseconds(rtime, max_standby_streaming_delay);

Which is implemented like this:

#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * (int64) 1000))

My guess is that the range was limited at some point to avoid concerns
of integer overflow in that multiplication, which I don't think actually
is a risk due the int64 cast there.

I confirmed the upper limit on this thing is the <36 minutes that Magnus
suggests. This is a terrible limitation to have slipped through. For
the pg_dump from the standby use case, the appropriate setting for most
people is in the multiple hours range, but not unlimited (lest an out of
control backup linger to overlap with what happens the next day).
Whichever approach is taken to make this better, I think it deserves a
backport too.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services and Support www.2ndQuadrant.us


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unnecessary limit on max_standby_streaming_delay
Date: 2010-12-17 15:22:41
Message-ID: 29595.1292599361@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Smith <greg(at)2ndquadrant(dot)com> writes:
> Magnus Hagander wrote:
>> The limit on max_standby_streaming_delay is currently 35 minutes
>> (around) - or you have to set it to unlimited. This is because the GUC
>> is limited to MAX_INT/1000, unit milliseconds.
>>
>> Is there a reason for the /1000, or is it just an oversight thinking
>> the unit was in seconds?

> My guess is that the range was limited at some point to avoid concerns
> of integer overflow in that multiplication, which I don't think actually
> is a risk due the int64 cast there.

Yes, it's certainly there on the thought that somebody might try to
convert the value to microseconds in integer arithmetic. If you run
through all the uses of the variable and confirm that that never
happens, maybe it'd be safe to enlarge the limit. Check the units-aware
GUC printing code in particular.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unnecessary limit on max_standby_streaming_delay
Date: 2010-12-17 16:28:12
Message-ID: 1292603292.22053.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On fre, 2010-12-17 at 12:57 +0100, Magnus Hagander wrote:
> The limit on max_standby_streaming_delay is currently 35 minutes
> (around) - or you have to set it to unlimited. This is because the GUC
> is limited to MAX_INT/1000, unit milliseconds.
>
> Is there a reason for the /1000, or is it just an oversight thinking
> the unit was in seconds?

Yeah, I actually noticed this week that log_min_duration_statement is
limited to the same 35 minutes for the same reason. Might be good to
address that, too. Note that statement_timeout does not have that
limit.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unnecessary limit on max_standby_streaming_delay
Date: 2011-03-11 03:20:15
Message-ID: 201103110320.p2B3KFn13624@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On fre, 2010-12-17 at 12:57 +0100, Magnus Hagander wrote:
> > The limit on max_standby_streaming_delay is currently 35 minutes
> > (around) - or you have to set it to unlimited. This is because the GUC
> > is limited to MAX_INT/1000, unit milliseconds.
> >
> > Is there a reason for the /1000, or is it just an oversight thinking
> > the unit was in seconds?
>
> Yeah, I actually noticed this week that log_min_duration_statement is
> limited to the same 35 minutes for the same reason. Might be good to
> address that, too. Note that statement_timeout does not have that
> limit.

Added to TODO:

Increase maximum values for max_standby_streaming_delay and
log_min_duration_statement

* http://archives.postgresql.org/pgsql-hackers/2010-12/msg01517.php

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +