Lisp HUG Maillist Archive

Re: portableaserve threads problems (repost)

Hi Martin,
   Thanks so much for responding so quickly.  I implemented your suggestion on Friday morning,  and so far,  so good.  I'll keep you posted on the new uptime statistics.  I've also attached a copy of the aserve file with the change,  in case others can use it.

Lawrence Au
Sauriel LLC

Re: portableaserve threads problems gone

Hi Martin,
    It's been several months,  and we still not seen a single failure due this this bug,  so I consider your fix to be a total success!

thank you,

Lawrence Au
Sauriel LLC.
On Mar 20, 2012, at 10:36 AM, Lawrence Au wrote:

Hi Martin,
   Thanks so much for responding so quickly.  I implemented your suggestion on Friday morning,  and so far,  so good.  I'll keep you posted on the new uptime statistics.  I've also attached a copy of the aserve file with the change,  in case others can use it.

Lawrence Au
Sauriel LLC

<main.cl>




On Mar 16, 2012, at 8:49 AM, Martin Simmons wrote:


Hi Lawrence,

It is a race condition between accept-thread-maybe-activate-worker-thread
setting the mailbox and worker-thread-get-socket-for-connection getting it.
Try changing

(mp:process-run-function name  () 'http-worker-thread)

to

(mp:process-run-function name  '(:mailbox t) 'http-worker-thread)

in the definition of make-worker-thread-internal under
#+aserve-not-using-run-reasons.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/


On Thu, 15 Mar 2012 14:09:50 -0400, Lawrence Au said:

I've been using portableaserve with Lispworks 5.1 on MacOS 10.5.8 for
years without incident,  but three months ago switched to Lispworks
6.0 and have now this problem,  as seen in the server log:

71.163.186.9 - - [Thu, 15 Mar 2012 17:19:14 GMT] "POST /klaggle HTTP/
1.1" 200 -1
71.163.186.9 - - [Thu, 15 Mar 2012 17:19:55 GMT] "POST /klaggle HTTP/
1.1" 200 -1
71.163.186.9 - - [Thu, 15 Mar 2012 17:20:47 GMT] "POST /klaggle HTTP/
1.1" 200 -1
aserve-accept-6: 03/15/12 - 13:20:56 - all threads busy, pause
aserve-accept-6: 03/15/12 - 13:20:57 - all threads busy, pause
aserve-accept-6: 03/15/12 - 13:20:58 - all threads busy, pause
aserve-accept-6: 03/15/12 - 13:20:59 - forced to create new thread
aserve-accept-6: 03/15/12 - 13:20:59 - can't even create new thread,
quitting

The problem is happening more and more frequently,  with MTBF down to
2 days now,  even with sparse server load.  I suspect the problem is
that old threads do not get relinquished after connections are
dropped.  The section of code which produces the errors is main.cl:

(let ((looped 0))
  (loop
    (if* (null workers)
       then (case looped
      (0 nil)
      ((1 2 3) (logmess "all threads busy, pause")
       (sleep 1))

      (4 (logmess "forced to create new thread")
 (make-worker-thread))

      (5 (logmess "can't even create new thread, quitting")
 (return-from http-accept-thread nil)))

    (setq workers (wserver-worker-threads server))
    (incf looped))
    (if* (accept-thread-maybe-activate-worker-thread (car workers)
sock)
       then (atomic-change-wserver-free-workers server nil)
    (return) ; satisfied
    )
    (pop workers)))

Has anyone any suggestions for how to prevent this problem?

Lawrence Au
Sauriel LLC


Updated at: 2020-12-10 08:36 UTC