Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

database - How do we perform swap operation in conflict-serializability?

Assume I have the following concurrent transactions:

----------------------
|Ti        | Tj      |
----------------------         
| write(Q) |         |
----------------------
|          | read(Q) |
----------------------
| read(Q)  |         |
----------------------
|          | write(Q)|
----------------------
| write(Q) |         |
----------------------
|          | write(Q)|
----------------------

If we draw the precedence-graph, we'll see that it is not conflict-serializable. Since the graph will be cyclic. The reason is:

----------------------
|          | write(Q)|
----------------------
| write(Q) |         |
----------------------
|          | write(Q)|
----------------------

From the book: "Database System Concepts - 6th edition" source

If a schedule S can be transformed into a schedule S' by a series of swaps of non-conflicting instructions, we say that S and S' are conflict equivalent. We say that a schedule S is conflict serializable if it is conflict equivalent to a serial schedule.

Now, what does this swap means?

Can I do something like:

----------------------
|Ti        | Tj      |
----------------------         
| write(Q) |         |
----------------------
| read(Q)  |         |
----------------------
| write(Q) |         |
----------------------
|          | read(Q) |
----------------------
|          | write(Q)|
----------------------
|          | write(Q)|
----------------------

Or can I change the order?

----------------------
|Ti        | Tj      |
----------------------         
| read(Q)  |         |
----------------------
| write(Q) |         |
----------------------
| write(Q) |         |
----------------------
|          | read(Q) |
----------------------
|          | write(Q)|
----------------------
|          | write(Q)|
----------------------

Regards

P.S. I looked at other answer but it is not explaining the swap operation.


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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...