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 :
- Obviously, this error is impairing our ability to manage the databases at our discretion, our operations are delayed and needs to be restarted
- 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