Last_SQL_Error: Error Table is marked as crashed and should be repaired

Today we had an issue with our Master-Master replication. Master2 was throwing the below error and the replication was stopped

Last_SQL_Errno: 145
Last_SQL_Error: Error 'Table './exampledb/exampletable' is marked as crashed and should be repaired' on query. Default database: 'livewbmy_db'. Query: 'INSERT INTO `exampletable` (`challenge`, `response`, `hashkey`, `expiration`) VALUES ('XBUL', 'xbul', 'a9e0f4e3dxxxxxccccccc0c8f8f1', '2016-09-29 21:10:03')'

Since its a Master-Master replication, we need to be careful before repairing the table on Master2.

Solution

  • Master1 – mysql -e "stop slave;"
  • Master2 – mysql -e "stop slave;"
  • Master2 – service mysqld stop
  •  run the below now to repair the table.
    [root@dr ~]# myisamchk /var/lib/mysql/exampledb/exampletable.MYI -r
    - recovering (with sort) MyISAM-table '/var/lib/mysql/exampledb/exampletable.MYI'
    Data records: 35564
    - Fixing index 1
    - Fixing index 2
    Data records: 35522
  • Master2 – Now start the slave with mysql -e “start slave;” and observe the show slave status \G and make sure Seconds_Behind_Master: has reached 0
  • Master1 – Start the slave with mysql -e “start slave;” and observe show slave status \G; and make sure it is in sync.

 

Please comment if found helpful.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top