AdvancedAbout 15 min

    Concurrency & Deadlocks

    Read the full article on Substack

    6 min read.

    Step through shared and exclusive locks, two-phase locking, what breaks when a lock is released early, and how a circular wait becomes a deadlock.

    Think of it this way: Imagine two people needing a hammer and nails to work. Person A grabs the hammer. Person B grabs the nails. Person A waits for the nails, and Person B waits for the hammer. Neither can proceed. That is a deadlock.

    Transaction 1not startedTransaction 2not startedRow A= 100Row B= 100

    Two transactions and one row, A. A lock says who may read or change it.

    1/8

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Growing or shrinking phase?

    Sort

    Sort each action into the phase of two-phase locking where it is allowed.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Growing phase

    Drop items here

    Shrinking phase

    Drop items here
    6 pieces left to place

    Quiz

    23 questions
    Question 1 of 23
    Score: 0

    If Transaction A holds a Shared Lock on Row 1, what happens if Transaction B requests an Exclusive Lock on Row 1?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going