postgresql/src/include
Tom Lane 22f6f2c1cc Improve management of statement timeouts.
Commit f8e5f156b added private state in postgres.c to track whether
a statement timeout is running.  This seems like bad design to me;
timeout.c's private state should be the single source of truth about
that.  We already fixed one bug associated with failure to keep those
states in sync (cf. be42015fc), and I've got little faith that we
won't find more in future.  So get rid of postgres.c's local variable
by exposing a way to ask timeout.c whether a timeout is running.
(Obviously, such an inquiry is subject to race conditions, but it
seems fine for the purpose at hand.)

To make get_timeout_active() as cheap as possible, add a flag in
the per-timeout struct showing whether that timeout is active.
This allows some small savings elsewhere in timeout.c, mainly
elimination of unnecessary searches of the active_timeouts array.

While at it, fix enable_statement_timeout to not call disable_timeout
when statement_timeout is 0 and the timeout is not running.  This
avoids a useless deschedule-and-reschedule-timeouts cycle, which
represents a significant savings (at least one kernel call) when
there is any other active timeout.  Right now, there usually isn't,
but there are proposals around to change that.

Discussion: https://postgr.es/m/16035-456e6e69ebfd4374@postgresql.org
2019-10-25 11:41:16 -04:00
..
access Remove last traces of heap_open/close in the tree 2019-10-19 11:18:15 +09:00
bootstrap Remove more unreferenced function declarations 2019-07-07 09:58:33 +09:00
catalog Implement jsonpath .datetime() method 2019-09-25 22:51:51 +03:00
commands Remove AtSubStart_Notify. 2019-10-04 08:19:25 -04:00
common Fix use of term "verifier" 2019-10-12 21:41:59 +02:00
datatype Update copyright for 2019 2019-01-02 12:44:25 -05:00
executor Fix crash caused by EPQ happening with a before update trigger present. 2019-10-04 13:50:49 -07:00
fe_utils Fix parallel restore of FKs to partitioned tables 2019-10-17 09:58:01 +02:00
foreign Fix inconsistencies and typos in the tree 2019-07-16 13:23:53 +09:00
jit Remove fmgr.h includes from headers that don't really need it. 2019-08-16 10:35:31 -07:00
lib Allow simplehash to use already-calculated hash values. 2019-08-01 16:05:49 -07:00
libpq In the postmaster, rely on the signal infrastructure to block signals. 2019-10-13 15:48:26 -04:00
mb Fix inconsistencies and typos in the tree, take 9 2019-08-05 12:14:58 +09:00
nodes Use Size instead of int64 to track allocated memory 2019-10-04 16:10:56 +02:00
optimizer Cosmetic improvements in setup of planner's per-RTE arrays. 2019-08-09 12:33:43 -04:00
parser Require the schema qualification in pg_temp.type_name(arg). 2019-08-05 07:48:41 -07:00
partitioning Improve pruning of a default partition 2019-08-04 11:18:45 -04:00
port Fix most -Wundef warnings 2019-10-19 18:31:38 +02:00
portability Update copyright for 2019 2019-01-02 12:44:25 -05:00
postmaster Fix inconsistencies and typos in the tree 2019-07-16 13:23:53 +09:00
regex Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
replication Rework WAL-reading supporting structs 2019-09-24 16:39:53 -03:00
rewrite Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
snowball Sync our Snowball stemmer dictionaries with current upstream 2019-07-04 13:26:48 +02:00
statistics Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
storage For PowerPC instruction "addi", use constraint "b". 2019-10-18 20:20:28 -07:00
tcop Revert hooks for session start and end, take two 2019-10-02 09:55:27 +09:00
tsearch Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
utils Improve management of statement timeouts. 2019-10-25 11:41:16 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Update some outdated links about XLC and UNIX specification 2019-10-08 14:31:30 +09:00
fmgr.h Make comment in fmgr.h match the one in fmgr.c. 2019-08-26 14:32:48 -04:00
funcapi.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
getaddrinfo.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
getopt_long.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Fix inconsistencies and typos in the tree, take 11 2019-08-19 16:21:39 +09:00
pg_config.h.in For all ppc compilers, implement compare_exchange and fetch_add with asm. 2019-10-18 20:20:52 -07:00
pg_config.h.win32 Remove some code for old unsupported versions of MSVC 2019-10-08 10:50:54 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_getopt.h Use our own getopt() on OpenBSD. 2019-01-18 15:06:26 -05:00
pg_trace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pgstat.h Remove fmgr.h includes from headers that don't really need it. 2019-08-16 10:35:31 -07:00
pgtar.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pgtime.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
port.h In the postmaster, rely on the signal infrastructure to block signals. 2019-10-13 15:48:26 -04:00
postgres.h Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rusagestub.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
windowapi.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00