Disconnections/Net Packets Out Of Order

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
anton.connect
Posts: 43
Joined: Thu 19 Jun 2008 14:30

Post by anton.connect » Thu 26 Jun 2008 11:22

The method ClearAllPools() doesn't clear the connections pool immediately.
Try to set Pooling = false in the connection string.
Tell me if it is helpful for you.

pleb
Posts: 37
Joined: Mon 23 Jun 2008 06:21
Location: Melbourne, Australia

Post by pleb » Thu 26 Jun 2008 23:00

Hi Nick,

If a problem presents itself randomly and the application is threaded, trust me it's a treading issue.

Here what's I've found

You don't lock when counting the queue. Sure you also peek and check for null, but just lock and this step is not needed. The peek step is not threadsafe. One item in the queue. Count step is a pass, peak step passes, or does it. Think about this situation.

One item in the queue

Thread 2 peeks
Thread 1 is blocked, until thread 2 unblocks after peeking,
Thread 1 then deqeues,
Thread 2 then dequeue (going to get null)
Thread 1 sends query (yep I worked)
Thread 2 sends null, (ooops)

logic for your reentrant method.

Setup:

define lock object in a scope both threads can see, such as a field, and set the lock object to a new object.

protected object myLocker = new object();

Method:

lock on myLocker
check queue count
yes, then deqeue
no, then unlock, and return (unlock will be automatic with sync lock in vb... I think)
dequeue item
unlock on myLocker

create new connection (use pooling ;) have some faith)
open connection
send query
close connection
return from method

Regards,

Pleb

NickG
Posts: 12
Joined: Mon 09 Jun 2008 13:54

Post by NickG » Mon 07 Jul 2008 15:05

Okay well i just checked back this but i have found a solution. My solution is to simply set my connection object ot nothing and reinstantiate it. This works and the method has been bulletproof. Although i'd perfer to know WHY i can't simply just re-.open the connection. Thank you for the information on threading i'm going to implement that at some point this week. Thanks for all the help!

Edit - I had the same problem with pooling disabled! so i don't know what exactly is causing me to have to null out the object and recreate it

Post Reply