[hunchentoot-devel] Handling Lisp errors.

Edi Weitz edi at agharta.de
Mon Apr 16 06:29:19 UTC 2007


On Sun, 15 Apr 2007 19:03:15 -0500, "Victor Kryukov" <victor.kryukov at gmail.com> wrote:

> The second question is: how do you use CLSQL thread-safely with
> Hunchentoot / SBCL? SBCL don't provide thread properties, so my
> first solution[1] was to create a hash-table and to assign each
> thread a connection, to check from every thread whether it already
> has a connection, and then to clean that hash-table periodically,
> closing connections for dead threads. That worked pretty well, but I
> was afraid of exhausting limit of database threads somehow, so I
> switched to the second solution.
>
> The second solution[2] is to open new connection every time I need
> to save something to database or read something from it, and to
> close it right after that. That of course solves connection limit
> problem (unless I have very many users simultaneously, which is not
> expected in the near term), however it's much slower.
>
> Anybody can share his/her strategy?

I'd use [2] but with pooled connections.  See the :POOL keyword
argument to CONNECT in CLSQL.  That should get rid of your performance
problems.

>  (let ((old-select (symbol-function 'clsql:select)))

That technique will break if you recompile the file the code is in.
I'd propose to do this (shadow the original SELECT with your own
function) with packages.



More information about the Tbnl-devel mailing list