Reputation: 123
I've built a C# application that updates a MySQL db table every 10 ms. The app creates a separate thread for each update. Using Workbench, I can see that there are many connections and for a while, this has been quite successful. Recently though, I find that after 2-3 hours of successful execution I am getting an exception which says "Table xxxx not found". I have both a read and an update using Entity Framework, as follows
try
{
u5s = (from u in cxt.universe5s
where u.CATEGORY == tval
select u).ToList();
. . .
u5.PC_CHANGE = chval;
cxt.SaveChanges();
}
catch (Exception myEx)
{
//throws my 'table not found' exception here
}
Using NET 4.0 and MySql 5.5.9. Does anyone else have an experience like this? Could it be caused by running out of connections? What is the best practice in this case as far as closing the connection after saving changes?
Sincerely Richard
Upvotes: 0
Views: 355
Reputation: 2380
This sounds like a concurrency issue. You might try to lock on a single connection object. That would also reduce the stress on the server.
See http://msdn.microsoft.com/en-us/library/c5kehkcz%28v=vs.80%29.aspx for details.
Hope this helps.
Upvotes: 1