fukamachi / cl-dbi

Database independent interface for Common Lisp
205 stars 28 forks source link

Non thread safe connect-cached #46

Closed svetlyak40wt closed 5 years ago

svetlyak40wt commented 5 years ago

Seems that cleanup-connection-pool should acquire a lock on a hashtable, but it didn't.

I've just catched such error:

  Traceback (most recent call last):
    File "NIL", line NIL, in SIGNAL-CO…
      (SB-IMPL::SIGNAL-CORRUPT-HASH-TABLE
       #<HASH-TABLE :TEST EQ :COUNT 15 {10021904E3}>)
    File "NIL", line NIL, in (FLET BOD…
      ((FLET "BODY-FUN-0" :IN REMHASH))
    File "NIL", line NIL, in REMHASH
      (REMHASH
       #<SB-THREAD:THREAD "Anonymous thread" FINISHED values: NIL {1007AEFF63}>
       #<HASH-TABLE :TEST EQ :COUNT 15 {10021904E3}>)
    File "/app/quicklisp/dists/quicklisp/software/cl-dbi-20190202-git/src/dbi.lisp", line 115, in CLEANUP-C…
      (DBI::CLEANUP-CONNECTION-POOL)
    File "/app/quicklisp/dists/quicklisp/software/cl-dbi-20190202-git/src/dbi.lisp", line 98, in CONNECT-C…
      (DBI:CONNECT-CACHED :POSTGRES :HOST "postgres" :DATABASE-NAME "ultralisp"
                          :USERNAME "ultralisp" :PASSWORD "ultralisp")
    File "/app/src/db.lisp", line 44, in CONNECT
      (ULTRALISP/DB::CONNECT :HOST NIL :DATABASE-NAME NIL :USERNAME NIL :PASSWORD
                             NIL :CACHED T)
    File "/app/src/cron.lisp", line 64, in PERFORM-C…
      (ULTRALISP/CRON::PERFORM-CHECKS)
    File "/app/quicklisp/dists/quicklisp/software/bordeaux-threads-v0.8.6/src/bordeaux-threads.lisp", line NIL, in (LAMBDA (…
      ((LAMBDA () :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
    File "NIL", line NIL, in (FLET BOD…
      ((FLET SB-UNIX::BODY :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
    File "NIL", line NIL, in (FLET WIT…
      ((FLET "WITHOUT-INTERRUPTS-BODY-4" :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))

  Condition: Corrupt NEXT-chain in #<HASH-TABLE :TEST EQ :COUNT 15 {10021904E3}>. This is probably caused by multiple threads accessing the same hash-table without locking.