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 10.3 database lock issue, QueryForLong cannot convert DBNull #268

Open
skipperTux opened this issue Feb 23, 2022 · 0 comments
Open

Comments

@skipperTux
Copy link

skipperTux commented Feb 23, 2022

Hi.
We are using Evolve 3.0.0 in our .NET 4.8 Desktop Application with a MariaDB 10.3.x database and MySqlConnector 1.3.14. Evolve works great, thanks for putting your time and passion into this project!
We recently have a very weird issue with long migrations. The migration has a lot of inserts, so first thing we did is increase the CommandTimeout. Migrations now work on most MariaDB test servers (Docker, Windows, local and network), however they do not work on a Synology NAS. It might be a problem with the Synology NAS or with this specific NAS (we are still looking into this, trying a different NAS system*).
However what I see from logs and code is that Evolve is unable to get/release the session level lock. Looking into the source code the TryAcquireApplicationLock and ReleaseApplicationLock are calling QueryForLong that does not check for the value to convert being NULL. (Is it safe to assume the value will never be NULL?) I checked the METADATA_LOCK_INFO before migration start and it is empty.
Also confusing is that I can get and release session level locks named 'Evolve' using some database tool (HeidiSQL, PHPMyAdmin). As said some of the scripts work, only long scripts fail with the error below. The error says that an 'object of type DBNull can not be converted', because SELECT RELEASE_LOCK does return DBNULL.

Evolve.EvolveSqlException: Ein Objekt kann nicht von DBNull in andere Typen umgewandelt werden. Sql query: SELECT RELEASE_LOCK('Evolve'); Ein Objekt kann nicht von DBNull in andere Typen umgewandelt werden. ---> System.InvalidCastException: Ein Objekt kann nicht von DBNull in andere Typen umgewandelt werden.
   bei System.DBNull.System.IConvertible.ToInt64(IFormatProvider provider)
   bei System.Convert.ToInt64(Object value)
   bei Evolve.WrappedConnectionEx.<>c.<QueryForLong>b__5_0(IDbCommand cmd)
   bei Evolve.WrappedConnectionEx.Execute[T](WrappedConnection wrappedConnection, String sql, Func`2 query, Action`1 setupDbCommand)

I tried to set EnableClusterMode to false, because from the docs I understand that no locks will be used then, and our migration is only running on a single database server, no cluster. However this results in a new error, this error says that the 'connection has been closed by the remote host', see below.

2022-02-23 18:48:06.586 +01:00 [ERR] DbScriptManager ERROR 'Eine vorhandene Verbindung wurde vom Remotehost geschlossen'
System.Net.Sockets.SocketException (0x80004005): Eine vorhandene Verbindung wurde vom Remotehost geschlossen
   bei System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   bei MySqlConnector.Utilities.SocketExtensions.Send(Socket socket, ReadOnlyMemory`1 data, SocketFlags flags) in /_/src/MySqlConnector/Utilities/SocketExtensions.cs:Zeile 36.
   bei MySqlConnector.Protocol.Serialization.SocketByteHandler.WriteBytesAsync(ReadOnlyMemory`1 data, IOBehavior ioBehavior) in /_/src/MySqlConnector/Protocol/Serialization/SocketByteHandler.cs:Zeile 125.

Any idea? Thanks.

  • Edit: Now tested on three (3) different Synology NAS MariaDB servers and getting this same error on all systems. Looks like an issue with Synology NAS MariaDB, Evolve and large scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant