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 thestate
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.