QuestionQ150

Architecture

Examine the following three statements, which execute concurrently.

Session 1: select count(*) from t1;

Session 2: update t1 set int=10 where PK=7;

Session 3: update t1 set int=10 where PK=4;

Which session or sessions must wait before completing?

  • A Session 3 must wait only for Session 2 to complete.
  • B Session 3 must wait for Session 1 and Session 2 to complete.
  • C Session 2 and Session 3 must wait for Session 1 to complete.
  • D Neither Session 2 nor Session 3 waits for Session 1 to complete.
Explanation

InnoDB processes an ordinary SELECT as a consistent nonlocking read, so it does not block concurrent modifications. Each UPDATE searches for a distinct primary-key value and locks only its own matching index record; the updates therefore do not conflict with each other or with the read.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!