[Nitro] re-using a db and threading headaches

Fang Sun nusgnaf at gmail.com
Sat Aug 26 09:05:09 EDT 2006


The fix is very simple, right now we use @store to maintain database
connection is Og isnot threadsafe, while in threadsafe mode we use
dynamic @pool, in close_store, we fall back to @store.close by
checking the size of @pool, that's not correct. The following patch is
again lastest repo, please apply.

On 8/26/06, Fang Sun <nusgnaf at gmail.com> wrote:
>  instance var @store defined in Og::Manager looks very suspecious.from
> the comment in the code:
> -------8<-----------
>   # The store used for persistence. This is a virtual field
>   # when running in thread_safe mode.
>
>   attr_accessor :store
> -------8<------------
> and in close_store it gets called:
> @store.close
>
> I add simple p @store in the og/manager.rb, it seems that it is always
> nil, that can explain the error you saw. But how does @store get used?
> I still don't know Og enought, hope George may give better explanation
> on Og intervals.
>
> On 8/26/06, Alex Pooley <alex at msgpad.com> wrote:
> > Yo!
> >
> > I've been working around two issues. One I have a solution for, and the
> > other issue I have a test case courtesy of manveru.
> >
> > 1. When I try to re-use an existing database Og dies on an exception
> > that the table already exists. I'm using sqlite. The easy fix is to
> > catch the exception in sql.rb at line 139. So instead of
> >
> > klass.allocate.og_create_schema(self)
> >
> > You end up with something more like
> >
> > begin
> >   klass.allocate.og_create_schema(self)
> > rescue Exception
> > end
> >
> >
> > 2. I'm running two threads. The first thread is running tests, and the
> > second thread is a mongrel server. Each thread is accessing the Og
> > store. Og will die trying to close the store in manager.rb (line 101),
> > because @store is nil. manveru came up with this test case while
> > discussing the problem on IRC: http://pastie.caboo.se/10334 . This
> > occurs in both the repo.nitroproject.org repository, and manveru's
> > latest.
> >
> >
> > --
> > Alex Pooley (msgpad founder)
> > w: http://msgpad.com
> > e: alex at msgpad.com
> > b: http://alexpooley.com
> >
> >
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: og.fix.patch.tgz
Type: application/x-gzip
Size: 7185 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20060826/eb70f72e/attachment-0001.tgz 


More information about the Nitro-general mailing list