Azure Database for PostgreSQL - Flexible Server Stuck in Stopping State

Jacopo Spolverati 20 Reputation points
2025-01-20T16:21:13.1066667+00:00

The Azure Database for PostgreSQL instance https://portal.azure.com/#@audiencerate.it/resource/subscriptions/a28473c4-30fc-4b70-93c0-2d50f9dc9dcd/resourceGroups/rg-cdp-dev-001/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-cdp-dev-italynorth-server-001/overview has been in a stopping state for 40 minutes. This cluster was stopped because it does not accept new connections.

What can be done to resolve this issue?

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Sina Salam 16,526 Reputation points
    2025-01-20T21:24:53.7133333+00:00

    Hello Jacopo Spolverati,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you having issue where cluster was stopped beyond consideration amount of time and because it does not accept new connections.

    I would like to give you best practices targeted diagnostics, with immediate corrective actions, and long-term steps to mitigate future occurrences.

    STEP A:

    • Run the following Azure CLI command to check the current state of the server using bash command: az postgres flexible-server show --name <server-name> --resource-group <resource-group> Look for the state property to confirm the stopping status.
    • If the server remains unresponsive, try forcing a restart using the CLI bash command:
    • az postgres flexible-server restart --name <server-name> --resource-group <resource-group>
    • Use the Azure Monitor logs to check for errors or blockers. Run the following to query logs:
             az monitor log-analytics query \
               --workspace <workspace-id> \
               --analytics-query "AzureDiagnostics | where ResourceId == '<server-resource-id>'"
      
    • Confirm if the server has management locks that might be preventing the stop action using bash command: az resource lock list --resource-name <server-name> --resource-group <resource-group> --resource-type "Microsoft.DBforPostgreSQL/flexibleServers"
    • Remove locks if present: az resource lock delete --ids <lock-id>
    • If resource exhaustion is suspected, scale the server up temporarily using bash command: az postgres flexible-server update --name <server-name> --resource-group <resource-group> --sku-name GP_Gen5_4

    STEP B:

    -- If the server becomes responsive, log in using `psql` and identify any blocking queries:
         SELECT pid, state, query FROM pg_stat_activity WHERE state != 'idle';
    -- Terminate blocking processes
         SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state != 'idle';
    
    • Visit the Azure Status Page - https://status.azure.com to confirm no platform outages and check the notifications in the Azure portal for planned maintenance.
    • If none of the above resolves the issue, escalate the problem via a support ticket with detailed diagnostics using bash command: az support ticket create --problem-classification-id <classification-id> --description "Server stuck in stopping state"

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Mahesh Kurva 2,260 Reputation points Microsoft Vendor
    2025-01-20T18:52:58.83+00:00

    Hi @Jacopo Spolverati,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    As I understand, your Azure Database for PostgreSQL instance is stuck in the stopping state. Here are a few steps you can take to resolve this issue:

    1.Sometimes, the stopping process can take longer than expected. Check the Azure portal to see if the status has changed.

    2.If the server is still stuck, try restarting it using the Azure portal or Azure CLI. You can use the following command in Azure CLI:

    az postgres flexible-server stop  [--name]
                                   [--resource-group]
                                   [--subscription]
    

    3.Long-running transactions can sometimes cause issues during restarts. Ensure there are no long-running transactions or queries impacting the server’s performance.

    For more information, please refer the document: https://docs.azure.cn/en-us/postgresql/flexible-server/how-to-stop-start-server-cli#stop-a-running-server

    If the above steps do not resolve the issue, it might be best to create a support ticket. If you have a support plan, could you please file a support ticket for deeper investigation and do share the SR# with us? In case if you don't have a support plan, please let us know here.

    Hope this helps. Do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

  2. RahulRandive 10,146 Reputation points
    2025-01-21T00:31:20.0866667+00:00

    Hi @Jacopo Spolverati

    What causes long recovery on Azure Database for PostgreSQL- Recent checkpoints are critical for fast server recovery. Once a restart happens, either it was a new instance (failover to healthy instance) or same instance (in-place restart) will connect to disk that has all logs, all WAL logs after the last successful checkpoint need to be applied to the data pages before the server starts to accept connections again.

    Another reason would be long running transactions are queries that are running for too long which impact database performance and can potentially cause issues during restarts.

    I hope your server should be back by now. If not, you'll need to open a support case to get it back online.

    Thank You!

    0 comments No comments

Your answer

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