Updated on 2025-08-07 GMT+08:00

Data Comparison (Comparing DR Items)

Comparison Scenarios

DR item comparison: You can compare DR items to check data consistency between the service database and DR database. Currently, you can compare the following items during DR:

  • Object-level comparison: compares databases, events, indexes, tables, views, and triggers.
  • Data-level comparison is classified into row comparison and value comparison.
    • Row comparison: It helps you compare the number of rows in the tables to be synchronized. This comparison method is recommended because it is fast.
    • Value comparison: It helps you check whether data in the synchronized table is consistent. The comparison process is relatively slow.

    To ensure that the comparison results are valid, compare data during off-peak hours by select Start at a specified time or compare cold data that is infrequently modified.

When you check data consistency, compare the number of rows first. If the number of rows are inconsistent, you can then compare the data in the table to determine the inconsistent data.

Constraints

  • During a comparison, the comparison items are case sensitive. If one of the service or DR database is case insensitive and the other one is case sensitive, the comparison result may be inconsistent.
  • If DDL operations were performed on the service database, you need to compare the objects again to ensure the accuracy of the comparison results.
  • If data in the DR database is modified separately, the comparison results may be inconsistent.
  • If the encoding of the service database character type is abnormal, the database driver will convert the character type to an abnormal code point during DRS disaster recovery or comparison. As a result, the values may be consistent but the bytes may be inconsistent.
  • Currently, only tables with primary keys support value comparison. For tables that do not support value comparison, you can compare rows. Therefore, you can compare data by row or value based on scenarios.
  • The DRS task cannot be suspended during value comparison. Otherwise, the comparison task may fail.
  • To prevent resources from being occupied for a long time, DRS limits the row comparison duration. If the row comparison duration exceeds the threshold, the row comparison task stops automatically. If the service database is a relational database, the row comparison duration is limited within 60 minutes. If the service database is a non-relational database, the row comparison duration is limited within 30 minutes.
  • To avoid occupying resources, the comparison results of DRS tasks can be retained for a maximum of 60 days. After 60 days, the comparison results are automatically cleared.
  • For a DR task from MySQL or TaurusDB, virtual columns in the source database do not support value comparison. During the comparison, virtual columns are filtered out.
  • Performing DDL operations on a table during value comparison may result in a task failure. In this case, you need to perform the comparison again. You are advised to minimize DDL operations on a table during the comparison.

Impact on Databases

  • Object comparison: System tables of the source and destination databases are queried, occupying about 10 sessions. The database is not affected. However, if there are a large number of objects (for example, hundreds of thousands of tables), the database may be overloaded.
  • Row comparison: The number of rows in the source and destination databases is queried, which occupies about 10 sessions. The SELECT COUNT statement does not affect the database. However, if a table contains a large amount of data (hundreds of millions of records), the database will be overloaded and the query results will be returned slowly.
  • Value comparison: All data in the source and destination databases is queried, and each field is compared. The query pressure on the database leads to high I/O. The query speed is limited by the I/O and network bandwidth of the source and destination databases. Value comparison occupies one or two CPUs, and about 10 sessions.

Estimated Comparison Duration

  • Object comparison: Generally, the comparison results are returned within several minutes based on the query performance of the source database. If the amount of data is large, the comparison may take dozens of minutes.
  • Row comparison: The SELECT COUNT method is used. The query speed depends on the database performance.
  • Value comparison: If the database workload is not heavy and the network is normal, the comparison speed is about 5 MB/s.

Prerequisites

  • You have logged in to the DRS console.
  • A DR task has been started.

Procedure

  1. On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
  2. On the Disaster Recovery Comparison tab, compare the service and DR databases.

    1. Check the integrity of the database object.

      Click Validate Objects. On the Object-Level Comparison tab, view the comparison result of each comparison item.

      Locate a comparison item you want to view and click View Details in the Operation column.

    2. After the comparison creation task is submitted, the Data-Level Comparison tab is displayed. Click to refresh the list and view the comparison result of the specified comparison type.
    3. To view the comparison details, locate the target comparison type and click View Results in the Operation column. On the displayed page, locate a pair of service and DR databases, and click View Details in the Operation column to view detailed comparison results.
      • You can also view comparison details of canceled comparison tasks.
      • You can sort the row comparison results displayed on the current page in ascending or descending order based on the number of rows in the source database table or the destination database table.
      • If a negative number is displayed in the differences column, the number of rows in the destination database table is greater than that in the source database table. If a positive number is displayed in the differences column, the number of rows in the source database table is greater than that in the destination database table.

Data Repair (in OBT)

If there is inconsistent data in the static value comparison result, you can select the inconsistent tables on the comparison details page to repair the data. The data repair result includes repair SQL statements that can be executed in the destination database. After the repair, you can view the repair SQL details of the inconsistent rows on the repair progress details page. You can also export and download all the inconsistent SQL statements generated in this comparison, and manually execute the SQL statements in the destination database based on the site requirements. There are the following restrictions on data repair:

  1. Data repair is in restricted use. Currently, only MySQL-to-MySQL tasks are supported.
  2. If a SQL statement to be repaired is an INSERT or UPDATE statement, all columns of the inconsistent row are displayed in the repair SQL details page. The column values are the current values of the corresponding columns in the source database.
  3. Historical comparison tasks may fail to be repaired due to lack of repair information. You need to perform comparison again and then repair the inconsistent data.
  4. For each task, only the repair progress details about the latest data repair are displayed.
  5. The maximum size of a single inconsistent row is 4 MB. If the size exceeds 4 MB, the corresponding repair SQL statements fail to be generated.
  6. In the repair SQL statements generated by DRS, the time type field is based on the UTC time. If there are time fields in a table, set the session time zone to UTC+0 time zone before executing the repair SQL statements in the destination database. The following table lists the SQL statements for setting the session time zone for each database type.
  7. Exercise caution when running DELETE statements in repair SQL statements.
Table 1 SQL statements for setting the session time zone to UTC+0 time zone for each database type

Database Type

Time Zone SQL

MYSQL

SET session time_zone='+00:00';