How do I fix a corrupt Joomla jos_session table

August 29, 2011

I manage a few Joomla websites on a underpowered virtual servers and they occasionally crash under load. Some of the time when they crash, the jos_session table becomes corrupt, yielding this error:

jtablesession::Store Failed
DB function failed with error number 1146
Table 'dbname.jos_session' doesn't exist SQL=INSERT INTO `jos_session` ( `session_id`,`time`,`username`,`gid`,`guest`,`client_id` ) VALUES ( 'rAxRWo70lP8aQOwtokou4IRsMZ','2444128272','','0','1','0' )

This is because jos_session is used to manage user sessions, so it is written to frequently. The most common cause of a corrupt table is a failed write. When the server runs out of resources, it is usually in the middle of a write, thus the corrupt jos_session table. Here’s a way to fix it in Joomla 1.5:

DROP TABLE IF EXISTS `jos_session`;
CREATE TABLE IF NOT EXISTS `jos_session` (
`username` varchar(150) default '',
`time` varchar(14) default '',
`session_id` varchar(200) NOT NULL default '0',
`guest` tinyint(4) default '1',
`userid` int(11) default '0',
`usertype` varchar(50) default '',
`gid` tinyint(3) unsigned NOT NULL default '0',
`client_id` tinyint(3) unsigned NOT NULL default '0',
`data` longtext,
PRIMARY KEY (`session_id`(64)),
KEY `whosonline` (`guest`,`usertype`),
KEY `userid` (`userid`),
KEY `time` (`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Because jos_session is storing temporary data, dropping it and recreating the structure is a simple fix. Had the table had data that we needed, we’d need to go more in depth for recovery.

[cta id=”1682″]

Stay in Touch!

Subscribe to our newsletter.

Solutions Architecture

browse through our blog articles

Blog Archive