-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

PostgreSQL 10 Administration Cookbook

Sometimes, the only way to let the system continue as a whole is by surgically terminating some offending database sessions. Yes, you read it right: surgically. You might indeed be tempted to reboot the server, but you should think of that as a last resort in a business continuity scenario.
In this recipe, you will learn how to intervene, from gracefully canceling a query to brutally killing the actual process from the command line.
You can either run this function as a superuser or with the same user as that of the offending backend (look for the usename
field in the pg_stat_activity
view).
Once you have figured out the backend you need to kill, use the function named pg_terminate_backend(pid)
to kill it.
When a backend executes the pg_terminate_backend(pid)
function, it sends a signal, SIGTERM
, to the backend as an argument after verifying that the process identified by the argument pid
is actually a PostgreSQL backend.
The backend receiving...