Creation of PostgreSQL replica server after point-in-time restore fails with timeout

Pavel Ottens 1 Reputation point
2020-10-21T19:42:10.477+00:00

Sorry, I couldn't find any place to report this issue.
Please correct me if there is more suitable resource for Azure bugs.

Preconditions
We have Azure PostgreSQL server X with replica server Y.
In case of emergency with Azure PostgreSQL server X we want to:

  1. Restore backup via Point-In-Time to new server X2;
  2. Recreate replica server with the same name Y from X2 server.

Expected result
The PostgreSQL replica server should be create successfully.

Actual result
Creation process fails with timeout after 1 hour:

Restore server...
{- Finished ..
  "administratorLogin": "dbadmin",
  "byokEnforcement": "Disabled",
  "earliestRestoreDate": "2020-10-21T18:39:56.803000+00:00",
  "fullyQualifiedDomainName": "psql-server-restored.postgres.database.azure.com",
  "id": "/subscriptions/.../resourceGroups/.../providers/Microsoft.DBforPostgreSQL/servers/psql-server-restored",
  "identity": null,
  "infrastructureEncryption": "Disabled",
  "location": "westus",
  "masterServerId": "",
  "minimalTlsVersion": "TLSEnforcementDisabled",
  "name": "psql-server-restored",
  "privateEndpointConnections": [],
  "publicNetworkAccess": "Enabled",
  "replicaCapacity": 5,
  "replicationRole": "None",
  "resourceGroup": "...",
  "sku": {
    "capacity": 2,
    "family": "Gen5",
    "name": "GP_Gen5_2",
    "size": null,
    "tier": "GeneralPurpose"
  },
  "sslEnforcement": "Enabled",
  "storageProfile": {
    "backupRetentionDays": 7,
    "geoRedundantBackup": "Disabled",
    "storageAutogrow": "Enabled",
    "storageMb": 102400
  },
  "tags": null,
  "type": "Microsoft.DBforPostgreSQL/servers",
  "userVisibleState": "Ready",
  "version": "11"
}
Create replica...
 - Running ..
Long-running operation wait cancelled.

Steps to reproduce

#!/bin/bash
set -o errexit

# PLEASE put your subscription id, resource group and server name to reproduce bug
subscriptionId=""
resourceGroup="myResourceGroup"
sourceServerName="psql-server"

sourceServerId="/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DBforPostgreSQL/servers/${sourceServerName}"
restoredServerId="/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DBforPostgreSQL/servers/${sourceServerName}-restored"

echo "Restore server..."
az postgres server restore \
    --resource-group "$resourceGroup" --subscription "$subscriptionId" \
    --name "${sourceServerName}-restored" --source-server "${sourceServerName}" \
    --restore-point-in-time "2020-10-22T01:00:00+07:00"

echo "Create replica..."
az postgres server replica create \
    --resource-group "$resourceGroup" --subscription "$subscriptionId" \
 --name "${sourceServerName}-replica" --source-server "$restoredServerId"

Additional context
This bug can be reproduced via Azure REST API.
I can't find info about replica server on Azure Portal.
Status of this operation is "Started" in "Activity log".

Workaround
Wait 5 minutes after that source server is restored.

Environment
Windows 10, WSL, Ubuntu 18.04
Azure CLI version

$ az version
{
  "azure-cli": "2.12.1",
  "azure-cli-core": "2.12.1",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}
Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. Navtej Singh Saini 4,221 Reputation points Microsoft Employee
    2020-11-07T00:54:28.527+00:00

    @Pavel Ottens

    We have received the reasoning and the workaround for this.

    If you tried to create a replica for the restored server X2, it also triggers a point-in-time restore first from X2 to the new replica with current timestamp as point-in-time.
    And if by then, there is no full backup (for XIO servers) or snapshot (for PFS servers) available for X2, restore will fail. The workaround is to wait for some time and after that source server is restored and backed up and it will work.

    Hope this helps, Please do check and confirm.

    Thanks
    Navtej S