[ZODB-Dev] _p_resolveConflicts

JohnD.Heintz JohnD.Heintz
Thu, 2 Aug 2001 16:52:46 -0500


That's what _p_independent does!

How does this prevent two threads (i.e. Connections) from generating the =
same=20
number?

For example:
class Factory(Persistent):
=09def build(self):
=09=09o =3D Part()
=09=09o.setId( generator.nextId() )
=09=09self.addPart(o)
=09=09return o

In this example the Factory instance should raise a ConflictError, but no=
t=20
the generator, right?

How would we do this without generating any ConflictErrors?  I thought th=
is=20
was the thrust of Randall's email, and it is a question I had a long time=
 ago.

Additionally: how would we provide ConflictError free indexing of newly=20
created things?  This might already be answered in the conflictResolution=
 of=20
BTrees and I missed it, but what if two connections both:
=09...
=09newId =3D generator.getNext()
=09part =3D Part( newId )
=09index[newId] =3D part
=09...

Is there any way to make this free of ConflictErrors?

Sorry if this is already answered, but I think it should be in an easy to=
=20
find FAQ.

John
=09=09


On Thursday 02 August 2001 15:20, Jim Fulton wrote:
> "Randall F. Kern" wrote:
> > OH!  That would be it then :(
> >
> > So is there any way (other than using an external storage medium) to
> > write a counter that will never cause a retry?  It's a major hotspot =
in
> > my system.
>
> Hm, now that you mention it, there's a hook that
> will let you do this::
>
>     def _p_independent(self):
>         # My state doesn't depend on or materially effect the state of
>         # other objects.
>         return 1
>
> See BTrees/Length.py.  This disables the consistency check for
> the object that implements the hook.
>
> Jim
>
> > -Randy
> >
> > > -----Original Message-----
> > > From: Jim Fulton [mailto:jim@digicool.com]
> > > Sent: Thursday, August 02, 2001 12:51 PM
> > > To: Randall F. Kern
> > > Cc: zodb-dev@zope.org
> > > Subject: Re: [ZODB-Dev] _p_resolveConflicts
> > >
> > > "Randall F. Kern" wrote:
> > > > Although my hook (_p_resolveConflicts) is called and is
> > >
> > > returning the
> > >
> > > > proper state, the transactions are still being retried :(
> > > >
> > > > Does the default FileStorage in Zope 2.4.0 support conflict
> > >
> > > resolution
> > >
> > > > or not?
> > >
> > > It does.
> > >
> > > Note that conflict errors can be detected when reading data.
> > > Conflict resolution cannot resolve conflicts detected when
> > > reading.  :(
> > >
> > > We need to add full support for "multi-version concurrency
> > > control", which will allow us to avoid read conflicts by
> > > reading non-current but consistent data.
> > >
> > > Jim
> > >
> > > --
> > > Jim Fulton           mailto:jim@digicool.com   Python Powered!
> > > Technical Director   (888) 344-4332            http://www.python.or=
g
> > > Digital Creations    http://www.digicool.com   http://www.zope.org
> >
> > _______________________________________________
> > For more information about ZODB, see the ZODB Wiki:
> > http://www.zope.org/Wikis/ZODB/
> >
> > ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> > http://lists.zope.org/mailman/listinfo/zodb-dev
>
> --
> Jim Fulton           mailto:jim@digicool.com   Python Powered!
> Technical Director   (888) 344-4332            http://www.python.org
> Digital Creations    http://www.digicool.com   http://www.zope.org
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev

--=20
=2E . . . . . . . . . . . . . . . . . . . . . . .

John D. Heintz | Senior Engineer

1016 La Posada Dr. | Suite 240 | Austin TX 78752
T 512.633.1198 | jheintz@isogen.com

w w w . d a t a c h a n n e l . c o m