Error DB004: Migration Status Fetch Failure During Postgres Migration

João Paulo Ferreira de Souza 0 Reputation points
2025-03-12T18:40:15.36+00:00

Encountered an error while migrating from a single Postgres server to a flexible Postgres server. The plan is to retire the single Postgres server on 03/28/2025.

In the development environment, automatic migration failed, but manual migration through the portal succeeded. Upon attempting a manual migration in the production environment, the following error occurred:

DB004: Failed to fetch the current migrations status. Please reference MigrationId 0b018c9f-50c7-4b5f-be62-5d2c435eeeb0, when contacting Microsoft customer support. Parameter name: SourceDBServerResourceId

Both the Source and Target databases are located in the same region and subscription, with no private endpoint configured. The total database size is less than 60GB.

What steps are necessary to successfully complete the migration?

Azure Database Migration service
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad Chaganti 770 Reputation points Microsoft External Staff Moderator
    2025-03-13T00:04:59.33+00:00

    Hi João Paulo Ferreira de Souza,

    To resolve the DB004: Failed to fetch the current migration status error when migrating from a single Postgres server to a flexible Postgres server

    please follow the below Steps,

    1.Verify Network Configuration

    Ensure that network access for both the source and target servers allows public access.

    If private endpoints are not configured, confirm that the firewall rules are set to allow traffic from all Azure services:

    Go to Networking settings → Add client IP to the allowed list.

    Ensure the "Allow access to Azure services" option is enabled.

    2.Check Source and Target Compatibility

    Confirm that both the source and target servers are running compatible PostgreSQL versions.

    Flexible Server supports PostgreSQL versions 11 to 15.

    If the source server is running an unsupported version, upgrade it before migrating.

    3.Validate SourceDBServerResourceId

    Confirm that the SourceDBServerResourceId is correct and accessible:

    Run the following in Azure CLI to check the resource details:

    az postgres server show --name <source-server-name> --resource-group <resource-group>
    

    If the source server was recently renamed or modified, refresh the resource information in Azure.

    4.Increase Timeout and Memory Settings

    In the target flexible server, increase the following parameters to handle larger transactions:

    ALTER SYSTEM SET statement_timeout = '600000'; -- 10 minutes
    ALTER SYSTEM SET work_mem = '64MB'; -- Increase memory for sorting
    

    Restart the server after applying these changes.

    5.Perform a Manual Migration Using pg_dump and pg_restore

    If the migration fails through the portal, try a manual approach:

    Step 1: Export the data from the source server:

    pg_dump -h <source-server> -U <username> -d <source-db> -F c -b -v -f dumpfile.dump
    

    Step 2: Import the data into the flexible server:

    pg_restore -h <target-server> -U <username> -d <target-db> -F c -v dumpfile.dump
    

    Step 3: Fix any extensions or permissions after the restore:

    GRANT ALL PRIVILEGES ON DATABASE <target-db> TO <username>;
    

    6.Enable Debug Logs for More Details

    Enable PostgreSQL logs for better visibility:

    ALTER SYSTEM SET logging_collector = 'on';
    ALTER SYSTEM SET log_statement = 'all';
    ALTER SYSTEM SET log_min_messages = 'debug';
    

    Review the logs in the pg_log directory to identify any underlying issues.

    check the below steps:
    Test the connection and migration after adjusting the settings.

    Monitor performance using Azure Monitor.

    If the error persists, provide the MigrationId for deeper analysis.

    I hope this information helps. Please do let us know if you have any further queries.

    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.