7

On my local machine, every time I've added a new field and want to add content to it for the first time I get the following error:

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 145 Table './databasename/craft_searchindex' is marked as crashed and should be repaired.

A simple mysql repair table fixes it, but this happens way too often. Is there something I can do to prevent this?

  • Did you resolve the issue? I'm in the same shoes. – Tibor Szasz May 3 '16 at 15:50
  • Just had this happen on the latest version (at the time) 3.0.5 :/ – Mediabeastnz May 3 '18 at 2:11
9

TL/DR: MySQL is horrible.

The craft_searchindex table is the only table that uses MySQL's older MyISAM storage engine, instead of InnoDB (like the rest of the tables), because InnoDB didn't add support for MySQL's full text search capabilities until very recently (version 5.6.4).

One of the many drawbacks of the MyISAM storage engine, as you've discovered, is that the tables using it can crash easily. The crashes can occur for a variety of reasons... low disk space, firmware issues, buggy MySQL, sudden server reboot, etc.

From the command line, you can run a "repair all" like so:

mysqlrepair -A --auto-repair
mysqlrepair -A -o

Or start a test that might help you diagnose why it's crashing:

mysqlrepair -A -c

Also, if you know you're running > MySQL 5.6.4 across all of your environments, you can change the storage engine for that table from MyISAM to InnoDB.

  • It keeps crashing for me when I start load testing with very gentle settings. Any idea how to circumvent this? – Tibor Szasz May 3 '16 at 15:49
  • 1
    Changing the craft_searchindex table to InnoDB will cause bugs now: github.com/craftcms/cms/issues/3862 – missmatsuko May 9 at 17:08
2

The quickfix for this issue is to login to phpMyAdmin and execute the following command in the SQL tab:

REPAIR TABLE craft_searchindex;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.