Each MyISAM index file (. MYI) has a counter at the head that can be used to check whether a table is properly closed. If you get the following warning from check table or MYISAMCHK, this counter is already out of sync:
clients are using or haven't closed the table proPerly
This warning does not exactly mean that the table has been corrupted, but you should at least check the table.
Counters work in the following ways:
· The table is updated in MySQL for the first time, and the counter of the index header is added one.
· In future updates, the counters are not changed.
· When the last instance of the table is closed (because an action flush table or because there is no space in the table buffer), the counter is reduced by one if the table has been updated at any point.
· When you repair or check the table and find that the table is intact, the counter is reset to zero.
· To avoid a transaction with other processes that might check the table, if the counter is zero, the counter is not reduced by one when it is closed.
In other words, the counter is not synchronized except in the following situations:
· The MyISAM table is not replicated with the lock tables and flush tables that were issued for the first time.
· MySQL crashes between an update and the last shutdown (note that the table may still be intact because MySQL always writes for everything between each statement).
· A table is modified by Myisamchk--recover or Myisamchk--update-state, and is mysqld used.
· Multiple MYSQLD servers are using tables, and one server executes repair table or check table on one table, and the table is also used by another server. In this structure, it is safe to use a check table, although you may get a warning from another server. However, REPAIR table should be avoided because when a server replaces the old one with a new data file, it does not send a signal to the other server.
In general, sharing a data directory among multiple servers is a bad idea.