P
Patrick Questembert
I am using the VS.NET 2003 OleDB objects and C# against MySQL 4.1 Gamma on
Windows XP. The summary of the problem is this: I am doing a series of
queries (no updates) using the OleDB DataReader, and after a few thousands
queries, the SQL server seems to be clogged and starts failing all requests.
Then, after a minute or two, things return to normal. It is as if my series
of queries exhausted a resource on the server which time heals.
I am a newcomer to OleDB and SQL so it is possible that I am misusing the
OleDB .NET objects. Or am I expecting too much from MySQL? Details below.
After successfully running a few thousands queries of the type:
OleDbCommand catCMD = DatabaseConnection.CreateCommand();
catCMD.CommandText = SELECT t1.mysum FROM (SELECT SUM(negative) AS mysum
FROM myTable WHERE time >='2003-08-22 16:00:00') AS t1;
myReader = catCMD.ExecuteReader();
at some point, the ExecuteReader command stops working, with no specific
error:
System.Data.OleDb.OleDbException: No error information available:
E_FAIL(0x80004005).
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.ExecuteReader()
Note that I am always closing any DataReader I am using, but leaving the
OleDBConnection open (and sometimes also reuse the OleDbCommand object on
it).
The first error materializes at random times (but always after a fair number
of queries, maybe 10,000). When that first error happens, most subsequent
queries fail as well, including attempts to re-open the connection to the
database. Even a completely different application talking directly to the
server, such as the mysql utility, stops working (fails to connect to the
database).
Then, usually, waiting a few minutes helps and things get back to normal.
I went so far as inserting a 5 minutes delay in my code any time I would get
an error ... and it completely solves the problem (although hardly a
real-life solution)!
I would appreciate feedback on:
- is this likely to be a problem with my code? I mean, should ANYTHING I do
in my code cause a separate application like mysql.exe to fail?
- is it a MySQL 4.1 Gamma robustness issue? Should I stay away from MySQL
for "serious" applications?
- as I mentioned, nothing I am trying to do in the program at the point of
error seems to help (except sleeping for a couple of minutes) - MySQL seems
to be simply unreachable for a while, busy dealing with memory leaks or
whatever. But for the more normal cases in the future where such an error
could be transient, any good practices (such as closing + re-opening the
connection to the database?
Much obliged,
Patrick
Windows XP. The summary of the problem is this: I am doing a series of
queries (no updates) using the OleDB DataReader, and after a few thousands
queries, the SQL server seems to be clogged and starts failing all requests.
Then, after a minute or two, things return to normal. It is as if my series
of queries exhausted a resource on the server which time heals.
I am a newcomer to OleDB and SQL so it is possible that I am misusing the
OleDB .NET objects. Or am I expecting too much from MySQL? Details below.
After successfully running a few thousands queries of the type:
OleDbCommand catCMD = DatabaseConnection.CreateCommand();
catCMD.CommandText = SELECT t1.mysum FROM (SELECT SUM(negative) AS mysum
FROM myTable WHERE time >='2003-08-22 16:00:00') AS t1;
myReader = catCMD.ExecuteReader();
at some point, the ExecuteReader command stops working, with no specific
error:
System.Data.OleDb.OleDbException: No error information available:
E_FAIL(0x80004005).
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.ExecuteReader()
Note that I am always closing any DataReader I am using, but leaving the
OleDBConnection open (and sometimes also reuse the OleDbCommand object on
it).
The first error materializes at random times (but always after a fair number
of queries, maybe 10,000). When that first error happens, most subsequent
queries fail as well, including attempts to re-open the connection to the
database. Even a completely different application talking directly to the
server, such as the mysql utility, stops working (fails to connect to the
database).
Then, usually, waiting a few minutes helps and things get back to normal.
I went so far as inserting a 5 minutes delay in my code any time I would get
an error ... and it completely solves the problem (although hardly a
real-life solution)!
I would appreciate feedback on:
- is this likely to be a problem with my code? I mean, should ANYTHING I do
in my code cause a separate application like mysql.exe to fail?
- is it a MySQL 4.1 Gamma robustness issue? Should I stay away from MySQL
for "serious" applications?
- as I mentioned, nothing I am trying to do in the program at the point of
error seems to help (except sleeping for a couple of minutes) - MySQL seems
to be simply unreachable for a while, busy dealing with memory leaks or
whatever. But for the more normal cases in the future where such an error
could be transient, any good practices (such as closing + re-opening the
connection to the database?
Much obliged,
Patrick