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
500 views
in Technique[技术] by (71.8m points)

sql - 2PL, Rigorous vs Strict Model, Is there any benefit?

In 2PL (two phase locking), what advantage(s) does the rigorous model have over the strict model?

I) There is no advantage over the strict model.

II) In contrast to the strict model, it guarantees that starvation cannot occur.

III) In contrast to the strict model, it guarantees that deadlock cannot occur.

IV) In contrast to the strict model, there is no need to predict data needed in the future.

My note says all of the above are false. I am a bit confused. Can someone clarify for me why all of this is false?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

What is Two-Phase Locking (2PL) Protocol ?

A transaction is two-phase locked if:

before reading x, it sets a read lock on x

before writing x, it sets a write lock on x

it holds each lock until after it executes the corresponding operation

after its first unlock operation, it requests no new locks

Now, what is Strict phase locking ?

Here a transaction must hold all its exclusive locks till it commits/aborts.

But ,whats rigorous 2PL ?

Rigorous two-phase locking is even stricter: here all locks are held till commit/abort. In this protocol transactions can be serialized in the order in which they commit.

Much deeper :

Strict 2PL :

enter image description here

Same as 2PL but Hold all exclusive locks until the transaction has already successfully committed or aborted. –It guarantees cascadeless recoverability

Rigorous 2PL :

enter image description here

Same as Strict 2PL but Hold all locks until the transaction has already successfully committed or aborted. –It is used in dynamic environments where data access patterns are not known before hand.

There is no deadlock. Also, a younger transaction requesting an item held by an older transaction is aborted and restart with the same timestamp, starvation is avoided.

I hope that above clear explanations with diagram must have made you clear about the concept and advantages of rigorous over the other.

Thanks


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

...