fukamachi / caveman

Lightweight web application framework for Common Lisp.
http://8arrow.org/caveman/
775 stars 63 forks source link

SQL connections kept open #99

Open uint opened 6 years ago

uint commented 6 years ago

It looks like SQL connections are kept open when using a dbi-store for session data storage. This might be related to #98, maybe?

Steps to reproduce:

  1. Set up a MySQL server.
  2. Follow the instructions in the Using session section of README.markdown.
  3. Create a sessions table in your DB. Otherwise you'll get an error about it. This worked for me:
    CL-USER> (datafly.db:connect-toplevel :mysql :database-name "test" :username "root" :password "bleh")
    #<DBD.MYSQL:<DBD-MYSQL-CONNECTION> {1004C22513}>
    CL-USER> (datafly.db:execute (sxql:create-table :sessions ((id :type '(:int 20) :primary-key t :unique t) (session_data :type '(:varchar 2048) :not-null nil :default nil))))
    ; No value
    CL-USER> (datafly.db:disconnect-toplevel)
    NIL
  4. Start your server.
  5. Open any served page in your browser ~75 times, which is probably the default for allowed connections in MySQL.

After that, every following request is met with:

MySQL error: "Too many connections" (errno = 1040).
   [Condition of type COM.HACKINGHAT.CL-MYSQL-SYSTEM:MYSQL-ERROR]