SQLSTATE[HY000]: General error: 126 Incorrect key file for table '

Facing this problem on the GUI:

FreePBX 13-High Availability

Your database table needs to be repaired.

How would I repair this and what is causing this?

I had a network outage where my HA nodes got swapped around, still this shouldn’t corrupt my database.

Log into the server and execute mysql and type “repair <tablename>”.

A lot depends on what caused your network outage. You’re right about “shouldn’t”, but the error message even tells you to repair the database table. You had the answer before you ever posted the question. I don’t know what did it, but the table needs repaired and nothing is going to solve this problem short of that.

If you only have access through a tool (myphpadmin or SQLYog), there should be an option to repair the table. If you have to access mysql through the command line and type “repair module_xml” where "“module_xml” is the name of the table that got corrupted.

Since I usually have root access to my database servers, I usually write a script that repairs all of the tables in a database whenever one of then gets corrupted.

We had the same error today and repaired it. Thanks guys.
Is that a common error? Could it be caused by a server crash i.e. unexpected reboot?

PDOException (HY000)
SQLSTATE[HY000]: General error: 126 Incorrect key file for table ‘./asterisk/kvstore.MYI’; try to repair it