Hi Jonas,
Jonas Borgström wrote:
> David Abrahams wrote:
>
>> on Sun Jun 01 2008, David Abrahams <dave-AT-boostpro.com> wrote:
>>
>>
>>
>>> on Sun Jun 01 2008, Jonas Borgström <jonas-AT-edgewall.com> wrote:
>>>
>>>
>>>
>>>> Anyway, I've attached my attempt at a process-wide LRU based connection
>>>> pool. It's still a work in progress but it would be very interesting to
>>>> know if and how well it works in your setup.
>>>>
>>>>
>>> I'll try popping it in tonight and we'll see what happens.
>>>
>>>
>> So far it looks good; it even fixed the two environments that were
>> broken by my patch, so you must've been onto something :-). Obviously I
>> never understood pool.py as well as I'd have liked. Thanks so much for
>> working on this.
>>
>>
> Yeah, it's a bit tricky and I ended up rewriting most of it to make sure
> I understood it all correctly.
>
Right, this was much needed.
>> Are you going to check it in? For me it fixes a *massive* problem that
>> was bringing all of my server's sites down as often as every 12 hrs.
>>
>>
>>
> Yeah I think so, since it fixes a few long standing issues especially
> Trac's bad habit of collecting a large number of databases connections
> and never releasing them.
> So unless someone objects I'm planning to commit this to trunk. It's a
> bit too dangerous to backport this to 0.11-stable this late in the game.
> But if it works well in trunk I think it would be a good candidate for
> 0.11.1.
>
> (I've attached an updated version with some cosmetic changes)
>
I've tested it, and found a bug by which the _available lock could be
released more than once (patch attached).
Once patched, tracd on Windows with Pysqlite 2.4.1 seems to work fine,
though more likely to trigger the timeout error:
- when I attempt three dozen concurrent requests on 2 environments
served by the same tracd, I trigger approx. 6-7 timeouts (only 1 with
the old pool)
- with 2 concurrent tracd processes, each serving 2 environments and a
dozen concurrent requests on each 4 targets, I trigger approximately 10
TimeoutError (only 1 with the old pool)
I have yet to study the new code in more details, but I already saw that
the thread affinity optimization for the dormant connections is gone, so
that might explain the difference.
Also, I'll do some more testing with other setups.
-- Christian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
diff --git a/trac/db/pool.py b/trac/db/pool.py
--- a/trac/db/pool.py
+++ b/trac/db/pool.py
@@ -82,8 +82,8 @@
start = time.time()
tid = threading._get_ident()
self._available.acquire()
- while True:
- try:
+ try:
+ while True:
# First choice: Return the same cnx already used by the thread
if (tid, key) in self._active:
cnx, num = self._active[(tid, key)]
@@ -116,8 +116,8 @@
self._available.wait(timeout)
else:
self._available.wait()
- finally:
- self._available.release()
+ finally:
+ self._available.release()
def _return_cnx(self, cnx, key, tid):
self._available.acquire()