Pay attention to the master-slave synchronization latency during development in multiple mysql instances.

Source: Internet
Author: User
For development under multiple mysql instances, you need to pay attention to the master-slave synchronization delay. This evening the server went online for testing and encountered a problem! After a piece of data is written to the database, the record cannot be read and a null pointer is reported. It's hard to understand. Call the development team lead to locate the problem. He explained that write operations use the master database, while read operations use the slave database. After writing the database

For development under multiple mysql instances, you need to pay attention to the master-slave synchronization delay. This evening the server went online for testing and encountered a problem! After a piece of data is written to the database, the record cannot be read and a null pointer is reported. It's hard to understand. Call the development team lead to locate the problem. He explained that write operations use the master database, while read operations use the slave database. After writing the database

Pay attention to the master-slave synchronization delay for development under multiple mysql instances

This evening, the server went online for testing and encountered a problem!

After a piece of data is written to the database, the record cannot be read and a null pointer is reported. It's hard to understand. Call the development team lead to locate the problem. He explained that write operations use the master database, while read operations use the slave database. After writing a database, this record does not appear in the read database immediately. It takes some time to synchronize data to the slave database. So I encountered a null pointer exception.

Back to read a lot of online Introduction to the master-slave synchronization mechanism. This is generally the case. After the master database executes the SQL write command, it writes the log to binlog. A thread in the slave database pulls the log file from the master database to obtain new data write operation logs. Write the pulled logs to the local relay-log. The SQL thread of the slave database is stored in the relay-log of the local machine.

Retrieve the log and execute it. So far, synchronization is complete. It can be seen that the synchronization between the master and slave nodes takes some time.

Good soldiers won't jump into the same trap. If you encounter similar problems in the future, the correct method is to query the data immediately after writing the data, you need to use the primary database (write database) for query instead of the slave database (read database ). I want to share my experience with you.

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.