Skip to content

Azure database for MySQL doesn't get detected properly #731

Closed
@spacentropy

Description

@spacentropy

Hi.

Short story: we've got three production incidents on Azure Database for MySQL & MySqlConnector because of this :-(

return ServerVersion.OriginalString == "5.6.26.0" || ServerVersion.OriginalString == "5.6.39.0";

Long story:

  • Azure Database for MySQL 5.7 identifies itself as 5.6.42.
  • MySqlConnector uses COM_CHANGE_USER as a connection reset method in 5.6. In 5.7 things have improved and we have mysql_reset_connection() method, which is considerably more efficient.
    MySqlConnector has a way to understand if it's talking to Azure Database for MySQL and issue select version() in order to get real version of MySQL. The way it's implemented is prone to error, as it uses hardcoded version number which MySQL presents as only means of getting the version. We use 0.44.1 version of connector which has only "5.6.26.0" hardcoded. I see that "5.6.39.0" has been added after a while, but right now our servers show "5.6.42.0", so even if we used 0.60, the detected version would still be wrong.

Because of these things combined, we've got three production incidents after Microsoft updated minor version of MySQL and introduced a slight latency in COM_CHANGE_USER. Servers with 5k+ queries per second would have 300+ threads active waiting for Change user with apps' latencies skyrocketing. We shouldn't see COM_CHANGE_USER at all, as we have MySQL 5.7.

I can make a PR adding "5.6.42.0" to this list, but let's make a more robust solution. Every time Microsoft updates their proxy version, we would have downtime. Maybe we could use connection string with something like ServerVersionOverride=5.7 or ForceGetServerVersion=true.
Or we could use DNS names of servers (*.mysql.database.azure.com) instead.
I personally think ServerVersionOverride=5.7 would better as it's takes roundtrips than getting the server version each time with select version().

Related issues:
#288

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions