WeBWorK Main Forum

Mysql table is marked as crashed and repair failed

Mysql table is marked as crashed and repair failed

by Bianca Sosnovski -
Number of replies: 4

Hi everyone,

Here is the new error message we have in our server. The error appears for a single account after  the server was out of disk (space https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5567#p16129).

Warning messages

Error messages

DBD::mysql::st execute failed: Table './webwork/MA119@002dS21@002dHAdner@002dPTN2_key' is marked as crashed and last (automatic?) repair failed at /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm line 837.

Call stack

The information below can help locate the source of the problem.

  • in WeBWorK::DB::Schema::NewSQL::Std::handle_error called at line 418 of /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm
  • in WeBWorK::DB::Schema::NewSQL::Std::_get_fields_where_prepex called at line 386 of /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm
  • in WeBWorK::DB::Schema::NewSQL::Std::get_fields_where called at line 446 of /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm
  • in WeBWorK::DB::Schema::NewSQL::Std::get_records_where called at line 746 of /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm
  • in WeBWorK::DB::Schema::NewSQL::Std::gets called at line 768 of /opt/webwork/webwork2/lib/WeBWorK/DB.pm
  • in WeBWorK::DB::getKeys called at line 763 of /opt/webwork/webwork2/lib/WeBWorK/DB.pm
  • in WeBWorK::DB::getKey called at line 793 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::check_session called at line 543 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::verify_normal_user called at line 308 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::do_verify called at line 216 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::verify called at line 160 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::call_next_authen_method called at line 213 of /opt/webwork/webwork2/lib/WeBWorK/Authen.pm
  • in WeBWorK::Authen::verify called at line 321 of /opt/webwork/webwork2/lib/WeBWorK.pm
Have anyone experience anything like this before? Any suggestions what to do to fix it?

Thank you.

In reply to Bianca Sosnovski

Re: Mysql table is marked as crashed and repair failed

by Danny Glin -

A quick google search pointed out the myisamchk command.

I've never used it before, but based on the documentation here's what I'm seeing:

If you run the command with no arguments it will check a myISAM table for errors, so you should be able to run

myisamchk /var/lib/mysql/webwork/MA119-S21-HAdner-PTN2_key.MYI

This is assuming that your mysql data is stored in /var/lib/mysql, so you may have to adjust that part of the path if your system is set up differently.  If I understand correctly, this will give you a report about the health of the table.  If you want myisamchk to try to repair the table, then you would add the -r flag.  I believe that you should stop the database before doing this.

The good news is that if a "..._key" table is the only one that is reporting as crashed, then you likely don't have to worry about losing student data.  I believe that the only thing stored in that table is user sessions, so if you have to delete the table and create a new empty one the only thing that should happen is that anyone who was logged in for that course gets logged out and has to log in again.

In reply to Danny Glin

Re: Mysql table is marked as crashed and repair failed

by Arnold Pizer -
Hi Bianca,

Just to add to Danny's reply, if you do have to drop the ..._key table, to recreate it log into the admin course and click on "Upgrade Courses" and upgrade the course which will recreate the table. Actually this is probably the best solution as probably no one can access the course anyway. Hopefully this is your only corrupted table.

Arnie
In reply to Arnold Pizer

Re: Mysql table is marked as crashed and repair failed

by Bianca Sosnovski -
Hi Danny and Arnold,

Thank you for your help.

I tried to repair and after some initial error and some googling to find out what to do about the error, I was able to repair the table.
But if didn't work I was ready to follow Arnold's suggestion and delete the table.

Here are the commands applied:
root@webwork:~# service mysql stop
root@webwork:~# cd /var/lib/mysql/webwork
root@webwork:/var/lib/mysql/webwork# myisamchk MA119-S21-HAdner-PTN2_key.MYI
myisamchk: error: File 'MA119-S21-HAdner-PTN2_key.MYI' doesn't exist

In the directory, the table is listed with different name (I guess because of encoding of "-". This suggests that in the future we should only use underscores in the name of the courses for our server):

root@webwork:/var/lib/mysql/webwork# myisamchk MA119@002dS21@002dHAdner@002dPTN2_key.MYI
myisamchk: error: 140 when opening MyISAM-table 'MA119@002dS21@002dHAdner@002dPTN2_key.MYI'
root@webwork:/var/lib/mysql/webwork# myisamchk -r -v -f MA119@002dS21@002dHAdner@002dPTN2_key.MYI
myisamchk: error: 140 when opening MyISAM-table 'MA119@002dS21@002dHAdner@002dPTN2_key.MYI'

After a google search for the error above, a post suggested to remove the extension ".MYI" and it worked.

root@webwork:/var/lib/mysql/webwork# myisamchk -r -v -f MA119@002dS21@002dHAdner@002dPTN2_key
- recovering (with sort) MyISAM-table 'MA119@002dS21@002dHAdner@002dPTN2_key'
Data records: 44
- Fixing index 1
- Searching for keys, allocating buffer for 398 keys
- Dumping 42 keys
Data records: 42
root@webwork:/var/lib/mysql/webwork# service mysql start
In reply to Bianca Sosnovski

Re: Mysql table is marked as crashed and repair failed

by Techno Umesh -
If this error occurs. Its an information, that one or more tables are corrupted in your database that needs to be repaired.

Here, In the First step, We need to find the corrupted tables to repair.

Execute a command to find the corrupted tables.

Myisamchk -s / var / lib / mysql/*/*.MYI
MyISAM-table ‘ /var / lib / mysql / dbname / table name. MYI ‘ should be rebuilt and marked as crashed.


Once, We found all the corrupted tables, Now we move to the next step to repair these tables by using another command line.

# myisamchk -r / var / lib / mysql / dbname / table name. MYI

Using the above command, you can fix all corrupted tables in your precious database.


Still not fixed, Then I strongly suggest you to move for a DIY MySQL repair tool because I believe your data is more valuable to your time or a few dollars. With help of any DIY tool, you can repair your data with ease & data security.


I found a tool for you that you can try Stellar Repair for MySQL It's recommended by many DBAs with 4.6 User ratings out of 5.

Thanks