Closed cmoore closed 12 years ago
Ugh, my code is terrible. The perils of iterative learning, I guess. I swear some of it is nice to read... no, really.
(defmacro @-m (&rest body)
`(with-mongo-connection (:db "liaison")
,@body))
(defmacro @-q (collection query &optional args)
`(@-m (docs (iter (db.find ,collection ,query ,@args)))))
(defmacro w/session (&rest body)
`(progn
(hunchentoot:start-session)
(setf (session-max-time hunchentoot:*session*) (* 60 60 24 265))
,@body))
(defun u/uid ()
(w/session
(session-value :uid)))
(defun has-preference (n)
(let ((the-user-doc (car (@-q "users" ($ "uid" (u/uid))))))
(get-element n the-user-doc)))
When this happens, I get the following in the mongo logs:
Sat Jul 14 22:55:39 [conn63] getMore: cursorid not found liaison.beacon 0
Still poking at things though.
Another interesting thing - from the slime repl:
LIAISON> (mongo-show)
G154877 -> (type-of MONGO) [name : DEFAULT ] {[id : 607A426E-3A2C-4C29-A81A-890F33640FB9] [port : 27017] [host : localhost] [db : liaison]}
G154863 -> (type-of MONGO) [name : G154863 ] {[id : CF1553B3-FB8B-424F-B547-C2C102930063] [port : 27017] [host : localhost] [db : liaison]}
DEFAULT -> (type-of MONGO) [name : DEFAULT ] {[id : 2156EE63-D540-4CA8-9DE5-2DDCDB5D78B6] [port : 27017] [host : localhost] [db : liaison]}
NIL
This was on Clozure 1.8. In SBCL 1.0.55 I can't seem to reproduce it.
mmmm. yes cl-mongo will/should open up a temporary connection when you use with-mongo-connection. So that's what G15.. etc refers to. You should have only one DEFAULT connection though !!
Heh, yea, I kinda figured that. I'm not sure how that happened as I wrap all of my mongo functions with (with-mongo-connection ..)
. Maybe it's a result of having done something wrong in the repl.
I haven't seen anything like this since, so I'm going to close this out.
Not sure if this is a bug, per se, or something I'm doing wrong.
Queries to mongodb are randomly throwing an error. I haven't dug into the source yet, though I plan on it later this afternoon, so I'm not sure of the significance of 10 below
(mongo-reply nil)
. Perhaps it's an incompatibility with the version of mongo I'm using.mongodb 2.0.6 cl-mongo: 20120208 (quicklisp current)
Have you or anyone else ever run into this sort of issue? I'll post the relative code in just a second.