Debugging COMM:START-UP-SERVER hang
"Adam Weaver (as adam at cleversure dot com dot au)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <SY5P282MB4638F68DCD5DF032F7B2B3BC9C73A@SY5P282MB4638.AUSP282.PROD.OUTLOOK.COM> |
Has anyone got any tips for working out why my DELIVERed app hangs after about a week uptime?
As far as I can tell:
```
(comm:start-up-server :process-name "FCGI" :function #'accept-fcgi-request :service port :reuseport t)
```
stops responding after a week. ish.
strace wasn't particularly helpful:
```
strace -p 31831
strace: Process 31831 attached
restart_syscall(<... resuming interrupted futex ...>) = -1 ETIMEDOUT (Connection timed out)
futex(0x8e827f8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1772158231, tv_nsec=840096000}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
futex(0x8e827f8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, {tv_sec=1772158236, tv_nsec=840336000}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
```
which looked identical to strace output from a newly started binary.
My ACCEPT-FCGI-REQUEST is reasonably benign:
```
(defun accept-fcgi-request (handle)
(handler-bind ((error (lambda (c) (declare (ignore c)) (return-from accept-fcgi-request))))
(process-fcgi-connection (make-instance 'comm:socket-stream :socket handle :direction :io :element-type '(unsigned-byte 8)))))
(defun process-fcgi-connection (connection)
(handler-bind ((error (lambda (c)
(declare (ignore c))
(ignore-errors (close connection) (return-from process-fcgi-connection))))
(fcgi-close-handle (lambda (c)
(declare (ignore c))
(ignore-errors (close connection) (return-from process-fcgi-connection)))))
(loop
(multiple-value-bind (type id buffer) (read-fcgi-record connection)
(handler-bind ((error (lambda (c) (output-fcgi-response nil id connection (princ-to-string c) "text/plain" 503))))
(declare (type fixnum type id) (type (array (unsigned-byte 8)) buffer))
(case* #'eql type
(+fcgi-begin-request+ (fcgi-begin-request id buffer))
(+fcgi-abort-request+ (fcgi-abort-request connection id))
(+fcgi-end-request+ (fcgi-end-request connection id 0 0))
(+fcgi-params+ (fcgi-params id buffer))
(+fcgi-stdin+ (fcgi-stdin connection id buffer))
(+fcgi-data+ (fcgi-data connection id buffer))
(+fcgi-get-values+ (fcgi-get-values connection id buffer))
(t (error "Unknown FCGI type ~S" type))))))))
```
with HANDLER-BINDs around socket read points.
But COMM:START-UP-SERVER spins up a new thread for every ACCEPT (very inefficient I know), so why would
COMM:START-UP-SERVER stop ACCEPTing new requests?
I've never had an issue when running locally (emacs/sly) with literal months of uptime.
Error seems to be in delivered apps only.
A