Azure / azure-postgresql

Azure Database for PostgreSQL (fully managed service for PostgreSQL in Azure)
MIT License
77 stars 78 forks source link

Azure PSQL Flexible Server: Azure Superuser connected on postgresql flexible server preventing management of own databases #122

Open fsismondi opened 1 month ago

fsismondi commented 1 month ago

Are you tring to create database from ARM template, Azure CLI or REST API? Azure CLI

What is the error message you received? ERROR: database 'db_name' is being accessed by other users DETAIL: There is 1 other session using the database. then ERROR: must be a superuser to terminate superuser process

Problem description

Sometimes, when we try to drop a database from any of our flexible servers (not only one, that issue is happening on multiple servers throughout the subscription), we get an error message saying that the database is being accessed by other users.

Since the application connected to the database is not running, we run the following query : 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'db_name';' and that's when the 2nd error message occurs.

Since we are not allowed by Azure to have a superuser, I can only assume that the connection is not from our side.

This raises several concerns :

  1. Obviously, this error is impairing our ability to manage the databases at our discretion, our operations are delayed and needs to be restarted
  2. From a data privacy perspective, we are not fine with Azure accessing our data without our consent

This behavior started around May/June in the Europe region, it only happened once in a while, but at the time I write this request, it happens multiple times a week.

More: This error has been hard for us to reproduce, we can only see the error messages in the logs afterwards. The nature of the error message is quite clear and it is certain that some superuser role is accessing the databases. If I check the roles present in the clusters, the only one with superuser access is "azuresu". Since the issue is random, it's hard to monitor precisely