deadlock question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blah Blah

    #1

    deadlock question

    how does mysql avoid deadlock with transactions?
    suppose two users simultaneously do the following:

    user 1:
    begin
    update A set foo="blah" where ...
    update B set bar="blah2" where ...
    commit

    user 2:
    begin
    update B set bar="blat" where ...
    update A set foo="blat2" where ...
    commit

    it's easy to imagine the second statement for each user relying upon
    information from the first (e.g., an automatically created key), or an
    intermediate select statement.

    since the database doesn't know what the second statement is going to be for
    either user, it's going to hit deadlock unless it locks *every* table in the
    database for one of them, but that seems problematic as well.

    anyone?

    daniel


Working...