O'Reilly logo

PostgreSQL 9 Administration Cookbook by Hannu Krosing, Simon Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Killing a specific session

Sometimes the only way to let the system as a whole continue is by terminating some offending database sessions.

Getting ready

Again, this is a superuser-only capability, so log in as a superuser.

How to do it...

Once you have figured out the backend you need to kill, use the function named

pg_terminate_backend(processid) to actually kill it.

How it works...

When a backend executes the pg_terminate_backend(processid) function, it sends a signal SIGQUIT to the backend given as an argument, after checking that the process identified by the argument processid actually is a PostgreSQL backend.

The backend receiving this signal stops whatever it is doing, and terminates it in a controlled way.

The client using that backend loses ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required