Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop a Redshfit database with connected users

Is it possible to drop active connections to Redshift in order to drop a database?

In my development environment I find myself recreating the schema very frequently and if there happens to be some stray process connected to the database this fails. I know it's possible to do this with Postgresql using pg_terminate_backend, but this doesn't seem to work on Redshift.

Deleting rows from the STV_SESSIONS table isn't an option, either.

Any ideas?

like image 306
Assaf Lavie Avatar asked Oct 17 '25 02:10

Assaf Lavie


1 Answers

http://docs.aws.amazon.com/redshift/latest/dg/PG_TERMINATE_BACKEND.html

Find the PIDs of current running queries

 select pid from stv_recents where status = 'Running';

and terminate all the queries with

 select pg_terminate_backend(pid); 
like image 155
androboy Avatar answered Oct 18 '25 23:10

androboy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!