fukamachi / anypool

General-purpose connection pooling library for Common Lisp
BSD 2-Clause "Simplified" License
25 stars 3 forks source link

Failure with queue-underflow-error condition. #4

Open gos-k opened 1 year ago

gos-k commented 1 year ago

I modified idle-timeout unittest to many time fetch and putback. And I executed unittest using make command.

diff --git a/tests/main.lisp b/tests/main.lisp
index bdc7962..00c4a83 100644
--- a/tests/main.lisp
+++ b/tests/main.lisp
@@ -120,7 +120,7 @@
                         collect (bt:make-thread
                                  (lambda ()
                                    (loop
-                                     repeat 1000
+                                     repeat 1000000
                                      do (let ((object (fetch pool)))
                                           (putback object pool))))))))
     (dolist (thread threads)

It failed with cl-speedy-queue:queue-underflow-error every time.

Unhandled CL-SPEEDY-QUEUE::QUEUE-UNDERFLOW-ERROR in thread #<SB-THREAD:THREAD tid=32 "Anonymous thread" RUNNING
                                                              {1002572553}>:
  Queue #(8 8
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC03B3}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC0553}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC06F3}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC0893}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC0A33}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 2004227
             :IDLE-TIMER #<TIMER {1001BD8213}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #:EMPTY
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BC8073}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 2004227
             :IDLE-TIMER #<TIMER {1001BC8213}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 13969607
             :IDLE-TIMER #<TIMER {1001B380D3}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 2004227
             :IDLE-TIMER #<TIMER {1001B38273}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 27111155
             :IDLE-TIMER #<TIMER {1001BD0073}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 2004227
             :IDLE-TIMER #<TIMER {1001BD0213}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 6340723
             :IDLE-TIMER #<TIMER {1001BD8073}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 31615694
             :IDLE-TIMER #<TIMER {1001BE0073}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 6340723
             :IDLE-TIMER #<TIMER {1001BE0213}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BE8073}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 34192003
             :IDLE-TIMER #<TIMER {1001BF0073}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 28075270
             :IDLE-TIMER #<TIMER {1001BF0213}>
             :ACTIVE-P T
             :TIMEOUT-P NIL)
          #S(ANYPOOL::ITEM
             :OBJECT 31615694
             :IDLE-TIMER #<TIMER {1001BC0213}>
             :ACTIVE-P NIL
             :TIMEOUT-P NIL)) is empty, and can't be dequeued anymore

Backtrace for: #<SB-THREAD:THREAD tid=32 "Anonymous thread" RUNNING {1002572553}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<CL-SPEEDY-QUEUE::QUEUE-UNDERFLOW-ERROR {1001BA8663}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<CL-SPEEDY-QUEUE::QUEUE-UNDERFLOW-ERROR {1001BA8663}>)
2: (INVOKE-DEBUGGER #<CL-SPEEDY-QUEUE::QUEUE-UNDERFLOW-ERROR {1001BA8663}>)
3: (ERROR CL-SPEEDY-QUEUE::QUEUE-UNDERFLOW-ERROR :QUEUE #(8 8 #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC03B3}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0553}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC06F3}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0893}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0A33}> :ACTIVE-P NIL :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 2004227 :IDLE-TIMER #<TIMER {1001BD8213}> :ACTIVE-P T :TIMEOUT-P NIL) #:EMPTY #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC8073}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 2004227 :IDLE-TIMER #<TIMER {1001BC8213}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 13969607 :IDLE-TIMER #<TIMER {1001B380D3}> :ACTIVE-P NIL :TIMEOUT-P NIL) ...))
4: (CL-SPEEDY-QUEUE:DEQUEUE #(8 8 #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC03B3}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0553}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC06F3}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0893}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC0A33}> :ACTIVE-P NIL :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 2004227 :IDLE-TIMER #<TIMER {1001BD8213}> :ACTIVE-P T :TIMEOUT-P NIL) #:EMPTY #S(ANYPOOL::ITEM :OBJECT 28075270 :IDLE-TIMER #<TIMER {1001BC8073}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 2004227 :IDLE-TIMER #<TIMER {1001BC8213}> :ACTIVE-P T :TIMEOUT-P NIL) #S(ANYPOOL::ITEM :OBJECT 13969607 :IDLE-TIMER #<TIMER {1001B380D3}> :ACTIVE-P NIL :TIMEOUT-P NIL) ...))
5: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN ANYPOOL:FETCH))
6: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-THREAD::CALL-WITH-MUTEX))
7: (SB-THREAD::CALL-WITH-MUTEX #<FUNCTION (FLET SB-THREAD::WITH-MUTEX-THUNK :IN ANYPOOL:FETCH) {7F91337765FB}> #<SB-THREAD:MUTEX "ANYPOOL-LOCK" contested owner=Anonymous thread> T NIL)
8: (ANYPOOL:FETCH #<ANYPOOL:POOL "test pool" (OPEN=2 / IDLE=-2) {1002571B03}>)
9: ((LAMBDA NIL :IN "/app/tests/main.lisp"))
10: ((LABELS BORDEAUX-THREADS::%BINDING-DEFAULT-SPECIALS-WRAPPER :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
11: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
12: ((FLET "WITHOUT-INTERRUPTS-BODY-156" :IN SB-THREAD::RUN))
13: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
14: ((FLET "WITHOUT-INTERRUPTS-BODY-149" :IN SB-THREAD::RUN))
15: (SB-THREAD::RUN)
16: ("foreign function: call_into_lisp_")
17: ("foreign function: funcall1")

unhandled condition in --disable-debugger mode, quitting