Azure Database for PostgreSQL: Issue with Deletion Due to Active Replicas — Metadata Stale or Stuck Role?

GustavoHiga-5354 0 Reputation points
2026-10-07T19:42:23.1533333+00:00

Problem description

I am attempting to delete an Azure Database for PostgreSQL flexible server (Citus) in West Europe, but the delete operation fails because the server reports that there are 2 active replicas, even though I believe the replica has already been removed. The error indicates that the server has active replicas, which prevents deletion.

Environment

Azure Database for PostgreSQL flexible server (Citus), PostgreSQL version 17, in West Europe, with a 2-node cluster and a geo-replica in Sweden Central.

What I've already tried

I created a geo-replica, performed switchovers, and then attempted to delete the source cluster via Azure CLI. The delete failed due to active replicas. I also checked the server state, which reports 'Ready' and 'Primary', but the delete still fails. I reviewed the replica list using Azure CLI and REST API, which returned an empty list, suggesting no visible replicas. I also checked the server's current state, which shows 'Ready' and 'Primary', but the service reports 2 active replicas, indicating potential stale metadata or stuck role states.

Current status

I am seeking guidance on how to resolve the discrepancy between the server's reported active replicas and the absence of visible replicas, to successfully delete the server. Specifically, I want to understand how to clear any stale geo-replication metadata or resolve potential stuck roles that prevent deletion.

Azure Database for PostgreSQL
0 comments No comments

2 answers

Sort by: Most helpful
  1. Allan Solomon Mejia 10,385 Reputation points
    2026-10-08T03:12:19.2333333+00:00

    Hello @GustavoHiga-5354

    First, confirm the Azure resource type. A Citus cluster managed through az cosmosdb postgres cluster normally uses Microsoft.DBforPostgreSQL/serverGroupsv2, which is Azure Cosmos DB for PostgreSQL, not a standard Azure Database for PostgreSQL flexible server. The two services use different replication and management APIs.

    A promoted read replica becomes an independent read/write cluster and that promotion is irreversible. Deleting replicas through the replica resource or the primary cluster’s Replicate data globally pane.

    Since:

    • The portal, Azure CLI, and REST API show no replica resources.
    • The source remains Ready and Primary.
    • Deletion still reports two active replicas.

    this points to service-side replication metadata that isn’t represented by currently visible ARM resources. SQL roles, Citus metadata tables, server restarts, and resource locks won’t provide a supported method to clear Azure control-plane replication metadata.

    I cannot find a Microsoft-documented CLI, REST operation, or PostgreSQL command that allows customers to manually clear this replica count. Don’t attempt to modify Citus system metadata or delete underlying nodes independently.

    This requires an Azure support case. Include:

    • The complete source cluster resource ID.
    • The former replica’s resource ID and region, if available.
    • Promotion, switchover, and deletion timestamps in UTC.
    • The failed delete operation ID and full error response.
    • Output from az cosmosdb postgres cluster show.
    • Confirmation that portal, CLI, and REST enumeration return no replicas.

    Ask support to inspect and reconcile the Microsoft.DBforPostgreSQL/serverGroupsv2 geo-replication relationship metadata before retrying the cluster deletion.

    Also note that Azure Cosmos DB for PostgreSQL is on a retirement path; Microsoft recommends Azure Database for PostgreSQL Elastic Clusters for new distributed PostgreSQL deployments.

    References:

    Azure CLI reference

    Create and manage read replicas

    Microsoft service guidance


    Help make this community better for everyone: If this answer helped or resolved your issue, please accept it or upvote it. If not, share more details in a comment so we can continue the discussion and find the right solution. Thank you.

    Was this answer helpful?

    0 comments No comments

  2. Rukshan edirisinghe 1,400 Reputation points
    2026-10-08T03:11:08.7366667+00:00

    Hi @GustavoHiga-5354

    After a switchover the roles swap, so the replica link can still be recorded on the other server even when the West Europe server's own replica list comes back empty. The docs are clear that replicas have to go before the primary can be deleted, so it's worth checking the link from the Sweden Central side first:

    1. Run az postgres flexible-server replica list --resource-group <rg> --name <sweden-server> and also open that server's Replication page in the portal. Note which server shows as Primary and which as Replica.
    2. If the Sweden Central cluster is still linked as a replica and it's the one you want to keep, promote it to a standalone server. That breaks the link without deleting any data. Wait for the operation to fully finish.
    3. Then run the delete on the West Europe cluster again.
    4. If both servers show no replication link and the delete still says 2 active replicas, the metadata is stuck on the service side. Open a support request and include the correlation ID from the failed delete in the Activity log, since only Microsoft can clear that.

    Which server shows as Primary on the Replication page right now, West Europe or Sweden Central?

    If this resolved your issue, please consider accepting it as the answer. If the delete keeps failing, let me know and I'll be happy to keep helping.

    Reference:

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.