Skip to content

Commit 5db4fdc

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 0f8977b commit 5db4fdc

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
@@ -4269,7 +4269,18 @@ PostgresMain(int argc, char *argv[],
42694269
firstchar = ReadCommand(&input_message);
42704270

42714271
/*
4272-
* (4) disable async signal conditions again.
4272+
* (4) turn off the idle-in-transaction timeout, if active. We do
4273+
* this before step (5) so that any last-moment timeout is certain to
4274+
* be detected in step (5).
4275+
*/
4276+
if (disable_idle_in_transaction_timeout)
4277+
{
4278+
disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false);
4279+
disable_idle_in_transaction_timeout = false;
4280+
}
4281+
4282+
/*
4283+
* (5) disable async signal conditions again.
42734284
*
42744285
* Query cancel is supposed to be a no-op when there is no query in
42754286
* progress, so if a query cancel arrived while we were idle, just
@@ -4280,15 +4291,6 @@ PostgresMain(int argc, char *argv[],
42804291
CHECK_FOR_INTERRUPTS();
42814292
DoingCommandRead = false;
42824293

4283-
/*
4284-
* (5) turn off the idle-in-transaction timeout
4285-
*/
4286-
if (disable_idle_in_transaction_timeout)
4287-
{
4288-
disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false);
4289-
disable_idle_in_transaction_timeout = false;
4290-
}
4291-
42924294
/*
42934295
* (6) check for any other interesting events that happened while we
42944296
* slept.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy