Bug #34001 | Connection pooling has too much unnecessary contention | ||
---|---|---|---|
Submitted: | 23 Jan 2008 1:56 | Modified: | 17 Nov 2008 23:36 |
Reporter: | Maxim Mass | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S5 (Performance) |
Version: | 5.1.4 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[23 Jan 2008 1:56]
Maxim Mass
[23 Jan 2008 2:06]
Maxim Mass
Note that pinging is removed from this code but could easily be added back in.. From our tests pinging often times doubled the amount of time spent executing a query and we removed it as we didn't see the point of doing it.
[21 Apr 2008 8:29]
Tonci Grgin
Maxim, if you agree, I will close this report and add a note to Bug#36194 that it should be checked together with this one.
[21 Apr 2008 19:06]
Maxim Mass
Tonci, that's not a problem for me -- whatever makes it easier to have the issues resolved one way or another. BTW, I idle in #mysql and #mysql-dev on freenode if you'd like to reach me under nick MaxM.
[22 Apr 2008 12:17]
Tonci Grgin
Maxim, I believe this is a part of ongoing work in c/NET 5.2 and will not be back-ported to 5.1 branch. If I'm wrong, Reggie will correct me. I wish I had time for free node, but I don't...
[24 Apr 2008 19:30]
Reggie Burnett
Maxim I this this patch is still a bit buggy. Consider this part: // wait till we are allowed in if (Interlocked.Decrement(ref counter) < 0) { int ticks = (int) settings.ConnectionTimeout * 1000; bool allowed = poolGate.WaitOne(ticks, false); if (!allowed) throw new MySqlException(Resources.TimeoutGettingConnection); } Let's assume you have a pool with 20 connections. Since you are not locking the entire object it is entirely possible that 20 threads could hit this method and execute the decrement before any of them executed the compare. This would cause all the threads to block on poolGate incorrectly. If I am misunderstanding your patch please let me know.
[7 May 2008 13:47]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/46456
[7 May 2008 13:48]
Reggie Burnett
Patch applied in 5.2.2
[16 May 2008 13:10]
MC Brown
A note has been added to the 5.2.2 changelog : There was a high level of contention in the connection pooling code that could lead to delays when opening connections and submitting queries. The connection pooling code has been modified to try and limit the effects of the contention issue.
[13 Nov 2008 0:52]
d di
Maxim, has the bug addressed in comment #[24 Apr 21:30] been resolved or is it still in the committed patch?
[17 Nov 2008 23:36]
Maxim Mass
David, I may be taking Reggie's concern out of context but looking at that code snippet I don't see the issue. Twenty threads hitting the decrement and context switching before the comparison would each get a different counter and the comparison will work regardless. Either way, the patch that Reggie submitted looks sufficiently different but similar in concept that it's likely a non-issue. I'm just glad it's fixed one way or another! :)