On Tue, Oct 20, 2009 at 10:34 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
> David Pollak <feeder.of.the.be...@gmail.com> writes:
>
>> At least the most recent version of Boot.scala has reasonable testing of
>> connection validity:
>>
>>     case x :: xs => try {
>>           x.setAutoCommit(false)
>>           Full(x)
>>         } catch {
>>           case e => try {
>>             pool = xs
>>             poolSize = poolSize - 1
>>             x.close
>>             newConnection(name)
>>           } catch {
>>             case e => newConnection(name)
>>           }
>>         }
>>
>> If the setAutoCommit(false) line fails, the connection is returned to the
>> pool.  You can put other logic here.
>
> Ok, I just made this change and added some logging around new/Release. I
> was a little surprised to see that newConnection is called three times
> for each request. Is this intentional?

Sorry, to keep adding to this thread, but I looked a little more in
the archetype implementation of ConnectionManager, and to me, it seems
like it is broken in several ways and will eventually lead to an OOME:

I think the logic is that pool should contain the list of connections
available for use by a request and not all the connections created?
But it seems like the implementation mix those two views:

First time through, pool is Nil so we match the first case statement,
create a new connection _AND ADD IT TO POOL_. First error: we return
the connection (ie it is in use) but still add it to the list of free
connections. Another request coming in while we process this request,
will get the same connection.

When releasing the connection, we add the released connection to the pool. Fine.

Next time, pool is not Nil so we match the x::xs case and return x.
Second error: we don't update pool to xs, x is still available for any
request coming in while we're using this connection.

And since connections are never removed from pool under normal
circumstances but always added on release, the pool list just keeps
growing.....

I'll post an updated version soon....

 /Jeppe

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to