Share via

Azure Data Factory UserErrorSourceQueryTimeout caused by Linked Service Azure Database for Postgresql

Mateusz Gródek 30 Reputation points
2025-09-16T08:41:47.3533333+00:00

Hello,

Recently, I have encountered the following error for Lookup or Script activities when the activity takes longer than 15 minutes to complete:

Operation on target Lookup1 failed: Failure happened on 'Source' side. ErrorCode=UserErrorSourceQueryTimeout,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Query source database timeout,Source=Microsoft.DataTransfer.DataContracts,''Type=System.TimeoutException,Message=,Source=Microsoft.DataTransfer.DataContracts,'

In linked service I set CommandTimeout = 0

In activity General Timeout default = 12h (0.12:00:00)

In activity Settings QueryTimeout default = 120min

There is no statement_timeout=0 in source DB. When I run query localy it works even after 15 min.

I have a solution because after I changing Linked Service version back to "1.0" everything works correctly. However, I need version 2.0 to run Scripts activity. Any advice?

User's image

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

Answer accepted by question author

  1. Anonymous
    2025-09-18T08:31:31.9633333+00:00

    Hi Mateusz Gródek,

    Greetings for the day!

    Following upon our discussion over private messaging.

    After checking with our internal team, I would like to share that this is a known issue with the Azure PostgreSQL V2 connector related to query timeouts.

    Resolution / Next Steps:

    • For customers using Azure IR, our product group is planning to release the fix in the next regular deployment cycle, scheduled to begin in early October. Since the rollout usually takes 1–2 weeks across all public regions, the fix should be available by the end of October.
    • For customers using SHIR, the product group has provided an estimated timeline of mid-November for the fix.

    We understand this may cause inconvenience, and we truly appreciate your patience while our team works to resolve this in next deployments.

    I hope this information has been helpful!

    Your feedback is important so please take a moment to accept answers. If you still have questions, please let us know what is needed in the comments so the question can be answered.

    If this answers your query, please click Accept Answer and Upvote for was this answer helpful.

    Thanks!

    Kalyani

    Was this answer helpful?

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sina Salam 28,686 Reputation points Volunteer Moderator
    2025-09-16T13:38:23.9833333+00:00

    Hello Mateusz Gródek,

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

    I understand that your Azure Data Factory UserErrorSourceQueryTimeout caused by Linked Service Azure Database for Postgresql.

    The following steps can help you to resolve the issue:

    Step 1: Set scriptBlockExecutionTimeout in the script activity to a high value:

    "scriptBlockExecutionTimeout": "02:00:00"This controls how long each script block can run. - https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-data-factory-script-activity-azure

    Step 2: In the activity policy section of the json file: "timeout": "1.12:00:00"This sets the overall timeout for the activity. - https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-data-factory-script-activity-azure.

    Step 3: Ensure the following in your Linked Service JSON to use Correct Linked Service v2.0 Configuration:

    "commandTimeout": 0,
    "connectionTimeout": 600,
    "pooling": false,
    "noResetOnClose": true
    

    These settings help avoid premature termination and connection reuse issues. - https://learn.microsoft.com/en-us/answers/questions/2044922/adf-postgresql-linked-service-connector-settings

    Step 4: Avoid hardcoding passwords. Use:

    "password": {
      "type": "AzureKeyVaultSecret",
      "store": {
        "referenceName": "<KeyVaultLinkedService>",
        "type": "LinkedServiceReference"
      },
      "secretName": "<your-secret-name>"
    }
    

    This ensures secure and stable credential handling. - https://learn.microsoft.com/en-us/azure/data-factory/connector-postgresql

    Step 5: Use Self-Hosted Integration Runtime (SHIR) if your PostgreSQL is behind a firewall or VNet, SHIR will help to avoid network timeouts. - https://learn.microsoft.com/en-us/azure/data-factory/connector-postgresql

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


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

    Was this answer helpful?

    1 person found this answer helpful.