From: Brett v. de S. <bv...@as...> - 2010-03-24 17:51:46
|
[I also posted this to the clsql mailing list.] I find that sb-ext:timout no longer works after connecting to a database using clsql. If I run the following test case, the first with-timeout works fine, while the one following the clsql:connect fails. Timeouts remain broken, even after disconnecting the database. (asdf:operate 'asdf:load-op 'clsql) (handler-case (sb-ext:with-timeout 1 (sleep 2) (format t "interrupt failed~%")) (sb-ext:timeout (c) (format t "interrupted ~A~%" c))) (setf clsql:*default-database* (clsql:connect (list nil "andes_test" "root" "sin(0)=0") :database-type :mysql :pool t :if-exists nil :make-default nil)) (handler-case (sb-ext:with-timeout 1 (sleep 2) (format t "interrupt failed~%")) (sb-ext:timeout (c) (format t "interrupted ~A~%" c))) (clsql:disconnect) I am using clsql-4.3.0 with on a linux machine. I also see the same behavior in OS X. en4052595> sbcl --version SBCL 1.0.36.31 en4052595> uname -a Linux en4052595 2.6.18-164.9.1.el5PAE #1 SMP Tue Dec 15 21:41:47 EST 2009 i686 i686 i386 GNU/Linux |
From: Nikodemus S. <nik...@ra...> - 2010-03-24 17:56:31
|
On 24 March 2010 19:51, Brett van de Sande <bv...@as...> wrote: > I find that sb-ext:timout no longer works after connecting to a > database using clsql. If I run the following test case, the > first with-timeout works fine, while the one following the > clsql:connect fails. Timeouts remain broken, even after > disconnecting the database. I'm guessing that some foreign library used by CLSQL installs its own signal handler for SIGALRM and doesn't reinstall ours when it is done. Cheers, -- Nikodemus |
From: Brett v. de S. <bv...@as...> - 2010-03-24 18:14:17
|
> >I'm guessing that some foreign library used by CLSQL installs its own >signal handler for SIGALRM and doesn't reinstall ours when it is done. By "foreign", you mean outside of lisp? Brett |
From: Nikodemus S. <nik...@ra...> - 2010-03-24 18:37:00
|
On 24 March 2010 20:14, Brett van de Sande <bv...@as...> wrote: >>I'm guessing that some foreign library used by CLSQL installs its own >>signal handler for SIGALRM and doesn't reinstall ours when it is done. > > By "foreign", you mean outside of lisp? Yes -- libmysql.so or equivalent in this case, most likely. That said, you might want to try using deadlines instead of timeouts. See SB-SYS:WITH-DEADLINE. Cheers, -- Nikodemus |
From: Brett v. de S. <bv...@as...> - 2010-03-24 21:58:24
|
>>>I'm guessing that some foreign library used by CLSQL installs its own >>>signal handler for SIGALRM and doesn't reinstall ours when it is done. Is there any way that I can save and reinstall the sbcl SIGALRM handler, as a wrapper around the mysql library calls? > >That said, you might want to try using deadlines instead of timeouts. >See SB-SYS:WITH-DEADLINE. It prbabably won't be sufficient, since I am using with-timeout to pick up code errors/hanging, rather than just slowness. |
From: Nikodemus S. <nik...@ra...> - 2010-03-25 06:40:56
|
On 24 March 2010 23:58, Brett van de Sande <bv...@as...> wrote: > It prbabably won't be sufficient, since I am using with-timeout to pick > up code errors/hanging, rather than just slowness. Ok. Just making sure you're cognizant of the risks involved as outlined in the WITH-TIMEOUT docstring. WITH-DEADLINE is able to break hangs from eg. deadlocks, but not hangs from endless loops, etc. Cheers, -- Nikodemus |
From: Brett v. de S. <bv...@as...> - 2010-03-24 22:59:49
|
> >Is there any way that I can save and reinstall the sbcl SIGALRM handler, >as a wrapper around the mysql library calls? Code-wise, the fix looks easy enough: #include <signal.h> struct sigaction old_action; sigaction (SIGALRM, NULL, &old_action); /* ... run mysql stuff */ sigaction (SIGALRM, &old_action, NULL); But it's in the wrong language, so I am at a complete loss as to where to put it. Ideally, one would fix the mysql library, but that looks like a lot of work... Brett |
From: Nikodemus S. <nik...@ra...> - 2010-03-25 06:36:06
|
On 25 March 2010 00:59, Brett van de Sande <bv...@as...> wrote: > But it's in the wrong language, so I am at a complete loss as > to where to put it. Ideally, one would fix the mysql library, > but that looks like a lot of work... (sb-sys::enable-interrupt sb-unix:sigalrm #'sb-unix::sigalrm-handler) Will reinstall SBCL's handler. Cheers, -- Nikodemus |
From: Brett v. de S. <bv...@as...> - 2010-03-26 04:54:07
|
>(sb-sys::enable-interrupt sb-unix:sigalrm #'sb-unix::sigalrm-handler) > >Will reinstall SBCL's handler. It looks like this restores the functionality of with-timeout. In the following code, the second with-timeout still fails: (asdf:operate 'asdf:load-op 'clsql) (handler-case (sb-ext:with-timeout 1 (sleep 2) (format t "interrupt failed~%")) (sb-ext:timeout (c) (format t "interrupted ~A~%" c))) (setf clsql:*default-database* (clsql:connect (list nil "andes_test" "root" "sin(0)=0") :database-type :mysql :pool t :if-exists nil :make-default nil)) (sb-sys::enable-interrupt sb-unix:sigalrm #'sb-unix::sigalrm-handler) (handler-case (sb-ext:with-timeout 1 (sleep 2) (format t "interrupt failed~%")) (sb-ext:timeout (c) (format t "interrupted ~A~%" c))) (clsql:disconnect) |
From: Brett v. de S. <bv...@as...> - 2010-03-26 04:56:35
|
> >It looks like this restores the functionality of with-timeout. Oops, significant typo... It looks like this does *not* restore the functionality of with-timeout. Brett van de Sande |
From: Nikodemus S. <nik...@ra...> - 2010-03-26 07:47:56
|
On 26 March 2010 06:56, Brett van de Sande <bv...@as...> wrote: >>It looks like this restores the functionality of with-timeout. > Oops, significant typo... > It looks like this does *not* restore the functionality of with-timeout. Oops, my bad -- I didn't check and misremembered. The C-level code in SBCL doesn't call sigaction() again if SBCL has earlier installed a low-level handler for the code -- the lisp-level handler is reinstalled, but whatever libmysql has done stays in force. I've logged this as: https://bugs.launchpad.net/sbcl/+bug/548612 In the realm of workarounds... if I may ask, what are you using SBCL/CLSQL/MySQL for? I know that people have generally have had very little trouble using Postgres with SBCL -- via either pg.lisp or Postmodern, so another DB might be one option, depending on your situation. SB-SYS:WITH-DEADLINE remains a more robust alternative to timeouts. Cheers, -- Nikodemus |
From: Brett v. de S. <bv...@as...> - 2010-03-26 20:33:03
|
>In the realm of workarounds... if I may ask, what are you using >SBCL/CLSQL/MySQL for? I know that people have generally have had very >little trouble using Postgres with SBCL -- via either pg.lisp or >Postmodern, so another DB might be one option, depending on your >situation. I think we are stuck with mysql, since that is what our partners use, and we have already build quite a bit of infrastructure on it. The interaction between mysql and the lisp process is pretty simple: we are just dumping log data via the SQL command INSERT. We also do a simple query using SELECT. That said, I am not particularly attached to using clsql, and I am wondering if there is another way to attach to the database. Brett |
From: Stelian I. <sio...@cd...> - 2010-03-26 20:43:02
|
On Fri, 2010-03-26 at 13:32 -0700, Brett van de Sande wrote: > >In the realm of workarounds... if I may ask, what are you using > >SBCL/CLSQL/MySQL for? I know that people have generally have had very > >little trouble using Postgres with SBCL -- via either pg.lisp or > >Postmodern, so another DB might be one option, depending on your > >situation. > > I think we are stuck with mysql, since that is what our partners > use, and we have already build quite a bit of infrastructure on it. > > The interaction between mysql and the lisp process is pretty simple: > we are just dumping log data via the SQL command INSERT. We also do > a simple query using SELECT. That said, I am not particularly attached > to using clsql, and I am wondering if there is another way to attach to > the database. http://paste.lisp.org/display/92632 -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib |
From: Brett v. de S. <bv...@as...> - 2010-04-03 19:15:04
|
>http://paste.lisp.org/display/92632 Thanks a lot! This proved to be a good solution for me. I made the following modifications: 1. I extended the code to work with sbcl, including the case of socket files if no host is given. 2. I implemented the API for old style passwords. The latest version of RedHat uses the old syle mysql passwords, by default. In addition, a database may include passwords encoded in the old format. In that case, mysql reverts back to old syle passwords. You can see the result at: http://github.com/bvds/andes/blob/master/Base/mysql-connect.cl I am not too sure how copyright/licensing works for this. I would like to offer it under the LGPL, but I don't really think I can claim copyright. Brett van de Sande |