Data synchronization method and device
By extracting and filtering incremental data in advance, and using data sharding technology to achieve full data synchronization and resumable transmission, it solves the problems of low data synchronization efficiency and poor fault tolerance in the existing technology, and improves the efficiency and consistency of data synchronization.
Patent Information
- Application Number
- CN202310165047.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2024-09-03
AI Technical Summary
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, repeated transmission of incremental data and full data results in low efficiency, and full data synchronization interruption requires re-synchronization of all data. Less fault tolerance.
By extracting and filtering incremental data in advance during the data synchronization process to avoid repeated data playback, data sharding technology is used to achieve breakpoint resume transmission of full data synchronization, and snapshots are released after the data shards are transmitted to reduce storage resource usage.
It improves the efficiency and consistency of data synchronization, reduces repeated data transmission, enhances fault tolerance and storage resource utilization, and reduces the impact on database queries.
Smart Images

Figure CN118585577A
Abstract
Description
Technical Field
[0001] 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
[0002] In application scenarios such as data disaster tolerance and backup, data synchronization needs to be achieved between the source database and the target database. In order to reduce the impact of data synchronization on the business, data synchronization must support non-stop migration, that is, online migration, so that the business can be synchronized without downtime during the data synchronization process.
[0003] Online migration mainly includes three stages, namely structure migration, full data synchronization and incremental data synchronization. In the relevant technical solutions, after the full data synchronization is started, it is necessary to start extracting and saving the incremental data so that it can be connected with the full data in the incremental data synchronization stage to ensure the integrity and consistency of the data. When the full data synchronization is completed, the saved incremental data will be parsed and replayed until the data in the target database is consistent with the data in the source database.
[0004] However, 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. Summary of the invention
[0005] The present application provides a data synchronization method, which improves the efficiency of data synchronization.
[0006] 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 comprising: 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 from 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 of 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 repeated with the data to be synchronized; and the data synchronization device plays the filtered incremental data back to the target database.
[0007] The data synchronization method provided in the embodiment of the present application also filters the incremental data before playing back the incremental data. 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 playback 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 to extract incremental data after the full data synchronization stage is started, which causes some incremental data to be missing. The data synchronization method provided in the embodiment of the present application starts to extract incremental data before the full data synchronization stage is started, avoiding data missing and improving the consistency and integrity of data synchronization.
[0008] In combination with the first aspect, in some 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.
[0009] 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 at the granularity of data shards, 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 the data shard, thereby releasing storage resources and improving the speed of database queries.
[0010] In combination with the first aspect, in certain implementations of the first aspect, the data synchronization device filters 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.
[0011] The data synchronization method provided in the embodiment of the present application also filters the incremental data according to the snapshot information before replaying the incremental data. The filtered incremental data does not contain the parts that are repeated with the data that has been transmitted to the target database, thereby avoiding the data that has been transmitted to the target database from being repeatedly replayed, and improving the efficiency of data synchronization.
[0012] 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.
[0013] 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.
[0014] The transaction information of incremental data may not contain 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 present application improves the accuracy of visibility judgment by adding generation information to the transaction information of incremental data, thereby being able to accurately filter incremental data and improve the efficiency of data synchronization.
[0015] In combination with the first aspect, in certain implementations of the first aspect, the data synchronization device begins 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 is advanced; the data synchronization device determines the generation information of the incremental data based on the reference point and the incremental data.
[0016] In the embodiment of the present application, a reference point is obtained when the logical replication slot advances the position, and the generation information can be determined based on the reference point and the incremental data, thereby realizing the visibility judgment of the snapshot information of the data shard and the transaction information of the incremental data, and then being able to accurately filter the incremental data and improve the efficiency of data synchronization. On the other hand, the above operation only requires the read (select) permission of the source database, which reduces the user's authorization scope to the minimum.
[0017] 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.
[0018] In an embodiment of the present application, data sharding in the full data synchronization stage is performed using 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.
[0019] In combination with the first aspect, in certain implementations of the first aspect, an identifier corresponding to at least one record of the data shard to be synchronized belongs to an interval.
[0020] In an embodiment of the present application, the recorded identifiers are sharded according to the intervals to which they belong, and the obtained 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.
[0021] 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.
[0022] In an embodiment of the present application, the data of the source database is divided into multiple data shards, the 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.
[0023] In combination with the first aspect, in some implementations of the first aspect, the method is applied to a cloud data center.
[0024] 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.
[0025] In a third aspect, a computing device is provided, including a processor and a memory, wherein the processor is used 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.
[0026] 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.
[0027] In a fifth aspect, a computer program product comprising instructions is provided. When the 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.
[0028] In a sixth aspect, a computer program product including 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.
[0029] 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.
[0030] 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
[0031] Figure 1 is a schematic diagram of a data synchronization method.
[0032] Figure 2 It is a system diagram based on a cloud server system according to an embodiment of the present application.
[0033] Figure 3 It is a schematic flowchart of a data synchronization method provided in an embodiment of the present application.
[0034] Figure 4 It is a schematic block diagram of a data synchronization device 400 provided in an embodiment of the present application.
[0035] Figure 5 An embodiment of the present application provides a schematic diagram of the architecture of a computing device 500.
[0036] Figure 6 It is a schematic diagram of the architecture of a computing device cluster provided in an embodiment of the present application.
[0037] Figure 7 It is a schematic diagram of a connection between computing devices 500A and 500B via a network provided in an embodiment of the present application.
[0038] Figure 8 It is a schematic flowchart of another data synchronization method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0040] The present application will present various aspects, embodiments or features around a system 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. In addition, combinations of these schemes may also be used.
[0041] In addition, in the embodiments of the present application, words such as "exemplary" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.
[0042] 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. A person of ordinary skill in the art can appreciate that with the evolution of the 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.
[0043] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0044] To facilitate understanding, relevant terms and concepts that may be involved in the embodiments of the present application are first introduced below.
[0045] Data synchronization: The process of synchronizing data in the source database to the target database. Data synchronization will not affect the data in the source database.
[0046] Full data: When the data synchronization process starts, the data existing in the source database is called full data.
[0047] Incremental data: After the data synchronization process is started, the source database does not stop writing, so the newly written data is called incremental data. Incremental data can include data insertion, modification, deletion, etc.
[0048] Transaction snapshot: A transaction snapshot can be a static data set seen by a transaction within a certain period of time. A transaction snapshot can correspond to a database version. For example, a transaction snapshot can be a read transaction snapshot. In the embodiment of the present application, a read transaction snapshot of a data shard is referred to as a snapshot of the data shard.
[0049] Sharding: Also known as data sharding, for example, the data in the database is divided into multiple parts, each part is called a shard.
[0050] 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.
[0051] PostgreSQL: PostgreSQL is an open source client / server relational database system.
[0052] GaussDB: GaussDB is an enterprise-level distributed relational database. GaussDB has enterprise-level complex transaction mixed load capacity, supports distributed transactions, and deployment across availability zones (AZs) in the same city, with zero data loss. GaussDB also has key capabilities such as high availability, high reliability, high security, elastic scaling, one-click deployment, fast backup and recovery, monitoring and alarm, etc. on the cloud, which can provide enterprises with comprehensive, stable, reliable, scalable, and high-performance enterprise-level database services.
[0053] 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 adopts a dual licensing policy, divided into community edition and commercial edition. MySQL has the characteristics of small size, fast speed, low total cost of ownership, and open source.
[0054] The embodiment of the present application provides a data synchronization method, which can be applied to a cloud data center. The following first introduces the relevant technical solutions.
[0055] Figure 1 A schematic diagram of a data synchronization method is shown.
[0056] See also Figure 1 , data synchronization may include three stages, namely, structure migration stage 110, full data synchronization stage 120, and incremental data synchronization stage 130. In the structure migration stage 110, structure query 111 and structure playback 112 may be performed. For example, a structured query language (such as SQL statements such as "show create table;") may be executed on the source database to obtain the table structure of the source database, and the table structure may be played back to the target database to achieve structure migration.
[0057] In the full data synchronization phase 120, it is necessary to start extracting and saving incremental data, that is, incremental extraction 131, so that the incremental data can be connected with the full data in the incremental data synchronization phase 130 to ensure data integrity and consistency. For example, the main process of the server 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 slot creation transaction.
[0058] The full data synchronization phase 120 requires full data query 121 and full data transmission 122. For example, creating a replication slot can also be regarded as a full data query 121, and the subprocess of the control server imports the snapshot of the slot creation transaction according to the snapshot name and performs full data transmission 122.
[0059] Incremental data synchronization phase 130 After the full data synchronization phase 120 , the server may write the incremental data in the logical replication slot to the target database until the data of the source database and the target database are synchronized. This process may also be referred to as incremental data playback 132 .
[0060] However, in Figure 1 In the data synchronization method shown, there are repeated parts between the incremental data and the full data, and these repeated parts are transmitted multiple times, resulting in low efficiency of data synchronization.
[0061] On the other hand, when full data synchronization is interrupted, the only option is to re-establish the logical replication slot and re-synchronize all data, which results in poor fault tolerance of data synchronization. In addition, the data synchronization device needs to hold a snapshot of the full data until full data synchronization is completed. During this period, since the synchronization granularity is the entire full data, the data synchronization device will not clean up the data visible in the snapshot, occupying storage resources, resulting in table space expansion and slow SQL queries.
[0062] The following describes the application scenarios of the embodiments of the present application. It should be noted that: Figure 2 The scenarios shown are only examples and do not constitute a limitation to the present application.
[0063] Figure 2 Schematic diagram of a cloud server system in an embodiment of the present application. Figure 2 As shown, the cloud management platform 210 is used to manage the infrastructure that provides multiple cloud services. The infrastructure includes multiple cloud data centers, each cloud data center includes multiple servers, and each server includes cloud service resources to provide corresponding cloud services to tenants.
[0064] The cloud management platform 210 provides an access interface (such as an interface or an application program interface (API)). The tenant can operate the client remote access 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 of the purchased virtual machine. The client can remotely log in to the virtual machine and install and run the tenant's application in the virtual machine. The tenant of the cloud service can be an individual, enterprise, school, hospital, administrative agency, etc.
[0065] The functions of the cloud management platform 210 include, but are not limited to, user console, computing management service, network management service, storage management service, authentication service, and image management service. The user console provides an interface or API to interact with tenants, the computing management service is used to manage servers running virtual machines and containers and 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 tenants' accounts and passwords, and the image management service is used to manage virtual machine images. Tenants can log in to the cloud management platform 210 through the Internet 220 using the client 230 to manage the rented cloud services.
[0066] Figure 3 A data synchronization method provided by an embodiment of the present application is shown, which is used to transfer data from a source database to a target database. The method filters out the parts of the incremental data that are repeated with the full data, avoids the incremental data from being repeatedly transmitted, and can improve the efficiency of data synchronization. For example, Figure 3 The method shown may be executed by a data synchronization device, which may be a server or the like.
[0067] It should be noted that the present application does not limit the specific form of the source database or the target database. For example, the source database may be a database with PostgreSQL as the data source, and the target database may be a database with PostgreSQL, MySQL, or GaussDB as the data source. Figure 3 The illustrated method can be applied to any data center, such as a cloud data center.
[0068] 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 related technical solutions. In the related 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 one by one, 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.
[0069] S310, the data synchronization device starts to extract 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.
[0070] During the data synchronization process, in order to achieve zero business downtime, the source database can continue to receive new data. The received new data is used as incremental data and is played back to the target database after the full data synchronization phase to make the data in the source database consistent with that in the target database. It can be understood that receiving here includes inserting, updating or deleting.
[0071] Starting to extract incremental data from the source database is a "start" action. Because incremental data is written by users according to business needs during the data synchronization process, in other words, when the data synchronization server starts to extract incremental data from the source database, there may not be incremental data in the source database. Therefore, extracting incremental data is a continuous process, and it will not end until the data synchronization is completed.
[0072] 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 create one first. Then, extract incremental data from the source database to the logical replication slot.
[0073] 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.
[0074] 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 started on the source database at the repeatable read isolation level to generate a snapshot of the data of the source database. If the data of the source database is modified between the start and commit of the read transaction, the modified record may be referred to as incremental data, but the snapshot of the data of the source database does not include these modified records. In other words, the snapshot of the data of the source database may include static data when the read transaction is started.
[0075] A record is a relatively complete set of information in a database. A record can also be called a row.
[0076] For example, the data synchronization server may transfer the data to be synchronized to the target database according to the 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 according to the snapshot of the data of the source database.
[0077] 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 already exists in the source database when the snapshot is obtained. Subsequently, the data synchronization server executes S320 to transfer all data in the source database to the target database.
[0078] Optionally, the source database includes multiple data shards, and the data to be synchronized is one of the multiple data shards.
[0079] 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. The following description is made by taking the first data shard as the data to be synchronized as an example.
[0080] 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.
[0081] It can be understood that the source database includes multiple data shards, and the first data shard is one of the multiple data shards.
[0082] For example, a read transaction is started on the 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 can include static data when the read transaction is started.
[0083] In some embodiments, the records in the source database may be logically sharded according to the identifier. For example, the identifier may be a primary key, and multiple primary keys are divided into several intervals according to certain rules, and the records corresponding to the primary key in each interval constitute a shard.
[0084] 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.
[0085] In other embodiments, the full data may be arbitrarily sharded, for example, a number of records corresponding to the value of a certain field may be grouped into one shard.
[0086] Exemplarily, obtaining a snapshot of the first data shard may generate a snapshot of the first data shard by querying (or reading) records. For example, records with primary key values between 1 and 1 million may be queried to generate a snapshot of records with primary key values between 1 and 1 million, which may be referred to as a snapshot of the first data shard.
[0087] It is understood that the identifier recorded in the embodiment of the present application is not limited to the primary key, and can also be a unique index, for example. 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.
[0088] 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 according to 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 shards are not affected.
[0089] 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 at the granularity of data shards, 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, each record corresponds to an identifier, and the method also includes: the data synchronization device obtains a snapshot of the data to be synchronized according to the identifier corresponding to at least one record of the data to be synchronized.
[0090] The identifier can be a primary key or a unique index. One record can correspond to one identifier.
[0091] A unique index can improve the access speed to the database and is used to query records. Unlike ordinary indexes, the value of a unique index is unique, but null values are allowed.
[0092] It is understood that the data synchronization server can determine the identifier corresponding to at least one record of a data shard. For example, suppose the query rule defined by the user is to query sequentially according to the primary key value, and query 500,000 records each time. In this case, the data synchronization server can perform calculations based on the primary key value of the last query to determine the primary key value of the current query, that is, the identifier corresponding to the record of this data shard.
[0093] This application does not limit the data sharding method in the full data synchronization stage. In addition to the above-mentioned sharding scheme by interval, sharding can also be performed in other ways. For example, the data sharding can be performed by the last digit of the primary key value, and the records with the last digit of the primary key value being 1 form 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 amount of data can be divided into multiple shards, and a table with a smaller amount of data can be used as a single shard.
[0094] For example, the data synchronization server may query according to the identifier corresponding to at least one record of the first data shard, thereby obtaining a snapshot of the first data shard. In other words, the data in the full data synchronization stage may be sharded according to the identifier, which includes a primary key or a unique identifier, so that the multiple data shards obtained do not overlap, and the sum of the various data shards is sufficient to constitute the data in the full data synchronization stage.
[0095] In an embodiment of the present application, data sharding in the full data synchronization stage is performed using 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.
[0096] Optionally, the identifier corresponding to the at least one record of the data to be synchronized belongs to an interval.
[0097] 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.
[0098] For example, records corresponding to primary key values between 300,000 and 700,000 are taken as the first data shard, so that 300,000 to 700,000 is the interval to which the identifier corresponding to the at least one record belongs.
[0099] In an embodiment of the present application, the recorded identifiers are sharded according to the intervals to which they belong, and the obtained 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.
[0100] Optionally, the identifiers corresponding to the records of the multiple data shards do not overlap.
[0101] 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.
[0102] It can be understood that the multiple data shards are not limited to the first data shard and the second data shard. For example, there may also be a third data shard, a fourth data shard, etc. The present application does not limit the specific number of the multiple data shards. In other words, the present application does not limit how many shards the data in the source database is divided into.
[0103] In an embodiment of the present application, the data of the source database is divided into multiple data shards, the 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.
[0104] S330, the data synchronization device filters the data in the incremental data that is repeated with the data to be synchronized.
[0105] The incremental data may be duplicated with the data to be synchronized in the source database. There are two sources of duplicate data, which are described in detail below with examples.
[0106] Source 1: If incremental data extraction begins before the full data synchronization phase, then between the first moment when incremental data extraction begins and the second moment when a snapshot of the source database's data to be synchronized is obtained, part of the data in the source database belongs to both incremental data and full data, resulting in duplication of incremental data and data in the source database.
[0107] For example, suppose a record is modified between the first moment and the second moment. Since the record is modified after the incremental synchronization is started, it is incremental data, and the modified data will be extracted as incremental data. On the other hand, since the record is modified before the second moment, the modified data is visible when the full synchronization is started. In other words, when the snapshot of the source database data is obtained, the snapshot contains the modified data. Therefore, the modified data belongs to both incremental data and full data, resulting in duplication of incremental data.
[0108] 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.
[0109] 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 obtaining a snapshot of the second data shard, the modified data in the second data shard is visible, that is, when obtaining a snapshot of the second data shard, 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.
[0110] Source 1 is because the incremental data is started before the full data synchronization phase is started, and source 2 is because the full data is transmitted in shards, and modifications to the later transmitted data shards are visible.
[0111] Optionally, the data synchronization device filters 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 data in the incremental data that is repeated with the data to be synchronized.
[0112] Snapshot information includes xmin, xmax and xip_list, and the visibility of transaction information can be judged based on the snapshot information. Among them, xmin refers to the earliest transaction information (txid) that is still active. Transactions earlier than xmin have either been committed and are visible, or have been rolled back and died; xmax refers to the first unassigned transaction information. Transaction information greater than or equal to xmax has not been started when the snapshot of the first data shard is obtained, so it is invisible; xip_list refers to the transaction information that is active when the snapshot is obtained. xip_list includes those active transaction information between xmin and xmax.
[0113] It should be noted that snapshots and snapshot information have different functions. Snapshots are used to transfer data, while snapshot information is used to determine visibility.
[0114] Transaction information can also be called transaction number or transaction ID. Transaction information can be a 32-bit integer, starting from 3 (decimal). During the creation of a new transaction, transaction information will be consumed continuously. When consumed to a certain extent, the transaction information will roll back to 3.
[0115] 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.
[0116] Based on the snapshot information, the transaction information of the incremental data can be judged for visibility, thereby filtering the incremental data. For example, based on the transaction information of xip_list in the snapshot information, try to read the transaction information of the incremental data. If it can be read, it means that the data is visible and needs to be filtered out and no longer replayed. If it cannot be read, it means that the data is invisible and needs to be replayed and retained.
[0117] The data synchronization method provided in the embodiment of the present application also filters the incremental data according to the snapshot information before replaying the incremental data. The filtered incremental data does not contain the parts that are repeated with the data that has been transmitted to the target database, thereby avoiding the data that has been transmitted to the target database from being repeatedly replayed, and improving the efficiency of data synchronization.
[0118] 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.
[0119] For example, if the incremental data is extracted from the logical replication slot in PostgreSQL, the transaction information of the incremental data is 32 bits and does not contain generation information. However, the transaction information in the snapshot information is 64 bits and contains generation information. If you want to make a feasibility judgment on the transaction information of the snapshot information and the incremental data, you also need to convert the format of the incremental data, that is, add the 32-bit generation information to the original incremental data transaction information to form 64-bit transaction information, and then make a visibility judgment with the snapshot information.
[0120] The transaction information of incremental data may not contain 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 present application improves the accuracy of visibility judgment by adding generation information to the transaction information of incremental data, thereby being able to accurately filter incremental data and improve the efficiency of data synchronization.
[0121] 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 is advanced; the data synchronization device determines the generation information of the incremental data based on the reference point and the incremental data.
[0122] The logical replication slot may include a position, which may indicate a log sequence number (LSN). The position is also used to indicate that data before the position can be cleared, while data after the position needs to be persisted.
[0123] Advancing a site may increase the LSN indicated by the site so that more data can be cleared.
[0124] When the site is advanced, a 64-bit transaction information can be obtained as a reference point, and the first 32 bits of the transaction information are generation information. For example, the transaction information can be obtained as a reference point through the txid_current instruction. Among them, txid_current is used to obtain the current transaction information. If the current transaction has no transaction information, a new transaction information is allocated.
[0125] After obtaining a piece of incremental data, the generation information of this piece of incremental data can be determined based on the reference point and the incremental data. Due to the rollback mechanism of the database, the generation information of the reference point and the incremental data is the same or adjacent, so the generation information of this piece of incremental data can be calculated.
[0126] In the embodiment of the present application, a reference point is obtained when the logical replication slot advances the position, and the generation information can be determined based on the reference point and the incremental data, thereby realizing the visibility judgment of the snapshot information of the data shard and the transaction information of the incremental data, and then being able to accurately filter the incremental data and improve the efficiency of data synchronization. On the other hand, the above operation only requires the read (select) permission of the source database, which reduces the user's authorization scope to the minimum.
[0127] S340, the data synchronization device plays back the filtered incremental data into the target database.
[0128] Playing back the filtered incremental data to the target database can be to execute the incremental data transaction on the target database. In other words, the target database can be modified in the same way as the source database during the full data synchronization phase to achieve consistency between the source database and the target database.
[0129] Optionally, the source database is a database using PostgreSQL as a data source.
[0130] The data synchronization method provided in the embodiment of the present application also filters the incremental data before playing back the incremental data. The filtered incremental data does not contain data that is repeated with the first data shard, thereby avoiding the data that has been transmitted to the target database from being repeatedly played back, and improving the efficiency of data synchronization. On the other hand, the related technical solution starts to extract incremental data after the full data synchronization stage is started, which results in the missing of some incremental data. The data synchronization method provided in the embodiment of the present application starts to extract incremental data before the full data synchronization stage is started, avoiding data missing and improving the consistency and integrity of data synchronization.
[0131] Combined with the above Figure 3 The method embodiments of the present application are described in detail. The device embodiments of the present application are described below. The device embodiments correspond to the method embodiments, so the parts not described in detail can refer to the previous method embodiments. The device can implement any possible implementation of the above method.
[0132] The present application also provides a data synchronization device 400, such as Figure 4 As shown, the device 400 includes: an extraction module 410, which is 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, which is 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, which is used to filter data in the incremental data that is repeated with the data to be synchronized; and a playback module 440, which is used to play back the filtered incremental data into the target database.
[0133] Figure 4 The data synchronization device 400 shown may be a data synchronization server, and the device 400 may be applied to a data center. The present application does not limit the data center, and may be applied to any data center, such as a cloud data center.
[0134] Among them, the extraction module 410, the transmission module 420, the filtering module 430 and the playback module 440 can all be implemented by software, or can be implemented by hardware. Exemplarily, the following takes the extraction module 410 as an example to introduce the implementation of the extraction module 410. Similarly, the implementation of the transmission module 420, the filtering module 430 and the playback module 440 can refer to the implementation of the extraction module 410.
[0135] As an example of a software functional unit, the extraction module 410 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned 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 (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 data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0136] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0137] As an example of a hardware functional unit, the extraction module 410 may include at least one computing device, such as a server, etc. Alternatively, the extraction module 410 may also be a device 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.
[0138] 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 computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0139] 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, the transmission module 420, the filtering module 430 and the playback module 440 are responsible for implementing can be specified as needed, and the extraction module 410, the transmission module 420, the filtering module 430 and the playback module 440 respectively implement different steps in the data synchronization method to realize the full functions of the data synchronization device.
[0140] The present application also provides a computing device 500. Figure 5 As shown, computing device 500 includes: bus 502, processor 504, memory 506 and communication interface 508. Processor 504, memory 506 and communication interface 508 communicate through bus 502. Computing device 500 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in computing device 500.
[0141] The bus 502 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus 502 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 502 may include a path for transmitting information between various components of the computing device 500 (eg, the memory 506, the processor 504, and the communication interface 508).
[0142] The processor 504 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0143] The memory 506 may include a volatile memory, such as a random access memory (RAM). The memory 506 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0144] The memory 506 stores executable program codes, and the processor 504 executes the executable program codes to respectively 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. That is, the memory 506 stores instructions for executing the data synchronization method.
[0145] 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.
[0146] The embodiment of the present application also provides 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 smart phone.
[0147] like Figure 6 As shown, 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.
[0148] 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 may jointly execute instructions for executing the data synchronization method.
[0149] It should be noted that the memory 506 in different computing devices 500 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the data synchronization device. That is, the instructions stored in the memory 506 in different computing devices 500 can implement the functions of one or more modules among the extraction module 410, the transmission module 420, the filtering module 430 and the playback module 440.
[0150] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network, etc. Figure 8 A possible implementation is shown. Figure 7 As shown, 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. At the same time, the memory 506 in the computing device 500B stores instructions for executing the functions of the filtering module 430 and the playback module 440.
[0151] Figure 7 The connection method between the computing device clusters shown may be based on the consideration that the data synchronization method provided in the present application requires a large amount of transmission of full data and filtered incremental data, and therefore the functions implemented by the filtering module 430 and the playback module 440 may be executed by the computing device 500B.
[0152] It should be understood that Figure 7 The functions of the computing device 500A shown in FIG. 5A may also be completed by multiple computing devices 500. Similarly, the functions of the computing device 500B may also be completed by multiple computing devices 500.
[0153] The present application embodiment also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Figure 6 and Figure 7 The difference is that 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.
[0154] 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 may jointly execute instructions for executing the data synchronization method.
[0155] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or 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, a method for synchronizing data of at least one computing device is implemented.
[0156] The embodiment of 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 the computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the data synchronization method.
[0157] Figure 8 Another data synchronization method provided by an embodiment of the present application is shown. Figure 8 This article takes PostgreSQL as an example.
[0158] See also Figure 8 , the source database 810 may include full data 811 and incremental data 812, wherein the full data referred to in the embodiment of the present application refers to the data existing in the source database after the data synchronization process is started. Figure 8 Some embodiments of the present invention.
[0159] 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.
[0160] In the transaction information of incremental data, due to the lack of generation information, it is impossible to directly perform visibility judgment with the transaction snapshot information obtained during the full data synchronization phase.
[0161] The transaction information conversion component 822 of the incremental extraction module 820 will obtain a transaction information as a reference point through the corresponding interface of PostgreSQL when reading the incremental data again after each advancement of the site, and calculate the generation information of the transaction information of the incremental data based on the obtained reference point. Specifically, based on the rollback mechanism of PostgreSQL, the generation of the transaction information of the incremental data 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 generation of the incremental data is the same as or adjacent to the generation of the reference point, thereby calculating the generation information of the transaction information of the incremental data.
[0162] 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.
[0163] In the full transmission module 830, data sharding is used as the minimum unit of reading, and each read transaction is responsible for reading one data shard. The full transmission module may include a sharding component 831, which divides the full amount of data into multiple data shards according to certain rules and forms query conditions. For example, the sharding component can be divided according to intervals, and a table that cannot be divided or a table with a small amount of data can be used as a data shard. The full transmission component 832 is used to transmit the read data shards to the target database 850.
[0164] In some embodiments, multiple data shards can be transmitted in parallel, thereby improving the efficiency of data synchronization. When the full data synchronization phase is interrupted, the data shards that have been transmitted do not need to be retransmitted, achieving the purpose of breakpoint resuming transmission based on data shards.
[0165] PostgreSQL automatically generates a snapshot for each query and provides an interface for obtaining snapshot information. The snapshot component of the full transfer module can explicitly start a transaction with a repeatable read isolation level each time it reads a data shard; all queries in the transaction will use the same snapshot information, which will be temporarily stored.
[0166] The incremental playback module 840 may include a data filtering component 841. Before replaying each incremental data, the data is filtered by judging the visibility of the transaction information of the incremental data and the snapshot information of the corresponding full data shard. If the incremental data is visible to the snapshot of the full shard, the data will no longer be replayed by the incremental playback component 842. Otherwise, the data will be replayed by the incremental playback component 842 to the target database 850. By accurately filtering the transaction snapshot information, the synchronized incremental data will not be replayed repeatedly.
[0167] The data synchronization method provided in the embodiment of the present application starts the incremental data extraction before the full data synchronization stage, and combines it with the filtering of incremental data, so as to decouple the reading of full data from the creation of logical replication slots, avoid data missing, data conflict, table locking and long-term holding of snapshots, and reduce the impact on the source database business.
[0168] 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 it. 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 cause the essence of the corresponding technical solutions to deviate 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
Data synchronization method and system
CN113535856A
Heterogeneous database increment synchronization method and system based on non-stop of source library
CN113656511A
Data migration method and device, equipment and storage medium
CN115080541A
Database migration method and device and storage medium
CN115269553A
Synchronized test master
US20170116220A1
Cited By
Database management method, database management device and computing device cluster
CN119988355A
Slow SQL (Structured Query Language) statistical method and equipment for PostgreSQL database and medium
CN121478801A
Data acquisition method and device, medium and program product
CN121478882A
Data synchronization method and apparatus
WO2026170948A1
