What is in xf_session Table?
The xf_session table in XenForo contains the session data for users (logged in members as well as guests). The xf_session tables help identify the members and guests currently online or were active recently. The hourly cron cleans up the session data from the xf_session table based on the expiry_date column in the table.
In admin cp > Options > User Options, there is a setting for “Online status timeout” which can be the number of minutes between 1 and 60 to consider users as online. Users will be considered offline if they do not interact with the system for the minutes specified.
What causes the error in xf_session table?
Each page load for each member or guests triggers a write operation for the xf_session table for the expiry_date and so is possibly the most frequently written table by XenForo.
If there is an unexpected shut down of MySQL server due to memory or any other issue, the table being frequently written are more likely to crash and is the root cause of the issue.
How to fix the xf_session issue?
The issue can’t be fixed from the XenForo admin cp and has to be done through phpMyAdmin (via CPanel or any other control panel). The REPAIR xf_session doesn’t work on session tables in MySQL. So one has to TRUNCATE the table.
Once you execute the above command, you will see your members online now has reduced to almost zero. If xf_session table crashes once a while, truncating the table should be fine but if the problem occurs frequently, find the root cause of the crash and opt for an alternative solution like a server-side caching with APC or Memcached for sessions to save the frequent database write operations. The above solution is not ideal for a repetitive occurrence of the issue because the forum won’t be accessible so long as the table remains crashed and you execute the above command from the phpMyAdmin.