1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Design Issue Deadlock found when trying to get lock; try restarting transaction

Discussion in 'Resolved Bug Reports' started by allewreK, Nov 9, 2013.

  1. allewreK

    allewreK Active Member

    Hello,

    I often have this error in my server error log :
    Code:
    Deadlock found when trying to get lock; try restarting transaction
    I read this thead : http://stackoverflow.com/questions/...ck-found-when-trying-to-get-lock-try-restarti and one solution would be to :
    When this error occur, there isn't any reason, the only thing I know is the more than my board grows, the more often this error occur.

    I have a big board with 1K visitors online during the last 15 minutes.

    Best regards.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The bug report unfortunately doesn't contain enough information to help debug the issue.

    If that error is occurring and is being logged in the Server Error Log in the Admin CP, you will need to include the full stack trace so Mike or others can trace what code is executing to cause it.
     
  3. Mike

    Mike XenForo Developer Staff Member

    As they say, dead locks happen. Really, in theory re-submitting wouldn't sort it because it'd be in the same state. You actually need to roll back the entire transaction and re-do it, which is by no means trivial with arbitrary transactions intermixed with logic.

    As such, the only recommendation is to attempt a resubmit.
     
  4. allewreK

    allewreK Active Member

    It can happen anytime, on any action.

    I allready tried to debug it, but no way, and it doesn't look like that an addon is causing this.

    Here are two stack trace I have, I have like 30/50 per days (that's negligeable due to the amount of visit I have, and since F5 solves it, but that's still a problem).

    Maybe @digitalpoint have a similar problem ? Since you have a big board.

    Here is one :

    Code:
    Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Deadlock found when trying to get lock; try restarting transaction - library/Zend/Db/Statement/Mysqli.php:214
    Code:
    #0 /home/username/public_html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
    #1 /home/username/public_html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
    #2 /home/username/public_html/library/Zend/Db/Adapter/Abstract.php(753): Zend_Db_Adapter_Abstract->query('??????SELECT *?...', 527484)
    #3 /home/username/public_html/library/XenForo/DataWriter/ConversationMaster.php(189): Zend_Db_Adapter_Abstract->fetchRow('??????SELECT *?...', 527484)
    #4 /home/username/public_html/library/XenForo/DataWriter/ConversationMessage.php(150): XenForo_DataWriter_ConversationMaster->addReply(Array)
    #5 /home/username/public_html/library/XenForo/DataWriter.php(1397): XenForo_DataWriter_ConversationMessage->_postSave()
    #6 /home/username/public_html/library/XenForo/ControllerPublic/Conversation.php(1088): XenForo_DataWriter->save()
    #7 /home/username/public_html/library/XenForo/FrontController.php(337): XenForo_ControllerPublic_Conversation->actionInsertReply()
    #8 /home/username/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #9 /home/username/public_html/index.php(13): XenForo_FrontController->run()
    #10 {main}
    Code:
    array(3) {
      ["url"] => string(67) "http://my-website.url.com/conversations/lobby-mw2.527484/insert-reply"
      ["_GET"] => array(0) {
      }
      ["_POST"] => array(8) {
        ["message_html"] => string(16) "<p>Message content :/</p>"
        ["_xfRelativeResolver"] => string(61) "http://my-website.url.com/conversations/lobby-mw2.527484/page-2"
        ["last_date"] => string(10) "1384032385"
        ["last_known_date"] => string(0) ""
        ["_xfToken"] => string(8) "********"
        ["_xfRequestUri"] => string(38) "/conversations/conversation.527484/page-2"
        ["_xfNoRedirect"] => string(1) "1"
        ["_xfResponseType"] => string(4) "json"
      }
    }
    Here is an other stack trace :
    Code:
    Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Deadlock found when trying to get lock; try restarting transaction - library/Zend/Db/Statement/Mysqli.php:214
    Code:
    #0 /home/username/public_html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
    #1 /home/username/public_html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
    #2 /home/username/public_html/library/XenForo/Model/Deferred.php(113): Zend_Db_Adapter_Abstract->query('?????INSERT INT...', Array)
    #3 /home/username/public_html/library/XenForo/Application.php(1288): XenForo_Model_Deferred->defer('MailQueue', Array, 'MailQueue', false, NULL)
    #4 /home/username/public_html/library/XenForo/Model/MailQueue.php(7): XenForo_Application::defer('MailQueue', Array, 'MailQueue')
    #5 /home/username/public_html/library/XenForo/Mail.php(224): XenForo_Model_MailQueue->insertMailQueue(Object(Zend_Mail))
    #6 /home/username/public_html/library/XenForo/Model/ThreadWatch.php(249): XenForo_Mail->queue('amegliololo13@g...', 'L0L0')
    #7 /home/username/public_html/library/XenForo/DataWriter/DiscussionMessage/Post.php(144): XenForo_Model_ThreadWatch->sendNotificationToWatchUsersOnReply(Array, NULL, Array)
    #8 /home/username/public_html/library/XenForo/DataWriter.php(1411): XenForo_DataWriter_DiscussionMessage_Post->_postSaveAfterTransaction()
    #9 /home/username/public_html/library/Dark/TaigaChat/DataWriter/DiscussionMessage/Post.php(7): XenForo_DataWriter->save()
    #10 /home/username/public_html/library/XenForo/ControllerPublic/Thread.php(548): Dark_TaigaChat_DataWriter_DiscussionMessage_Post->save()
    #11 /home/username/public_html/library/XenForo/FrontController.php(337): XenForo_ControllerPublic_Thread->actionAddReply()
    #12 /home/username/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #13 /home/username/public_html/index.php(13): XenForo_FrontController->run()
    #14 {main}
    Code:
    array(3) {
      ["url"] => string(105) "http://mysite.com/threads/thread-title.255/add-reply"
      ["_GET"] => array(0) {
      }
      ["_POST"] => array(9) {
        ["message_html"] => string(45) "<p>Message ?</p>"
        ["_xfRelativeResolver"] => string(102) "http://mysite.com/threads/thread-title.255/page-2"
        ["attachment_hash"] => string(32) "e062dda2987dddfb08107703ae039bd8"
        ["last_date"] => string(10) "1384033713"
        ["last_known_date"] => string(10) "1384033713"
        ["_xfToken"] => string(8) "********"
        ["_xfRequestUri"] => string(79) "/threads/thread-title.255/page-2"
        ["_xfNoRedirect"] => string(1) "1"
        ["_xfResponseType"] => string(4) "json"
      }
    }
    Each stack is unique.
     
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    P: I have seen a "Deadlock found when trying to get a lock" MySQL error in my error logs.
    S: Reload the page to restart whatever process you were attempting. Deadlocks can occur with any transaction or query in an InnoDB MySQL database. They are very difficult to programmatically prevent and shouldn't occur often. If they occur fairly often, it is recommended that you discuss possible solutions with your host. Here is some further reading related to deadlocks:
    http://xenforo.com/community/threads/mysql-deadlock.60778/
    http://xenforo.com/community/threads/deadlock.60097/
    http://xenforo.com/community/thread...to-get-lock-try-restarting-transaction.47820/
    http://xenforo.com/community/threads/vb-3-8-xf-via-cli-importer-discrepancies.27794/#post-327157

    http://xenforo.com/community/threads/troubleshooting-faq-frequent-problems-solutions.62138/
     
    allewreK likes this.
  6. digitalpoint

    digitalpoint Well-Known Member

    Nope... I have yet to run into a deadlock issue on my setup. I'm using ndbcluster storage engine for all tables, not InnoDB or MyISAM, so that probably has something to do with it (we do well over 1,000 SQL writes per second).
     
  7. ehsanix

    ehsanix Member

    What did you do with those deadlock?
     
  8. Marcel

    Marcel Active Member

    I've not come across these yet on our forum.
    Until today.
    I'm going through and mass deleting spammers that have been spambanned in the past.
    Had to do it in such a way that I got all banned users with 'spam' in the reason into a specific usergroup.
    Then batch updated those users (A good few hundred).

    While this is running, I've had a few deadlocks pop up on the server error log (one I caused as a user too, posting in a different tab). I assume it's just because of the load the database is under while deleting the users.
     
  9. ehsanix

    ehsanix Member

    I had a few deadlocks per week 6 months ago. Nowadays I have more than thousands deadlocks per day. It may come from a plugin update, but is this normal? (I don't think so)
    Most of them are on xf_deferred.
     
  10. Mike

    Mike XenForo Developer Staff Member

    Thousands per day is not normal. I should note that there are tweaks in 1.4 (and the latest version of 1.3, IIRC) that are designed to reduce some of the common deadlock causes.
     
    ehsanix likes this.
  11. denam

    denam Active Member

    A deadlock also happened to our fresh migrated board on xenforo version 1.4.6 this week.

     

Share This Page