Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f2a69e9

Browse files
committed
Further second thoughts about idle_session_timeout patch.
On reflection, the order of operations in PostgresMain() is wrong. These timeouts ought to be shut down before, not after, we do the post-command-read CHECK_FOR_INTERRUPTS, to guarantee that any timeout error will be detected there rather than at some ill-defined later point (possibly after having wasted a lot of work). This is really an error in the original idle_in_transaction_timeout patch, so back-patch to 9.6 where that was introduced.
1 parent 820f882 commit f2a69e9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/backend/tcop/postgres.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,7 +4201,18 @@ PostgresMain(int argc, char *argv[],
42014201
firstchar = ReadCommand(&input_message);
42024202

42034203
/*
4204-
* (4) disable async signal conditions again.
4204+
* (4) turn off the idle-in-transaction timeout, if active. We do
4205+
* this before step (5) so that any last-moment timeout is certain to
4206+
* be detected in step (5).
4207+
*/
4208+
if (disable_idle_in_transaction_timeout)
4209+
{
4210+
disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false);
4211+
disable_idle_in_transaction_timeout = false;
4212+
}
4213+
4214+
/*
4215+
* (5) disable async signal conditions again.
42054216
*
42064217
* Query cancel is supposed to be a no-op when there is no query in
42074218
* progress, so if a query cancel arrived while we were idle, just
@@ -4212,15 +4223,6 @@ PostgresMain(int argc, char *argv[],
42124223
CHECK_FOR_INTERRUPTS();
42134224
DoingCommandRead = false;
42144225

4215-
/*
4216-
* (5) turn off the idle-in-transaction timeout
4217-
*/
4218-
if (disable_idle_in_transaction_timeout)
4219-
{
4220-
disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false);
4221-
disable_idle_in_transaction_timeout = false;
4222-
}
4223-
42244226
/*
42254227
* (6) check for any other interesting events that happened while we
42264228
* slept.

0 commit comments

Comments
 (0)