PostgreSQL 11 Administration Cookbook
by Simon Riggs, Gianni Ciolli, Sudheer Kumar Meesala, Sheldon Strauch
How it works…
The pg_terminate_backend() function sends a signal directly to the operating system process for that session.
It's possible that the session may have closed by the time pg_terminate_backend() is named. As PID numbers are assigned by the operating system, it could even happen that you try to terminate a given session (let's call it session A), but you actually terminate another session (let's call it session B).
Here is how it could happen. Suppose you take note of the PID of session A and decide to disconnect it. Before you actually issue pg_terminate_backend(), session A disconnects, and right after, a new session, session B, is given exactly the same PID. So, when you terminate that PID, you hit session B instead.
On the one ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access