Need some information adding parameters to the Connection string for MYSQL link Service

Senthil Avanasi 0 Reputation points
2025-03-18T16:33:23.2066667+00:00

Hi ,

I am using the ADF on Connecting MySQL database using Link Service. When executing the Copy Activities from MySQL as Source and SQLServer as the Sink, I am running in to the exception after couple of runs.

Failure happened on 'Source' side. 'Type=MySqlConnector.MySqlException,Message=Prepared statement needs to be re-prepared,Source=mscorlib,'

How do i set in the connection string to IgnorePrepare=true so that I can ignore and avoid the exceptions

, IgnorePrepare false If true, calls to MySqlCommand.Prepare(Async) are ignored (and will be no-ops). This option is provided for backwards compatibility with MySQL Connector/NET (before 8.0.23) and should not be used

Is there any other way i can get rid of these errors. Please advice.

Regards

Senthil Avanasi

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,442 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Chandra Boorla 11,670 Reputation points Microsoft External Staff
    2025-03-18T21:42:46.8733333+00:00

    @Senthil Avanasi

    Apologies for any confusion caused by the previous response.

    Thanks for sharing the details! Based on the image you provided; we can see that you have added IgnorePrepare=true in the Linked Service JSON configuration. However, ADF may not officially support this parameter in the connection settings, which means it could be ignored during execution.

    Possible Solutions to Fix the "Prepared statement needs to be re-prepared" Error:

    Use a Custom Query Instead of Selecting a Table - Instead of selecting a table directly in the Copy Activity, try using the "Query" option and writing a direct SELECT statement:

    SELECT * FROM your_table_name;
    

    This prevents ADF from using prepared statements, which are causing the issue.

    Increase MySQL Cache Settings (If You Have DB Access) - If you have control over the MySQL database, increasing these parameters can help prevent statement cache invalidation:

    SET GLOBAL table_open_cache = 4000;
    SET GLOBAL table_definition_cache = 2000;
    SET GLOBAL performance_schema_max_table_instances = 4000;
    

    Enable ADF Retry Logic - You can configure retries in Copy Activity → Settings: Retry count = 3 Retry interval (seconds) = 10 This ensures that ADF retries in case of transient failures.

    Conclusion:

    IgnorePrepare=true may not be supported in ADF Linked Services.

    Use custom queries instead of selecting tables.

    Optimize MySQL cache settings if possible.

    Add retries in ADF for transient errors.

    For additional information, please refer the following link:

    Appreciate if you could share the feedback on our feedback channel. Which would be open for the user community to upvote & comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and gives insight into the potential impact of implementing the suggested feature.

    I hope this information helps.

    Thank you.


  2. AnnuKumari-MSFT 34,456 Reputation points Microsoft Employee
    2025-03-25T06:27:18.8466667+00:00

    Hi Senthil Avanasi ,

    If you use version 2.0, the following properties are supported for MySQL linked service:

    User's image

    IgnorePrepare is not in the list of supported properties. It essentially should get or set a boolean value indicating if calls to Prepare() should be ignored as per https://documentation.help/MySQL-Connector.Net/P_MySql_Data_MySqlClient_MySqlConnectionStringBuilder_IgnorePrepare.htm

    Kindly try if you could achieve it using 'treatTinyAsBoolean' property.

    |treatTinyAsBoolean|When set to true, tinyint(1) values are returned as Boolean. Setting this property to false causes tinyint(1) to be returned as SByte/Byte.

    Version 2.0 treats tinyint(1) as Boolean type by default. For more information, see this article. To let the connector return tiny as numeric, set treatTinyAsBoolean=false in the connection properties.NoGoing through the difference between v1 and v2 connectors, doesn't seem like any changes have been made to remove the property . I also checked with the internal team and according to them , the error you are facing is not due to the connector issue. Kindly recheck your environment and configurations. You might want to try the V2 connector with SHIR setup as well.

    User's image

    Hope that helps. Kindly accept the answer by clicking on Accept answer button. Thankyou


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.