Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Ghost update in concurrent transaction

 
   Database Forums (Home) -> Technology and Theory RSS
Next:  ? how to loop through summary query resultset and..  
Author Message
Sudin

External


Since: Aug 29, 2004
Posts: 2



(Msg. 1) Posted: Sun Aug 29, 2004 12:14 pm
Post subject: Ghost update in concurrent transaction
Archived from groups: comp>databases>theory (more info?)

Hello can anyone explain what ghost update does in a concurrent
transaction? What I haven't understood is suppose an integrity
constraint exists which says x+y+z = 1000 and concurrent transaction
table below:
========
Transaction1 Transaction2
bot
r1(x)
bot
r2(y)
r1(y)
y = y - 100
r2(z)
z = z + 100
w2(y)
w2(z)
commit
r1(z)
s = x+y+z
commit
=======
The textbook explains this as to what Ghost update is:
Transaction2 doesn't violate integrity constraint whereas the
Transaction1 (variable s) becomes 1100 ?? and then transaction1
observes only "some" of the effects of Transaction2 & thus has a state
the doesn't satisfy integrity constraint. And that is Ghost Update.

Now what i partly understand in the above transaction as:
1. t1 starts with read x
2. t2 starts with read y
3. t1 reads y
4. t2 decreases y by 100
5. t2 reads z
6. t2 increases z by 100
7. t2 writes y & z
8. t2 commit ( so this means y,z values are already written to the
disk?
and Transaction2 ends??)
9. t1 reads z which has been increased by 100 (z+100)
10. t1 assigns s = x+y+ (z+100)
11. t1 ends with commit.

So now Ghost update exist because of the written value of z (i.e
z+100) & the integrity constraint between them but isn't that what is
to be assumed in a transaction ( one transaction reads, writes,
commits & the other transactions reads its value from the disk??? ) Is
this a ghost update because of the integrity constraint that says the
total must be 1000?
I would appreciate ur help. Smile
cheers
Sudin.

 >> Stay informed about: Ghost update in concurrent transaction 
Back to top
Login to vote
Dan106

External


Since: Aug 06, 2004
Posts: 30



(Msg. 2) Posted: Sun Aug 29, 2004 11:22 pm
Post subject: Re: Ghost update in concurrent transaction [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Sudin" wrote in message

 > Hello can anyone explain what ghost update does in a concurrent
 > transaction? What I haven't understood is suppose an integrity
 > constraint exists which says x+y+z = 1000 and concurrent transaction
 > table below:
 > ========
 > Transaction1 Transaction2
 > bot
 > r1(x)
 > bot
 > r2(y)
 > r1(y)
 > y = y - 100
 > r2(z)
 > z = z + 100
 > w2(y)
 > w2(z)
 > commit
 > r1(z)
 > s = x+y+z
 > commit
 > =======
 > The textbook explains this as to what Ghost update is:
 > Transaction2 doesn't violate integrity constraint whereas the
 > Transaction1 (variable s) becomes 1100 ?? and then transaction1
 > observes only "some" of the effects of Transaction2 & thus has a state
 > the doesn't satisfy integrity constraint. And that is Ghost Update.
 >
 > Now what i partly understand in the above transaction as:
 > 1. t1 starts with read x
 > 2. t2 starts with read y
 > 3. t1 reads y
 > 4. t2 decreases y by 100
 > 5. t2 reads z
 > 6. t2 increases z by 100
 > 7. t2 writes y & z
 > 8. t2 commit ( so this means y,z values are already written to the
 > disk?
 > and Transaction2 ends??)
 > 9. t1 reads z which has been increased by 100 (z+100)
 > 10. t1 assigns s = x+y+ (z+100)
 > 11. t1 ends with commit.
 >
 > So now Ghost update exist because of the written value of z (i.e
 > z+100) & the integrity constraint between them but isn't that what is
 > to be assumed in a transaction ( one transaction reads, writes,
 > commits & the other transactions reads its value from the disk??? ) Is
 > this a ghost update because of the integrity constraint that says the
 > total must be 1000?
 > I would appreciate ur help. Smile

Hi Sudin,

I am assuming that the original values (before T1 and T2) are such that
x+y+z = 1000.

Might I suggest that you create two serial schedules, each reflecting a
serial execution of one transaction and then the other (T1->T2 and then
T2->T1), with no interference of interleaving by the other transaction. If
you work through these two scenarios, you will see that in either case, the
integrity constraint is not violated by either transaction at commit time.
In other words, the variable s would have a value of 1000 for T1 in either
case, and x+y+z would still evaluate to 1000 for T2 in either case.

The issue is not really the integrity constraint (in fact, the mode of
integrity constraint as either deferred or immediate might have an effect on
the effectiveness of the check), but the fact that the schedule involves the
interleaving of operations of T1 and T2 and thefore allows for a condition
where the two transactions interfere with one another and results in
inconsistency. We can determine this because we can define a consistent
transition of states by using a formal criterion based on what would happen
if transactions were only allowed to occured in a serial fashion (T1 and
then T2, or vice versa), totally isolated from one another. Since the
result of the "Ghost Update" schedule does not produce a final state that is
equivalent to a schedule that is serial across transactions, we can
determine that the *isolation* of each transaction is circumspect. Since
the effects of the interleaved schedule presented by the textbook are not
equivalent to a serial schedule, the schedule is not considered to be
*serializable*.

The "Ghost Update" is really another term for the "Inconsistent Analysis"
problem.

BTW, in SQL-92 parlance, this problem seems to imply that the isolation
level defined across transactions is *Read Uncommited* because we can see
that both a dirty read and a non-repeatable read are allowed.

 > cheers
 > Sudin.

HTH,

Dan G.

 >> Stay informed about: Ghost update in concurrent transaction 
Back to top
Login to vote
Sudin

External


Since: Aug 29, 2004
Posts: 2



(Msg. 3) Posted: Mon Aug 30, 2004 1:39 am
Post subject: Re: Ghost update in concurrent transaction [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Dan" wrote in message ...


  > > Hello can anyone explain what ghost update does in a concurrent
  > > transaction? What I haven't understood is suppose an integrity
  > > constraint exists which says x+y+z = 1000 and concurrent transaction
  > > table below:
  > > ========

[snip]

 >
 > Hi Sudin,
 >
 > I am assuming that the original values (before T1 and T2) are such that
 > x+y+z = 1000.
 >
 > Might I suggest that you create two serial schedules, each reflecting a
 > serial execution of one transaction and then the other (T1->T2 and then
 > T2->T1), with no interference of interleaving by the other transaction. If
 > you work through these two scenarios, you will see that in either case, the
 > integrity constraint is not violated by either transaction at commit time.
 > In other words, the variable s would have a value of 1000 for T1 in either
 > case, and x+y+z would still evaluate to 1000 for T2 in either case.
 >
 > The issue is not really the integrity constraint (in fact, the mode of

Word to word from the book it says "Transaction t1 observes only some
of the effects of the transaction t2, and thus observes a state that
does not satisfy the integrity constraints. This is called a ghost
update.

So, t1 violates integrity constraint because it read a value of z that
had value
z+100 which would in turn mean s = x + y + (z+100) instead of s = x +
y + z?? Isn't it because of this that the value of s is 1100 (
mentioned in the text ) instead of 1000 and hence ghost update?

 > integrity constraint as either deferred or immediate might have an effect on
 > the effectiveness of the check), but the fact that the schedule involves the
 > interleaving of operations of T1 and T2 and thefore allows for a condition
 > where the two transactions interfere with one another and results in
 > inconsistency. We can determine this because we can define a consistent
 > transition of states by using a formal criterion based on what would happen
 > if transactions were only allowed to occured in a serial fashion (T1 and
 > then T2, or vice versa), totally isolated from one another. Since the
 > result of the "Ghost Update" schedule does not produce a final state that is
 > equivalent to a schedule that is serial across transactions, we can
 > determine that the *isolation* of each transaction is circumspect. Since
 > the effects of the interleaved schedule presented by the textbook are not
 > equivalent to a serial schedule, the schedule is not considered to be
 > *serializable*.
 >
 > The "Ghost Update" is really another term for the "Inconsistent Analysis"
 > problem.

Nice, didn't know that. Smile

 > BTW, in SQL-92 parlance, this problem seems to imply that the isolation
 > level defined across transactions is *Read Uncommited* because we can see
 > that both a dirty read and a non-repeatable read are allowed.
 >
  > > cheers
  > > Sudin.
 >
 > HTH,
 >
 > Dan G.

thanx for the promptness.
cheers
Sudin.
 >> Stay informed about: Ghost update in concurrent transaction 
Back to top
Login to vote
D Guntermann

External


Since: Aug 26, 2003
Posts: 11



(Msg. 4) Posted: Mon Aug 30, 2004 8:23 pm
Post subject: Re: Ghost update in concurrent transaction [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Sudin" wrote in message


...


   > > > Hello can anyone explain what ghost update does in a concurrent
   > > > transaction? What I haven't understood is suppose an integrity
   > > > constraint exists which says x+y+z = 1000 and concurrent transaction
   > > > table below:
   > > > ========
 >
 > [snip]
 >
  > >
[snip]

If
  > > you work through these two scenarios, you will see that in either case,
the
  > > integrity constraint is not violated by either transaction at commit
time.
  > > In other words, the variable s would have a value of 1000 for T1 in
either
  > > case, and x+y+z would still evaluate to 1000 for T2 in either case.
  > >
[snip]

 > Word to word from the book it says "Transaction t1 observes only some
 > of the effects of the transaction t2, and thus observes a state that
 > does not satisfy the integrity constraints. This is called a ghost
 > update.
 >

Just out of curiosity, what textbook are you referring to? The phrasing of
the problem doesn't seem very rigorous or formal.

 > So, t1 violates integrity constraint because it read a value of z that
 > had value
 > z+100 which would in turn mean s = x + y + (z+100) instead of s = x +
 > y + z??

Yes.

Isn't it because of this that the value of s is 1100 (
 > mentioned in the text ) instead of 1000 and hence ghost update?

Yes. You got it.
[snip]

  > >
   > > > cheers
   > > > Sudin.
  > >
  > > HTH,
  > >
  > > Dan G.
 >
 > thanx for the promptness.
 > cheers
 > Sudin.

Dan G.
 >> Stay informed about: Ghost update in concurrent transaction 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Do we always have to update or insert? Why can't we just r.. - Many times when dealing with database updates I find myself writing something like this: Update .... set .. where ... If (no update was done) then Insert ..... end if Or..

Theoretical Basis for SELECT FOR UPDATE - Hi all, I am interested to hear people's opinions on the validity of SELECT FOR UPDATE. It is not something that I've ever had to use, or even felt the need for, but I don't confuse that fact with any kind of proof or disproof of the technique's..

How to update multiple rows atomically - Here's a possibly-interesting DML question. I want to update multiple rows in a table, but I only want to do so if I can do the update on all of them. A small example: CREATE TABLE T( id int primary key, owner int default 0 ); insert int...

Non Sequitur - <satire> Meteorologists have noted that there is an unusually high number of hurricanes in the Caribbean this year. Experts are in disagreement as to what the fundamental cause is. However, one frequent observer has conjectured that, "this...

The word "symbol" - A few days ago, VC commented on my use of the word "symbol" saying that I was inventing new terminology. I'm trying to restrain the urge to rant, and just give a sober reply. There is a book on my shelves, thanks to Joe Celko, who mailed it...
   Database Forums (Home) -> Technology and Theory All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]