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

Deadlock Avoidance by Xon 1.0.11

Workarounds for sporadic deadlocks on busy forums

  1. Xon

    Xon Well-Known Member

    Xon submitted a new resource:

    Deadlock Avoidance - Workarounds for sporadic deadlocks on busy forums

    Read more about this resource...
    semprot, Fuhrmann, eva2000 and 3 others like this.
  2. TheComputerGuy

    TheComputerGuy Active Member

    Just installed on largest forum. 15M Posts!
    Xon likes this.
  3. TheComputerGuy

    TheComputerGuy Active Member

    Actually, it throws a number of errors conflicting with the tapatalk addon.

    Parse error: syntax error, unexpected T_STRING, expecting T_CATCH in /home/xxx/library/SV/DeadlockAvoidance/XenForo/DataWriter/ReportComment.php on line 12
    Last edited: Jan 11, 2016
  4. Xon

    Xon Well-Known Member

    @TheComputerGuy sorry, but I don't think this add-on will work for you.

    Not that surprising, but there is little I can do to fix that as I don't have tapatalk installed.

    This add-on requires php 5.5, not php 5.4, I'll update the add-on description to correctly state that.
  5. TheComputerGuy

    TheComputerGuy Active Member

    Makes sense! thanks for the quick reply...We are upgrading to php 5.6+ soon....but the tapatalk...well its sticking around.

  6. Xon

    Xon Well-Known Member

  7. HWS

    HWS Well-Known Member

    We use galera for multi master replication. The add-on does not work always, we got this error even with it installed:

    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
    Generated By: Unknown Account, Today at 1:31 AM
    Stack Trace
    #0 /var/www/*****/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
    #1 /var/www/*****/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
    #2 /var/www/*****/library/XenForo/Model/Thread.php(2422): Zend_Db_Adapter_Abstract->query('\n\t\t\tINSERT  INT...', 571128)
    #3 /var/www/*****/library/XenForo/ControllerPublic/Thread.php(159): XenForo_Model_Thread->logThreadView(571128)
    #4 /var/www/*****/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #5 /var/www/*****/index.php(13): XenForo_FrontController->run()
    #6 {main}
    Request State
    array(3) {
      ["url"] => string(62) "http://*****/threads/threadtitle.571128/"
      ["_GET"] => array(1) {
        ["/threads/threadtitle_571128/"] => string(0) ""
      ["_POST"] => array(0) {
  8. Xon

    Xon Well-Known Member

    @HWS That is really weird, I'm not sure how the hell you can get a deadlock from a single-statement insert on a code path with no explicit transactions for a table never touched by the thread or post DataWriters.

    Especially when this add-on isn't even active in that code-path, or any other code paths related to xf_thread_view table!
  9. HWS

    HWS Well-Known Member

    Weird for us too. Must have something to do with the Galera setup. We hoped it will be solved with your add-on. Unfortunately it isn't. Would help if XF automatically retries transactions out of the box.
  10. Xon

    Xon Well-Known Member

    This add-on wasn't designed to target that sort of deadlock, but to target what is basically a design flaw in DataWriters. There are a few other sites patched, which are called inside a DataWriter transaction which shouldn't be.

    Hmm, I think what you are seeing is the fact that updateThreadViews and logThreadView interact poorly with Galera. Especially if the xf_thread_view tables is the default table types.

    One of my other add-ons (Redis View Counters) uses Redis to store view counters logs until they can be persisted to the database as very simple update statements, without the update/join/truncate hoops. But this does require switching over from Memcache to Redis as your caching layer.

    And I don't think how that Redis View Counter add-on uses Redis will work with a Redis cluster, which is a long term plan to fix.
    Last edited: Jan 15, 2016
    eva2000 likes this.
  11. HWS

    HWS Well-Known Member

    We converted all *_view tables from memory to innodb, since this is Galera'a only supported table type.

    I'll try your Redis add-on.
    Xon likes this.
  12. Xon

    Xon Well-Known Member

    eva2000 likes this.
  13. Xon

    Xon Well-Known Member

  14. melbo

    melbo Well-Known Member

    What's a large forum?
    So if we have 100 online trying to post 'something' at the same time or we have 1000 doing the same.
    Won't we hit these deadlocks either way? and would it hurt to install this addon on a not large forum?
  15. Xon

    Xon Well-Known Member

    I've developed these features for forums which peak at 2000-3000 users online within 15 minutes, and as they grow I'll update this add-on to keep it scaling.

    This add-on also introduces shortcuts; such as remove the list of online members which I feel are useless when you have that many online.

    Installing this add-on wouldn't hurt, but at the same time it introduces non-standard behaviour which may surprise you.
    semprot, melbo and eva2000 like this.
  16. Xon

    Xon Well-Known Member

    eva2000 likes this.
  17. Xon

    Xon Well-Known Member

  18. Xon

    Xon Well-Known Member

  19. Xon

    Xon Well-Known Member

  20. RobParker

    RobParker Well-Known Member

    How would we see if deadlocks are happening to us like this?

    Our forum falls into the "busy" category so it sounds like we might benefit from this but we also have a pretty powerful server so not sure...

Share This Page