0

I have a Windows Forms application, where the underlying database is MySql. Versions are as follows:

MySql Server v5.6

MySql Connector for .NET v6.5.4

Windows 7 64-bit

I get the error with the stack trace below, in an INTERMITTENT pattern. It happens each time in different parts of the application. Sometimes it takes a couple of days to happen, sometimes I get this 3 or 4 times a day.

On the specific occurrence where I collected this stack trace error, having the dialog box with the error still showing on the screen, I managed to open a second instance of my windows forms application, in parallel, only to notice that this second instance was working flawlessly. This is the pattern (or lack of it): whenever this issue shows up, just closing and restarting the application, or even opening another instance in parallel, is enough to restore database access. If I don't exit the application when this failure happens, all subsequent attempts the application makes to access MySql database fail, no matter what. The error dialog box option to "ignore this error and attempt to continue" allows me to conclude that it seems like MySql database backend and that particular instance of the windows forms application got "disconnected", even to subsequent attempts.

I understand that the stack trace information is a chain of events with the most recent at the top, so is it correct to assume that the failing point is at this event?

at MySql.Data.MySqlClient.NativeDriver.ExecutePacket(MySqlPacket packetToExecute)

I tried researching on this specific "MySql NativeDriver.ExecutePacket.. Object reference not set" everywhere, I could only get reports of people having this on seemingly unrelated issues with varying execution contexts, many of them even reporting as MySql bugs submitted to be fixed.

Anyway, I would appreciate any insight on the issue at hand, even suggestions on how to maybe properly debugging and even tuning MySql's configuration properties. I am open to any ideas.

See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at MySql.Data.MySqlClient.NativeDriver.ExecutePacket(MySqlPacket packetToExecute)
   at MySql.Data.MySqlClient.NativeDriver.SendQuery(MySqlPacket queryPacket)
   at MySql.Data.MySqlClient.Driver.SendQuery(MySqlPacket p)
   at MySql.Data.MySqlClient.Statement.ExecuteNext()
   at MySql.Data.MySqlClient.PreparableStatement.ExecuteNext()
   at MySql.Data.MySqlClient.PreparableStatement.Execute()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at CodeFluent.Runtime.MySQL.CodeFluentMySQLPersistenceHook.SetForeignKeyChecks(MySqlConnection mySqlConnection)
   at CodeFluent.Runtime.MySQL.CodeFluentMySQLPersistenceHook.AfterOpenConnection(IDbConnection connection)
   at CodeFluent.Runtime.CodeFluentPersistence.OpenConnection()
   at CodeFluent.Runtime.CodeFluentPersistence.InternalExecuteReader(CommandBehavior behavior, Boolean firstTry)
   at CodeFluent.Runtime.CodeFluentPersistence.ExecuteReader(CommandBehavior behavior)
   at CodeFluent.Runtime.CodeFluentPersistence.ExecuteReader()
   at S5T.AssociadoSetorCob.LoadBypCodigo(Int32 pCodigo)
   at S5TWin.FormGeraArqBanco.cmbSetor_MontaPesquisaTextBox(String& desc)
   at S5TWin.ComboCF.txtCodigo_Leave(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnLeave(EventArgs e)
   at System.Windows.Forms.Control.NotifyLeave()
   at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1022 (RTMGDR.030319-1000)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1001 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

Long list of loaded assemblies, cut short for brevity

Renato Xavier
  • 123
  • 1
  • 9
  • 1
    NullReferenceException in a code that belongs to the MyqlClient's NativeDriver class looks like a bug in that client/class (maybe already reported: https://bugs.mysql.com/bug.php?id=61094). You should try to upgrade to 6.9.8 or report this error to MySQL dev guys. – Simon Mourier Dec 29 '15 at 19:35
  • Thanks for the attention, @SimonMourier, I reported this error to MySql bug dev guys. The approach of upgrading to 6.9.8 raised OTHER ISSUE: every access is slow, very slow. Just by switching connectors and nothing else... That's why for now I reverted it all back 6.5.4, which gives me a "sweet spot" on this responsiveness issue... – Renato Xavier Jan 05 '16 at 18:05
  • 1
    Looking at MySQL forums (https://bugs.mysql.com/bug.php?id=61094) and also other questions (http://stackoverflow.com/questions/29094122/c-how-to-catch-exception-in-mysql-rollback), it looks like it's due to an earlier exception that does not keep things in a state like it should. So maybe it depends on things you do or things happening before that (transaction failure? etc. maybe record all errors prior to this one, with a tool such as http://getglimpse.com/). Otherwise if it's fixed in latest version, then try to find out why it's so slow... – Simon Mourier Jan 05 '16 at 18:11
  • Regarding slow responsiveness, I just posted another question [here](http://stackoverflow.com/questions/34618873/how-to-solve-low-performance-issues-with-net-mysql-connector-on-latest-versions). I'll try to investigate further if things I do, monitor the application behavior more closely. – Renato Xavier Jan 05 '16 at 18:36

0 Answers0