diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-07 11:45:09 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-07 11:45:09 -0500 |
commit | 28489f1260d5055b02018d3286e0447804363707 (patch) | |
tree | 020d4ccc07c768573aa3b7881a988fd696fee3b5 /src/backend/tcop/postgres.c | |
parent | 83589107b6cdf34340043239dd93d79b91ac2813 (diff) |
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.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 194d27e12a3..8df8bea0d6f 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4082,7 +4082,18 @@ PostgresMain(int argc, char *argv[], firstchar = ReadCommand(&input_message); /* - * (4) disable async signal conditions again. + * (4) turn off the idle-in-transaction timeout, if active. We do + * this before step (5) so that any last-moment timeout is certain to + * be detected in step (5). + */ + if (disable_idle_in_transaction_timeout) + { + disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false); + disable_idle_in_transaction_timeout = false; + } + + /* + * (5) disable async signal conditions again. * * Query cancel is supposed to be a no-op when there is no query in * progress, so if a query cancel arrived while we were idle, just @@ -4094,15 +4105,6 @@ PostgresMain(int argc, char *argv[], DoingCommandRead = false; /* - * (5) turn off the idle-in-transaction timeout - */ - if (disable_idle_in_transaction_timeout) - { - disable_timeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, false); - disable_idle_in_transaction_timeout = false; - } - - /* * (6) check for any other interesting events that happened while we * slept. */ |