diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-10 10:26:54 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-10 10:26:54 -0400 |
commit | 511540dadf1166d80b864f63979178f324844060 (patch) | |
tree | b020d15352b84a5482c5b5064d6cd84793b1bdb8 /src/test/isolation/isolationtester.c | |
parent | 9cf5c31964315181e475fc37a5e9ad2204fe3484 (diff) | |
download | postgresql-511540dadf1166d80b864f63979178f324844060.tar.gz postgresql-511540dadf1166d80b864f63979178f324844060.zip |
Move isolationtester's is-blocked query into C code for speed.
Commit 4deb41381 modified isolationtester's query to see whether a
session is blocked to also check for waits occurring in GetSafeSnapshot.
However, it did that in a way that enormously increased the query's
runtime under CLOBBER_CACHE_ALWAYS, causing the buildfarm members
that use that to run about four times slower than before, and in some
cases fail entirely. To fix, push the entire logic into a dedicated
backend function. This should actually reduce the CLOBBER_CACHE_ALWAYS
runtime from what it was previously, though I've not checked that.
In passing, expose a SQL function to check for safe-snapshot blockage,
comparable to pg_blocking_pids. This is more or less free given the
infrastructure built to solve the other problem, so we might as well.
Thomas Munro
Discussion: https://postgr.es/m/20170407165749.pstcakbc637opkax@alap3.anarazel.de
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r-- | src/test/isolation/isolationtester.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 4d18710bdfd..3af5a706ce9 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -224,20 +224,12 @@ main(int argc, char **argv) */ initPQExpBuffer(&wait_query); appendPQExpBufferStr(&wait_query, - "SELECT pg_catalog.pg_blocking_pids($1) && '{"); + "SELECT pg_catalog.pg_isolation_test_session_is_blocked($1, '{"); /* The spec syntax requires at least one session; assume that here. */ appendPQExpBufferStr(&wait_query, backend_pids[1]); for (i = 2; i < nconns; i++) appendPQExpBuffer(&wait_query, ",%s", backend_pids[i]); - appendPQExpBufferStr(&wait_query, "}'::integer[]"); - - /* Also detect certain wait events. */ - appendPQExpBufferStr(&wait_query, - " OR EXISTS (" - " SELECT * " - " FROM pg_catalog.pg_stat_activity " - " WHERE pid = $1 " - " AND wait_event IN ('SafeSnapshot'))"); + appendPQExpBufferStr(&wait_query, "}')"); res = PQprepare(conns[0], PREP_WAITING, wait_query.data, 0, NULL); if (PQresultStatus(res) != PGRES_COMMAND_OK) |