2PL's rule says:

Upgrading of lock (from S(a) to X (a)) is allowed in growing phase.

But what if upgrading lies after the last lock and before the first unlock? Does it still count "in the growing phase"? For example, is the transaction below a 2PL?

  • $\begingroup$ You have also posted this on Stack Overflow. Please don't cross-post! $\endgroup$
    – Pseudonym
    Oct 16, 2020 at 4:17

1 Answer 1


It's allowed.

You can upgrade any locks during the growing phase, and downgrade any locks you want during the shrinking phase, and it's a valid 2PL. What you can't do is release/downgrade during the growing phase, or acquire/upgrade during the shrinking phase, because this breaks the phase ordering rule.

Note that even during the shrinking phase, downgrading breaks strict 2PL, because it releases an exclusive lock. More on this in a moment.

I think the reason why you may be asking is that your example transaction reads Y, then upgrades, then writes Y. You may be wondering what happens if some other transaction holds a shared lock on Y, and also wants to upgrade.

This is a deadlock situation, so one of them wins and the other transaction is aborted, or rolled back to at least the point where the shared lock on Y was acquired. The lock upgrade operation can and does cause aborts. Similarly, downgrading can cause cascading aborts, which is yet another reason why most database systems prefer strict locking.

  • $\begingroup$ Thanks! That really clarified all my doubt. $\endgroup$
    – soma
    Oct 16, 2020 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.