[elephant-devel] Sqlite-3 backend, threads and transactions
Ignas Mikalajunas
ignas.mikalajunas at gmail.com
Wed Apr 19 22:06:12 UTC 2006
On 4/19/06, Robert L. Read <read at robertlread.net> wrote:
>
> I am a little surprised by your use of clsql:start-transaction; the
> normal idiom for
> this is:
>
> (with-transaction (:store-controller *store-controller*)
> (loop for obj in objs
> for key in keys
> do (setf (get-value key bt) obj))))
> (this is an example for testcollections.lisp)
>
> Are you saying in your email that you could not use this way of doing
> things? The
> with-transaction macro should be indpendent of the type of the
> store-controller.
>
And indeed it is independent, but calls to ele:start-transaction,
ele:commit-transaction and ele:abort-transaction are throwing an error for
me and their code seems to be BDB specific. I would like to use
with-transacton, yet it aborts the transaction on "any non-local exit",
while i want to rollback only when some error occurs. TBNL redirect code
does (throw 'tbnl:tbnl-handler-done), aborting transaction on each redirect.
As in web applications (save-data-to-database)
(redirect-to-avoid-double-post) is a very common pattern, i was getting my
data reverted every time. So i am doing manual commits/rollbacks, depending
on whether the request processing code raised an error or not.
You wrote:
> As sqlite requires each thread to have it's own connection by throwing
> an error if one thread tries to reuse a connection created by another
> thread at least on Ubuntu Dapper. Google says that it depends on a
> compile time flag for libsqlite3.
>
> The current Elephant code has no notion of this, and I'm pretty sure it
> will hand the same connection
> to several threads. Obviously, you could solve this problem by using
> mutexes to make sure that
> only one thread accesses the controller, but that might be quite
> unpleasant for you code.
>
At the moment i am doing exactly this - making sure that only one thread is
working with elephant at the same time, though it is more of a workaround
than a solution.
If these comments can help you provide anymore information about what your
> possible solutions
> are, please reply so I can think about it before I begin debugging it
> tonight or tomorrow.
>
You can find more info about the issue with sqlite here:
http://projects.edgewall.com/trac/ticket/2196
hope that helps.
--
Ignas Mikalajūnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20060420/d1bd5d84/attachment.html>
More information about the elephant-devel
mailing list