pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Rearm statement_timeout after each executed query.
5+ messages / 4 participants
[nested] [flat]
Commits from this thread:
2018-02-09 be42015fcc Clear stmt_timeout_active if we disable_all_timeouts.
* pgsql: Rearm statement_timeout after each executed query.
@ 2017-09-19 02:41 Andres Freund <andres@anarazel.de>
2018-02-06 04:21 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Andres Freund @ 2017-09-19 02:41 UTC (permalink / raw)
To: pgsql-committers
Rearm statement_timeout after each executed query.
Previously statement_timeout, in the extended protocol, affected all
messages till a Sync message. For clients that pipeline/batch query
execution that's problematic.
Instead disable timeout after each Execute message, and enable, if
necessary, the timer in start_xact_command(). As that's done only for
Execute and not Parse / Bind, pipelining the latter two could still
cause undesirable timeouts. But a survey of protocol implementations
shows that all drivers issue Sync messages when preparing, and adding
timeout rearming to both is fairly expensive for the common parse /
bind / execute sequence.
Author: Tatsuo Ishii, editorialized by Andres Freund
Reviewed-By: Takayuki Tsunakawa, Andres Freund
Discussion: https://postgr.es/m/20170222.115044.1665674502985097185.t-ishii@sraoss.co.jp
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f8e5f156b30efee5d0038b03e38735773abcb7ed
Modified Files
--------------
src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 65 insertions(+), 12 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query.
2017-09-19 02:41 pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
@ 2018-02-06 04:21 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-02-08 00:04 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Thomas Munro <thomas.munro@enterprisedb.com>
0 siblings, 1 reply; 5+ messages in thread
From: Peter Eisentraut @ 2018-02-06 04:21 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; pgsql-hackers <pgsql-hackers@postgresql.org>
On 9/18/17 22:41, Andres Freund wrote:
> Rearm statement_timeout after each executed query.
This appears to have broken statement_timeout behavior in master such
that only every second query is affected by it. For example:
create table t1 as select * from generate_series(0, 100000000) as _(a);
set statement_timeout = '1s';
explain analyze select from t1 where a = 55; -- gets canceled
explain analyze select from t1 where a = 55; -- completes (>1s)
explain analyze select from t1 where a = 55; -- gets canceled
explain analyze select from t1 where a = 55; -- completes (>1s)
etc.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query.
2017-09-19 02:41 pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
2018-02-06 04:21 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
@ 2018-02-08 00:04 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-09 20:50 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Munro @ 2018-02-08 00:04 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-hackers <pgsql-hackers@postgresql.org>
On Tue, Feb 6, 2018 at 5:21 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> On 9/18/17 22:41, Andres Freund wrote:
>> Rearm statement_timeout after each executed query.
>
> This appears to have broken statement_timeout behavior in master such
> that only every second query is affected by it.
Yeah, I also just ran into this while testing a nearby complaint about
statement timeouts vs parallel query. In the error path
stmt_timeout_active remains true, so the next statement does nothing
in enable_statement_timeout(). I think we just need to clear that
flag in the error path, right where we call disable_all_timeouts().
See attached.
--
Thomas Munro
http://www.enterprisedb.com
Attachments:
fix-statement-timeout.patch (application/octet-stream, 501B) download
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index ddc3ec860ae..eb3ca07df71 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3913,6 +3913,9 @@ PostgresMain(int argc, char *argv[],
disable_all_timeouts(false);
QueryCancelPending = false; /* second to avoid race condition */
+ /* Forget about any active statement timeout. */
+ stmt_timeout_active = false;
+
/* Not reading from the client anymore. */
DoingCommandRead = false;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query.
2017-09-19 02:41 pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
2018-02-06 04:21 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-02-08 00:04 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-02-09 20:50 ` Robert Haas <robertmhaas@gmail.com>
2018-02-14 18:35 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 5+ messages in thread
From: Robert Haas @ 2018-02-09 20:50 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; Andres Freund <andres@anarazel.de>; pgsql-hackers <pgsql-hackers@postgresql.org>
On Wed, Feb 7, 2018 at 7:04 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Tue, Feb 6, 2018 at 5:21 PM, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
>> On 9/18/17 22:41, Andres Freund wrote:
>>> Rearm statement_timeout after each executed query.
>>
>> This appears to have broken statement_timeout behavior in master such
>> that only every second query is affected by it.
>
> Yeah, I also just ran into this while testing a nearby complaint about
> statement timeouts vs parallel query. In the error path
> stmt_timeout_active remains true, so the next statement does nothing
> in enable_statement_timeout(). I think we just need to clear that
> flag in the error path, right where we call disable_all_timeouts().
> See attached.
Looks right. Committed, but I thought the comment was strange (forget
about?) so I just left that out.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query.
2017-09-19 02:41 pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
2018-02-06 04:21 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-02-08 00:04 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-09 20:50 ` Re: [COMMITTERS] pgsql: Rearm statement_timeout after each executed query. Robert Haas <robertmhaas@gmail.com>
@ 2018-02-14 18:35 ` Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 5+ messages in thread
From: Andres Freund @ 2018-02-14 18:35 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers <pgsql-hackers@postgresql.org>
On 2018-02-09 15:50:44 -0500, Robert Haas wrote:
> On Wed, Feb 7, 2018 at 7:04 PM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
> > On Tue, Feb 6, 2018 at 5:21 PM, Peter Eisentraut
> > <peter.eisentraut@2ndquadrant.com> wrote:
> >> On 9/18/17 22:41, Andres Freund wrote:
> >>> Rearm statement_timeout after each executed query.
> >>
> >> This appears to have broken statement_timeout behavior in master such
> >> that only every second query is affected by it.
> >
> > Yeah, I also just ran into this while testing a nearby complaint about
> > statement timeouts vs parallel query. In the error path
> > stmt_timeout_active remains true, so the next statement does nothing
> > in enable_statement_timeout(). I think we just need to clear that
> > flag in the error path, right where we call disable_all_timeouts().
> > See attached.
>
> Looks right. Committed, but I thought the comment was strange (forget
> about?) so I just left that out.
Thanks Peter, Thomas, Robert!
- Andres
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-02-14 18:35 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-19 02:41 pgsql: Rearm statement_timeout after each executed query. Andres Freund <andres@anarazel.de>
2018-02-06 04:21 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-02-08 00:04 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-09 20:50 ` Robert Haas <robertmhaas@gmail.com>
2018-02-14 18:35 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox