MySQL Primary-Replica Data Comparison with NineData
As business scope expands, many companies choose the MySQL primary-replica architecture to ensure the high availability of core businesses. This solution typically includes primary-replica data synchronization, data backup and recovery, read-write separation, and high availability switching, making it a mature and reliable database architecture. However, under certain circumstances, this solution may have issues with inconsistent primary-replica data, which may be caused by the following reasons:
- Binlog Loss: The primary database fails, leading to the accidental loss of Binlog. The replica database, which relies on Binlog for data synchronization, will not be able to synchronize the latest data, causing inconsistency between the primary and replica.
- Non-deterministic Operations in the Master Database: The primary database performs non-deterministic operations, such as executing the RAND() function or operations involving timestamps. Due to the different execution timing in the replica database, this leads to the occurrence of primary-replica inconsistency.
- Unauthorized Operations: Due to operational errors or other unforeseen reasons, personnel directly connect to the replica database to perform data operations using account passwords, leading to inconsistent primary-replica data.
Problems Caused by Master-Slave Inconsistency
- Business Interruption: When the primary database fails and triggers a primary-replica switch, the replica database is upgraded to the new primary database. Due to the inconsistency between the new primary database and the original primary database, it will cause business logic confusion or interruption.
- Data Loss: If the primary-replica switch is executed without the replica database fully synchronizing the data from the primary database, it may lead to the permanent loss of that part of the data.
To avoid the above problems and ensure the stability of the MySQL primary-replica architecture and data consistency, additional monitoring and synchronization solutions are needed to address potential data inconsistencies in different scenarios. NineData's data comparison feature perfectly solves these issues.
Challenges of Existing Solutions
To verify the consistency of MySQL primary-replica database data, companies usually use some open-source tools. However, in some scenarios, these tools may face some challenges:
- Performance Overhead: Running data comparison tools on large-scale data tables may bring significant performance overhead. Especially in high-concurrency production environments, ensuring consistency may require a long execution time, thereby affecting the normal operation of the database.
- Real-time: Most open-source tools run offline and do not provide real-time monitoring. When teams must detect issues and respond quickly, this can leave consistency problems undiscovered.
- Manual Triggering: Most comparison tools require manual execution by DBAs or operations teams. In frequently changing environments, scheduled checks can be forgotten or missed, increasing the risk of data consistency issues.
- Operational Complexity: Many tools rely on command-line workflows and require multiple configuration and execution steps. Non-specialist developers or operations teams may need extra time to learn and operate them, which increases the overall cost.
NineData's Solution
NineData's database comparison feature quickly compares data between primary and replica databases. You can run one-time comparisons or schedule long-running periodic comparison tasks to track primary-replica changes in real time, discover inconsistencies, and fix them quickly. Compared to other data comparison tools, NineData provides the following advantages:
Comprehensive Comparison Features: Supports consistency comparison of database table structure and data, and provides one-time comparison, periodic comparison, quick comparison, and other comparison features suitable for various usage scenarios.
Powerful Performance: Based on large server clusters, it supports comparison of data exceeding 1 TB, with a comparison data volume of hundreds of megabytes per second.
One-click Difference Repair: Automatically generates repair SQL for inconsistent content, and inconsistent data can be repaired by simply copying and pasting, saving a lot of time and effort.
Comprehensive Data Source Support: Supports various data sources such as MySQL, SQL Server, PostgreSQL, ClickHouse, Doris, SelectDB, Redis, etc.
Visual Interface: Has a simple and intuitive user interface, which can perform data comparison without complex settings, and presents comparison results in intuitive charts and reports, making it easy for you to understand data differences.
Step One: One-minute Quick Configuration of Comparison Task

Step Two: View Comparison Results
Data Comparison

Structure Comparison

Step Three: Quick Repair of Inconsistent Content
Repair Data

Repair Structure

Step Four: Verify Repair Results
Verify Data Repair

Verify Structure Repair

Step Five: View Task Logs and Monitoring Metrics
