MySQL handles problems with tables that are not properly closed

Source: Internet
Author: User
Tags flush one table

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.