aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-03-16 23:22:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-03-16 23:22:57 -0400
commitd43837d03067487560af481474ae985df894f786 (patch)
tree7289d038a184fa3dc59195aaa27538714ea85ad9 /src/backend/tcop/postgres.c
parentd2bef5f7db5f3afdbbb3f58b8eff49f0bc7ef790 (diff)
downloadpostgresql-d43837d03067487560af481474ae985df894f786.tar.gz
postgresql-d43837d03067487560af481474ae985df894f786.zip
Add lock_timeout configuration parameter.
This GUC allows limiting the time spent waiting to acquire any one heavyweight lock. In support of this, improve the recently-added timeout infrastructure to permit efficiently enabling or disabling multiple timeouts at once. That reduces the performance hit from turning on lock_timeout, though it's still not zero. Zoltán Böszörményi, reviewed by Tom Lane, Stephen Frost, and Hari Babu
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 407c548cf8f..587d065f1cc 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2883,7 +2883,22 @@ ProcessInterrupts(void)
(errcode(ERRCODE_QUERY_CANCELED),
errmsg("canceling authentication due to timeout")));
}
- if (get_timeout_indicator(STATEMENT_TIMEOUT))
+
+ /*
+ * If LOCK_TIMEOUT and STATEMENT_TIMEOUT indicators are both set, we
+ * prefer to report the former; but be sure to clear both.
+ */
+ if (get_timeout_indicator(LOCK_TIMEOUT, true))
+ {
+ ImmediateInterruptOK = false; /* not idle anymore */
+ (void) get_timeout_indicator(STATEMENT_TIMEOUT, true);
+ DisableNotifyInterrupt();
+ DisableCatchupInterrupt();
+ ereport(ERROR,
+ (errcode(ERRCODE_QUERY_CANCELED),
+ errmsg("canceling statement due to lock timeout")));
+ }
+ if (get_timeout_indicator(STATEMENT_TIMEOUT, true))
{
ImmediateInterruptOK = false; /* not idle anymore */
DisableNotifyInterrupt();