Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
378 views
in Technique[技术] by (71.8m points)

database - How to determine the whether the transaction is conflict-serializable or not?

I've the following question:

read(T1, x)
read(T2, x)
write(T1, x)
write(T2, x)
commit(T1)
commit(T2)

State whether the schedule is conflict-serializable, recoverable and avoids cascading abort?

I approach the problem like:

----------------------
|   T1    |   T2     |
----------------------
| read(x) |          |
----------------------
|         | read(x)  |
----------------------
| write(x)|          |
----------------------
|         | write(x) |
----------------------
| commit  |          |
----------------------
|         | commit   |
----------------------

I thought like, since there was no cycle (acyclic) in the precedence graph , it was conflict-serializable. Also transaction T1 can be transformed to the transaction T2 by swapping:

----------------------
|   T1    |   T2     |
----------------------
| read(x) |          |
----------------------
| write(x)|          |
----------------------
| commit  |          |
----------------------
|         | read(x)  |
----------------------
|         | write(x) |
----------------------
|         | commit   |
----------------------
  • Is it recoverable? I think yes, since T1 commits after writing and T2 reads, writes and commit.

  • Is it cascedeless? I think no, since T1 and T2 are not committing after writing.

  • Is it avoiding cascadeless abort? I think yes, since it is recoverable.

However, the answer is:

  • Not conflict serializable

  • Recoverable

  • Avoids cascading abort

Now, why is this conflict-seriable?

  • Most probably the answer is the cycle occurs between T2 read(x) -> T1 write(x) -> T2 write(x).

  • If I'm correct, then why the schedule 3 is conflict-serializable?

    • enter image description here

Regards


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...