Skip to main content
wrap
Source Link
Rick James
  • 79.4k
  • 5
  • 51
  • 117
    START TRANSACTION;
    
    insert into `user_chat_messages` (`user_chat_id`, `from_user_id`, `content`)
        values (1, 2, 'dfasfdfk);
    update `user_chats`
        set `updated_at` = '2018-06-28 08:33:14' where `id` = 1;
    
    COMMIT;
    START TRANSACTION;
    
    insert into `user_chat_messages` (`user_chat_id`, `from_user_id`, `content`) values (1, 2, 'dfasfdfk);
    update `user_chats` set `updated_at` = '2018-06-28 08:33:14' where `id` = 1;
    
    COMMIT;
    START TRANSACTION;
    
    insert into `user_chat_messages` (`user_chat_id`, `from_user_id`, `content`)
        values (1, 2, 'dfasfdfk);
    update `user_chats`
        set `updated_at` = '2018-06-28 08:33:14' where `id` = 1;
    
    COMMIT;
Typo.
Link
MDCCL
  • 8.5k
  • 3
  • 31
  • 62

Why does this query resultsresult in deadlock?

The name of the DBMS of relevance is specified via tags, so I removed a reference from the title. Modified formatting..
Source Link
MDCCL
  • 8.5k
  • 3
  • 31
  • 62

Why does this MySQL query results in deadlock?

I provide below the raw MYSqlMySQL query and also the code in which I do that programatically. If two requests are being done at the same time results in the following error pattern:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: update user_chatssetupdated_at= 2018-06-29 10:07:13 whereid = 1)

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: update user_chats set updated_at = 2018-06-29 10:07:13 where id = 1)

Why does this MySQL query results in deadlock?

I provide below the raw MYSql query and also the code in which I do that programatically. If two requests are being done at the same time results in the following error pattern:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: update user_chatssetupdated_at= 2018-06-29 10:07:13 whereid = 1)

Why does this query results in deadlock?

I provide below the raw MySQL query and also the code in which I do that programatically. If two requests are being done at the same time results in the following error pattern:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: update user_chats set updated_at = 2018-06-29 10:07:13 where id = 1)

added 169 characters in body
Source Link
Kristi Jorgji
  • 293
  • 2
  • 3
  • 7
Loading
added 1066 characters in body
Source Link
Kristi Jorgji
  • 293
  • 2
  • 3
  • 7
Loading
added 20 characters in body
Source Link
Kristi Jorgji
  • 293
  • 2
  • 3
  • 7
Loading
Source Link
Kristi Jorgji
  • 293
  • 2
  • 3
  • 7
Loading