mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
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
This commit is contained in:
@@ -15747,7 +15747,7 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
|
||||
<row>
|
||||
<entry><literal><function>pg_blocking_pids(<type>int</type>)</function></literal></entry>
|
||||
<entry><type>int[]</type></entry>
|
||||
<entry>Process ID(s) that are blocking specified server process ID</entry>
|
||||
<entry>Process ID(s) that are blocking specified server process ID from acquiring a lock</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
@@ -15793,6 +15793,12 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
|
||||
<entry>server start time</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>pg_safe_snapshot_blocking_pids(<type>int</type>)</function></literal></entry>
|
||||
<entry><type>int[]</type></entry>
|
||||
<entry>Process ID(s) that are blocking specified server process ID from acquiring a safe snapshot</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>pg_trigger_depth()</function></literal></entry>
|
||||
<entry><type>int</type></entry>
|
||||
@@ -16067,6 +16073,25 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
|
||||
server started.
|
||||
</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>pg_safe_snapshot_blocking_pids</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
<function>pg_safe_snapshot_blocking_pids</function> returns an array of
|
||||
the process IDs of the sessions that are blocking the server process with
|
||||
the specified process ID from acquiring a safe snapshot, or an empty array
|
||||
if there is no such server process or it is not blocked. A session
|
||||
running a <literal>SERIALIZABLE</literal> transaction blocks
|
||||
a <literal>SERIALIZABLE READ ONLY DEFERRABLE</literal> transaction from
|
||||
acquiring a snapshot until the latter determines that it is safe to avoid
|
||||
taking any predicate locks. See <xref linkend="xact-serializable"> for
|
||||
more information about serializable and deferrable transactions. Frequent
|
||||
calls to this function could have some impact on database performance,
|
||||
because it needs access to the predicate lock manager's shared
|
||||
state for a short time.
|
||||
</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>version</primary>
|
||||
</indexterm>
|
||||
|
||||
Reference in New Issue
Block a user