Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mariadb in docker mariadb:lts #613

Open
nikkilocke opened this issue Sep 3, 2024 · 6 comments
Open

Mariadb in docker mariadb:lts #613

nikkilocke opened this issue Sep 3, 2024 · 6 comments

Comments

@nikkilocke
Copy link

I am switching my dotnet code from using mysql to mariadb.
I dumped my mysql database.
I created a new docker container based on mariadb:lts
I loaded my database.
I fired up my dotnet app, and immediately got an exception

MySql.Data.MySqlClient.SchemaProvider.GetIndexesAsync System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.UInt32'

The full stack trace is:

webapp-1     | Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.UInt32'.
webapp-1     |    at MySql.Data.MySqlClient.SchemaProvider.GetIndexesAsync(String[] restrictions, Boolean execAsync, CancellationToken cancellationToken)
webapp-1     |    at MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternalAsync(String collection, String[] restrictions, Boolean execAsync, CancellationToken cancellationToken)
webapp-1     |    at MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternalAsync(String collection, String[] restrictions, Boolean execAsync, CancellationToken cancellationToken)
webapp-1     |    at MySql.Data.MySqlClient.SchemaProvider.GetSchemaAsync(String collection, String[] restrictions, Boolean execAsync, CancellationToken cancellationToken)
webapp-1     |    at MySql.Data.MySqlClient.MySqlConnection.GetSchemaAsync(Boolean execAsync, String collectionName, String[] restrictionValues, CancellationToken cancellationToken)
webapp-1     |    at MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName)
webapp-1     |    at CodeFirstWebFramework.MySqlDatabase.Tables()
webapp-1     |    at CodeFirstWebFramework.Database.Upgrade()
webapp-1     |    at CodeFirstWebFramework.WebServer.registerServer(ServerConfig server)
webapp-1     |    at CodeFirstWebFramework.WebServer..ctor()
webapp-1     |    at BasecampGateway.Program.Main(String[] args) in /builds/nikki/basecampgateway/BasecampGateway/Program.cs:line 56
database-1   | 2024-09-03 14:17:00 3 [Warning] Aborted connection 3 to db: 'BasecampGateway' user: 'BasecampGateway' host: '172.16.98.3' (Got an error reading communication packets)
webapp-1     | Aborted

webapp-1 is the dotnet program, database-1 is the mariadb database.

@nikkilocke
Copy link
Author

I suspect the issue may be here, in MySQL.Data/src/SchemaProvider.cs:296

        foreach (MySqlSchemaRow index in indexes.Rows)
        {
          if (1 != (connection.driver.Version.isAtLeast(8, 0, 1) ?
            (uint)index["SEQ_IN_INDEX"] :
            (long)index["SEQ_IN_INDEX"]))
            continue;

It seems a totally unnecessary conditional - why not always cast it to a long (if that works), or even use ToString and compare it to "1"?

I guess I should report this to the mysql-connector-net repo?

@grooverdan
Copy link
Member

grooverdan commented Sep 3, 2024

Thanks for tracing it down.

Yes, its a bit odd an implementation. I can see why the size was reduced, the number of elements in a index is limited, 32 in MariaDB and I haven't tested in MySQL, but 3072 bytes would impose a limit of that number. I'm not sure a mysql-connector-net bug report would achieve much, they have indicated they don't care about MariaDB compatibility, so if you do, emphasise some non-MariaDB improvements by the change.

https://github.com/mysql-net/MySqlConnector is an alternate and supports MariaDB as a server.

I've raised this a potential change in MariaDB to reduce the size of this return value for compatibility - https://jira.mariadb.org/browse/MDEV-34864. I've written a patch MariaDB/server#3498. If you'd like a container version for testing let me know.

@nikkilocke
Copy link
Author

nikkilocke commented Sep 4, 2024 via email

@grooverdan
Copy link
Member

Per https://jira.mariadb.org/browse/MDEV-34864 - a server change was made to resolve this incompatibility.

@nikkilocke
Copy link
Author

nikkilocke commented Sep 9, 2024 via email

@iangilfillan
Copy link
Contributor

The fix will be applied to the upcoming Q4 set of releases. You can view the estimated release dates on https://jira.mariadb.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants