Redshift Serverless Terminate Active Connections?

246 views Asked by At

I have a Redshift Serverless database that I need to delete. When I run the command:

drop database [my_database_name]

an error is returned:

SQL Error [55006]: ERROR: database "[my_database_name]" is being accessed by other users

The error makes sense. I need to close the active connections before dropping the database. But how on earth do we do this in Redshift Serverless?

In a traditional Redshift Cluster (Non-Serverless), you can query active sessions with:

select *
from pg_catalog.stv_sessions

and drop individual connections with:

SELECT PG_TERMINATE_BACKEND([PID])

But trying to query pg_catalog.stv_sessions on Redshift Serverless returns:

SQL Error [42501]: ERROR: permission denied for relation stv_sessions

The user I'm connected with is a super user so should have all allowed functionality. So, how do we see a list of active connections on Redshift Serverless?

1

There are 1 answers

0
gbeaven On

Found reference to the pg_stat_activity table in this answer.

Querying that object returned multiple connections. Killed them using the procpid and dropped the database.