aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-10-11 12:03:26 -0700
committerAndres Freund <andres@anarazel.de>2017-10-11 14:02:41 -0700
commit61ace8fe7fe82dc04c1de493a414597989f05e56 (patch)
treedce216cedf0705fe499e7a7eb06c5ae5ef320933
parentfbac00a4a8d3d9ff97ceb7176fce038fea5239b5 (diff)
downloadpostgresql-61ace8fe7fe82dc04c1de493a414597989f05e56.tar.gz
postgresql-61ace8fe7fe82dc04c1de493a414597989f05e56.zip
Prevent idle in transaction session timeout from sometimes being ignored.
The previous coding in ProcessInterrupts() could lead to idle_in_transaction_session_timeout being ignored, when statement_timeout occurred earlier. The problem was that ProcessInterrupts() would return before processing the transaction timeout if QueryCancelPending was set while QueryCancelHoldoffCount != 0 - which is the case when reading new commands from the client. Ergo when the idle transaction timeout would hit. Fix that by removing the early return. Alternatively the transaction timeout code could have been moved up, but that early return seems like an issue that could hit other cases too. Author: Lukas Fittl Bug: #14821 Discussion: https://www.postgresql.org/message-id/20170921010956.17345.61461%40wrigleys.postgresql.org https://www.postgresql.org/message-id/CAP53PkxQnv3OWJpyNPGJYT62uY=n1=2CF_Lpc6gVOFnc0-gazw@mail.gmail.com Backpatch: 9.6-, where idle_in_transaction_session_timeout was introduced.
-rw-r--r--src/backend/tcop/postgres.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index b8d860ebdbf..63a1994e61e 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2914,26 +2914,24 @@ ProcessInterrupts(void)
" database and repeat your command.")));
}
- if (QueryCancelPending)
+ /*
+ * Don't allow query cancel interrupts while reading input from the
+ * client, because we might lose sync in the FE/BE protocol. (Die
+ * interrupts are OK, because we won't read any further messages from
+ * the client in that case.)
+ */
+ if (QueryCancelPending && QueryCancelHoldoffCount != 0)
{
- bool lock_timeout_occurred;
- bool stmt_timeout_occurred;
-
/*
- * Don't allow query cancel interrupts while reading input from the
- * client, because we might lose sync in the FE/BE protocol. (Die
- * interrupts are OK, because we won't read any further messages from
- * the client in that case.)
+ * Re-arm InterruptPending so that we process the cancel request
+ * as soon as we're done reading the message.
*/
- if (QueryCancelHoldoffCount != 0)
- {
- /*
- * Re-arm InterruptPending so that we process the cancel request
- * as soon as we're done reading the message.
- */
- InterruptPending = true;
- return;
- }
+ InterruptPending = true;
+ }
+ else if (QueryCancelPending)
+ {
+ bool lock_timeout_occurred;
+ bool stmt_timeout_occurred;
QueryCancelPending = false;