Re: Rollback?

Sébastien Bigaret <[email protected]> Tue, 12 Sep 2006 12:14:04 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
    Hi Wolgang & all,

Wolfgang Keller wrote:
> Hello,
> =

> just out of curiosity:
> =

> Is the possibility to rollback changes on the roadmap of Modeling? This i=
s =

> for the case where several instances of an application using modeling run=
 in =

> parallel at different sites, and a transaction needs to be distributed ov=
er =

> more than one instance of the application...

I'm not sure to understand what you mean by "a transaction needs to be dist=
ributed over more than one instance". If what follows doers not answer your=
 question, or if you need further explanations, please do not hesitate to a=
sk.

For the moment being, an EditingContext (EC) is the abstraction, at the obj=
ect level, of a transaction. One EC, one transaction, that can be committed=
 (hence, producing a transaction at the database level), or rolled back.  Y=
ou can also have sub-tranbsactions at the object level (see http://modeling=
.sourceforge.net/UserGuide/nested-editing-context.html).

Now as far as I understand it, your next question is about concurrent modif=
ications in different ECs. That can happen: in the same process, different =
threads, or in different processes --see below.

> And, what would happen in Modeling if a different application, which does=
 not =

> pass through Modeling, but connects directly to the underlying database, =

> modifies records in this database? Does Modeling go so far and notice whe=
n a =

> lock on a record is acquired by a different application, lock the =

> corresponding object in memory, and then update the objects in memory wit=
h =

> the changes the other applications makes to the database? Or is such a =

> function totally utopian? *duck*

The features you ask for is partially addressed by a patch described here:

  http://permalink.gmane.org/gmane.comp.python.modeling/374

although that they are addressed in a different but (imho) equivalent way, =
as described below.

With this patch:

- an EditingContext saving changes broadcasts its changes to others, who in=
 turn merge the committed changes with their own, uncommitted, changes.
(for now, this only works within the same process, with e.g. ECs dispatched=
 in different threads, but NOT for ECs that are created in different proces=
ses)

- if, as you described, an external application changes some database value=
s, any EC saving its changes will receive an OptimisticLockingFailure excep=
tion when trying to save changes on some of the externally modified datas.
In this case: external application=3D=3Dan other process; it can be anythin=
g modifying the db, and particularly: an other application using the modeli=
ng framework.

This is obviously the first step, in further development the externally mod=
ified objects would be sent back to the EC so that you can choose to refres=
h the values, examine the differences and accept or discard the changes.


Explicit database-locking would be called Pessimlistic Locking, where modif=
ying an object implies acquiring a lock on the corresponding database colum=
n(s) until changes are saved (or discarded).  This feature is on the TODO l=
ist, but development has not started yet.


-- S=E9bastien.


Wolfgang Keller wrote:
> Hello,
> =

> just out of curiosity:
> =

> Is the possibility to rollback changes on the roadmap of Modeling? This i=
s =

> for the case where several instances of an application using modeling run=
 in =

> parallel at different sites, and a transaction needs to be distributed ov=
er =

> more than one instance of the application...
> =

> And, what would happen in Modeling if a different application, which does=
 not =

> pass through Modeling, but connects directly to the underlying database, =

> modifies records in this database? Does Modeling go so far and notice whe=
n a =

> lock on a record is acquired by a different application, lock the =

> corresponding object in memory, and then update the objects in memory wit=
h =

> the changes the other applications makes to the database? Or is such a =

> function totally utopian? *duck*
> =

> TIA,
> =

> Sincerely,
> =

> Wolfgang Keller
> =



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easi=
er
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D1=
21642