Data synchronization method and device

By extracting and filtering incremental data in advance during the data synchronization process, data sharding technology is used to achieve full data synchronization and resumable transmission, which solves the problems of low data synchronization efficiency and poor fault tolerance in the existing technology, and improves the efficiency of data synchronization. efficiency and completeness.

WO2024174516A1PCT designated stage expired Publication Date: 2024-08-29HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD

Patent Information

Application Number
PCT/CN2023/120314
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-24
Filing Date
2023-09-21
Publication Date
2024-08-29

AI Technical Summary

Technical Problem

Existing data synchronization technology has problems such as low efficiency, poor fault tolerance, and high storage resource usage during the full data synchronization process. In particular, due to the repeated transmission of incremental data and full data, the data synchronization efficiency is low, and the full data When data synchronization is interrupted, all data needs to be resynchronized, which has low fault tolerance.

Method used

By extracting and filtering incremental data in advance during the data synchronization process, the playback of duplicate data is avoided, data sharding technology is used to achieve breakpoint resumption of full data synchronization, and snapshot resources are released during the full data synchronization stage to reduce storage usage.

Benefits of technology

It improves the efficiency and fault tolerance of data synchronization, avoids the transmission of repeated data during the data synchronization process, reduces the occupation of storage resources, and enhances the integrity and consistency of data synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023120314_29082024_PF_FP_ABST
    Figure CN2023120314_29082024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the field of data processing and provides a data synchronization method. The method is used for transmitting data of a source database to a target database. The method comprises: extracting incremental data from the source database at a first moment, wherein the incremental data is data, in the source database, that is inserted, updated or deleted after the first moment; according to a snapshot of data to be synchronized of the source database at a second moment, transmitting said data to the target database; filtering data in the incremental data repeated with said data; and returning the filtered incremental data to the target database. By filtering the incremental data, the method improves the data synchronization efficiency. In addition, according to the method, data at a full data synchronization stage can be fragmented, and concurrent transmission is performed by taking data fragments as the granularity, thereby implementing breakpoint continuous transmission at the full data synchronization stage, and improving the performance and fault tolerance of the data synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Data synchronization method and device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 24, 2023, with application number 202310165047.2 and application name “Data Synchronization Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of data processing, and more specifically, to a data synchronization method and apparatus, a computing device, a computing device cluster, a computer program product, and a computer-readable storage medium. Background Art

[0003] In application scenarios such as data disaster tolerance and backup, data synchronization between the source and target databases is required. To minimize the impact of data synchronization on the business, data synchronization must support non-stop migration, or online migration, to achieve zero business downtime during the data synchronization process.

[0004] Online migration primarily consists of three phases: structure migration, full data synchronization, and incremental data synchronization. In related technical solutions, after full data synchronization is initiated, incremental data must be extracted and saved to ensure continuity with the full data during the incremental data synchronization phase, ensuring data integrity and consistency. After full data synchronization is complete, the saved incremental data is parsed and replayed until the data in the target database is consistent with that in the source database.

[0005] However, there are duplicate parts between the incremental data and the full data, and these duplicate parts are transmitted multiple times, resulting in low data synchronization efficiency.

[0006] Summary of the Invention

[0007] The present application provides a data synchronization method, which improves the efficiency of data synchronization.

[0008] In a first aspect, a data synchronization method is provided, which is used to transfer data from a source database to a target database. The method includes: a data synchronization device extracts incremental data from the source database starting at a first moment, wherein the incremental data is data inserted, updated or deleted in the source database after the first moment; the data synchronization device transfers the data to be synchronized to the target database based on a snapshot of the data to be synchronized in the source database at a second moment, wherein the first moment is before the second moment; the data synchronization device filters data in the incremental data that is duplicated with the data to be synchronized; and the data synchronization device plays the filtered incremental data back into the target database.

[0009] The data synchronization method provided in the embodiment of the present application also filters the incremental data before replaying it. The filtered incremental data does not contain any duplicate parts of the data that has been transmitted to the target database, thereby avoiding the repeated replay of the data that has been transmitted to the target database and improving the efficiency of data synchronization. On the other hand, the related technical solution starts extracting incremental data only after the full data synchronization phase is started, which results in the missing of some incremental data. The data synchronization method provided in the embodiment of the present application starts extracting incremental data before the full data synchronization phase is started, avoiding data missing and improving the consistency and integrity of data synchronization.

[0010] In combination with the first aspect, in certain implementations of the first aspect, the source database includes multiple data shards, and the data shard to be synchronized is one of the multiple data shards.

[0011] In related technical solutions, if the full data synchronization phase is interrupted, all data can only be synchronized again, which has low fault tolerance. The data synchronization method provided in the embodiment of the present application implements breakpoint resumption in the full data synchronization phase by sharding the data in the full data synchronization phase and transmitting it at the granularity of data shards, thereby improving the fault tolerance of data synchronization. On the other hand, related technical solutions need to save snapshots of all data in the full data synchronization phase. The data synchronization method provided in the embodiment of the present application can choose to delete the snapshot of a data shard after transmitting the data shard, thereby freeing up storage resources and improving the speed of database queries.

[0012] In combination with the first aspect, in certain implementations of the first aspect, the data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized, including: the data synchronization device obtains snapshot information of the data to be synchronized; the data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data to filter the data in the incremental data that is repeated with the data to be synchronized.

[0013] The data synchronization method provided in the embodiments of the present application further filters the incremental data based on snapshot information before replaying it. The filtered incremental data does not contain any duplicates of data already transferred to the target database, thereby preventing the repeated replay of data already transferred to the target database and improving the efficiency of data synchronization.

[0014] In combination with the first aspect, in some implementations of the first aspect, the source database is a database using PostgreSQL as a data source.

[0015] In combination with the first aspect, in certain implementations of the first aspect, the method also includes: the data synchronization device determines the generation information of the incremental data; the data synchronization device adds the generation information to the transaction information of the incremental data; wherein, the data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data, including: the data synchronization device performs visibility judgment on the snapshot information and the transaction information with the generation information.

[0016] The transaction information of incremental data may not include generation information. When performing visibility judgment with the snapshot information of the full data, the transaction information of the incremental data needs to be formatted. The method provided in the embodiment of the application improves the accuracy of visibility judgment by adding generation information to the transaction information of incremental data, thereby accurately filtering incremental data and improving the efficiency of data synchronization.

[0017] In combination with the first aspect, in certain implementations of the first aspect, the data synchronization device starts to extract incremental data from the source database at a first moment, including: the data synchronization device determines a logical replication slot at the first moment, wherein the logical replication slot is used to transmit and control the incremental data, and the logical replication slot includes a site; wherein, the data synchronization device determines the generation information of the incremental data, including: the data synchronization device obtains a reference point when the site of the logical replication slot advances; the data synchronization device determines the generation information of the incremental data based on the reference point and the incremental data.

[0018] In this embodiment, a reference point is obtained when a logical replication slot advances its position. Generation information can be determined based on the reference point and incremental data, thereby ensuring visibility between snapshot information and transaction information for the incremental data of the data shard. This allows for accurate filtering of incremental data and improves data synchronization efficiency. Furthermore, the above operations only require read (select) permissions on the source database, minimizing the scope of user authorization.

[0019] In combination with the first aspect, in certain implementations of the first aspect, the data to be synchronized includes at least one record, each record corresponds to an identifier, and the method further includes: the data synchronization device obtains a snapshot of the data to be synchronized based on the identifier corresponding to at least one record of the data to be synchronized.

[0020] In an embodiment of the present application, data sharding in the full data synchronization stage is performed using the identifiers recorded in the data shards, and the resulting data shards do not overlap, and the sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0021] In combination with the first aspect, in some implementations of the first aspect, the identifier corresponding to at least one record of the data shard to be synchronized belongs to an interval.

[0022] In an embodiment of the present application, the recorded identifiers are sharded according to the intervals to which they belong, and the resulting data shards do not overlap. The sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0023] In combination with the first aspect, in certain implementations of the first aspect, the identifiers corresponding to the records of the multiple data shards do not overlap.

[0024] In an embodiment of the present application, the data of the source database is divided into multiple data shards, and the data shards do not overlap with each other. The sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0025] In combination with the first aspect, in certain implementations of the first aspect, the method is applied to a cloud data center.

[0026] In a second aspect, an embodiment of the present application provides a data synchronization device, which includes a module for implementing the first aspect or any possible implementation method of the first aspect.

[0027] In a third aspect, a computing device is provided, comprising a processor and a memory, wherein the processor is configured to execute instructions stored in the memory so that the computing device executes the data synchronization method of the first aspect or any possible implementation of the first aspect.

[0028] In a fourth aspect, a computing device cluster is provided, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the data synchronization method of the first aspect or any possible implementation of the first aspect.

[0029] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed by a computing device, enables the computing device to execute the data synchronization method of the first aspect or any possible implementation of the first aspect.

[0030] In a sixth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device cluster, the computing device cluster executes the data synchronization method of the first aspect or any possible implementation of the first aspect.

[0031] In a seventh aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer program instructions are executed by a computing device, the computing device executes the data synchronization method of the first aspect or any possible implementation of the first aspect.

[0032] In an eighth aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the data synchronization method of the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] FIG1 is a schematic diagram of a data synchronization method.

[0034] FIG2 is a system diagram of a cloud server system according to an embodiment of the present application.

[0035] FIG3 is a schematic flowchart of a data synchronization method provided in an embodiment of the present application.

[0036] FIG4 is a schematic block diagram of a data synchronization device provided in an embodiment of the present application.

[0037] FIG5 is a schematic diagram of the architecture of a computing device provided in an embodiment of the present application.

[0038] FIG6 is a schematic diagram of the architecture of a computing device cluster provided in an embodiment of the present application.

[0039] FIG7 is a schematic diagram of a connection between two computing devices via a network provided in an embodiment of the present application.

[0040] FIG8 is a schematic flowchart of another data synchronization method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] The technical solution in this application will be described below with reference to the accompanying drawings.

[0042] This application will present various aspects, embodiments, or features in the context of systems that may include multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and / or may not include all of the devices, components, modules, etc. discussed in conjunction with the figures. Furthermore, combinations of these aspects may also be used.

[0043] Additionally, in the embodiments of this application, words such as "exemplary" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner.

[0044] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field will know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0045] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0046] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of this application.

[0047] Data synchronization: The process of synchronizing data from a source database to a target database. Data synchronization does not affect the data in the source database.

[0048] Full data: When the data synchronization process starts, the data existing in the source database is called full data.

[0049] Incremental data: After the data synchronization process starts, the source database continues to write data, so the newly written data is called incremental data. Incremental data can include data insertion, modification, deletion, etc.

[0050] Transaction snapshot: A transaction snapshot can be a static dataset viewed by a transaction over a period of time. A transaction snapshot can correspond to a database version. For example, a transaction snapshot can be a read transaction snapshot. In this embodiment, the read transaction snapshot of a data shard is referred to as a snapshot of that data shard.

[0051] Sharding: Also known as data sharding, for example, the data in the database is divided into multiple parts, each part is called a shard.

[0052] Structured Query Language (SQL): SQL is a database language with multiple functions such as data manipulation and data definition. This language is interactive and can provide greater convenience for users.

[0053] PostgreSQL: PostgreSQL is an open source client / server relational database system.

[0054] GaussDB: GaussDB is an enterprise-grade distributed relational database. It has the capacity to handle complex enterprise-grade transactions with mixed loads, supports distributed transactions, and deploys across availability zones (AZs) in the same city with zero data loss. GaussDB also boasts key capabilities such as high cloud availability, high reliability, high security, elastic scaling, one-click deployment, rapid backup and recovery, and monitoring and alerting, providing enterprises with comprehensive, stable, reliable, scalable, and high-performance enterprise-grade database services.

[0055] MySQL: MySQL is a relational database management system. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL uses a dual licensing policy, with both a community edition and a commercial edition. MySQL is characterized by its small size, high speed, low total cost of ownership, and open source code.

[0056] The present invention provides a data synchronization method that can be applied to a cloud data center. The following first introduces the relevant technical solutions.

[0057] FIG1 shows a schematic diagram of a data synchronization method.

[0058] As shown in Figure 1, data synchronization can include three phases: structure migration 110, full data synchronization 120, and incremental data synchronization 130. During structure migration 110, structure query 111 and structure replay 112 can be performed. For example, a structured query language (such as SQL statements such as "show create table;") can be executed on the source database to obtain the source database's table structure, and the table structure can be replayed into the target database to achieve structure migration.

[0059] During the full data synchronization phase 120, incremental data extraction and storage (incremental extraction 131) must be initiated. This allows the incremental data to be joined with the full data during the incremental data synchronization phase 130 to ensure data integrity and consistency. For example, the server's master process can be controlled to connect to the database, create a logical replication slot for transmitting and controlling incremental data, and export the snapshot name of the transaction that created the slot.

[0060] The full data synchronization phase 120 involves performing a full data query 121 and a full data transfer 122. For example, creating a replication slot can be considered a full data query 121. The control server's child process imports the snapshot of the slot creation transaction based on the snapshot name and performs a full data transfer 122.

[0061] Incremental Data Synchronization Phase 130 After the full data synchronization phase 120 , the server can write the incremental data in the logical replication slot to the target database until the source database and the target database are synchronized. This process can also be called incremental data playback 132 .

[0062] However, in the data synchronization method shown in FIG1 , there are duplicate parts between the incremental data and the full data, and these duplicate parts are transmitted multiple times, resulting in low efficiency of data synchronization.

[0063] On the other hand, if full data synchronization is interrupted, the only option is to re-establish the logical replication slot and resynchronize all data, resulting in poor fault tolerance for data synchronization. Furthermore, the data synchronization device must maintain a snapshot of the full data until full data synchronization is complete. During this period, because the synchronization granularity is the entire full data set, the data synchronization device does not clean up data visible in the snapshot, which consumes storage resources, causes tablespace bloat, and slows SQL queries.

[0064] The following introduces the application scenarios of the embodiments of the present application. It should be noted that the scenario shown in Figure 2 is only an example and does not constitute a limitation to the present application.

[0065] Figure 2 is a system diagram of a cloud server system according to an embodiment of the present application. As shown in Figure 2, a cloud management platform 210 is used to manage the infrastructure that provides multiple cloud services. The infrastructure includes multiple cloud data centers, each of which includes multiple servers, each of which includes cloud service resources to provide corresponding cloud services to tenants.

[0066] The cloud management platform 210 provides an access interface (such as an interface or application program interface (API)). Tenants can use the client to remotely access the access interface to register a cloud account and password on the cloud management platform and log in to the cloud management platform. After the cloud management platform successfully authenticates the cloud account and password, the tenant can further pay to select and purchase a virtual machine with specific specifications (processor, memory, disk) on the cloud management platform. After the payment is successful, the cloud management platform provides the remote login account and password for the purchased virtual machine. The client can remotely log in to the virtual machine and install and run the tenant's applications in the virtual machine. Tenants of cloud services can include individuals, enterprises, schools, hospitals, administrative agencies, etc.

[0067] The functions of the cloud management platform 210 include, but are not limited to, a user console, computing management services, network management services, storage management services, authentication services, and image management services. The user console provides an interface or API for interacting with tenants. The computing management service is used to manage servers running virtual machines and containers, as well as bare metal servers. The network management service is used to manage network services (such as gateways, firewalls, etc.). The storage management service is used to manage storage services (such as data bucket services). The authentication service is used to manage tenant accounts and passwords. The image management service is used to manage virtual machine images. Tenants can use the client 230 to log in to the cloud management platform 210 through the Internet 220 to manage the rented cloud services.

[0068] Figure 3 illustrates a data synchronization method provided by an embodiment of the present application, which is used to transfer data from a source database to a target database. This method filters out portions of incremental data that duplicate the full data, preventing duplicate transmission of incremental data and improving data synchronization efficiency. For example, the method illustrated in Figure 3 can be executed by a data synchronization device, such as a server.

[0069] It should be noted that this application does not limit the specific form of the source database or the target database. For example, the source database can be a database with PostgreSQL as the data source, and the target database can be a database with PostgreSQL, MySQL, or GaussDB as the data source. For example, the method shown in Figure 3 can be applied to any data center, such as a cloud data center.

[0070] On the other hand, the sum of the data shards in the embodiments of the present application is different from the full data in the relevant technical solutions. In the relevant technical solutions, after the process of full data transmission is started, the full data will not change. However, if in the scenario of shard transmission, the data is transmitted piece by piece, the data shards transmitted later may change relative to when the data transmission is started. However, for the convenience of comparison with the relevant technical solutions, the concept of full data is still used below. The full data synchronization phase mentioned below, in the scenario of shard transmission, refers to the stage of transferring each data shard from the source database to the target database. If the shard transmission is not specifically stated, the full data can be either the static data already in the source database when the full data synchronization phase is started, or the sum of each data shard.

[0071] S310 , the data synchronization device starts extracting incremental data from the source database at a first moment, wherein the incremental data is data inserted, updated, or deleted in the source database after the first moment.

[0072] During data synchronization, to ensure zero service downtime, the source database can continue receiving new data. This new data is considered incremental data and is played back to the target database after the full data synchronization phase to ensure consistency between the source and target databases. This includes inserts, updates, and deletes.

[0073] Starting to extract incremental data from the source database is a "startup" action. This is because incremental data is written by users based on business needs during the data synchronization process. In other words, when the data synchronization server begins extracting incremental data from the source database, the source database may not already have any incremental data. Therefore, extracting incremental data is a continuous process that only ends when data synchronization is complete.

[0074] For example, when you start extracting incremental data from the source database, you can start a logical replication slot. If a logical replication slot does not exist, you can first create one. Then, extract incremental data from the source database into the logical replication slot.

[0075] S320: The data synchronization device transfers the data to be synchronized to the target database according to a snapshot of the data to be synchronized of the source database at a second moment, wherein the first moment is before the second moment.

[0076] A snapshot consists of a visible version of at least one record. The snapshot referred to in the embodiments of the present application may be a read transaction snapshot. For example, a read transaction is initiated on the source database at the repeatable read isolation level to generate a snapshot of the data in the source database. If the data in the source database is modified between the start and commit of the read transaction, the modified records may be referred to as incremental data, but the snapshot of the data in the source database does not include these modified records. In other words, the snapshot of the data in the source database may include the static data at the time the read transaction is initiated.

[0077] A record is a relatively complete set of information in a database. A record can also be called a row.

[0078] For example, the data synchronization server may transfer the data to be synchronized to the target database based on a snapshot of the data to be synchronized. In other words, the data synchronization server may transfer the records of the source database to the target database based on a snapshot of the data in the source database.

[0079] In some embodiments, the data synchronization server may obtain a snapshot of all data in the source database at the second moment. That is, the snapshot includes all static data that existed in the source database at the time the snapshot was obtained. Subsequently, the data synchronization server executes S320 to transfer all data in the source database to the target database.

[0080] Optionally, the source database includes multiple data shards, and the data to be synchronized is one of the multiple data shards.

[0081] For example, the first data shard is one of the multiple data shards, and the second data shard is another data shard among the multiple data shards.

[0082] The first data shard includes part of the data in the source database. For example, the first data shard may include part of the records in the source database.

[0083] It can be understood that the source database includes multiple data shards, and the first data shard is one of the multiple data shards.

[0084] For example, a read transaction is initiated on a first data shard under the Repeatable Read isolation level to generate a snapshot of the first data shard. If the first data shard is modified between the start and commit of the read transaction, the modified records can be called incremental data, but the snapshot of the first data shard does not include these modified records. In other words, the snapshot of the first data shard may include the static data at the time the read transaction was initiated.

[0085] In some embodiments, records in the source database may be logically sharded based on identifiers. For example, the identifier may be a primary key. Multiple primary keys are divided into several intervals according to a certain rule, and the records corresponding to the primary keys in each interval constitute a shard.

[0086] Among them, the primary key can also be called the primary keyword, which is a field in the database. The value of the primary key can be used to uniquely indicate a record in the database.

[0087] In other embodiments, the full data can be arbitrarily sharded, for example, a shard can be formed by grouping records corresponding to the value of a certain field.

[0088] Exemplarily, obtaining a snapshot of the first data shard may involve querying (or reading) records to generate a snapshot of the first data shard. For example, records with primary key values ​​between 1 and 1,000,000 may be queried to generate a snapshot of records with primary key values ​​between 1 and 1,000,000. This snapshot may be referred to as the snapshot of the first data shard.

[0089] It is understood that the identifier of the record in the embodiment of the present application is not limited to the primary key, and can also be, for example, a unique index. The data synchronization server can transfer the first data shard to the target database based on the snapshot of the first data shard. In other words, the data synchronization server can transfer the record of a data shard to the target database based on the snapshot of the data shard.

[0090] It can be understood that in the process of obtaining a snapshot of the first data shard and transmitting the first data shard to the target database based on the snapshot of the first data, if an interruption occurs and the transmission of the first data shard fails, the data synchronization server only needs to retransmit the first data shard, and the previously transmitted data shard will not be affected.

[0091] In the related technical solutions, if the full data synchronization stage is interrupted, all data can only be synchronized again, and the fault tolerance is low. The data synchronization method provided in the embodiment of the present application implements breakpoint resumption in the full data synchronization stage by sharding the data in the full data synchronization stage and transmitting it with the data shard as the granularity, thereby improving the fault tolerance of data synchronization. On the other hand, the related technical solutions need to save snapshots of all data in the full data synchronization stage. The data synchronization method provided in the embodiment of the present application can choose to delete the snapshot of a data shard after transmitting a data shard, thereby releasing storage resources and improving the speed of database queries. Optionally, the data to be synchronized includes at least one record, and each record corresponds to an identifier. The method also includes: the data synchronization device obtains a snapshot of the data to be synchronized based on the identifier corresponding to at least one record of the data to be synchronized.

[0092] An identifier can be a primary key or a unique index. One record can correspond to one identifier.

[0093] A unique index can speed up access to the database and is used to query records. Unlike ordinary indexes, unique index values ​​are unique but allow null values.

[0094] It is understood that the data synchronization server can determine the identifier corresponding to at least one record in a data shard. For example, suppose a user defines a query rule to sequentially query by primary key value, querying 500,000 records at a time. In this case, the data synchronization server can calculate the primary key value of the current query based on the primary key value of the previous query to determine the identifier corresponding to the record in this data shard.

[0095] This application does not limit the data sharding method in the full data synchronization phase. In addition to the above-mentioned sharding scheme by interval, sharding can also be performed in other ways. For example, the data can be sharded by the last digit of the primary key value, and the records with the last digit of the primary key value being 1 can be composed into a data shard. When obtaining a snapshot of the data shard, the records with the last digit of the primary key value being 1 can be queried to generate a snapshot of the data shard. For another example, the data can be divided according to the size of the data, and a table with a larger data volume can be divided into multiple shards, and a table with a smaller data volume can be used as a single shard.

[0096] For example, the data synchronization server can query based on the identifier corresponding to at least one record of the first data shard to obtain a snapshot of the first data shard. In other words, the data in the full data synchronization phase can be sharded based on the identifier, including the primary key or unique identifier, so that the multiple data shards obtained do not overlap and the sum of the data shards is sufficient to constitute the data in the full data synchronization phase.

[0097] In an embodiment of the present application, data sharding in the full data synchronization stage is performed using the identifiers recorded in the data shards, and the resulting data shards do not overlap, and the sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0098] Optionally, the identifier corresponding to the at least one record of the data to be synchronized belongs to an interval.

[0099] The identifiers corresponding to the records in the data shard belong to an interval. That is, the identifiers can be divided into intervals, and the records corresponding to the identifiers in an interval constitute a data shard.

[0100] For example, records corresponding to primary key values ​​between 300,000 and 700,000 are used as the first data shard. Thus, 300,000 to 700,000 is the interval to which the identifier corresponding to the at least one record belongs.

[0101] In an embodiment of the present application, the recorded identifiers are sharded according to the intervals to which they belong, and the resulting data shards do not overlap. The sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0102] Optionally, the identifiers corresponding to the records of the multiple data shards do not overlap.

[0103] For example, relative to the first data shard, the second data shard is another data shard among the multiple data shards of the source database. The identifier of the second data shard does not overlap with the identifier of the first data shard, that is, the records of the first data shard do not overlap with the records of the second data shard.

[0104] It can be understood that multiple data shards are not limited to the first data shard and the second data shard. For example, there can also be a third data shard, a fourth data shard, etc. The present application does not limit the specific number of multiple data shards. In other words, the present application does not limit how many shards the data in the source database is divided into.

[0105] In an embodiment of the present application, the data of the source database is divided into multiple data shards, and the data shards do not overlap with each other. The sum of the data shards constitutes the data in the full data synchronization stage, thereby improving the efficiency and integrity of data synchronization.

[0106] S330: The data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized.

[0107] Incremental data may duplicate data to be synchronized with the source database. Duplicate data can come from two sources, as described in detail below with examples.

[0108] Source 1: If incremental data extraction begins before full data synchronization, then between the time incremental data extraction begins and the time a snapshot of the source database's data to be synchronized is obtained, some data in the source database will be both incremental and full data, resulting in duplication of incremental data and source database data.

[0109] For example, suppose a record is modified between a first time point and a second time point. Since the record was modified after incremental synchronization was started, it is considered incremental data and will be extracted as such. On the other hand, since the record was modified before the second time point, the modified data will be visible when full synchronization is started. In other words, when a snapshot of the source database data is obtained, the snapshot will contain the modified data. Therefore, the modified data is considered both incremental and full data, resulting in duplication of incremental data.

[0110] It can be understood that in the case of source 1, if the data of the source database is sharded, data duplication may occur in any data shard of the source database.

[0111] Source 2: In the data sharding scenario, assume that after the first data shard is transmitted, a snapshot of the second data shard is obtained, wherein the second data shard is another data shard of the source database, and when the first data shard is transmitted, the extraction of incremental data is already started. If the second data shard is modified when the first data shard is transmitted, the modified data in the second data shard will be extracted as incremental data. When the snapshot of the second data shard is obtained, the modified data in the second data shard is visible, that is, when the snapshot of the second data shard is obtained, the snapshot contains the modified data of the second data shard. Therefore, the modified part of the first data shard belongs to both incremental data and full data, resulting in duplication of incremental data.

[0112] Source 1 is because the incremental data is started before the full data synchronization phase is started. Source 2 is because the full data is transmitted in shards, and modifications to the later transmitted data shards are visible.

[0113] Optionally, the data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized, including: the data synchronization device obtains snapshot information of the data to be synchronized; the data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data to filter the data in the incremental data that is repeated with the data to be synchronized.

[0114] Snapshot information includes xmin, xmax, and xip_list, which can be used to determine the visibility of transaction information. xmin refers to the earliest active transaction information (txid). Transactions older than xmin have either been committed and are visible, or rolled back and are dead. xmax refers to the first unassigned transaction information. Transactions greater than or equal to xmax have not yet started when the snapshot of the first data shard is taken, and therefore are invisible. xip_list refers to the active transaction information at the time the snapshot is taken. xip_list includes active transaction information between xmin and xmax.

[0115] It should be noted that snapshots and snapshot information have different functions. Snapshots are used to transmit data, while snapshot information is used to determine visibility.

[0116] Transaction information can also be called a transaction number or transaction ID. Transaction information can be a 32-bit integer, starting at 3 (decimal). During the creation of a new transaction, transaction information is continuously consumed. When consumed to a certain extent, the transaction information rolls back to 3.

[0117] Transaction information can also be a 64-bit integer. The first 32 bits are called generation information. When the transaction information is rolled back, the generation information value is increased by 1.

[0118] Based on the snapshot information, you can determine the visibility of incremental data transaction information and filter the incremental data. For example, based on the transaction information in the xip_list in the snapshot information, try to read the incremental data transaction information. If you can read it, it means that the data is visible and needs to be filtered out and not replayed. If you cannot read it, it means that the data is invisible and needs to be replayed and retained.

[0119] The data synchronization method provided in the embodiments of the present application further filters the incremental data based on snapshot information before replaying it. The filtered incremental data does not contain any duplicates of data already transferred to the target database, thereby preventing the repeated replay of data already transferred to the target database and improving the efficiency of data synchronization.

[0120] Optionally, the method also includes: the data synchronization device determines the generation information of the incremental data; the data synchronization device adds the generation information to the transaction information of the incremental data; wherein, the data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data, including: the data synchronization device performs visibility judgment on the snapshot information and the transaction information with the generation information.

[0121] For example, if incremental data is extracted from a logical replication slot in PostgreSQL, the transaction information in the incremental data is 32 bits long and does not include generation information. In contrast, the transaction information in the snapshot is 64 bits long and includes generation information. To verify feasibility between snapshot information and incremental data transaction information, the incremental data format must be converted. Specifically, the 32-bit generation information is appended to the original incremental data transaction information to form 64-bit transaction information, which can then be compared with the snapshot information for visibility verification.

[0122] The transaction information of incremental data may not include generation information. When performing visibility judgment with the snapshot information of the full data, the transaction information of the incremental data needs to be formatted. The method provided in the embodiment of the application improves the accuracy of visibility judgment by adding generation information to the transaction information of incremental data, thereby accurately filtering incremental data and improving the efficiency of data synchronization.

[0123] Optionally, the data synchronization device starts to extract incremental data from the source database at a first moment, including: the data synchronization device determines a logical replication slot at the first moment, wherein the logical replication slot is used to transmit and control the incremental data, and the logical replication slot includes a site; wherein, the data synchronization device determines the generation information of the incremental data, including: the data synchronization device obtains a reference point when the site of the logical replication slot advances; the data synchronization device determines the generation information of the incremental data based on the reference point and the incremental data.

[0124] A logical replication slot may include a location, which may indicate a log sequence number (LSN). The location is also used to indicate that data before the location can be cleared, while data after the location needs to be persisted.

[0125] Advancing a site may increase the LSN indicated by the site so that more data can be cleared.

[0126] When a site is advanced, a 64-bit transaction information can be obtained as a reference point. The first 32 bits of this transaction information are generation information. For example, the txid_current instruction can be used to obtain transaction information as a reference point. txid_current is used to obtain the current transaction information. If the current transaction does not have transaction information, a new transaction information is assigned.

[0127] After obtaining a piece of incremental data, the generation information of this piece of incremental data can be determined based on the base point and the incremental data. Due to the database's rollback mechanism, the base point and the generation information of the incremental data are the same or adjacent, so the generation information of this piece of incremental data can be calculated.

[0128] In this embodiment, a reference point is obtained when a logical replication slot advances its position. Generation information can be determined based on the reference point and incremental data, thereby ensuring visibility between snapshot information and transaction information for the incremental data of the data shard. This allows for accurate filtering of incremental data and improves data synchronization efficiency. Furthermore, the above operations only require read (select) permissions on the source database, minimizing the scope of user authorization.

[0129] S340: The data synchronization device plays back the filtered incremental data into the target database.

[0130] Playing back the filtered incremental data to the target database involves executing the incremental data's transactions on the target database. This means that modifications made to the source database during the full data synchronization phase can be made to the target database to achieve consistency between the source and target databases.

[0131] Optionally, the source database is a database using PostgreSQL as a data source.

[0132] The data synchronization method provided in the embodiment of the present application also filters the incremental data before replaying it. The filtered incremental data does not contain data that is repeated with the first data shard, thereby avoiding the data that has been transferred to the target database from being repeatedly replayed, and improving the efficiency of data synchronization. On the other hand, the related technical solution starts extracting incremental data only after the full data synchronization phase is started, which results in the loss of some incremental data. The data synchronization method provided in the embodiment of the present application starts extracting incremental data before the full data synchronization phase is started, avoiding data loss and improving the consistency and integrity of data synchronization.

[0133] The method embodiment of the present application is described in detail above in conjunction with Figure 3. The following describes the device embodiment of the present application. The device embodiment corresponds to the method embodiment, so for parts not described in detail, please refer to the previous method embodiments. The device can implement any possible implementation method of the above method.

[0134] The present application also provides a data synchronization device 400, as shown in Figure 4, the device 400 includes: an extraction module 410, used to extract incremental data from the source database starting at a first moment, wherein the incremental data is data inserted, updated or deleted in the source database after the first moment; a transmission module 420, used to transmit the data to be synchronized to the target database based on a snapshot of the data to be synchronized in the source database at a second moment, wherein the first moment is before the second moment; a filtering module 430, used to filter data in the incremental data that is repeated with the data to be synchronized; and a playback module 440, used to play back the filtered incremental data into the target database.

[0135] The data synchronization device 400 shown in Figure 4 may be a data synchronization server, and the device 400 may be applied to a data center. This application does not limit the data center and may be applied to any data center, such as a cloud data center.

[0136] The extraction module 410, transmission module 420, filtering module 430, and playback module 440 can all be implemented via software or hardware. For example, the following describes the implementation of the extraction module 410, taking the extraction module 410 as an example. Similarly, the implementation of the transmission module 420, filtering module 430, and playback module 440 can refer to the implementation of the extraction module 410.

[0137] As an example of a software functional unit, the extraction module 410 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the extraction module 410 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.

[0138] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.

[0139] As an example of a hardware functional unit, extraction module 410 may include at least one computing device, such as a server. Alternatively, extraction module 410 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0140] The multiple computing devices included in the extraction module 410 can be distributed in the same region or in different regions. The multiple computing devices included in the extraction module 410 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the extraction module 410 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.

[0141] It should be noted that, in other embodiments, the extraction module 410 can be used to execute any step in the data synchronization method, the transmission module 420 can be used to execute any step in the data synchronization method, the filtering module 430 can be used to execute any step in the data synchronization method, and the playback module 440 can be used to execute any step in the data synchronization method. The steps that the extraction module 410, transmission module 420, filtering module 430, and playback module 440 are responsible for implementing can be specified as needed. By having the extraction module 410, transmission module 420, filtering module 430, and playback module 440 respectively implement different steps in the data synchronization method, the full functionality of the data synchronization device is realized.

[0142] This application also provides a computing device 500. As shown in Figure 5, computing device 500 includes a bus 502, a processor 504, a memory 506, and a communication interface 508. Processor 504, memory 506, and communication interface 508 communicate with each other via bus 502. Computing device 500 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 500.

[0143] Bus 502 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG5 shows a single line, but this does not imply a single bus or type of bus. Bus 502 may include a path for transmitting information between various components of computing device 500 (e.g., memory 506, processor 504, and communication interface 508).

[0144] The processor 504 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0145] The memory 506 may include volatile memory, such as random access memory (RAM). The memory 506 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0146] The memory 506 stores executable program code, which the processor 504 executes to implement the functions of the aforementioned extraction module 410, transmission module 420, filtering module 430, and playback module 440, thereby implementing the data synchronization method. In other words, the memory 506 stores instructions for executing the data synchronization method.

[0147] The communication interface 508 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 500 and other devices or a communication network.

[0148] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0149] As shown in Figure 6, the computing device cluster includes at least one computing device 500. The memory 506 in one or more computing devices 500 in the computing device cluster may store the same instructions for executing the data synchronization method.

[0150] In some possible implementations, the memory 506 of one or more computing devices 500 in the computing device cluster may also store partial instructions for executing the data synchronization method. In other words, the combination of one or more computing devices 500 can jointly execute the instructions for executing the data synchronization method.

[0151] It should be noted that the memory 506 in different computing devices 500 in the computing device cluster can store different instructions, each for executing a portion of the functions of the data synchronization apparatus. In other words, the instructions stored in the memory 506 in different computing devices 500 can implement the functions of one or more of the extraction module 410, transmission module 420, filtering module 430, and playback module 440.

[0152] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network (WAN) or a local area network (LAN), among others. FIG. 7 illustrates a possible implementation. As shown in FIG. 7 , two computing devices 500A and 500B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 506 in the computing device 500A stores instructions for executing the functions of the extraction module 410 and the transmission module 420. Simultaneously, the memory 506 in the computing device 500B stores instructions for executing the functions of the filtering module 430 and the playback module 440.

[0153] The connection method between the computing device clusters shown in Figure 7 can be considered to be that the data synchronization method provided in this application requires a large amount of transmission of full data and filtered incremental data, so the functions implemented by the filtering module 430 and the playback module 440 are considered to be handed over to the computing device 500B for execution.

[0154] It should be understood that the functionality of the computing device 500A shown in FIG7 may also be implemented by multiple computing devices 500. Similarly, the functionality of the computing device 500B may also be implemented by multiple computing devices 500.

[0155] The present application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similar to the connection methods of the computing device clusters in Figures 6 and 7. However, the memory 506 in one or more computing devices 500 in this computing device cluster can store the same instructions for executing the data synchronization method.

[0156] In some embodiments, the memory 506 of one or more computing devices 500 in the computing device cluster may also store partial instructions for executing the data synchronization method. In other words, the combination of one or more computing devices 500 can jointly execute the instructions for executing the data synchronization method.

[0157] The present application also provides a computer program product including instructions. This computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, it implements a method for synchronizing data on the at least one computing device.

[0158] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device, or a data storage device such as a data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the data synchronization method.

[0159] Figure 8 shows another data synchronization method provided by an embodiment of the present application. Figure 8 uses PostgreSQL as an example for illustration.

[0160] 8 , a source database 810 may include full data 811 and incremental data 812 , wherein the full data referred to in the embodiments of the present application refers to the data existing in the source database after the data synchronization process is started.

[0161] Before the full synchronization is started, the incremental extraction module 820 can start the incremental extraction. Specifically, a non-temporary logical replication slot 821 can be started. If the logical replication slot 821 does not exist, a logical replication slot 821 will be created first.

[0162] Due to the lack of generation information in the transaction information of incremental data, visibility cannot be directly judged with the transaction snapshot information obtained during the full data synchronization phase.

[0163] The transaction information conversion component 822 of the incremental extraction module 820 retrieves a transaction information as a reference point through the corresponding PostgreSQL interface when reading the incremental data again after each advancement. Based on this reference point, it calculates the generation information of the incremental data's transaction information. Specifically, based on PostgreSQL's rollback mechanism, the generation of the incremental data's transaction information is the same as or adjacent to the reference point. By comparing the lower 32-bit transaction number of the reference point with the transaction number of the incremental data, it can be determined whether the incremental data's generation is the same as or adjacent to the generation of the reference point, thereby calculating the generation information of the incremental data's transaction information.

[0164] The generation information is added to the transaction information of the incremental data, thereby converting the transaction information of the incremental data into a format that can be used for visibility judgment.

[0165] In the full-data transfer module 830, data shards are used as the minimum unit of read, with each read transaction responsible for reading one data shard. The full-data transfer module may include a sharding component 831, which divides the full data into multiple data shards according to certain rules and forms query conditions. For example, the sharding component can be divided by intervals; tables that cannot be divided or have a small amount of data can be used as a single data shard. The full-data transfer component 832 is used to transfer the read data shards to the target database 850.

[0166] In some embodiments, multiple data shards can be transmitted in parallel, improving data synchronization efficiency. If the full data synchronization phase is interrupted, the already transmitted data shards do not need to be retransmitted, achieving the goal of resuming data transmission at the data shard granularity.

[0167] PostgreSQL automatically generates a snapshot for each query and provides an API for retrieving snapshot information. The snapshot component of the full-data transfer module explicitly initiates a transaction with the repeatable read isolation level each time a data shard is read. All queries within the transaction will use the same snapshot information, which is temporarily stored.

[0168] The incremental playback module 840 may include a data filtering component 841. Before replaying each incremental data entry, the component filters the data by comparing the transaction information of the incremental data with the snapshot information of the corresponding full data shard. If the incremental data entry is visible to the snapshot of the full shard, the incremental playback component 842 will no longer replay the data entry. Otherwise, the incremental playback component 842 will replay the data entry to the target database 850. This precise filtering of transaction snapshot information prevents duplicate playback of already synchronized incremental data.

[0169] The data synchronization method provided in the embodiment of the present application starts incremental data extraction before the full data synchronization stage, and combines it with filtering incremental data to decouple the reading of full data from the creation of logical replication slots, avoiding data loss, data conflicts, table locking, and long-term snapshot holding, thereby reducing the impact on the source database business.

[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.

Claims

1. A data synchronization method, It is characterized in that The method is used to transfer data from a source database to a target database, and the method comprises: The data synchronization device starts extracting incremental data from the source database at a first moment, wherein the incremental data is data inserted, updated or deleted in the source database after the first moment; The data synchronization device transmits the data to be synchronized to the target database according to a snapshot of the data to be synchronized of the source database at a second moment, wherein the first moment is before the second moment; The data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized; The data synchronization device plays back the filtered incremental data into the target database.

2. The method according to claim 1, It is characterized in that The source database includes multiple data shards, and the data to be synchronized is one of the multiple data shards.

3. The method according to claim 1 or 2, It is characterized in that The data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized, including: The data synchronization device obtains snapshot information of the data to be synchronized; The data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data to filter out data in the incremental data that is repeated with the data to be synchronized.

4. The method according to any one of claims 1 to 3, It is characterized in that The source database is a database using PostgreSQL as a data source.

5. The method according to claim 3, It is characterized in that Also includes: The data synchronization device determines the generation information of the incremental data; The data synchronization device adds the generation information to the transaction information of the incremental data; The data synchronization device performs visibility judgment on the snapshot information and the transaction information of the incremental data, including: The data synchronization device performs visibility judgment on the snapshot information and the transaction information with generation information.

6. The method according to claim 5, It is characterized in that The data synchronization device starts extracting incremental data from the source database at a first moment, including: The data synchronization device determines a logical replication slot at the first moment, wherein the logical replication slot is used to transmit and control the incremental data, and the logical replication slot includes a site; The data synchronization device determines the generation information of the incremental data, including: The data synchronization device acquires a reference point when advancing at the location of the logical replication slot; The data synchronization device determines generation information of the incremental data according to the reference point and the incremental data.

7. The method according to any one of claims 2 to 6, It is characterized in that The data to be synchronized includes at least one record, each record corresponds to an identifier, and the method further includes: The data synchronization device obtains a snapshot of the data to be synchronized according to an identifier corresponding to at least one record of the data to be synchronized.

8. The method according to claim 7, It is characterized in that The identifier corresponding to at least one record of the data to be synchronized belongs to an interval.

9. The method according to claim 7 or 8, It is characterized in that The identifiers corresponding to the records of the multiple data shards do not overlap.

10. The method according to any one of claims 1 to 9, It is characterized in that The method is applied to a cloud data center.

11. A data synchronization device, It is characterized in that The device is used to transfer data from a source database to a target database, and the device comprises: an extraction module, configured to extract incremental data from the source database starting at a first moment, wherein the incremental data is data inserted, updated or deleted from the source database after the first moment; a transmission module, configured to transmit the data to be synchronized to the target database according to a snapshot of the data to be synchronized of the source database at a second moment, wherein the first moment is before the second moment; A filtering module, used to filter data in the incremental data that is duplicated with the data to be synchronized; The playback module is used to play back the filtered incremental data into the target database.

12. The device according to claim 11, It is characterized in that The source database includes multiple data shards, and the data to be synchronized is one of the multiple data shards.

13. The device according to claim 11 or 12, It is characterized in that The filtering module is specifically used for: Obtaining snapshot information of the data to be synchronized; A visibility judgment is performed on the snapshot information and the transaction information of the incremental data to filter out data in the incremental data that is repeated with the data to be synchronized.

14. The device according to any one of claims 11 to 13, It is characterized in that The source database is a database using PostgreSQL as a data source.

15. The device according to claim 13, It is characterized in that Also includes: A conversion module, used to determine generation information of the incremental data; The conversion module is also used to add the generation information to the transaction information of the incremental data; The filtering module is specifically used to perform visibility judgment on the snapshot information and the transaction information with generation information.

16. The device according to claim 15, It is characterized in that The extraction module is specifically used to determine a logical replication slot at the first moment, wherein the logical replication slot is used to transmit and control the incremental data, and the logical replication slot includes a site; Wherein, the conversion module is specifically used for: When the position of the logical replication slot is advanced, obtaining a reference point; Generation information of the incremental data is determined based on the reference point and the incremental data.

17. The device according to any one of claims 12 to 16, It is characterized in that The data to be synchronized includes at least one record, each record corresponds to an identifier, and the device further includes: The acquisition module is used to acquire a snapshot of the data to be synchronized according to an identifier corresponding to at least one record of the data to be synchronized.

18. The device according to claim 17, It is characterized in that The identifier corresponding to at least one record of the data to be synchronized belongs to an interval.

19. The device according to claim 17 or 18, It is characterized in that The identifiers corresponding to the records of the multiple data shards do not overlap.

20. The device according to any one of claims 11 to 19, It is characterized in that The device is applied to a cloud data center.

21. A computing device, It is characterized in that The method comprises a processor and a memory, wherein the processor is configured to execute instructions stored in the memory so that the computing device executes the method according to any one of claims 1 to 10.

22. A computing device cluster, It is characterized in that comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 10.

23. A computer program product comprising instructions, It is characterized in that When the instructions are executed by a computing device, the computing device is caused to perform the method according to any one of claims 1 to 10.

24. A computer program product comprising instructions, It is characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the method according to any one of claims 1 to 10.

25. A computer-readable storage medium, It is characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a computing device, the computing device performs the method as claimed in any one of claims 1 to 10.

26. A computer-readable storage medium, It is characterized in that The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Full-amount data synchronization method and device, equipment and medium

    CN113094442A

  • Data synchronization method and system

    CN113535856A

  • Data verification method and device, electronic equipment and computer readable storage medium

    CN114896641A

  • Automated online upgrade of database replication

    US20220188278A1

Cited By

  • Data migration method and device and electronic equipment

    CN118796801A

  • Method and system for synchronizing openGauss database data to heterogeneous database and electronic equipment

    CN121579591A

  • Method, system and electronic equipment for synchronizing openGauss database data to heterogeneous databases

    CN121579591B

  • Data migration method and apparatus, and electronic device, computer-readable storage medium and computer program product

    WO2026149046A1