Table './dbname/sessions' is marked as crashed and should be repaired query: sess_write UPDATE sessions SET uid = 0, cache = 0, hostname = '67.195.112.119', session = 'localizer_contentlanguages|s:20:\"a:1:{s:3:\"eng\";i:1;}\";', timestamp = 1277138140 WHERE sid = '2cdf7dd30bd3ce06f5b9576d7da5a232' in /home/domain/public_html/includes/database.mysql.inc on line 174.

A corrupt sessions table is rare. We've only noticed it 3 times so far.

Steps to Fix

- in phpMyAdmin select the sessions table and select the "repair table" option. If this does not work then
- select the sessions table and then chose the "empty" table option. This will truncate the table and cause all data in the sessions table to be lost. The repercussion of this being that all your users will have to log in again.

Comments

Anonymous’s picture

Encountered a crashed sessions table last night while I was sleeping on a medium-trafficked site that requires users to login. They were not pleased. But the fix was easy, as stated above.

110810 7:29:51 [ERROR] /usr/libexec/mysqld: Table './mydbname/sessions' is marked as crashed and should be repaired

cgdigitaltreats’s picture

i truncated the mysql hoping that would work. The system still says it has a crashed sesssions. Can't figure it out. ANy idea?

Warning: Table './pojack1_nycDrup/sessions' is marked as crashed and should be repaired query: SELECT u.*, s.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = '56880c41cdc0f9d56b26723b2cff46aa' in /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc on line 135

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc:135) in /home/pojack1/public_html/nyclightwave/includes/bootstrap.inc on line 1161

Warning: Cannot modify header information - headers already sent by (output started at /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc:135) in /home/pojack1/public_html/nyclightwave/includes/bootstrap.inc on line 725

Warning: Cannot modify header information - headers already sent by (output started at /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc:135) in /home/pojack1/public_html/nyclightwave/includes/bootstrap.inc on line 726

Warning: Cannot modify header information - headers already sent by (output started at /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc:135) in /home/pojack1/public_html/nyclightwave/includes/bootstrap.inc on line 727

Warning: Cannot modify header information - headers already sent by (output started at /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc:135) in /home/pojack1/public_html/nyclightwave/includes/bootstrap.inc on line 728

Fatal error: Call to undefined function filter_xss() in /home/pojack1/public_html/nyclightwave/includes/common.inc on line 655

Warning: Table './pojack1_nycDrup/sessions' is marked as crashed and should be repaired query: UPDATE sessions SET uid = 0, cache = 0, hostname = '108.6.169.171', session = '', timestamp = 1320860604 WHERE sid = '56880c41cdc0f9d56b26723b2cff46aa' in /home/pojack1/public_html/nyclightwave/includes/database.mysql.inc on line 135

cgdigitaltreats’s picture

If your not logged in, the site still works. But if you try to log in it gives you that sessions error. I have no idea how to get past this. Anybody have an idea??

Antonio

cgdigitaltreats’s picture

the sessions table is empty, yet i'm still still getting that error, does anyone know where it's pulling that data from?

Antonio

Anonymous’s picture

PHPMyAdmin has the "repair table" option, so I would recommend using that if you haven't.

It's possible (I think) that even if it's empty a table that needs to be repaired won't work right.

cgdigitaltreats’s picture

I repaired the table, and I think that did the trick. The site seems to be running, and I can log in.

Thanks.

Antonio

Sourcery’s picture

I had the headers problem which also referred to the sessions table. Doing a repair fixed it fast and easy. Thank you for the info!

SQL show index from `sessions` failed : Table './drupal6/sessions' is marked as crashed and should be repaired

/Kristian

rionka’s picture

Thank you for this thread. I found several tables corrupt - sessions, cache_filter, cache_form, accesslog - but truncating helped.

ressa’s picture

I repaired a crashed accesslog table with phpmyadmin, after installing following these instructions:
http://library.linode.com/databases/mysql/phpmyadmin-ubuntu-10.10-maverick

I don't plan on using phpmyadmin much in the future, so I removed the symbolic link after fixing the table with rm -rf /usr/share/phpmyadmin/
...and restarted the server. The space before the command is intentional, so it won't be saved in the history.

awaller’s picture

My site is showing:

PHP Warning: Table 'sessions' is marked as crashed and should be repaired\nquery: DELETE FROM sessions WHERE timestamp < 1368144437

in the error log once every few days. As you can see, it is automatically clearing sessions older than a certain timestamp. It seems to recover with no consequence, and the site runs with no issues from what I can tell. Users can still log in.

Can I repair the table while the site is "live" or must I take it down during the repair?

Also, I'm on drupal 6, so the sessions table is MyISAM. I've read the converting the table to InnoDB can help. Same question... Can this be done on the fly, or would it require downtime?

sander-martijn’s picture

Worked like a charm, thank you. I didn't have the repair table option, but since the sessions table is basically all temporary data, I just flushed it and that worked perfectly. Thanks for this post, it helped me fix my clients' site quickly!

vmevada102’s picture

As per this forum post, the table has been repaired.

But regularly damages this table in my website.

Please suggest, how can i prevent the damage of this table