XF 1.4 Double Posts, MySQL Lock Timeout errors

Denny Crane

Member
I've been getting a lot of both on my site lately.

http://www.sportstwo.com.

What I think is going on is users are clicking on the submit post button two or more times because they're on mobile and there's a lot of lag.

I just read a thread where one guy submitted the same post 4 times in a row.

I'm seeing only a handful (like 12-15) per day of these MySQL Lock Timeout errors in the server log.

Any suggestions?
 
So here's something you might be able to fix.

They click the Post Reply button. It goes disabled, then enabled too soon. In theory, you should be using setTimout of 30 seconds and check the XHR in the handler to see if the server isn't responding. On error, popup, re-enable the Post Reply button.

We see no error popups and the button is enabled within a couple of seconds.

Any way to adjust that time?
 
The submit re-enables in 5 seconds. This is really just part of a generic system to prevent accidental double clicks in most cases. This is controlled by XenForo.MultiSubmitFix in js/xenforo/xenforo.js.

In normal cases, 99% of forms shouldn't be taking anywhere near 5 seconds to return. I'd say most of the forms that would normally take that long are in the control panel. The number of alerts/emails sent with a thread reply could cause some amount of delay but it shouldn't be significant in most cases (especially as it only triggers for people who had read the last message posted).

Disabling the flood check may increase the number of duplicate posts by virtue of them not being blocked by the check.

In terms of the screenshot in your latest post, I don't believe there's anything that would block scrolling and that certainly isn't a report we've had before. With certain client actions not working, it does almost seem to imply that the JS hasn't loaded correctly (though it should generally fall back gracefully in that case). Alternatively, it could be down to a server response timing out, though the quote button shouldn't really be involved in locks as it's only selecting so the issues discussed shouldn't contribute to that.
 
As I said, the submit button should be linked to the XHR, not to its own timer. You are guaranteed to generate lock wait timeout if the user clicks the button again before the XHR returns. It's a race condition between his first and second tries!

I turned everything back on after setting flood check to 4 seconds. There were 2 errors over the past 20 hours. This is including the MySQL slave.

Rather than trying to scale xenforo across multiple instances, I may just move to AWS on a single really big instance and deal with the possible unavailability due to the AWS host being rebooted or rebooting after apt-get update.

One thing you guys really should consider is storing avatars and attachments in the database. Sure it makes the database larger in byte size (and mysqldump files, too).

On the other hand, you can fetch it from the database and store it in the filesystem and serve it from there. If the avatar or attachment is updated, store it in the database and filesystem. If the avatar or attachment is updated, store the new one in the database. The storing into the filesystem would be on demand.

If you implemented this, anyone could build an AMI from xenforo and spin up 1, 2, ... 10 without having to deal with data and internal_data directory synchronization. Adding another instance to a load balancer automatically pulls the avatars and attachments to the filesystem on demand.
 
I did move the site to a good sized (8 core 15G) AWS instance. It's WAY faster, but at flood control 0 I hit submit and there was a long delay. The animated AJAX pending graphic was in the upper right corner of the browser window. The button enabled, I clicked it again.

I clicked a total of two times.

My post appeared 5 times in a row in the thread.

I'm seeing no errors in the server log. I am seeing what's generally a normal thing - spotty internet between my machine and the server.

I'm reasonably sure you need to tie the button enable to the XHR like I suggested.

If the button gets stuck off, the user can copy his post to notepad and reload and copy paste back.
 
More server errors after the move.

upload_2015-2-28_6-57-0.webp


Server Error Log
Error Info
ErrorException: array_fill(): Number of elements must be positive - library/XenForo/ControllerPublic/Forum.php:553
Generated By: Draco, Today at 12:41 AM
Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(2, 'array_fill(): N...', '/home/mschwartz...', 553, Array)
#1 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/ControllerPublic/Forum.php(553): array_fill(0, 0, true)
#2 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/Andy/SimilarThreads/ControllerPublic/Forum.php(13): XenForo_ControllerPublic_Forum->actionCreateThread()
#3 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(347): Andy_SimilarThreads_ControllerPublic_Forum->actionCreateThread()
#4 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
["url"] => string(72) "http://www.sportstwo.com/forums/portland-trail-blazers.123/create-thread"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}



Server Error Log
Error Info
ErrorException: array_fill(): Number of elements must be positive - library/XenForo/ControllerPublic/Forum.php:553
Generated By: Draco, Yesterday at 11:54 PM
Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(2, 'array_fill(): N...', '/home/mschwartz...', 553, Array)
#1 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/ControllerPublic/Forum.php(553): array_fill(0, 0, true)
#2 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/Andy/SimilarThreads/ControllerPublic/Forum.php(13): XenForo_ControllerPublic_Forum->actionCreateThread()
#3 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(347): Andy_SimilarThreads_ControllerPublic_Forum->actionCreateThread()
#4 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
["url"] => string(72) "http://www.sportstwo.com/forums/portland-trail-blazers.123/create-thread"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}




Server Error Log
Error Info
ErrorException: array_fill(): Number of elements must be positive - library/XenForo/ControllerPublic/Forum.php:553
Generated By: Draco, Yesterday at 11:54 PM
Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(2, 'array_fill(): N...', '/home/mschwartz...', 553, Array)
#1 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/ControllerPublic/Forum.php(553): array_fill(0, 0, true)
#2 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/Andy/SimilarThreads/ControllerPublic/Forum.php(13): XenForo_ControllerPublic_Forum->actionCreateThread()
#3 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(347): Andy_SimilarThreads_ControllerPublic_Forum->actionCreateThread()
#4 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 /home/mschwartz/github/mschwartz/sportstwo-xenforo/htdocs/index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
["url"] => string(72) "http://www.sportstwo.com/forums/portland-trail-blazers.123/create-thread"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Hey Mike,


Thanks for all the help.

Things are running like a top on AWS.

I think everyone might want to avoid Digital Ocean for hosting until they get their act together.

This is the response I got from them after letting them know I was leaving and that their spotty LAN network was causing us issues.

upload_2015-2-28_14-17-14.webp

Please consider tying the post reply button to the XHR timeout :)
 
Wow, we just tried to migrate a pretty big forum (25 million posts) to Xenforo on the same type of server at AWS we had our vBulletin instance on, and saving posts gets crushed in a minute or two after turning it on so that hardly anyone succeeds in saving a post.

Something is doing table scan (i.e. unindexed) queries on xf_post which are very slow since the table is 27 GB large. These table scans lock the entire table, so nothing can write to the table during the time of the query.

We're considering adding indexes to that table so the queries are indexed and don't lock it. We did this years ago on vBulletin and it worked like a charm.

We're logging slow queries now to get more info on what's going on.
 
Please consider tying the post reply button to the XHR timeout :)
I agree with that request. The Post Reply button lights back up after 5 seconds, but meanwhile it takes the post 45 seconds to time out. So our members just keep trying the Post Reply button, creating cascading failures.

Or if they get lucky and some of their efforts save in under 45 seconds, they get cascading duplicate posts.
 
Top Bottom