Every so often, the following error is throwing:
modifyThreadUserPostCount does a select then insert or update. While it runs in a transaction, if there is nothing to select, then the row isn't going to be enrolled into the transaction to that row being blocked. The default transaction level does not block new rows! (SERIALIZABLE isn't usable in most MySQL clustered solutions).
Most of the contents of modifyThreadUserPostCount can be replaced with just:
Alternatively, updating the existing code so if the insert fails, an update occurs.
Code:
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Duplicate entry '351160-712' for key 'PRIMARY' - library/Zend/Db/Statement/Mysqli.php:214
#0 /var/www/html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
#1 /var/www/html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 /var/www/html/library/Zend/Db/Adapter/Abstract.php(574): Zend_Db_Adapter_Abstract->query('INSERT INTO `xf...', Array)
#3 /var/www/html/library/XenForo/Model/Thread.php(2053): Zend_Db_Adapter_Abstract->insert('xf_thread_user_...', Array)
#4 /var/www/html/library/XenForo/DataWriter/DiscussionMessage/Post.php(105): XenForo_Model_Thread->modifyThreadUserPostCount(351160, 712, 1)
...
modifyThreadUserPostCount does a select then insert or update. While it runs in a transaction, if there is nothing to select, then the row isn't going to be enrolled into the transaction to that row being blocked. The default transaction level does not block new rows! (SERIALIZABLE isn't usable in most MySQL clustered solutions).
Most of the contents of modifyThreadUserPostCount can be replaced with just:
Code:
$db->query('
insert into xf_thread_user_post (thread_id, user_id, post_count) values
(?, ?, ?)
on duplicate key update post_count = post_count + VALUES(post_count)
', array($threadId, $userId, $modifyValue));
Alternatively, updating the existing code so if the insert fails, an update occurs.
Last edited: