On Mon, 31 Jul 2000 10:21:35 -0700, Wolf Siberski <[EMAIL PROTECTED]>
wrote:

>Hamid Lahooti wrote:
>Hey, that's a surprise. Before I read Your post I
>was convinced that optimistic locking is deadlock free.
>
>But While trying to write an answer to convince You, too,
>I got serious doubts, and now I'm not sure at all about it.

Good! Doubts are what brings forward the most fundamental learning
experiences :-)

>Let's simulate a simple concurrent update to get
>that more clear. Suppose we have Bean a (for simplicity
>stored in table A ) and Bean b (stored in B)
>
>The core idea of optimistic locking is
>working copies. Transaction1 gets
>it's working copies of a and b just by reading
>without any locking. The same for transaction2.
>
>Now t1 and t2 start to update their copies
>which leads to a' and  b' rsp. a'' rsp b''.
>
>Both transactions start to write their changes back.
>t1 writes a' to the db. No (explicit) locking involved.
>t2 writes b'' to the db. No (explicit) locking involved.
>
>But now it gets interesting.
>
>Transaction1 tries to write b' to the db.
>For isolation reasons t1 can't yet see
>the change from a to a'.
>Will the update succeed? I don't think so.
>My guess is that the db will wait until
>transaction2 is completed.
>But now t2 starts to write b''...
>Looks like a deadlock to me.
>
>(had we used a lower isolation level here,
>t1 would have got a db error when writing a';
>but the interesting case is complete transaction
>isolation).
>
>Are there other possibilities for the db
>to handle that problem which avoid the
>deadlock?

I would guess that transaction commits are atomic. Apply as necessary to
above scenario for solution.

If some DB fellow (Evan?) could confirm this that'd be great.

/Rickard

--
Rickard �berg

Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to