40{
44 const char *wait_event_type;
46 int32 *interesting_pids;
48 int num_interesting_pids;
49 int num_blocking_pids;
50 int dummy;
53
54 /* Check if blocked_pid is in an injection point. */
56 if (proc == NULL)
58 wait_event_type =
60 if (wait_event_type && strcmp("InjectionPoint", wait_event_type) == 0)
62
63 /* Validate the passed-in array */
66 elog(
ERROR,
"array must not contain nulls");
70
71 /*
72 * Get the PIDs of all sessions blocking the given session's attempt to
73 * acquire heavyweight locks.
74 */
75 blocking_pids_a =
77
83
84 /*
85 * Check if any of these are in the list of interesting PIDs, that being
86 * the sessions that the isolation tester is running. We don't use
87 * "arrayoverlaps" here, because it would lead to cache lookups and one of
88 * our goals is to run quickly with debug_discard_caches > 0. We expect
89 * blocking_pids to be usually empty and otherwise a very small number in
90 * isolation tester cases, so make that the outer loop of a naive search
91 * for a match.
92 */
93 for (
i = 0;
i < num_blocking_pids;
i++)
94 for (
j = 0;
j < num_interesting_pids;
j++)
95 {
96 if (blocking_pids[
i] == interesting_pids[
j])
98 }
99
100 /*
101 * Check if blocked_pid is waiting for a safe snapshot. We could in
102 * theory check the resulting array of blocker PIDs against the
103 * interesting PIDs list, but since there is no danger of autovacuum
104 * blocking GetSafeSnapshot there seems to be no point in expending cycles
105 * on allocating a buffer and searching for overlap; so it's presently
106 * sufficient for the isolation tester's purposes to use a single element
107 * buffer and check if the number of safe snapshot blockers is non-zero.
108 */
111
113}
#define PG_GETARG_ARRAYTYPE_P(n)
#define DatumGetArrayTypeP(X)
bool array_contains_nulls(ArrayType *array)
int ArrayGetNItems(int ndim, const int *dims)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_INT32(n)
#define PG_RETURN_BOOL(x)
Assert(PointerIsAligned(start, uint64))
Datum pg_blocking_pids(PG_FUNCTION_ARGS)
static Datum Int32GetDatum(int32 X)
int GetSafeSnapshotBlockingPids(int blocked_pid, int *output, int output_size)
PGPROC * BackendPidGetProc(int pid)
const char * pgstat_get_wait_event_type(uint32 wait_event_info)
#define UINT32_ACCESS_ONCE(var)