[elephant-devel] a bug when not use elephant:*store-controller* when close-store

Ian Eslick eslick at media.mit.edu
Wed Jul 28 14:05:23 UTC 2010


Probably a global parameter with a more expected default is appropriate.

Multi-store operation is not a commonly supported operating mode, although we've made provisions for it over time.  The current behavior was intended to solve the following problem.

1) System one opens a store and starts using it.
2) A second system opens a store (test at the REPL, etc) and overwrites the global *store-controller* variable.
3) System one starts writing objects into store 2 silently - oops!

I tended to work with a database that powered a website, but also did interactive work with a second database interactively and didn't want that default changed and I found it annoying to constantly get errors when I had error checking in there.

open-store interactions with *store-controller* could have the following variables set by *open-store-policy*

1) :one-only: open-store sets *store-controller* the first time and errors if it is already set
2) :one-only silent: as above, but no error
3) :last-one-wins: silently set the global *store-controller* to the value of the last opened store.

:one-only is the default.  If you are using multiple stores in a system you should use (with-store (spec) ...) to ensure that code uses the proper store.

Ian


On Jul 28, 2010, at 12:36 AM, Alex Mizrahi wrote:

> LPP> the documentation for close-store says:
> 
> LPP>   If you pass a custom store controller,
> LPP>   you are responsible for setting it to NIL.
> 
> What is "it" in this context"? I think it is pretty hard to read this as 
> "you are responsible for setting elephant:*current-controller* to NIL".
> 
> LPP> Do you think this behavior should be changed?
> 
> I think so -- behaviour of open-store/close-store is not symmetric and is 
> pretty ugly. I don't know what is a right fix, though...
> 
> A simple solution would be to set *current-controller* to NIL in close-store 
> if passed custom store matches *current-controller*.
> I think it should work in all cases except when *current-controller* is 
> re-bound, e.g. via with-store.
> 
> Better solution would be to prevent open-store from setting *current-store* 
> at all. E.g. with a parameter:
> 
>        (defparameter *foo* (open-store '(:BDB ...) :set-default NIL)
> 
> Or we can set this behaviour globally, e.g. if we set *current-controller* 
> to something other than NIL or a store:
>   (setf *current-controller* :no-default-controller)
> 
> this will prevent open-store from overwriting it.
> 
> 
> 
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel





More information about the elephant-devel mailing list