[elephant-devel] Dropping DB connection during writes
Tayssir John Gabbour
tjg at pentaside.org
Thu Nov 20 16:16:17 UTC 2008
Hi!
With Elephant under both Postmodern and CLSQL, I'm consistently losing
my DB connection. This apparently happens when writing from fairly
simultaneous threads. (Two threads may write to the same btree key at
around the same time.)
All I do is add objects to a BTree, keyed by their UUID. (And there's
two simple indexes.) No persistent metaclasses or anything; I just use
it as a persistent table.
Am I doing something terribly wrong? Code and error messages at the
end of this email.
All the best,
Tayssir
;;; How I add stuff to the DB
(defmethod save-to-db (thing)
(with-city-store
(setf (get-value (moderator-ontology:uuid thing) (my-btree))
thing)))
(defmacro with-city-store (&body body)
`(if *store-controller*
(progn , at body)
(with-open-store (citycouncil-config:*citycouncil-store-spec*)
;; removing with-transaction doesn't have much effect
(with-transaction ()
, at body))))
(defun create-indexes (&key (btree (my-btree)))
(with-city-store
(add-index btree
:index-name *semantic-type-index-name*
:key-form '(lambda (secondary-db primary-key value)
(declare (ignore secondary-db primary-key))
(values t (type->storage-location value))))
(add-index btree
:populate t
:index-name *owner-index-name*
:key-form '(lambda (secondary-db primary-key value)
(declare (ignore secondary-db primary-key))
(if (typep value 'moderator-ontology:icon)
(values t (moderator-ontology:owner value))
(values nil nil))))))
;;; CLSQL messages
Condition CONTROLLER-LOST-ERROR was signalled.
[Condition of type CONTROLLER-LOST-ERROR]
Restarts:
0: [CONTINUE] Open a new instance and continue?
1: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"hunchentoot-worker-204" RUNNING {B90AFB9}>)
Backtrace:
0: ((SB-PCL::FAST-METHOD ELEPHANT::GET-CON (PERSISTENT)) #<unused
argument> #<unused argument> #<SQL-BTREE oid:0> #<unused argument>)
Locals:
ELEPHANT::INSTANCE = #<SQL-BTREE oid:0>
1: ((SB-PCL::FAST-METHOD GET-VALUE (T DB-CLSQL::SQL-BTREE))
#<unavailable argument> #<unavailable argument> :STORE-2008-06-24
#<SQL-BTREE oid:0>)
Locals:
SB-DEBUG::ARG-0 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-2 = :STORE-2008-06-24
SB-DEBUG::ARG-3 = #<SQL-BTREE oid:0>
2: ((LAMBDA ()))
[No Locals]
3: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-CLSQL::SQL-STORE-CONTROLLER T)) ..)[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 8
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-2 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-3 = #<SQL-STORE-CONTROLLER (POSTGRESQL localhost
elephant_test #1=griffie #1# ...
SB-DEBUG::ARG-4 = #<CLOSURE (LAMBDA ()) {AA2988D}>
There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION DB-CLSQL::CONTROLLER-DB (1)>
when called with arguments
(NIL).
[Condition of type SIMPLE-ERROR]
Restarts:
0: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"hunchentoot-worker-204" RUNNING {B90AFB9}>)
Backtrace:
0: ((LAMBDA (SWANK-BACKEND::DEBUGGER-LOOP-FN)) #<FUNCTION (LAMBDA #)
{ADF2D6D}>)
Locals:
SB-KERNEL:*HANDLER-CLUSTERS* = :<NOT-AVAILABLE>
SWANK-BACKEND::*SLDB-STACK-TOP* = :<NOT-AVAILABLE>
SWANK-BACKEND::DEBUGGER-LOOP-FN = #<FUNCTION (LAMBDA ()) {ADF2D6D}>
1: (SWANK::DEBUG-IN-EMACS #<SIMPLE-ERROR {B368FA9}>)
2: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION
SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {B369205}>)
3: (SWANK::CALL-WITH-REDIRECTED-IO #<SWANK::CONNECTION {B23A3D9}>
#<CLOSURE (LAMBDA #) {B369215}>)
4: (SWANK::CALL-WITH-CONNECTION #<SWANK::CONNECTION {B23A3D9}>
#<CLOSURE (LAMBDA #) {B369205}>)
5: (SWANK:INVOKE-SLIME-DEBUGGER #<SIMPLE-ERROR {B368FA9}>)
6: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION
SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {B3691E5}>)
7: (INVOKE-DEBUGGER #<SIMPLE-ERROR {B368FA9}>)
8: (INVOKE-DEBUGGER #<SIMPLE-ERROR {B368FA9}>)[:EXTERNAL]
9: ((SB-PCL::FAST-METHOD HUNCHENTOOT:MAYBE-INVOKE-DEBUGGER (T))
#<unavailable argument> #<unavailable argument> #<SIMPLE-ERROR
{B368FA9}>)
10: (SIGNAL #<SIMPLE-ERROR {B368FA9}>)[:EXTERNAL]
11: (ERROR "~@<There is no applicable method for the generic function
~2I~_~S~\n ~I~_when called with arguments
~2I~_~S.~:>")[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 3
SB-DEBUG::ARG-1 = "~@<There is no applicable method for the
generic function ~2I~_~S~\n ..
12: ((SB-PCL::FAST-METHOD NO-APPLICABLE-METHOD (T)) #<unavailable
argument> #<unavailable argument> #<STANDARD-GENERIC-FUNCTION
DB-CLSQL::CONTROLLER-$ 13: (DB-CLSQL::SQL-GET-FROM-CLCN-NTH 0
:STORE-2008-06-24 NIL 0)
14: ((LAMBDA ()))
15: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-CLSQL::SQL-STORE-CONTROLLER T)) ..)[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 8
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-2 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-3 = #<SQL-STORE-CONTROLLER (POSTGRESQL localhost
elephant_test #1=griffie #1# ...
SB-DEBUG::ARG-4 = #<CLOSURE (LAMBDA ()) {AA2988D}>
16: ((SB-PCL::FAST-METHOD LOCATE-ICON-BY-OWNER (STRING))
#<unavailable argument> #<unavailable argument>
"bc3c7276-3a80-0780-23e1-40c33cd1b238")
;;; Postmodern messages
Database error: #<SB-SYS:FD-STREAM for "a socket" {BCC6AB1}> is closed
[Condition of type CL-POSTGRES:DATABASE-SOCKET-ERROR]
Restarts:
0: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"artificial-thread" RUNNING {BCA96B9}>)
Backtrace:
0: ((LAMBDA ()))
1: (DB-POSTMODERN::POSTGRES-FORMAT #<MODERATOR-ONTOLOGY:MEETING
{BC9EED1}> :OBJECT)
2: ((LAMBDA ()))
3: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
4: ((SB-PCL::FAST-METHOD (SETF DB-POSTMODERN::INTERNAL-GET-VALUE) (T
T DB-POSTMODERN::PM-BTREE)) ..)
5: ((SB-PCL::FAST-METHOD (SETF GET-VALUE) (T T
DB-POSTMODERN::PM-INDEXED-BTREE)) ..)
6: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
7: ((SB-PCL::FAST-METHOD ADD (MODERATOR-ONTOLOGY:UUID-MIXIN))
#<unavailable argument> #<unavailable argument>
#<MODERATOR-ONTOLOGY:MEETING {BC9EED1}>)
(#<SB-IMPL::HANDLER INPUT on BOGUS descriptor 10: #<CLOSURE #
{BB053AD}>>) has a bad file descriptor.
[Condition of type SIMPLE-ERROR]
Restarts:
0: [REMOVE-THEM] Remove bogus handlers.
1: [RETRY-THEM] Retry bogus handlers.
2: [CONTINUE] Go on, leaving handlers marked as bogus.
3: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"artificial-thread" RUNNING {B9E68D9}>)
Backtrace:
0: (SB-IMPL::HANDLER-DESCRIPTORS-ERROR)
1: (SB-IMPL::SUB-SUB-SERVE-EVENT NIL NIL)
2: (SB-IMPL::SUB-SERVE-EVENT NIL NIL NIL)
3: (SB-SYS:WAIT-UNTIL-FD-USABLE 10 :INPUT NIL)
4: (SB-IMPL::REFILL-INPUT-BUFFER #<SB-SYS:FD-STREAM for "a socket" {B9F8AA1}>)
5: (SB-IMPL::INPUT-UNSIGNED-8BIT-BYTE #<SB-SYS:FD-STREAM for "a
socket" {B9F8AA1}> T NIL)
6: (CL-POSTGRES::READ-UINT1 #<unavailable argument>)
7: (CL-POSTGRES::SEND-EXECUTE #<SB-SYS:FD-STREAM for "a socket"
{B9F8AA1}> #<unavailable argument> #<unavailable argument>
#<unavailable argument>)
8: ((LABELS #:G303))
9: ((LAMBDA ()))
10: (DB-POSTMODERN::POSTGRES-FORMAT #<MODERATOR-ONTOLOGY:MEETING
{B9D1459}> :OBJECT)
11: ((LAMBDA ()))
12: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
13: ((SB-PCL::FAST-METHOD (SETF DB-POSTMODERN::INTERNAL-GET-VALUE) (T
T DB-POSTMODERN::PM-BTREE)) ..)
14: ((SB-PCL::FAST-METHOD (SETF GET-VALUE) (T T
DB-POSTMODERN::PM-INDEXED-BTREE)) ..)
15: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
16: ((SB-PCL::FAST-METHOD ADD (MODERATOR-ONTOLOGY:UUID-MIXIN))
#<unavailable argument> #<unavailable argument>
#<MODERATOR-ONTOLOGY:MEETING {B9D1459}>)
Database error: Connection to database server lost.
[Condition of type CL-POSTGRES:DATABASE-CONNECTION-LOST]
Restarts:
0: [RECONNECT] Try to reconnect.
1: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"artificial-thread" RUNNING {ACBD271}>)
Backtrace:
0: (CL-POSTGRES::ENSURE-CONNECTION #<CL-POSTGRES:DATABASE-CONNECTION
{AD297E9}>)
1: (CL-POSTGRES:EXEC-QUERY #<CL-POSTGRES:DATABASE-CONNECTION
{AD297E9}> #<unavailable argument> CL-POSTGRES:IGNORE-ROW-READER)
2: (POSTMODERN:ABORT-TRANSACTION #<POSTMODERN::TRANSACTION-HANDLE {B221ED9}>)
3: ((SB-PCL::FAST-METHOD CONTROLLER-ABORT-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
4: ((FLET #:CLEANUP-FUN-[EXECUTE-TRANSACTION]23))[:CLEANUP]
5: ((SB-PCL::FAST-METHOD ELEPHANT::EXECUTE-TRANSACTION
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER T)) ..)[:EXTERNAL]
6: ((SB-PCL::FAST-METHOD ADD (MODERATOR-ONTOLOGY:UUID-MIXIN))
#<unavailable argument> #<unavailable argument>
#<MODERATOR-ONTOLOGY:MEETING {ACB0121}>)
7: ((FLET SB-THREAD::WITH-MUTEX-THUNK))
Condition CONTROLLER-LOST-ERROR was signalled.
[Condition of type CONTROLLER-LOST-ERROR]
Restarts:
0: [CONTINUE] Open a new instance and continue?
1: [TERMINATE-THREAD] Terminate this thread (#<THREAD
"artificial-thread" RUNNING {B7F38D9}>)
Backtrace:
0: ((SB-PCL::FAST-METHOD ELEPHANT::GET-CON (PERSISTENT)) #<error
printing object>)
1: (ELEPHANT::INITIALIZE-PERSISTENT-SLOTS #<unavailable argument>
#<unavailable argument> #<unavailable argument> #<unavailable
argument> #<unavailabl$ 2: ((SB-PCL::FAST-METHOD SHARED-INITIALIZE
:AROUND (PERSISTENT-OBJECT T)) #<unavailable argument> #<unavailable
argument> #<unavailable argument> #<un$ 3: ((LAMBDA (SB-PCL::.PV.
SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-INT:&MORE
SB-PCL::.DFUN-MORE-CONTEXT. SB-PCL::.DFUN-MORE-COUNT.)) #<error print$
4: ((SB-PCL::FAST-METHOD MAKE-INSTANCE (CLASS)) #<unavailable
argument> #<unavailable argument> #<PERSISTENT-METACLASS
DB-POSTMODERN::PM-INDEXED-BTREE$ 5: ((FLET DB-POSTMODERN::INIT-ROOT))
6: ((SB-PCL::FAST-METHOD ELEPHANT::OPEN-CONTROLLER
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER)) ..)[:EXTERNAL]
7: ((SB-PCL::FAST-METHOD ELEPHANT::OPEN-CONTROLLER :AROUND
(DB-POSTMODERN::POSTMODERN-STORE-CONTROLLER)) ..)[:EXTERNAL]
8: (OPEN-STORE (:POSTMODERN (:POSTGRESQL "localhost" #1="griffie"
#1# #1# :PORT ...)))[:EXTERNAL]
9: ((SB-PCL::FAST-METHOD ADD (MODERATOR-ONTOLOGY:UUID-MIXIN))
#<unavailable argument> #<unavailable argument>
#<MODERATOR-ONTOLOGY:MEETING {B7E6EB1}>)
More information about the elephant-devel
mailing list