Mysql error: Duplicateentry & amp; #39; 127 & amp; #39; forkey & am

Source: Internet
Author: User

Sometimes I am lucky. When I think that I have mastered a certain knowledge point, another problem occurs immediately, so that I can know that my previous cognition is incomplete.

As described in my previous blog post, if an auto-increment field reaches the upper limit and data is still inserted into it, a prompt will appear for Failed to read auto-increment value from storage engine. However, I encountered another error message: Duplicate entry '000000' for key 'Primary '. After troubleshooting, it is also because the auto-increment field has reached the upper limit. Why are there different prompts for the same problem?

The test result is as follows:

1. If no data exists in the data table at this time, and we use statements such as insert into values to INSERT data, the words Duplicate entry '000000' for key 'Primary 'will be displayed. (Because the test field I set is tinyint, It is 127)

2. If no data exists in the data table at this time, and we use statements such as insertinto select from, and the storage engine is INNODB, A message such as Failed to read auto-increment value from storage engine is displayed;

3. If there is data in the data table at this time, there will always be errors such as Duplicate entry '000000' for key 'Primary.

Therefore, it is easy to understand the Duplicate entry '000000' for key 'primary. Another prompt is caused by the unique level-2 cache of the INNODB engine. The data is not inserted into the data table first, but stored in the cache first, only to increase the auto-increment in the table. Therefore, when the auto increment reaches the limit, when InnoDB needs to obtain the auto increment value and store it to the cache, it finds that no higher number is found.

Zookeeper

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.