Applies to VoipNow 3 and newer! |
After running out of disk space or after similar unexpected events, database tables often become corrupted. Depending on the table that has crashed, this can affect various system functions. To identify and fix the issue, follow the steps below.
Usually you can find this issue in the logs. For example, when Asterisk tries to read the call_history table, it reports a message similar to the one below.
MySQL server error.SELECT SUM(duration) AS in_sum FROM call_history WHERE start >= '2015-01-01' AND start < ADDDATE('2015-01-01', INTERVAL 1 MONTH) AND flow = 'in'Table 'call_history' is marked as crashed and should be repaired |
As a result, reports will not work.
mysqlcheck -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow call_history |
When the table is OK, the output is this:
voipnow.call_history OK |
You can also perform a check on all tables (beware that this will create load on the system):
mysqlcheck -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow |
To fix the table, simply log in to MySQL.
mysql -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow |
And run:
MariaDB [voipnow]> repair table call_history; |