[hunchentoot-devel] Strange race condition?

Edi Weitz edi at agharta.de
Mon Aug 20 16:59:26 UTC 2007


On Sat, 18 Aug 2007 09:17:07 +0200, John Thingstad <john.thingstad at chello.no> wrote:

> I have just written a blog program.  Functionally it is complete,
> but it contains a big and serious flaw.  At intermittent intervals
> it gives a error like:
>
> [2007-08-18 09:05:58 [ERROR]] While accessing database
> #<CLSQL-MYSQL:MYSQL-DATAB
> ASE localhost/blog/jthing OPEN 219A8C6F>
>    with expression "SELECT * FROM BLOG_ITEMS WHERE (ID = 224)":
>    Error 2006 / MySQL server has gone away
>    has occurred.
>
> It seems like a clsql error.. So why am I reporting it to here?
>
> Well the first thing to do is to isolate what is causing the error.
> After eliminating that the error was in my code (which included a
> rewrite) I found it down to the following lines:
>
>      (with-html-output-to-string
>          (*standard-output* nil :prologue t :indent t)
>        (:html :xmlns "http://www.w3.org/1999/xhtml"
>         (:head
>          (:title (fmt "~A - ~A"
>                       (escape-string (getf blog :title))
>                       (escape-string (getf item :title))))
>          (:link :href *blog-css-file*
>           :rel "stylesheet" :type "text/css")
>          (:link :href *tree-css-file*
>           :rel "stylesheet" :type "text/css"
>           :media "screen, projection")
>          (:script :type "text/javascript" :src *tree-js-file* "")
>          (:script :type "text/javascript"
>           (fmt "~%addLoadListener( function() { treeMenu('~A', '~A'); });"
>                "navigation"
>                (format nil "~A?id=~D"
>                        (script-name)
>                        item-id))))
>
> So it should be reported to cl-who right. Wrong!  The problem isn't
> in the code that is generated.  It appers to be the fact that I am
> including 2 css files and a javascript file.  It is the UPLOAD of
> these from the client and the inerruption of the thread that causes
> the problem.  Has anyone here experienced anything simular?

FWIW, I don't understand from your description what exactly happens
and where you think the problems comes from.  I don't even see how the
code snippet above is related to MySQL and what the client /uploads/
to the server.

I have only one wild guess (as you're talking about thread
interruption): If you've wrapped all of your handlers with a function
or macro that connects to the database and if they all try to connect
using the /same/ connection, then this is probably the cause.  Maybe
connection pooling will help.



More information about the Tbnl-devel mailing list