skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. Redshift Serverless, under the hood, is an ordinary, normal Redshift cluster.

    AWS have gone to considerable lengths to hide this fact from users, which I think is why you cannot access the very large majority of the system tables.

    https://www.redshiftresearchproject.org/white_papers/downloads/serverless.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search