mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

Quiz Notes (Transactions and Locks) Question #477

Closed Eshaan-Lumba closed 7 months ago

Eshaan-Lumba commented 8 months ago

In the first set of notes for Transactions and Locks, on problem 27, why Line 4 cause a block? The CREATE INDEX CONCURRENTLY command on Line 4 acquires a SHARE UPDATE EXCLUSIVE lock that, as per the table in the documentation should not get blocked by the ROW EXCLUSIVE MODE command in Line 3.

mikeizbicki commented 8 months ago

Good question!

The short answer is that you're not responsible for what's going on. I meant to take this out of the notes, but apparently the changes never got committed to github on accident.

The long answer is that technically, the command is not blocked, it just takes a very long time to run. For a command to be blocked, that means that it cannot start running until all the relevant locks are released. In this case, however, you are correct that the locks do not conflict, and so the command is not blocked and is allowed to run. The CREATE INDEX CONCURRENTLY command will continue to run, however, until all concurrent transactions are terminated. It is actually performing some subtle work in the background while it is doing this, so it's not technically blocked. The documentation on command covers this in detail, but again you're not responsible for this on the quiz.