Data synchronization method, database system and computing device cluster

By setting up a master replication cluster in the primary region to concurrently synchronize data, the problems of data synchronization latency and increased RPO in cross-region database systems are solved, achieving efficient data synchronization and business performance assurance.

CN120994741APending Publication Date: 2025-11-21HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411214722.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-05-20
Filing Date
2024-08-30
Publication Date
2025-11-21

Smart Images

  • Figure CN120994741A_ABST
    Figure CN120994741A_ABST
Patent Text Reader

Abstract

The invention discloses a data synchronization method, a database system and a computing device cluster, and belongs to the technical field of databases. The database system comprises a master region and m slave regions. The master region includes a master replication cluster and a master database node. The master replication cluster includes replication nodes that are compute nodes that are logically different from the master database nodes. And after the main replication cluster obtains the to-be-synchronized data generated by the main database node, generating at least one replication task corresponding to the to-be-synchronized data. And the main replication cluster adds the at least one replication task to a task queue. And the master replication cluster concurrently obtains the at least one replication task from the task queue, and concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task. The problem that the to-be-synchronized data cannot be synchronized to the slave region in time due to resource limitation of the master database node can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to Chinese patent application No. 202410637819.2, filed on May 20, 2024, entitled “A Data Synchronization Method and Apparatus”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of database technology, and in particular to a data synchronization method, a database system, and a computing device cluster. Background Technology

[0003] Database systems can be used to store business data. To ensure high availability of business operations, database systems with cross-region disaster recovery (DR) capabilities (one master and multiple slaves) have emerged. Such database systems typically include one primary region and multiple secondary regions. The primary region is used to store (i.e., write) data for the business based on write requests sent by business clients, and to synchronize this data with the multiple secondary regions. This ensures that in the event of a disaster in the primary region, the business can switch to a secondary region, which will then guarantee its continued operation.

[0004] In a database system with cross-region disaster recovery capabilities (one master and multiple slaves), the problem to be solved is how the master region can synchronize data to multiple slave regions in a timely manner while ensuring business performance and maintaining a relatively small recovery point objective (RPO). Summary of the Invention

[0005] This application provides a data synchronization method, a database system, and a computing device cluster. The technical solution of this application is as follows.

[0006] Firstly, a data synchronization method is provided, applied to a database system. The database system includes a primary region and m secondary regions, where m is a positive integer. The primary region includes a primary replication cluster and a primary database node, where the primary database node is a compute node with deployed database instances. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node. The method includes: the primary database node generating data to be synchronized; the primary replication cluster acquiring the data to be synchronized; the primary replication cluster generating at least one replication task corresponding to the data to be synchronized, the at least one replication task being used to synchronize the data to be synchronized to the m secondary regions; the primary replication cluster adding the at least one replication task to a task queue; the primary replication cluster concurrently acquiring the at least one replication task from the task queue; and the primary replication cluster concurrently synchronizing the data to be synchronized to the m secondary regions based on the at least one replication task acquired from the task queue.

[0007] The technical solution provided in this application sets up a master replication cluster in the master region, which concurrently synchronizes the data to be synchronized to m slave regions. Therefore, it avoids the problem of insufficient resources of the master database node in the master region causing the data to be synchronized to fail to be synchronized to the slave regions in a timely manner. This application can synchronize the data to be synchronized to the slave regions in a timely manner, reducing the RPO of the slave regions and the synchronization lag between the master and slave regions. It avoids backpressure on front-end services due to large RPO of slave regions and / or large synchronization lag between the master and slave regions. It can synchronize the data to be synchronized to the m slave regions in a timely manner while ensuring business performance, guaranteeing a small RPO and a small synchronization interval (lag) between the master and slave regions. When the master replication cluster includes multiple replication nodes, these multiple replication nodes concurrently synchronize the data to be synchronized to the m slave regions according to at least one replication task corresponding to the data to be synchronized. This can improve the throughput of the master replication cluster, thereby improving the throughput of the master region. It can also increase the number of incremental data that the master region can handle and the number of slave regions that the master region can support, making it suitable for database systems with a large number of slave regions.

[0008] Optionally, the primary replication cluster generates at least one replication task corresponding to the data to be synchronized, including: the primary replication cluster generates m replication tasks corresponding to the data to be synchronized, and the m replication tasks correspond one-to-one with the m slave regions; the primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task obtained from the task queue, including: the primary replication cluster synchronizes the data to be synchronized to the slave region corresponding to each of the m replication tasks obtained from the task queue, wherein the process of the primary replication cluster synchronizing the data to be synchronized to the m slave regions according to the m replication tasks is parallel.

[0009] Optionally, the primary replication cluster generates at least one replication task corresponding to the data to be synchronized, including: the primary replication cluster generates one replication task corresponding to the data to be synchronized; the primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task obtained from the task queue, including: the primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the one replication task obtained from the task queue.

[0010] Optionally, the method further includes: for each replication task in the task queue: after completing each replication task, the primary replication cluster removes each replication task from the task queue; or, after completing each replication task, the primary replication cluster marks each replication task as completed.

[0011] The technical solution provided in this application allows the primary replication cluster to remove a replication task from the task queue after completion, thus avoiding the occupation of queue resources by completed replication tasks. Alternatively, after completing a replication task, the primary replication cluster marks the task in the task queue as complete, facilitating the retrieval of replication tasks from the queue based on their status.

[0012] Optionally, the primary replication cluster includes multiple replication threads, which are allocated to the at least one replication node. The primary replication cluster concurrently retrieves the at least one replication task from the task queue, including: the multiple replication threads concurrently retrieve the at least one replication task from the task queue; the primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions based on the at least one replication task retrieved from the task queue, including: the replication node where the replication thread that retrieved the at least one replication task is located concurrently synchronizes the data to be synchronized to the m slave regions based on the at least one replication task.

[0013] Optionally, the size of the primary replication cluster can be elastically scaled according to the load of data synchronization on the primary replication cluster.

[0014] The technical solution provided in this application allows the size of the primary replication cluster to be elastically scaled up or down according to the load of the data being synchronized by the primary replication cluster. Therefore, the size of the primary replication cluster can be expanded or reduced according to the load of the data being synchronized by the primary replication cluster, so that the primary replication cluster can meet business needs, ensure a small RPO, and reduce the cost of the primary replication cluster.

[0015] Optionally, the load of the master replication cluster synchronizing data is characterized by at least one of the following: the utilization rate of the computing resources of the master replication cluster; the utilization rate of the transmission resources of the master replication cluster; and the transmission rate of the transmission resources of the master replication cluster.

[0016] Optionally, each of the m slave regions includes a slave replication cluster, and the master replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task obtained from the task queue, including: the master replication cluster concurrently sending the data to be synchronized to the slave replication clusters in the m slave regions according to the at least one replication task obtained from the task queue.

[0017] Optionally, the first replication cluster is one of the replication clusters included in the primary replication cluster and the m slave regions, and the second replication cluster is another replication cluster included in the primary replication cluster and the m slave regions; the replication nodes in the first replication cluster and the replication nodes in the second replication cluster are fully connected in a point-to-point manner; or, the first replication cluster and the second replication cluster further include replication agent nodes respectively, the replication agent nodes in the first replication cluster are connected to the replication nodes in the first replication cluster, the replication agent nodes in the second replication cluster are connected to the replication nodes in the second replication cluster, and the replication agent nodes in the first replication cluster are connected to the replication agent nodes in the second replication cluster.

[0018] Optionally, the task queue can be a distributed queue, which can improve the availability of the task queue.

[0019] Secondly, a database system is provided, comprising a primary region and m secondary regions, where m is a positive integer. The primary region includes a primary replication cluster and a primary database node, the primary database node being a compute node with a database instance deployed thereon. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node. The primary database node is used to: generate data to be synchronized; the primary replication cluster is used to: acquire the data to be synchronized; generate at least one replication task corresponding to the data to be synchronized, the at least one replication task being used to synchronize the data to be synchronized to the m secondary regions; add the at least one replication task to a task queue; concurrently acquire the at least one replication task from the task queue; and concurrently synchronize the data to be synchronized to the m secondary regions based on the at least one replication task acquired from the task queue.

[0020] Optionally, the primary replication cluster is used to: generate m replication tasks corresponding to the data to be synchronized, the m replication tasks corresponding one-to-one with the m slave regions; and synchronize the data to be synchronized to the slave region corresponding to each of the m replication tasks obtained from the task queue, wherein the process of the primary replication cluster synchronizing the data to be synchronized to the m slave regions according to the m replication tasks is parallel.

[0021] Optionally, the primary replication cluster is used to: generate a replication task corresponding to the data to be synchronized; and concurrently synchronize the data to be synchronized to the m slave regions based on the replication task obtained from the task queue.

[0022] Optionally, the primary replication cluster is also used to: for each replication task in the task queue: remove each replication task from the task queue after it is completed; or, mark each replication task as completed after it is completed.

[0023] Optionally, the primary replication cluster includes multiple replication threads, which are allocated in the at least one replication node. These multiple replication threads are used to: concurrently retrieve the at least one replication task from the task queue; the replication node where the replication thread that retrieves the at least one replication task is located is used to: concurrently synchronize the data to be synchronized to the m slave regions according to the at least one replication task.

[0024] Optionally, the size of the primary replication cluster can be elastically scaled according to the load of data synchronization on the primary replication cluster.

[0025] Optionally, the load of the master replication cluster synchronizing data is characterized by at least one of the following: the utilization rate of the computing resources of the master replication cluster; the utilization rate of the transmission resources of the master replication cluster; and the transmission rate of the transmission resources of the master replication cluster.

[0026] Optionally, each of the m slave regions includes a slave replication cluster, the master replication cluster being used to concurrently send the data to be synchronized to the slave replication clusters in the m slave regions based on the at least one replication task obtained from the task queue.

[0027] Optionally, the first replication cluster is one of the replication clusters included in the primary replication cluster and the m slave regions, and the second replication cluster is another replication cluster included in the primary replication cluster and the m slave regions; the replication nodes in the first replication cluster are fully connected to the replication nodes in the second replication cluster in a point-to-point manner; or, the first replication cluster and the second replication cluster each include replication agent nodes, the replication agent nodes in the first replication cluster are connected to the replication nodes in the first replication cluster, the replication agent nodes in the second replication cluster are connected to the replication nodes in the second replication cluster, and the replication agent nodes in the first replication cluster are connected to the replication agent nodes in the second replication cluster.

[0028] Thirdly, a computing device cluster is provided, including at least one computing device, each of the at least one computing device including a processor and a memory, wherein 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 to cause the computing device cluster to perform the method provided as described in the first aspect or any alternative to the first aspect.

[0029] Fourthly, a computer-readable storage medium is provided that stores a computer program, which, when executed, implements the method provided by the first aspect or any alternative method of the first aspect described above.

[0030] Fifthly, a computer program product is provided, comprising a program or code that, when executed, implements the method provided as described in the first aspect or any alternative method of the first aspect.

[0031] In a sixth aspect, a chip is provided, the chip including programmable logic circuitry and / or program instructions, the chip being used to implement the methods provided as described in the first aspect or any alternative to the first aspect.

[0032] The technical effects of the second to sixth aspects mentioned above can be referred to the technical effects of the first aspect and its optional implementation schemes, and will not be elaborated here. Attached Figure Description

[0033] Figure 1 This is a schematic diagram of a database system provided in an embodiment of this application;

[0034] Figure 2 This is a schematic diagram of another database system provided in an embodiment of this application;

[0035] Figure 3 This is a schematic diagram illustrating the working process of a database system provided in an embodiment of this application;

[0036] Figure 4 This is a schematic diagram of another database system provided in an embodiment of this application;

[0037] Figure 5 This is a schematic diagram of yet another database system provided in the embodiments of this application;

[0038] Figure 6 This is a schematic diagram illustrating the connection of a replication cluster in different regions according to an embodiment of this application;

[0039] Figure 7 This is a schematic diagram illustrating the connection of replication clusters in different regions, as provided in another embodiment of this application.

[0040] Figure 8 This is a schematic diagram illustrating the connection of a replication cluster in a different region, as provided in an embodiment of this application.

[0041] Figure 9 This is a schematic diagram of a replication cluster provided in an embodiment of this application;

[0042] Figure 10 This is a schematic diagram of another replication cluster provided in an embodiment of this application;

[0043] Figure 11 This is a flowchart of a data synchronization method provided in an embodiment of this application;

[0044] Figure 12 This is a mapping diagram of a copying task and the data to be synchronized provided in an embodiment of this application;

[0045] Figure 13 This is another mapping diagram between replication tasks and data to be synchronized provided in an embodiment of this application;

[0046] Figure 14 This is a state transition diagram for a copying task provided in an embodiment of this application;

[0047] Figure 15 This is a schematic diagram of a computing device provided in an embodiment of this application;

[0048] Figure 16 This is a schematic diagram of a computing device cluster provided in an embodiment of this application;

[0049] Figure 17 This is a schematic diagram of another computing device cluster provided in an embodiment of this application. Detailed Implementation

[0050] The embodiments of this application will now be described in further detail with reference to the accompanying drawings.

[0051] As business operations evolve towards global distribution and the demand for multi-site active-active high availability grows, there is a need to synchronize business data across global regions. Typically, database systems are used to store this data. However, traditional database systems have poor cross-regional capabilities, cannot support global access across regions, and are ill-suited to the trend of global distributed business evolution, failing to meet the demands for multi-site active-active high availability.

[0052] To adapt to the global distributed evolution of business and meet the high availability requirements of geographically dispersed, multi-site active-active architectures, cloud database vendors have begun to offer database systems with cross-region disaster recovery (DR) capabilities, typically consisting of a primary region and multiple secondary regions. The primary region provides read-write (RW) capabilities to support both reading and writing of data. Secondary regions provide read-only (RO) capabilities to support read-only data (i.e., only supporting data reading and not writing). The primary region is used to store (i.e., write) the business's data based on write requests sent by business clients, and to synchronize the business's data to the multiple secondary regions. This ensures that in the event of a disaster in the primary region, the business can switch to a secondary region, which will then guarantee its continued operation. Database systems with cross-region disaster recovery capabilities generally need to ensure that secondary regions have low recovery point objectives (RPO) to reduce data loss. RPO (Recovery Point Objective) is a crucial metric for measuring the service recovery capability of a region. It characterizes the point in time a region can restore service after an interruption. For example, if a primary region fails, causing a service interruption at 11:30:25 on July 16, 2024, and a secondary region restores and ensures the normal operation of the service, and the secondary region can restore the service to 11:30:23 on July 16, 2024 (data for the service within 2 seconds between 11:30:23 and 11:30:25 on July 16, 2024 may not have been synchronized from the primary region to the secondary region), then the RPO of the secondary region is 2 seconds.

[0053] A primary region typically includes a primary database node, which is a compute node with deployed database instances. This primary database node handles data access requests from clients (such as write and read requests). Currently, this primary database node usually synchronizes data to multiple secondary regions. However, because the primary database node must handle both client data access requests and synchronize data with secondary regions, its bandwidth, compute, and memory resources may limit its ability to synchronize data to all secondary regions in a timely manner. Furthermore, as the amount of data generated by the primary region (e.g., data written to the primary region based on write requests) increases, the RPO (Recovery Point Objective) of the secondary regions increases, leading to a greater synchronization lag between the primary and secondary regions. For example, a database system includes one master region and five slave regions. Under a pure write workload, the incremental data (i.e., the data generated per second by the master region) is 40 megabits per second (MBps). The master database node in the master region requires at least 200 MBps of bandwidth to synchronize data to the five slave regions. This may far exceed the throughput capacity of the master database node, leading to a continuous increase in the RPO (Recovery Point Objective) of the slave regions and a continuous increase in the synchronization lag between the master and slave regions. Increasing the bandwidth of the master database node may cause its network interface card (NIC) to become a bottleneck for data synchronization performance. Adding NICs to the master database node may also cause its computing resources, such as memory resources, to become bottlenecks for data synchronization performance. Computing resources include, for example, central processing unit (CPU) resources. The synchronization lag between a primary region and a secondary region refers to the time difference between when the primary region synchronizes the latest incremental data (e.g., the latest incremental data written to the primary region) to the secondary region and when the primary region generates the incremental data (e.g., the time the incremental data was written to the primary region). For example, if the primary region generates incremental data 1 at 14:18:00 on July 16, 2024, and the primary database node in the primary region synchronizes incremental data 1 to the secondary region at 14:20:00 on July 16, 2024, then the synchronization lag between the primary region and the secondary region is 2 minutes.If the rate at which the primary region generates data exceeds the rate at which it synchronizes data to the secondary region, the data generated by the primary region will not be synchronized to the secondary region in a timely manner. Furthermore, as time goes on, the amount of data that the primary region cannot synchronize to the secondary region in a timely manner will increase, leading to a larger and larger synchronization lag between the primary and secondary regions.

[0054] Aurora Global Database and PolarDB Global Database Network (PolarDB GDN) are two commonly used database systems with cross-region disaster recovery capabilities, featuring a master-slave architecture. The following is an introduction to Aurora Global Database and PolarDB GDN.

[0055] Aurora Global Database supports a master-slave architecture, consisting of one master region and five slave regions. The master region provides read and write capabilities to support data reading and writing. The five slave regions provide read-only capabilities to support read-only data. The master database node in the master region asynchronously synchronizes data to the five slave regions through a cross-region network between the master region and the five slave regions. If the master database node's resources are insufficient, causing an increase in the RPO of the slave regions and the synchronization lag between the master and slave regions, it will put back pressure on front-end services. For example, Aurora Global Database promises an RPO of less than 1 second. If the RPO of all five slave regions exceeds 1 second, the master region will suspend writing data to front-end services (e.g., the master region will suspend processing data write requests sent by clients to pause writing data to the front-end services) until at least one slave region's RPO is less than 1 second. However, this back pressure on front-end services will affect their performance.

[0056] PolarDB GDN supports a maximum of one master and four slaves. This example illustrates PolarDB GDN as a database system with cross-region disaster recovery capabilities (one master and four slaves). This PolarDB GDN consists of one master region and four slave regions. The master region provides read and write capabilities to support data reading and writing. The four slave regions provide read-only capabilities to support read-only data. The master database node in the master region asynchronously synchronizes data to the four slave regions through the cross-region network between the master region and the four slave regions. PolarDB GDN promises an RPO of less than 2 seconds, but it does not mention how to address the issue of increased RPO in slave regions due to insufficient resources of the master database node, or increased synchronization lag between the master and slave regions.

[0057] It is evident that PolarDB GDN cannot resolve the issue of increased RPO in slave regions and increased synchronization lag between master and slave regions due to insufficient resources on the master database node. While Aurora Global Database can address this issue, it impacts the performance of front-end services. Therefore, in database systems with cross-region disaster recovery capabilities (one master and multiple slaves), the key challenge is ensuring timely data synchronization from the master region to multiple slave regions while maintaining a low RPO and minimal synchronization lag between master and slave regions, all while guaranteeing the performance of front-end services.

[0058] This application provides a data synchronization scheme applied to a database system, which includes a primary region and m secondary regions, where m is a positive integer. The primary region includes a primary replication cluster and a primary database node. The primary database node is a compute node with a database instance deployed on it. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node. After acquiring the data to be synchronized generated by the primary database node, the primary replication cluster generates at least one replication task corresponding to the data to be synchronized. The primary replication cluster adds the at least one replication task to a task queue. The primary replication cluster concurrently retrieves the at least one replication task from the task queue and concurrently synchronizes the data to be synchronized to the m secondary regions according to the at least one replication task. This application sets up a primary replication cluster in the primary region, and the primary replication cluster concurrently synchronizes the data to be synchronized to the m secondary regions. Therefore, it can avoid the situation where insufficient resources of the primary database node in the primary region prevent the data to be synchronized from being synchronized to the secondary regions in a timely manner. This application embodiment can synchronize the data to be synchronized to the slave regions in a timely manner, reducing the RPO of the slave regions and the synchronization lag between the master region and the slave regions. It avoids backpressure on front-end services due to large RPOs of slave regions and / or large synchronization lags between the master and slave regions. It can synchronize the data to be synchronized to the m slave regions in a timely manner while ensuring service performance, guaranteeing a small RPO and a small synchronization lag between the master and slave regions. In an optional embodiment, the master replication cluster includes multiple replication nodes. These multiple replication nodes concurrently synchronize the data to be synchronized to the m slave regions according to at least one replication task. This can improve the throughput of the master replication cluster, thereby improving the throughput of the master region. It can also increase the number of incremental data that the master region can handle and the number of slave regions that the master region can support, making it suitable for database systems with a large number of slave regions.

[0059] The technical solutions of the embodiments of this application are described below. First, the application scenarios of the embodiments of this application are introduced.

[0060] The application scenario of this application provides a database system for storing business data. For example, the database system stores (also known as writing) business data based on data write requests from business clients.

[0061] In this embodiment, the database system is a database system with cross-region disaster recovery capabilities. The database system includes a primary region and m secondary regions, where m is a positive integer. For example, the database system is a database system with one primary and multiple secondary cross-region disaster recovery capabilities, including one primary region and multiple secondary regions, where m is an integer greater than 1. For example, m can be equal to 2, 4, 5, 8, 10, etc.

[0062] The main region and the m subordinate regions can be located in different geographical areas, and different subordinate regions can be located in different geographical areas. For example, at least two of the main region and the m subordinate regions may be located in different countries, different cities within the same country, or different geographical areas within the same city. The main region and the m subordinate regions are connected via network communication, which includes any network that can be used for cross-region communication, such as a local area network, the Internet, or a private network. This application does not limit the distribution of regions or the network used for cross-region communication.

[0063] The primary region provides read and write capabilities to support data reading and writing. For example, the primary region allows clients to read data from and write data to the primary region. The m secondary regions provide read-only capabilities to support read-only data. For example, each secondary region allows clients to read data from the secondary region but does not support clients to write data to the secondary region. The primary region is used to store the data for a service-based client's data write request, and to concurrently synchronize the service data to the m secondary regions, so that in the event of a disaster in the primary region, the service can switch to a secondary region, and the secondary regions can guarantee the normal operation of the service. In this embodiment, the primary region includes a primary replication cluster, which concurrently synchronizes data to the m secondary regions. In a specific embodiment, each of the m secondary regions includes a secondary replication cluster, and the primary replication cluster concurrently sends data to the secondary replication clusters in the m secondary regions; after receiving the data sent by the primary replication cluster, each secondary replication cluster in the secondary region stores the data sent by the primary replication cluster in the secondary region. This enables the master replication cluster to synchronize data with the m slave regions. It should be noted that, in this embodiment, the master replication cluster refers to the replication cluster within the master region, and the slave replication cluster refers to the replication cluster within the slave regions. For any region, when the region is the master region, the replication cluster within that region is the master replication cluster; after the region's status changes from master to slave, the replication cluster within that region changes from master to slave. Similarly, for any region, when the region is a slave region, the replication cluster within that region is a slave replication cluster; after the region's status changes from slave to master, the replication cluster within that region changes from slave to master.

[0064] For the sake of brevity and ease of description, the following explanation will use m equal to 2 as an example.

[0065] As an example, please refer to Figure 1This diagram illustrates a database system according to an embodiment of this application. The database system includes regions 1-3, which are connected via network communication. Region 1 is the master region, and regions 2-3 are slave regions. Region 1 provides read / write capabilities to support data reading and writing. Regions 2-3 provide read-only capabilities to support read-only data. Region 1 is used for business-based clients (…). Figure 1 (Not shown in the image) The data write request sent stores the service data in region 1 and concurrently synchronizes the service data to regions 2-3, so that in the event of a disaster in region 1, the service can be switched to region 2 or region 3, and the normal operation of the service can be guaranteed by region 2 or region 3. For example Figure 1 As shown, regions 1 to 3 each include a replication cluster, which concurrently synchronizes data from regions 2 to 3. For ease of description, the replication cluster in region 1 is referred to as replication cluster 1, the replication cluster in region 2 as replication cluster 2, and the replication cluster in region 3 as replication cluster 3. Since region 1 is the master region and regions 2 to 3 are slave regions, replication cluster 1 is the master replication cluster, and replication clusters 2 to 3 are all slave replication clusters. Replication cluster 1 concurrently sends data to replication clusters 2 and 3; replication cluster 2 receives the data sent by replication cluster 1 and stores it in region 2; replication cluster 3 receives the data sent by replication cluster 1 and stores it in region 3; thus, replication cluster 1 in region 1 synchronizes data from regions 2 to 3.

[0066] In this embodiment, each of the primary region and the m secondary regions further includes a storage pool and at least one database node. The storage pool stores data. The database node manages data information (e.g., index information, version information, etc.). In each region, the storage pool and database node are communicatively connected to the replication cluster. The replication cluster in each region stores data in the storage pool within that region and sends the data information to the database node in that region, enabling the database node to manage the data information. For example, the storage pool and database node in the primary region are communicatively connected to the primary replication cluster in that primary region, which stores data in the storage pool and sends the data information to the database node. Similarly, the storage pool and database node in each secondary region are communicatively connected to the secondary replication cluster in that secondary region, which stores data in the storage pool within that secondary region and sends the data information to the database node. The storage pool includes at least one storage node, which can be a storage server, a memory, or any other medium that can be used to store data. This example illustrates the process using the primary region and each of the m secondary regions, including a storage pool and three database nodes. Please refer to [link / reference]. Figure 2 This illustrates a schematic diagram of another database system provided in an embodiment of this application. For example... Figure 2As shown, region 1 includes storage pool 1 and database nodes 11-13; region 2 includes storage pool 2 and database nodes 21-23; and region 3 includes storage pool 3 and database nodes 31-33. Storage pool 1 and database nodes 11-13 are communicatively connected to replication cluster 1. Storage pool 2 and database nodes 21-23 are communicatively connected to replication cluster 2. Storage pool 3 and database nodes 31-33 are communicatively connected to replication cluster 3. Storage pools 1-3 are used to store data. Database nodes 11-13 are used to manage information about the data stored in storage pool 1. Database nodes 21-23 are used to manage information about the data stored in storage pool 2. Database nodes 31-33 are used to manage information about the data stored in storage pool 3. After replication cluster 1 stores data in storage pool 1, it sends information about that data to database nodes 11-13 so that these nodes can manage the data. After receiving data from replication cluster 1, replication cluster 2 stores the data in storage pool 2 and sends the data information to database nodes 21-23 for management. Similarly, after receiving data from replication cluster 1, replication cluster 3 stores the data in storage pool 3 and sends the data information to database nodes 31-33 for management.

[0067] In this embodiment, the database nodes in the main region and each of the m slave regions may include a master database node and slave database nodes. Both master and slave database nodes are compute nodes with deployed database instances. Both master and slave database nodes can be used to handle data access requests from clients. For example, the master database node in the main region provides read / write capabilities to support data reading and writing, and is used to handle data write requests, data read requests, data query requests, data deletion requests, data update requests, etc., from clients. The slave database nodes in the main region, the master database nodes in each slave region, and the slave database nodes in each slave region all provide read-only capabilities to support read-only data, and are used to handle data read requests from clients. As an example, such as... Figure 2As shown, database node 11 is the master database node in region 1, and database nodes 12 and 13 are slave database nodes in region 1. Database node 11 handles data write requests, data read requests, data query requests, data delete requests, and data update requests from clients, while database nodes 12 and 13 handle data read requests from clients. Database node 21 is the master database node in region 2, and database nodes 22 and 23 are slave database nodes in region 2. Database nodes 21 and 23 handle data read requests from clients. Database node 31 is the master database node in region 3, and database nodes 32 and 33 are slave database nodes in region 3. Database nodes 31 and 33 handle data read requests from clients.

[0068] In an optional embodiment, each of the primary region and the m secondary regions further includes a database proxy node. The database proxy node in each region provides a unified entry point for clients to access that region. Each database proxy node in a region can communicate with the database nodes in that region and can forward data access requests and responses between the client and the database nodes in that region. For example, the database proxy node in each region can forward data access requests and responses between the client and the primary database node in that region. In a specific embodiment, the database proxy node in each region can be used to: receive a data access request from a client; send the data access request to the primary database node in that region; receive the data access response from the primary database node in that region; and send the data access response to the client. The database proxy node in each region can also be used for load balancing among the multiple database nodes in that region; therefore, the database proxy node is also called a load balancing (LB) node. It should be noted that since the primary region supports both reading and writing of data, while the secondary region only supports read-only data, the data access requests mentioned above can include data read requests, data write requests, data query requests, data delete requests, and data update requests for the primary region; for the secondary region, the data access requests mentioned above are data read requests. When a database proxy node in a secondary region receives a data write request from a client, that database proxy node can forward the data write request to the primary region (e.g., to a database proxy node in the primary region) for processing.

[0069] Please continue to refer to this. Figure 2 Region 1 includes database proxy node 1, Region 2 includes database proxy node 2, and Region 3 includes database proxy node 3. Database proxy node 1 communicates with database nodes 11-13. Database proxy node 2 communicates with database nodes 21-23. Database proxy node 3 communicates with database nodes 31-33. Database proxy node 1 is used to communicate with clients (…). Figure 2Database proxy node 1 (not shown) provides a unified entry point for accessing region 1 (e.g., providing clients with a unified entry point for writing and reading data from region 1) and performs load balancing among database nodes 11-13. Database proxy node 2 provides clients with a unified entry point for accessing region 2 (e.g., providing clients with a unified entry point for reading data from region 2) and performs load balancing among database nodes 21-23. Database proxy node 3 provides clients with a unified entry point for accessing region 3 (e.g., providing clients with a unified entry point for reading data from region 3) and performs load balancing among database nodes 31-33. Database proxy node 1 can be used to forward data access requests (e.g., data write requests, data read requests, data query requests, data delete requests, data update requests, etc.) and data access responses between clients and database nodes 11-13. Database proxy node 2 can be used to forward data access requests (e.g., data read requests) and data access responses between clients and database nodes 21-23. Database proxy node 3 can be used to forward data access requests (e.g., data read requests) and data access responses between the client and database nodes 31-33. In a specific embodiment, database node 11 is the master database node in region 1, and database nodes 12-13 are slave database nodes in region 1. Database node 11 provides read / write capabilities to support data reading and writing, while database nodes 12-13 provide read-only capabilities to support read-only data. Database proxy node 1 can be used to: receive data access requests from clients; send the data access request to database node 11; receive the data access response from database node 11 for the data access request; and send the data access response to the client. Database node 21 is the master database node in region 2, and database nodes 22-23 are slave database nodes in region 2. Database nodes 21-23 provide read-only capabilities to support read-only data. Database proxy node 2 can be used to: receive data access requests from clients; send the data access request to database node 21; receive the data access response from database node 21 for the data access request; and send the data access response to the client. Database node 31 is the master database node in region 3, and database nodes 32 and 33 are slave database nodes in region 3. Database nodes 31 and 33 provide read-only capability to support read-only data. Database proxy node 3 can be used to: receive data access requests from clients; send the data access request to database node 31; receive the data access response from database node 31 to the data access request; and send the data access response to the client.

[0070] Please refer to Figure 3 This illustration shows a schematic diagram of the working process of a database system provided in an embodiment of this application. The database system is... Figure 2 The database system shown. Figure 3 For simplicity, the network used for communication between different regions in this database system, as well as the connection relationships between database agent nodes, database nodes, replication clusters, and storage pools in each region, are not shown. This information can be found in [reference needed]. Figure 2 And its description. Figure 3 The arrows between database agent nodes, database nodes, replication clusters, and storage pools indicate the direction of signal flow. For example... Figure 3 As shown, the client sends a data write request A to database proxy node 1, requesting that target data be written to the database system. After receiving data write request A, database proxy node 1 sends data write request A to database node 11 (the primary database node in region 1). After receiving data write request A, database node 11 sends data write request A to replication cluster 1. After receiving data write request A, replication cluster 1 writes the target data to storage pool 1 according to data write request A, and sends the target data information (the target data information is...) to database nodes 11-13. Figure 3 Data information A in the middle, Figure 3 For simplicity, the arrow lines indicating the information sent by replication cluster 1 to database node 11 are not shown. Then, replication cluster 1 generates a data write response A, which is a response to the data write request A. Replication cluster 1 sends data write response A to database node 11. After receiving data write response A, database node 11 sends data write response A to database agent node 1. After receiving data write response A, database agent node 1 sends data write response A to the client. Furthermore, after receiving data write request A (e.g., after replication cluster 1 writes the target data to storage pool 1), replication cluster 1 concurrently synchronizes the target data to region 2 and region 3. Specifically, replication cluster 1 concurrently sends the target data to replication cluster 2 and replication cluster 3. After receiving the target data, replication cluster 2 stores the target data in storage pool 2, sends the target data information to database nodes 21-23, and sends a synchronization response to replication cluster 1. After receiving the target data, replication cluster 3 stores the target data in storage pool 3, sends the target data information to database nodes 31-33, and sends a synchronization response to replication cluster 1. This completes the writing of the target data to the database system and the synchronization of the target data from region 1 to regions 2-3.

[0071] In this embodiment, the data to be synchronized to the m slave regions in the primary region (e.g., the aforementioned target data) can be generated by the primary database node in the primary region. For example, the primary database node in the primary region generates the data to be synchronized based on data write requests from clients. In one example, the data write request from the client carries the data to be synchronized, and the primary database node in the primary region obtains the data to be synchronized from the data write request. In another example, the primary database node in the primary region generates the data to be synchronized based on data carried by multiple data write requests from clients. The replication cluster (i.e., the primary replication cluster) in the primary region is used to: obtain the data to be synchronized generated by the primary database node in the primary region; generate at least one replication task corresponding to the data to be synchronized; add the at least one replication task to a task queue; concurrently obtain the at least one replication task from the task queue; and concurrently synchronize the data to be synchronized to the m slave regions based on the at least one replication task obtained from the task queue. In an optional embodiment, the primary replication cluster includes a thread pool and at least one replication node. The thread pool includes multiple replication threads, which are allocated to the at least one replication node. These multiple replication threads are used to concurrently retrieve the at least one replication task from the task queue. The replication node containing the replication thread that retrieves the at least one replication task concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task. For example... Figure 1 and Figure 2 As shown, replication cluster 1 includes multiple replication threads ( Figure 1 and Figure 2 (not shown in the image) and at least one replica node ( Figure 1 and Figure 2 (Not shown in the diagram), the multiple replication threads are used to concurrently obtain the at least one replication task from the task queue. The replication node where the replication thread that obtained the at least one replication task is located concurrently sends the data to be synchronized to replication cluster 2 and replication cluster 3 according to the at least one replication task, so as to concurrently synchronize the data to be synchronized to region 2 and region 3. In an optional embodiment, each replication cluster in the slave region (i.e., the slave replication cluster) includes a thread pool and at least one replication node. The thread pool in each slave replication cluster includes multiple replication threads, and the replication threads in the thread pool of each slave replication cluster are assigned to at least one replication node in the slave replication cluster. The operations described above that are performed by the slave replication cluster can be specifically performed by the replication threads of the slave replication cluster. For example Figure 1 and Figure 2 As shown, replication clusters 2 and 3 each include multiple replication threads ( Figure 1 and Figure 2 (Not shown in the diagram) and at least one replication node; the plurality of replication threads in replication cluster 2 are allocated to at least one replication node in replication cluster 2, and the operations described above that are performed by replication cluster 2 can be specifically performed by the replication threads in replication cluster 2; the plurality of replication threads in replication cluster 3 are allocated to at least one replication node in replication cluster 3, and the operations described above that are performed by replication cluster 3 can be specifically performed by the replication threads in replication cluster 3. Here, a replication thread is a thread used for data replication (i.e., data synchronization), and a replication thread can also be called a synchronization thread.

[0072] In this embodiment, both the master replication cluster and the slave replication cluster can be single-node or multi-node replication clusters. A single-node replication cluster includes one replication node, and multiple replication threads in the single-node replication cluster are allocated to this single replication node. The thread pool in the single-node replication cluster is composed of the replication threads in this single replication node. A multi-node replication cluster includes multiple replication nodes, and multiple replication threads in the multi-node replication cluster are allocated to these multiple replication nodes. The thread pool in the multi-node replication cluster is composed of the replication threads in these multiple replication nodes. For either the master or slave replication cluster, if the replication cluster is a single-node replication cluster, the operations described above performed by the replication cluster are specifically performed by one replication node in the replication cluster; if the replication cluster is a multi-node replication cluster, the operations described above performed by the replication cluster are specifically performed by multiple replication nodes in the replication cluster. For example, if the master replication cluster is a single-node replication cluster, the master replication cluster includes one replication node, which is used to: obtain the data to be synchronized generated by the master database node in the master region; generate at least one replication task corresponding to the data to be synchronized; and add the at least one replication task to the task queue. The replication thread in a replication node is used to concurrently retrieve the at least one replication task from the task queue. The replication node is then used to concurrently synchronize the data to be synchronized to the m slave regions based on the at least one replication task retrieved from the task queue by the replication thread in the replication node. For example, in the case where the primary replication cluster is a multi-node replication cluster, the primary replication cluster includes multiple replication nodes, including a primary replication node and slave replication nodes (e.g., the multiple replication nodes include one primary replication node, and the replication nodes other than the primary replication node are slave replication nodes). The primary replication node is used to: retrieve the data to be synchronized generated by the primary database node in the primary region; generate at least one replication task corresponding to the data to be synchronized; and add the at least one replication task to the task queue. The replication threads in the primary replication node and the replication threads in the slave replication nodes are used to concurrently retrieve the at least one replication task from the task queue. The replication node containing the replication thread that retrieves the at least one replication task concurrently synchronizes the data to be synchronized to the m slave regions based on the at least one replication task. The primary replication node is also called the leader replication node, and the secondary replication node is also called the follower replication node.

[0073] In one embodiment, please refer to Figure 4 The diagram illustrates another database system provided in the embodiments of this application. Figure 4This explanation uses an example where both the replication cluster in the primary region (i.e., the primary replication cluster) and the replication cluster in the secondary region (i.e., the secondary replication cluster) are single-node replication clusters. Figure 4 As shown, region 1 includes replication cluster 1, region 2 includes replication cluster 2, and region 3 includes replication cluster 3. Replication cluster 1 includes one replication node 11, replication cluster 2 includes one replication node 21, and replication cluster 3 includes one replication node 31. Multiple replication threads in replication cluster 1 are allocated to replication node 11. Multiple replication threads in replication cluster 2 are allocated to replication node 21. Multiple replication threads in replication cluster 3 are allocated to replication node 31. Replication node 11 is used to: obtain the data to be synchronized generated by database node 11 (the primary database node in the primary region); generate at least one replication task corresponding to the data to be synchronized; and add the at least one replication task to a task queue. Multiple replication threads in replication node 11 are used to concurrently obtain the at least one replication task from the task queue. Replication node 11 is used to concurrently send the data to be synchronized to replication nodes 21 and 31 according to the at least one replication task obtained from the task queue by the replication threads in replication node 11, so as to concurrently synchronize the data to be synchronized to region 2 and region 3. After receiving the data to be synchronized, replication node 21 stores the data in storage pool 2 and sends the data information to database nodes 21-23. After receiving the data to be synchronized, replication node 31 stores the data in storage pool 3 and sends the data information to database nodes 31-33.

[0074] In another embodiment, please refer to Figure 5 This illustrates a schematic diagram of yet another database system provided in an embodiment of this application. Figure 5 This explanation assumes that both the replication cluster in the primary region (i.e., the primary replication cluster) and the replication cluster in the secondary region (i.e., the secondary replication cluster) are multi-node replication clusters, and that each replication cluster consists of three replication nodes. Figure 5As shown, region 1 includes replication cluster 1, region 2 includes replication cluster 2, and region 3 includes replication cluster 3. Replication cluster 1 includes three replication nodes 11-13, replication cluster 2 includes three replication nodes 21-23, and replication cluster 3 includes three replication nodes 31-33. Multiple replication threads in replication cluster 1 are allocated to replication nodes 11-13. Multiple replication threads in replication cluster 2 are allocated to replication nodes 21-23. Multiple replication threads in replication cluster 3 are allocated to replication nodes 31-33. Replication nodes 11-13 include a master replication node and slave replication nodes (e.g., replication node 11 is the master replication node, and replication nodes 12-13 are slave replication nodes). Replication node 11 is used to: obtain the data to be synchronized generated by database node 11 (the master database node in the main region); generate at least one replication task corresponding to the data to be synchronized; and add the at least one replication task to the task queue. Multiple replication threads in replication nodes 11-13 are used to concurrently obtain the at least one replication task from the task queue. Among the multiple replication threads in replication nodes 11-13, the replication node containing the replication thread that has obtained at least one replication task concurrently sends the data to be synchronized to replication nodes 21-23 and 31-33 according to the at least one replication task, so as to concurrently synchronize the data to be synchronized to region2 and region3. After any replication node 21-23 receives the data to be synchronized, the replication thread in that replication node stores the data to be synchronized in storage pool 2 and sends the information of the data to be synchronized to database nodes 21-23. After any replication node 31-33 receives the data to be synchronized, the replication thread in that replication node stores the data to be synchronized in storage pool 3 and sends the information of the data to be synchronized to database nodes 31-33.

[0075] Figure 4 This explanation uses the example of a replication cluster in the primary region (i.e., the primary replication cluster) and a replication cluster in the secondary region (i.e., the secondary replication cluster) both being single-node replication clusters. Figure 5 This example illustrates the concept of multi-node replication clusters in both the primary region (i.e., the primary replication cluster) and the secondary region (i.e., the secondary replication cluster). This is merely an example. In other embodiments, some regions within the primary and secondary regions may have single-node replication clusters, while others may have multi-node replication clusters. For instance, the primary region may have a multi-node replication cluster, while the secondary region may have a single-node replication cluster. Furthermore, Figure 4Taking the example of equal numbers of replication nodes in each replication cluster, in other embodiments, the number of replication nodes in different replication clusters may not be equal. For example, the number of replication nodes in the primary replication cluster may be greater than the number of replication nodes in the secondary replication cluster. Whether the replication cluster is a single-node replication cluster or a multi-node replication cluster, and the number of replication nodes included in a multi-node replication cluster, can be configured by the user during replication cluster deployment.

[0076] In the case where the replication cluster in at least one of the aforementioned primary region and m secondary regions is a multi-node replication cluster, the replication nodes in the replication cluster of the primary region (i.e., the master replication cluster) are fully connected to the replication nodes in the replication clusters of the m secondary regions (i.e., the secondary replication clusters). That is, each replication node in the replication cluster of the primary region (i.e., the master replication cluster) is connected to each replication node in the replication cluster of each secondary region (i.e., the secondary replication cluster). For example, the replication nodes in the replication cluster of the primary region (i.e., the master replication cluster) are fully connected to the replication nodes in the replication clusters of the m secondary regions (i.e., the secondary replication clusters) in a point-to-point manner; or, the replication cluster in at least one of the primary region and m secondary regions includes a replication proxy node, and the replication nodes in the replication cluster of the primary region (i.e., the master replication cluster) and the replication nodes in the replication clusters of the m secondary regions (i.e., the secondary replication clusters) are fully connected through the replication proxy node. As an example, the first replication cluster is a replication cluster comprised of one of the primary region and m secondary regions, and the second replication cluster is a replication cluster comprised of the other of the primary region and m secondary regions. For instance, the first replication cluster is the replication cluster in the primary region (i.e., the primary replication cluster), and the second replication cluster is the replication cluster in a secondary region (i.e., the secondary replication cluster). Replication nodes in the first replication cluster and replication nodes in the second replication cluster are fully connected point-to-point. Alternatively, the first and second replication clusters also each include replication proxy nodes, with replication proxy nodes in the first replication cluster connected to replication nodes in the first replication cluster, replication proxy nodes in the second replication cluster connected to replication nodes in the second replication cluster, and replication proxy nodes in the first replication cluster connected to replication proxy nodes in the second replication cluster. Or, the second replication cluster also includes replication proxy nodes, with replication proxy nodes in the second replication cluster connected to replication nodes in the second replication cluster, and replication nodes in the first replication cluster connected to replication proxy nodes in the second replication cluster. Alternatively, the first replication cluster may also include replication agent nodes, which are connected to the replication nodes in the first replication cluster, and the replication nodes in the second replication cluster are connected to the replication agent nodes in the first replication cluster. In a specific embodiment, the replication clusters (i.e., slave replication clusters) in the m slave regions are referred to as replication clusters S1 to Sm, and replication clusters S1 to Sm are located one-to-one in the m slave regions. The replication cluster in the master region (i.e., the master replication cluster) is fully connected to the replication nodes in replication clusters S1 to Sm in a point-to-point manner.Alternatively, the replication cluster in the primary region (i.e., the primary replication cluster) and each replication cluster in replication clusters S1 to Sm also include replication agent nodes. Each replication agent node in a replication cluster is connected to a replication node in that replication cluster, and the replication agent nodes in the replication cluster in the primary region (i.e., the primary replication cluster) are connected to the replication agent nodes in replication clusters S1 to Sm. Alternatively, each replication cluster in replication clusters S1 to Sm (i.e., the secondary replication cluster) also includes replication agent nodes. Each replication agent node in replication clusters S1 to Sm is connected to a replication node in that replication cluster, and the replication nodes in the replication cluster in the primary region (i.e., the primary replication cluster) are connected to the replication agent nodes in replication clusters S1 to Sm. The replication agent nodes in the replication clusters provide a unified entry point for communication with the replication clusters to improve their availability. The replication agent nodes in the replication clusters can also be used for load balancing among multiple replication nodes in the replication cluster; therefore, replication agent nodes are also called LB nodes.

[0077] In one embodiment, please refer to Figure 6 This illustrates a connection diagram of a replication cluster in regions 1-3 provided in an embodiment of this application. For example... Figure 6 As shown, region 1 includes replication cluster 1, region 2 includes replication cluster 2, and region 3 includes replication cluster 3. Replication cluster 1 includes three replication nodes 11-13, replication cluster 2 includes three replication nodes 21-23, and replication cluster 3 includes three replication nodes 31-33. Replication node 11 is connected to each of replication nodes 21-23 and 31-33 in a point-to-point manner; replication node 12 is connected to each of replication nodes 21-23 and 31-33 in a point-to-point manner; and replication node 13 is connected to each of replication nodes 21-23 and 31-33 in a point-to-point manner. That is, replication nodes 11-13 are fully connected to replication nodes 21-23 and 31-33 in a point-to-point manner.

[0078] In another embodiment, please refer to Figure 7 This illustrates a connection diagram of another replication cluster in regions 1-3 provided in an embodiment of this application. For example... Figure 7As shown, region 1 includes replication cluster 1, region 2 includes replication cluster 2, and region 3 includes replication cluster 3. Replication cluster 1 includes replication agent node 1 and three replication nodes 11-13; replication cluster 2 includes replication agent node 2 and three replication nodes 21-23; and replication cluster 3 includes replication agent node 3 and three replication nodes 31-33. Replication agent node 1 is connected to replication nodes 11-13, replication agent node 2 is connected to the three replication nodes 21-23, and replication agent node 3 is connected to the three replication nodes 31-33. Furthermore, replication agent node 1 is connected to replication agent nodes 2-3. That is, replication nodes 11-13 are fully connected to replication nodes 21-23 and 31-33 through replication agent nodes 1-3.

[0079] In another embodiment, please refer to Figure 8 This illustrates a connection diagram of a replication cluster in regions 1-3 provided in an embodiment of this application. For example... Figure 8 As shown, region 1 includes replication cluster 1, region 2 includes replication cluster 2, and region 3 includes replication cluster 3. Replication cluster 1 includes three replication nodes 11-13, replication cluster 2 includes replication proxy node 2 and three replication nodes 21-23, and replication cluster 3 includes replication proxy node 3 and three replication nodes 31-33. Replication proxy node 2 is connected to the three replication nodes 21-23, replication proxy node 3 is connected to the three replication nodes 31-33, and each replication node 11-13 is connected to replication proxy nodes 2-3. That is, replication nodes 11-13 are fully connected to replication nodes 21-23 and replication nodes 31-33 through replication proxy nodes 2-3.

[0080] It should be noted that, Figure 8 The example given is that the replication cluster in the slave region (i.e., the slave replication cluster) includes replication agent nodes, while the replication cluster in the master region (i.e., the master replication cluster) does not include replication agent nodes. This is merely an example. In other embodiments, the replication cluster in the master region (i.e., the master replication cluster) includes replication agent nodes, and at least one replication cluster in the slave region (i.e., the slave replication cluster) does not include replication agent nodes. This application does not limit this aspect. Figures 6 to 8This example only illustrates the connection relationship between the replication clusters in the primary region and the replication clusters in the secondary region. The replication clusters in the primary and secondary regions can also be connected in other ways. The connection method can be determined based on the cost and communication pressure of the network used to connect the primary and secondary regions. This application does not limit the connection method between the replication clusters in the primary and secondary regions, as long as the replication nodes in the replication clusters in the primary and secondary regions can communicate with each other.

[0081] As mentioned earlier, in the case of a multi-node replication cluster, the replication cluster includes multiple replication nodes, including a master replication node and slave replication nodes. The master replication node can be one elected from among the multiple replication nodes. In an optional embodiment, the replication cluster also includes a management node, which is communicatively connected to the multiple replication nodes. The management node is used to manage the multiple replication nodes, monitor their health status, elect a master replication node from among them, and perform master-slave switching among the multiple replication nodes. For example, the management node manages the multiple replication nodes through a consensus protocol, which can be Paxos, Zookeeper, Gossip, or ETCD, or other proprietary protocols. After the management node elects a master replication node from among the multiple replication nodes, the master replication node periodically sends heartbeat signals to the management node to renew its keep-alive contract. If the management node determines that the primary replica node has lost its heartbeat (e.g., the management node has not received a heartbeat signal from the primary replica node for several consecutive heartbeat cycles), the management node will re-elect a primary replica node from among the multiple replica nodes, thereby achieving the switchover between the primary and secondary replica nodes. This is illustrated using the replica cluster in the primary region (i.e., the primary replica cluster) as an example. Please refer to [link to relevant documentation]. Figure 9 and Figure 10 , Figure 9 and Figure 10 The diagram illustrates two types of replication clusters 1 provided in embodiments of this application. Replication cluster 1 is as follows: Figures 1 to 3 and Figures 5 to 8 The replication cluster in region1 (also known as the primary region) is shown. Figure 9 Taking replication cluster 1 excluding replication agent nodes as an example, Figure 10 Let's take replication cluster 1, which includes replication agent nodes, as an example. Figure 9As shown, replication cluster 1 includes management node 1 and replication nodes 11-13. Management node 1 is communicatively connected to replication nodes 11-13. Management node 1 is used to manage replication nodes 11-13, monitor their health status, elect a master replication node from among the replication nodes 11-13, and perform master-slave switching among the replication nodes 11-13. Figure 10 As shown, replication cluster 1 includes replication agent node 1, management node 1, and replication nodes 11-13. Replication agent node 1 communicates with replication nodes 11-13, management node 1 communicates with replication nodes 11-13, and replication agent node 1 communicates with management node 1. Management node 1 manages replication nodes 11-13, monitors their health status, elects a master replication node from among them, and performs master / slave switching among replication nodes 11-13. Replication agent node 1 provides a unified entry point for communication with replication cluster 1. Replication agent node 1 also queries management node 1 for the master replication node (i.e., queries which replication node is the master replication node) to communicate with that master replication node. For example, the primary database node in region1 sends a data write request to replication agent node 1. After receiving the data write request, replication agent node 1 sends the data write request to the primary replication node in replication cluster 1. The primary replication node stores the data requested to be written in storage pool 1 in region1 and sends the data information to database nodes 11-13. It should be noted that this example uses the replication cluster in the primary region (i.e., the primary replication cluster). When the replication cluster in the secondary region (i.e., the secondary replication cluster) is a multi-node replication cluster, the structure and description of the replication cluster in the secondary region can refer to the structure and description of the replication cluster in the primary region. This embodiment will not be elaborated here.

[0082] In an optional embodiment, the replication cluster in the primary region (i.e., the primary replication cluster) is a serverless replication cluster. The size of the primary replication cluster can elastically scale with the load of the data it synchronizes, and / or, the size of the primary replication cluster can elastically scale with changes in the identity of the region where the primary replication cluster resides. For example, the size of the primary replication cluster can elastically scale within a preset range with the load of the data it synchronizes, and / or, the size of the primary replication cluster can elastically scale within a preset range with changes in the identity of the region where the primary replication cluster resides. That is, the elastic scaling of the primary replication cluster can have a range, which can be specified by the user. The identity of the region where the primary replication cluster resides includes a primary region or a secondary region. After the identity of the region where the primary replication cluster resides changes from a primary region to a secondary region, the identity of the primary replication cluster changes to a secondary replication cluster. The load of the data it synchronizes is characterized by at least one of the following: the utilization rate of the primary replication cluster's computing resources; the utilization rate of the primary replication cluster's transmission resources; and the transmission rate of the primary replication cluster's transmission resources. For example, computing resources are CPU resources, and the utilization rate of computing resources is CPU utilization; transmission resources are network interface cards (NICs), and the utilization rate of transmission resources is the bandwidth utilization rate of the NIC. The transmission rate of transmission resources is the number of times the NIC sends data per unit time (e.g., packets per second, PPS). In one embodiment, the primary replication cluster is a single-node replication cluster, which includes one replication node. The utilization rate of the computing resources of the primary replication cluster is the utilization rate of the computing resources of the single replication node, the utilization rate of the transmission resources of the primary replication cluster is the utilization rate of the transmission resources of the single replication node, and the transmission rate of the transmission resources of the primary replication cluster is the transmission rate of the transmission resources of the single replication node. In another embodiment, the primary replication cluster is a multi-node replication cluster, which includes multiple replication nodes. The utilization rate of the computing resources of the primary replication cluster includes the utilization rate of the computing resources of the multiple replication nodes. The utilization rate of the transmission resources of the primary replication cluster includes the utilization rate of the computing resources of the multiple replication nodes. The transmission rate of the transmission resources of the primary replication cluster includes the transmission rate of the transmission resources of the multiple replication nodes.

[0083] In this embodiment, the size of the primary replication cluster can be elastically scaled by increasing or decreasing the specifications of the replication nodes in the primary replication cluster, and / or by increasing or decreasing the number of replication nodes in the primary replication cluster. Increasing the specifications of a replication node includes increasing its computing resources, memory resources, and transmission resources (e.g., adding a network interface card to the replication node). Decreasing the specifications of a replication node includes decreasing its computing resources, memory resources, and transmission resources (e.g., removing some network interface cards from the replication node). Increasing the number of replication nodes in the primary replication cluster means adding replication nodes to the primary replication cluster. Decreasing the number of replication nodes in the primary replication cluster means removing at least one replication node from the primary replication cluster.

[0084] In one embodiment, the size of the primary replication cluster is elastically scaled based on the load of the synchronization data. Specifically, the load of the synchronization data determines whether the primary replication cluster meets the expansion or reduction conditions. If the primary replication cluster meets the expansion condition, its size is increased by increasing the specifications of the replication nodes, and / or by increasing the number of replication nodes. If the primary replication cluster meets the reduction condition, its size is decreased by decreasing the specifications of the replication nodes, and / or by decreasing the number of replication nodes. For example, if the primary replication cluster meets the expansion condition, its size is first increased by increasing the specifications of the replication nodes; if the expansion condition is still met after increasing the specifications, the size is then increased by increasing the number of replication nodes. For example, if the primary replication cluster meets the scaling-down condition and is a multi-node replication cluster, the size of the primary replication cluster is first reduced by decreasing the number of replication nodes. If the primary replication cluster still meets the scaling-down condition after reducing the number of replication nodes, the size of the primary replication cluster is then reduced by decreasing the specifications of the replication nodes. As another example, if the primary replication cluster meets the scaling-down condition and is a single-node replication cluster, the size of the primary replication cluster is reduced by decreasing the specifications of the replication nodes. The following describes the implementation methods for elastically scaling the size of the primary replication cluster based on the load of the synchronized data, in two different scenarios.

[0085] The first scenario: The primary replication cluster is a single-node replication cluster, consisting of one replication node. The scaling condition includes at least one of the following: the utilization rate of the replication node's computing resources (e.g., CPU utilization) is greater than a first threshold and continuously increases from the region's RPO; the utilization rate of the replication node's transmission resources (e.g., network interface card bandwidth utilization) is greater than a second threshold; the transmission rate of the replication node's transmission resources (e.g., network interface card PPS) is greater than a third threshold. The scaling condition includes at least one of the following: the utilization rate of the replication node's computing resources (e.g., CPU utilization) is less than a fourth threshold; the utilization rate of the replication node's transmission resources (e.g., network interface card bandwidth utilization) is less than a fifth threshold; the transmission rate of the replication node's transmission resources (e.g., network interface card PPS) is less than a sixth threshold.

[0086] In one embodiment, the primary replication cluster meets an expansion condition where the utilization rate of the computing resources of a replication node is greater than a first threshold and the RPO from the region continues to increase. The size of the primary replication cluster is expanded by increasing the specifications of the replication node. For example, the size of the primary replication cluster is expanded by increasing the computing resources and / or memory resources of the replication node.

[0087] In another embodiment, the primary replication cluster meets an expansion condition, which includes the utilization of transmission resources of a replication node being greater than a second threshold, thereby expanding the size of the primary replication cluster by increasing the number of replication nodes in the primary replication cluster.

[0088] In another embodiment, the primary replication cluster meets the scaling conditions, which include the transmission rate of the transmission resources of a replication node being greater than a third threshold, thereby expanding the size of the primary replication cluster by increasing the number of replication nodes in the primary replication cluster.

[0089] In another embodiment, the primary replication cluster meets a scaling-up condition, and the size of the primary replication cluster is reduced by scaling down the specifications of the replication nodes within it. Specifically, if the primary replication cluster satisfies the following conditions: the utilization rate of the computing resources of a replication node is less than a fourth threshold, and / or the utilization rate of the transmission resources of a replication node is less than a fifth threshold, and / or the transmission rate of the transmission resources of a replication node is less than a sixth threshold, the size of the primary replication cluster is reduced by scaling down the specifications of that replication node. For example, the size of the primary replication cluster is reduced by decreasing the computing resources and / or memory resources and / or transmission resources of that replication node.

[0090] The four embodiments described in the first scenario are merely examples and are not intended to limit the technical solutions of the embodiments of this application. When the expansion condition is that the utilization rate of the computing resources of a replica node is greater than a first threshold and the RPO from the region continues to increase, the size of the primary replication cluster can also be expanded by increasing the number of replica nodes in the primary replication cluster. When the expansion condition includes that the utilization rate of the transmission resources of a replica node is greater than a second threshold, the size of the primary replication cluster can also be expanded by increasing the specifications of the replica node (e.g., increasing the transmission resources of the replica node). When the expansion condition includes that the transmission rate of the transmission resources of a replica node is greater than a third threshold, the size of the primary replication cluster can also be expanded by increasing the specifications of the replica node.

[0091] Furthermore, it is easy to understand that in this first case, the primary replication cluster is a single-node replication cluster. After increasing the number of replication nodes in the primary replication cluster, the primary replication cluster changes from a single-node replication cluster to a multi-node replication cluster.

[0092] The second scenario: The primary replication cluster is a multi-node replication cluster, comprising multiple replication nodes. The expansion condition includes at least one of the following: the number of replication nodes whose computing resource utilization (e.g., CPU utilization) is greater than a first threshold is greater than a first number and continuously increases from the region's RPO; the number of replication nodes whose transmission resource utilization (e.g., network interface card bandwidth utilization) is greater than a second threshold is greater than a second number; the number of replication nodes whose transmission resource transfer rate (e.g., network interface card PPS) is greater than a third threshold is greater than a third number. The reduction condition includes at least one of the following: the number of replication nodes whose computing resource utilization (e.g., CPU utilization) is less than a fourth threshold is greater than a fourth number; the number of replication nodes whose transmission resource utilization (e.g., network interface card bandwidth utilization) is less than a fifth threshold is greater than a fifth number; the number of replication nodes whose transmission resource transfer rate (e.g., network interface card PPS) is less than a sixth threshold is greater than a sixth number. As an example, the expansion condition includes at least one of the following: the utilization rate of the computing resources of the plurality of replica nodes is greater than a first threshold and continuously increases from the region's RPO; the utilization rate of the transmission resources of the plurality of replica nodes is greater than a second threshold; and the transmission rate of the transmission resources of the plurality of replica nodes is greater than a third threshold. The reduction condition includes at least one of the following: the utilization rate of the computing resources of the plurality of replica nodes is less than a fourth threshold; the utilization rate of the transmission resources of the plurality of replica nodes is less than a fifth threshold; and the transmission rate of the transmission resources of the plurality of replica nodes is less than a sixth threshold.

[0093] In one embodiment, the primary replication cluster satisfies an expansion condition, which is that the number of replication nodes among the plurality of replication nodes whose computing resource utilization is greater than a first threshold is greater than a first number and whose RPO from the region continuously increases (e.g., the computing resource utilization of all replication nodes is greater than the first threshold and the RPO from the region continuously increases). The size of the primary replication cluster is expanded by increasing the specifications of all or some of the replication nodes among the plurality of replication nodes (e.g., increasing the computing resources and / or memory resources of all or some of the replication nodes among the plurality of replication nodes), and / or by increasing the number of replication nodes in the primary replication cluster. For example, the size of the primary replication cluster is first expanded by increasing the specifications of all or some of the replication nodes among the plurality of replication nodes; if the primary replication cluster still satisfies the expansion condition after expanding the specifications of the replication nodes, the size of the primary replication cluster is then expanded by increasing the number of replication nodes in the primary replication cluster.

[0094] In another embodiment, the primary replication cluster satisfies an expansion condition, which includes the number of replication nodes whose transmission resource utilization is greater than a second threshold being greater than a second number (e.g., the transmission resource utilization of all replication nodes is greater than the second threshold). The size of the primary replication cluster is expanded by increasing the number of replication nodes in the primary replication cluster.

[0095] In another embodiment, the primary replication cluster satisfies an expansion condition, which includes the number of replication nodes whose transmission resource transmission rate is greater than a third threshold being greater than a third number (e.g., the transmission resource transmission rate of all replication nodes is greater than the third threshold). The size of the primary replication cluster is expanded by increasing the number of replication nodes in the primary replication cluster.

[0096] In another embodiment, the primary replication cluster satisfies a scaling-down condition, which is that the number of replication nodes whose computing resource utilization is less than a fourth threshold is greater than a fourth number (e.g., the computing resource utilization of all replication nodes is less than the fourth threshold). The size of the primary replication cluster is reduced by scaling down the specifications of all or some of the replication nodes (e.g., reducing the computing resources and / or memory resources of all or some of the replication nodes), and / or by reducing the number of replication nodes in the primary replication cluster. For example, the size of the primary replication cluster is first reduced by decreasing the number of replication nodes; if the primary replication cluster still satisfies the scaling-down condition after reducing the number of replication nodes, the size of the primary replication cluster is then reduced by scaling down the specifications of the replication nodes.

[0097] In another embodiment, the primary replication cluster satisfies a shrinkage condition, which includes a greater than a fifth number of replication nodes whose transmission resource utilization is less than a fifth threshold (e.g., the transmission resource utilization of all replication nodes is less than the fifth threshold). The size of the primary replication cluster is reduced by decreasing the number of replication nodes in the primary replication cluster.

[0098] In another embodiment, the primary replication cluster satisfies a shrinking condition, which includes the number of replication nodes whose transmission resource transmission rate is less than a sixth threshold being greater than a sixth number (e.g., the transmission resource transmission rate of all replication nodes is less than the sixth threshold). The size of the primary replication cluster is reduced by decreasing the number of replication nodes in the primary replication cluster.

[0099] The six embodiments described in the second scenario are merely examples and are not intended to limit the technical solutions of the embodiments of this application. When the expansion condition includes a number of replication nodes whose transmission resource utilization rate is greater than the second threshold and which is greater than the second number, the size of the primary replication cluster can also be expanded by increasing the specifications of all or some of the replication nodes. When the expansion condition includes a number of replication nodes whose transmission resource transmission rate is greater than the third threshold and which is greater than the third number, the size of the primary replication cluster can also be expanded by increasing the specifications of all or some of the replication nodes. When the reduction condition includes a number of replication nodes whose transmission resource utilization rate is less than the fifth threshold and which is greater than the fifth number, the size of the primary replication cluster can also be reduced by reducing the specifications of all or some of the replication nodes. When the reduction condition includes a number of replication nodes whose transmission resource transmission rate is less than the sixth threshold and which is greater than the sixth number, the size of the primary replication cluster can also be reduced by reducing the specifications of all or some of the replication nodes.

[0100] Furthermore, it is easy to understand that in this second scenario, the primary replication cluster is a multi-node replication cluster. After reducing the number of replication nodes in the primary replication cluster, the primary replication cluster may change from a multi-node replication cluster to a single-node replication cluster.

[0101] It should be noted that the first threshold, second threshold, third threshold, fourth threshold, fifth threshold, sixth threshold, first quantity, second quantity, third quantity, fourth quantity, fifth quantity, and sixth quantity described above can all be set according to actual conditions. For example, the first threshold is 95%, the second threshold is 90%, the third threshold is 90%, the fourth threshold is 20%, the fifth threshold is 10%, and the sixth threshold is 10%. The first quantity, second quantity, third quantity, fourth quantity, fifth quantity, and sixth quantity can be equal or unequal. For example, the first quantity, second quantity, third quantity, fourth quantity, fifth quantity, and sixth quantity are equal, and the ratio of each of the first quantity, second quantity, third quantity, fourth quantity, fifth quantity, and sixth quantity to the number of replication nodes in the aforementioned master replication cluster is greater than 0.8. Furthermore, the continuous increase of RPO described above can mean that the RPO continuously increases within a preset duration (e.g., 5 seconds). In some embodiments, scaling up the replica node is described as "scale up," scaling down the replica node is described as "scale down," increasing the number of replica nodes in the replica cluster is described as "scale out," and decreasing the number of replica nodes in the replica cluster is described as "scale in." The information described above for characterizing the load of data synchronization in the primary replica cluster is merely illustrative. Other information can also be used to characterize the load of data synchronization in the primary replica cluster. The information used to characterize the load of data synchronization in the primary replica cluster can be set according to actual needs, and this application embodiment does not limit this.

[0102] In another embodiment, the size of the primary replication cluster is elastically scaled based on the identity change of the region where the primary replication cluster resides. For example, the size of the primary replication cluster is reduced based on the identity change of the region where the primary replication cluster resides. In a specific embodiment, the primary region and a slave region undergo an identity switch, with the primary region becoming a slave region and the slave region becoming a primary region. After the identity switch, if the replication cluster in the original primary region (i.e., the primary region before the identity switch) is a multi-node replication cluster, the original primary replication cluster is adjusted to a single-node replication cluster, or its size is adjusted to a target size. If the original primary replication cluster is a single-node replication cluster, its size is adjusted to a target size. The target size can be a default size, or the same as the size of the replication cluster in the slave region where the identity switch occurred. In an optional embodiment, the replication cluster in the region (i.e., the slave replication cluster) is also a serverless replication cluster. The size of the slave replication cluster can be elastically scaled. After a switchover occurs between the primary region and a slave region, the size of the replication cluster in the new primary region (i.e., the primary region after the switchover) (i.e., the new primary replication cluster) is adjusted to the same size as the original primary replication cluster. Furthermore, the size of the new primary replication cluster can elastically scale according to changes in the load of the synchronized data. The triggering conditions for a switchover between the primary and slave regions include a failure (or disaster) of the primary region or manual triggering of the switchover. As an example, such as... Figures 1 to 8As shown, region1 is the primary region, and region2 is the secondary region. Region1 includes replication cluster 1, and region2 includes replication cluster 2. Assume that a failure in region1 causes a role switch between region1 and region2, or that the role switch is manually triggered. After the role switch, region1 becomes a secondary region, and region2 becomes a primary region. Following the role switch, if replication cluster 1 is a multi-node replication cluster, it is adjusted to a single-node replication cluster, or its size is adjusted to a target size; if replication cluster 1 is a single-node replication cluster, its size is adjusted to a target size. The target size is the default size, or the same as the size of replication cluster 2. In an optional embodiment, the size of replication cluster 2 can be elastically scaled. After the role switch between region1 and region2, the size of replication cluster 2 is adjusted to be the same as the original size of replication cluster 1 (i.e., replication cluster 1 before the size adjustment), and the size of replication cluster 2 can elastically scale according to changes in the synchronization data load of replication cluster 2.

[0103] In this embodiment, the size of the primary replication cluster can be elastically scaled. The size of the primary replication cluster can be increased or decreased according to the load of data synchronization, ensuring that the primary replication cluster can meet business needs, maintain a low RPO, and reduce its cost. In an optional embodiment, the secondary replication cluster is also a serverless replication cluster, and its size can also be elastically scaled according to the load of data synchronization, thus reducing the cost of the secondary replication cluster.

[0104] In this embodiment, each of the primary region and the aforementioned m secondary regions may include at least one availability zone (AZ). The database proxy node, replication proxy node, database node, and replication node in each region may be located within that AZ. The database proxy node, replication proxy node, database node, and replication node may be located in the same AZ or in different AZs. Multiple database nodes in the same region may be located in the same AZ or in different AZs. Multiple replication nodes in the same region may be located in the same AZ or in different AZs. The database proxy node, database node, replication proxy node, and replication node can all be compute nodes. Compute nodes can be servers, virtual machines (VMs), containers, elastic compute services (ECS), etc., and this embodiment does not limit their use. Furthermore, in this embodiment, the replication nodes in the primary replication cluster are compute nodes logically different from the primary database nodes in the primary region. For example, the replication nodes in the primary replication cluster are compute nodes logically different from the individual database nodes in the primary region. Optionally, in each of the primary region and the aforementioned m secondary regions, the replication nodes in the replication cluster of that region are compute nodes that are logically different from the database nodes in that region.

[0105] In this embodiment, the master database node and master replication cluster in the master region can implement the data synchronization method provided in this embodiment by running an executable program. For example, the executable program is presented in the form of an application installation package. After the master region installs the application installation package, it can implement the data synchronization method provided in this embodiment by running the executable program. The client involved in this embodiment can be deployed on a terminal device, and the user interacts with the database system through the client. For example, the user triggers the client to send a data access request to the database system by operating the client. The terminal device can be a desktop computer, laptop computer, tablet computer, mobile phone, smartphone, cloud host, portable mobile terminal, multimedia player, e-book reader, wearable device, smart home appliance, artificial intelligence device, smart wearable device, or vehicle terminal device, etc. In optional embodiments, each of the above-mentioned master region and each of the above-mentioned m slave regions includes at least one server. For example, each of the above-mentioned master region and each of the above-mentioned m slave regions is a cluster composed of several servers, or a cloud computing service center, which is not limited in this embodiment.

[0106] In this embodiment, the database system includes a primary region and m secondary regions. The primary region includes a primary replication cluster and a primary database node. The primary database node (i.e., the primary database node in the primary region) is a compute node with a deployed database instance. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node (i.e., the primary database node in the primary region). The primary database node (i.e., the primary database node in the primary region) is used to generate data to be synchronized. The primary replication cluster is used to: acquire the data to be synchronized; generate at least one replication task corresponding to the data to be synchronized, the at least one replication task being used to synchronize the data to be synchronized to the m secondary regions; add the at least one replication task to a task queue; concurrently acquire the at least one replication task from the task queue; and concurrently synchronize the data to be synchronized to the m secondary regions according to the at least one replication task acquired from the task queue.

[0107] In one embodiment, the primary replication cluster is configured to: generate m replication tasks corresponding to the data to be synchronized, each of the m replication tasks corresponding to one of the m slave regions; and synchronize the data to be synchronized to the slave region corresponding to each of the m replication tasks obtained from the task queue, wherein the process of the primary replication cluster synchronizing the data to be synchronized to the m slave regions according to the m replication tasks is parallel. In another embodiment, the primary replication cluster is configured to: generate one replication task corresponding to the data to be synchronized; and concurrently synchronize the data to be synchronized to the m slave regions according to the one replication task obtained from the task queue.

[0108] In an optional embodiment, the master replication cluster is further configured to: for each replication task in the task queue: delete each replication task from the task queue after each replication task is completed; or, mark each replication task as completed after each replication task is completed.

[0109] In an optional embodiment, the primary replication cluster includes multiple replication threads, which are allocated in the at least one replication node. The multiple replication threads are used to: concurrently obtain the at least one replication task from the task queue; the replication node where the replication thread that obtained the at least one replication task is located is used to: concurrently synchronize the data to be synchronized to the m slave regions according to the at least one replication task.

[0110] In an optional embodiment, each of the m slave regions includes a slave replication cluster, the master replication cluster being used to: concurrently send the data to be synchronized to the slave replication clusters in the m slave regions according to the at least one replication task obtained from the task queue.

[0111] It should be noted that the meaning of "XX in the region" in the embodiments of this application can be "XX included in the region", where "XX" can be a database node, database proxy node, storage pool, replication cluster, etc. For example, a database node in the main region refers to the database nodes included in the main region. A database proxy node in the main region refers to the database proxy nodes included in the main region. A database node in the secondary region refers to the database nodes included in the secondary region. A database proxy node in the secondary region refers to the database proxy nodes included in the secondary region. A storage pool in the main region refers to the storage pool included in the main region. A storage pool in the secondary region refers to the storage pool included in the secondary region. A replication cluster in the main region refers to the replication cluster included in the main region. A replication cluster in the secondary region refers to the replication cluster included in the secondary region. Furthermore, it should be understood that the above description of the database system is for illustrative purposes only and is not intended to limit the technical solutions of the embodiments of this application. As those skilled in the art will know, the database system can be appropriately adjusted as business needs change, and the embodiments of this application will not be listed one by one here.

[0112] The above is an introduction to the application scenarios (i.e., database systems) of the embodiments of this application. The method embodiments of this application are described below.

[0113] Please refer to Figure 11 The diagram illustrates a flowchart of a data synchronization method provided in an embodiment of this application. This data synchronization method is applied to a database system provided in the aforementioned application scenario. The database system includes a primary region and m secondary regions. The primary region includes a primary replication cluster and a primary database node, which is a compute node with a deployed database instance. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node. For ease of description, the primary database node will be referred to as primary database node P below. For example, the database system is as follows... Figures 1 to 8 As shown, the primary region is region1, the primary replication cluster is replication cluster 1, and the primary database node is database node 11. See also... Figure 11 The data synchronization method includes the following steps S101 to S106.

[0114] S101. The master database node P generates data A to be synchronized.

[0115] In an optional embodiment, the master database node P generates data A to be synchronized based on a data write request from a client. In one embodiment, the data write request carries data A to be synchronized, and the master database node P obtains data A to be synchronized from the data write request. In another embodiment, the master database node P generates data A to be synchronized based on multiple data write requests from clients. For example, the multiple data write requests carry data, and the master database node P generates data A to be synchronized based on the data carried by the multiple data write requests.

[0116] S102. The master replication cluster obtains data A to be synchronized.

[0117] In one embodiment, after the primary database node P generates data A to be synchronized, it sends data A to the primary replication cluster, which then receives the data A. In another embodiment, after generating data A, the primary database node P stores data A in a storage pool within the primary region, and the primary replication cluster retrieves data A from that storage pool.

[0118] In an optional embodiment, the primary region includes a data queue for storing data to be synchronized and queuing it. After the primary replication cluster acquires data A to be synchronized, it stores data A in the data queue. The queue resources of this data queue may include persistent storage media and / or non-persistent storage media. For example, the queue resources (i.e., storage resources) include persistent and / or non-persistent storage media of the replication nodes in the primary replication cluster, and / or persistent and / or non-persistent storage media of the database nodes in the primary region, and / or persistent and / or non-persistent storage media in the storage pool of the primary region. This data queue can be a distributed queue, and its structure can be a graph, tree, or list structure, etc. This embodiment does not limit the structure of the data queue, as long as it ensures that the data queue can be accessed concurrently by the primary replication cluster. Distributed queues have higher availability; therefore, this data queue has higher availability.

[0119] S103. The primary replication cluster generates at least one replication task corresponding to the data A to be synchronized, and the at least one replication task is used to synchronize the data A to be synchronized to m slave regions.

[0120] In this embodiment, the at least one replication task corresponding to the data A to be synchronized can be one replication task or m replication tasks. When the at least one replication task is one replication task, it is used to synchronize the data A to be synchronized to the m slave regions (i.e., to all slave regions among the m slave regions). When the at least one replication task is m replication tasks, each of the m replication tasks corresponds one-to-one with one of the m slave regions, and each of the m replication tasks is used to synchronize the data A to be synchronized to the slave region corresponding to that replication task among the m slave regions. The following describes the two cases separately.

[0121] Scenario 1: The at least one replication task corresponding to the data A to be synchronized is a single replication task used to synchronize the data A to be synchronized to the m slave regions. The primary replication cluster generates this single replication task corresponding to the data A to be synchronized.

[0122] Please refer to Figure 12 This diagram illustrates the correspondence between data to be synchronized and replication tasks according to an embodiment of this application. Data to be synchronized 1 corresponds to replication task 1, data to be synchronized 2 corresponds to replication task 2, and data to be synchronized 3 corresponds to replication task 3. Replication task 1 is used to synchronize data to be synchronized 1 to the m slave regions. Replication task 2 is used to synchronize data to be synchronized 2 to the m slave regions. Replication task 3 is used to synchronize data to be synchronized 3 to the m slave regions. For example, the m slave regions are... Figures 1 to 8 In the database system shown, regions 2 and 3 are used for replication. Replication task 1 is used to synchronize data 1 to be synchronized to regions 2 and 3. Replication task 2 is used to synchronize data 2 to be synchronized to regions 2 and 3. Replication task 3 is used to synchronize data 3 to be synchronized to regions 2 and 3. Data A to be synchronized can be any of the data 1 to 3. For example, if data A is data 1, the corresponding replication task is replication task 1. Another example is if data A is data 2, and the corresponding replication task is replication task 2. Yet another example is if data A is data 3, and the corresponding replication task is replication task 3.

[0123] In an optional embodiment, each replication task carries an identifier for the data to be synchronized corresponding to that replication task, indicating that each replication task corresponds to that data to be synchronized. Figure 12For example, replication task 1 carries the identifier of data to be synchronized 1 to indicate that replication task 1 corresponds to data to be synchronized 1; replication task 2 carries the identifier of data to be synchronized 2 to indicate that replication task 2 corresponds to data to be synchronized 2; replication task 3 carries the identifier of data to be synchronized 3 to indicate that replication task 3 corresponds to data to be synchronized 3. Furthermore, in this first case, since each replication task is used to synchronize the data to be synchronized corresponding to each of the m slave regions, it can be considered that each replication task corresponds to the m slave regions. In an optional embodiment, each replication task also carries the identifiers of the m slave regions to indicate that each replication task corresponds to the m slave regions. For example, replication task 1 carries the identifiers of region 2 and region 3 to indicate that replication task 1 corresponds to region 2 and region 3; replication task 2 carries the identifiers of region 2 and region 3 to indicate that replication task 2 corresponds to region 2 and region 3; replication task 3 carries the identifiers of region 2 and region 3 to indicate that replication task 3 corresponds to region 2 and region 3. It should be noted that the description here is merely an example. In other embodiments, for the first case, the replication task may not carry the identifier of the slave region. By default, each replication task corresponds to all slave regions. This application embodiment does not limit this.

[0124] In an optional embodiment, the replication task corresponding to the data to be synchronized A carries the identifier of the data to be synchronized A and the identifiers of the m slave regions. The primary replication cluster generates the replication task corresponding to the data to be synchronized A based on the identifier of the data to be synchronized A and the identifiers of the m slave regions. For example, the m slave regions are... Figures 1 to 8 In the database system shown, regions 2 and 3 are used by the master replication cluster to generate a replication task corresponding to the data to be synchronized, based on the identifier of the data to be synchronized, the identifier of region 2, and the identifier of region 3.

[0125] The second scenario: The at least one replication task corresponding to the data A to be synchronized consists of m replication tasks. These m replication tasks correspond one-to-one with the m slave regions. Each of the m replication tasks is used to synchronize the data A to be synchronized to the slave region corresponding to that replication task. The primary replication cluster generates these m replication tasks corresponding to the data A to be synchronized.

[0126] Please refer to Figure 13 This illustrates another correspondence diagram between data to be synchronized and replication tasks provided in an embodiment of this application. Figure 13 Let's take m=2 as an example. Figure 13 As shown, data to be synchronized 1 corresponds to replication tasks 12-13, and replication tasks 12-13 correspond one-to-one with the m slave regions. Data to be synchronized 2 corresponds to replication tasks 22-23, and replication tasks 22-23 correspond one-to-one with the m slave regions. Data to be synchronized 3 corresponds to replication tasks 32-33, and replication tasks 32-33 correspond one-to-one with the m slave regions. Replication tasks 12-13 are used to synchronize data to be synchronized 1 to the m slave regions. Replication tasks 22-23 are used to synchronize data to be synchronized 2 to the m slave regions. Replication tasks 32-33 are used to synchronize data to be synchronized 3 to the m slave regions. For example, the m slave regions are... Figures 1 to 8 In the database system shown, replication tasks 12, 22, and 32 correspond to region 2, while replication tasks 13, 23, and 33 correspond to region 3. Replication task 12 is used to synchronize data 1 to be synchronized to region 2. Replication task 13 is used to synchronize data 1 to be synchronized to region 3. Replication task 22 is used to synchronize data 2 to be synchronized to region 2. Replication task 23 is used to synchronize data 2 to be synchronized to region 3. Replication task 32 is used to synchronize data 3 to be synchronized to region 2. Replication task 33 is used to synchronize data 3 to be synchronized to region 3. The data to be synchronized, A, can be any one of data 1 to 3. For example, if data A is data 1, the m replication tasks corresponding to data A are replication tasks 12 to 13. As another example, if data A is data 2, the m replication tasks corresponding to data A are replication tasks 22 to 23. For example, if the data to be synchronized A is data to be synchronized 3, then the m replication tasks corresponding to the data to be synchronized A are replication tasks 32 to 33.

[0127] In an optional embodiment, each replication task carries an identifier for the data to be synchronized corresponding to that replication task, indicating that each replication task corresponds to that data to be synchronized. For example, replication tasks 12-13 each carry an identifier for data 1 to be synchronized, indicating that replication tasks 12-13 correspond to data 1 to be synchronized; replication tasks 22-23 each carry an identifier for data 2 to be synchronized, indicating that replication tasks 22-23 correspond to data 2 to be synchronized; and replication tasks 32-33 each carry an identifier for data 3 to be synchronized, indicating that replication tasks 32-33 correspond to data 3 to be synchronized. In an optional embodiment, each replication task carries an identifier for the slave region corresponding to that replication task, indicating that each replication task corresponds to the slave region. For example, replication tasks 12, 22, and 32 may also carry an identifier for region 2, indicating that replication tasks 12, 22, and 32 correspond to region 2; and replication tasks 13, 23, and 33 may also carry an identifier for region 3, indicating that replication tasks 13, 23, and 33 correspond to region 3. This application does not limit the scope of the embodiments.

[0128] In this embodiment, the primary replication cluster can generate m replication tasks corresponding to the data to be synchronized, A, based on the data to be synchronized A and the m slave regions. In an optional embodiment, each of the m replication tasks carries an identifier of the data to be synchronized A and an identifier of the slave region corresponding to that replication task. The primary replication cluster generates a replication task corresponding to the data to be synchronized A and each of the m slave regions based on the identifier of the data to be synchronized A and the identifier of each slave region.

[0129] S104. The primary replication cluster adds at least one replication task corresponding to the data A to be synchronized to the task queue.

[0130] This task queue is the task queue of the primary region. The queue resources (i.e., storage resources) of this task queue may include persistent storage media and / or non-persistent storage media. For example, the queue resources of this task queue include non-persistent memory and / or persistent memory of the replication nodes in the primary replication cluster. This task queue can be a distributed queue, and its structure can be a graph structure, tree structure, or table structure, etc. Furthermore, the structure of this task queue may be the same as or different from the structure of the aforementioned data queue. This application embodiment does not limit the structure of the task queue, as long as it ensures that the task queue can be accessed concurrently by the primary replication cluster. Distributed queues have higher availability; therefore, designing this task queue as a distributed queue can improve its availability.

[0131] As mentioned earlier, the at least one replication task corresponding to the data A to be synchronized can be one replication task or m replication tasks. The following describes the two cases separately.

[0132] The first case (corresponding to the first case in S103): The at least one replication task corresponding to the data A to be synchronized is a replication task, and the master replication cluster adds the replication task to the task queue.

[0133] In an optional embodiment, the primary region further includes a data queue. After the primary replication cluster obtains the data A to be synchronized, it also stores the data A to be synchronized in this data queue. For example... Figure 12 As shown, data 1 to 3 to be synchronized are in the data queue, and replication task 1 corresponding to data 1, replication task 2 corresponding to data 2, and replication task 3 corresponding to data 3 are all in the task queue. Data A to be synchronized can be any of the data 1 to 3. For example, if data A is data 1, the replication task corresponding to data A is replication task 1. Another example is if data A is data 2, and the replication task corresponding to data A is replication task 2. Yet another example is if data A is data 3, and the replication task corresponding to data A is replication task 3.

[0134] The second scenario (corresponding to the second scenario in S103): The at least one replication task corresponding to the data A to be synchronized is m replication tasks, and the master replication cluster will add the m replication tasks to the task queue.

[0135] In an optional embodiment, the primary region further includes a data queue. After the primary replication cluster obtains the data A to be synchronized, it also stores the data A to be synchronized in this data queue. For example... Figure 13 As shown, data 1 to 3 to be synchronized are in the data queue, and replication tasks 12 to 13 corresponding to data 1, replication tasks 22 to 23 corresponding to data 2, and replication tasks 32 to 33 corresponding to data 3 are all in the task queue. Data A to be synchronized can be any of the data 1 to 3. For example, if data A is data 1, the m replication tasks corresponding to data A are replication tasks 12 to 13. Another example is if data A is data 2, and the m replication tasks corresponding to data A are replication tasks 22 to 23. Yet another example is if data A is data 3, and the m replication tasks corresponding to data A are replication tasks 32 to 33.

[0136] In this embodiment, the primary replication cluster can be a single-node replication cluster or a multi-node replication cluster. When the primary replication cluster is a single-node cluster, it includes one replication node, and steps S102 to S104 are executed by this single replication node. When the primary replication cluster is a multi-node cluster, it includes multiple replication nodes, including a primary replication node and slave replication nodes (e.g., the multiple replication nodes include one primary replication node and at least one slave replication node), and steps S102 to S104 are executed by the primary replication node.

[0137] S105. The primary replication cluster concurrently retrieves at least one replication task corresponding to the data A to be synchronized from the task queue.

[0138] In a specific embodiment, the primary replication cluster includes multiple replication threads, which are distributed across at least one replication node in the primary replication cluster. These multiple replication threads concurrently acquire replication tasks from the task queue. For example, the primary replication cluster may be a single-node replication cluster, comprising one replication node, with the multiple replication threads distributed across that single replication node. As another example, the primary replication cluster may also be a single-node replication cluster, comprising multiple replication nodes, with the multiple replication threads distributed across those multiple replication nodes.

[0139] As mentioned earlier, the at least one replication task corresponding to the data A to be synchronized can be one replication task or m replication tasks. The following describes the two cases separately.

[0140] The first case (corresponding to the first case in S103 to S104): The at least one replication task corresponding to the data A to be synchronized is a replication task, and the master replication cluster concurrently obtains the replication task from the task queue.

[0141] Please continue to refer to this. Figure 12In one example, the data to be synchronized A is data to be synchronized 1, and the at least one replication task corresponding to data to be synchronized A is replication task 1. The primary replication cluster concurrently retrieves replication task 1 from the task queue. In another example, the data to be synchronized A is data to be synchronized 2, and the at least one replication task corresponding to data to be synchronized A is replication task 2. The primary replication cluster concurrently retrieves replication task 2 from the task queue. In yet another example, the data to be synchronized A is data to be synchronized 3, and the at least one replication task corresponding to data to be synchronized A is replication task 3. The primary replication cluster concurrently retrieves replication task 3 from the task queue. In a specific embodiment, the primary replication cluster includes multiple replication threads, which concurrently retrieve the replication task corresponding to data to be synchronized A from the task queue. Assume that the multiple replication threads include replication threads 1 to k, where k is an integer greater than 1. In one example, the data to be synchronized A is data to be synchronized 1, and the at least one replication task corresponding to data to be synchronized A is replication task 1. Replication threads 1 to k concurrently retrieve replication task 1 from the task queue. In another example, the data to be synchronized A is data to be synchronized 2, and the at least one replication task corresponding to the data to be synchronized A is replication task 2. Replication threads 1 to k concurrently retrieve replication task 2 from the task queue. In yet another example, the data to be synchronized A is data to be synchronized 3, and the at least one replication task corresponding to the data to be synchronized A is replication task 3. Replication threads 1 to k concurrently retrieve replication task 3 from the task queue.

[0142] The second scenario (corresponding to the second scenario in S103 to S104): The at least one replication task corresponding to the data A to be synchronized is m replication tasks, and the master replication cluster concurrently obtains the m replication tasks from the task queue.

[0143] Please continue to refer to this. Figure 13In one example, the data to be synchronized, A, is data 1, and the m replication tasks corresponding to data A are replication tasks 12-13. The primary replication cluster concurrently retrieves replication tasks 12-13 from the task queue. In another example, the data to be synchronized, A, is data 2, and the m replication tasks corresponding to data A are replication tasks 22-23. The primary replication cluster concurrently retrieves replication tasks 22-23 from the task queue. In yet another example, the data to be synchronized, A, is data 3, and the m replication tasks corresponding to data A are replication tasks 32-33. The primary replication cluster concurrently retrieves replication tasks 32-33 from the task queue. In a specific embodiment, the primary replication cluster includes multiple replication threads, which concurrently retrieve the m replication tasks corresponding to data A from the task queue. In one example, the data to be synchronized, A, is data 1, and the m replication tasks corresponding to data A are replication tasks 12-13. Replication threads 1-k concurrently retrieve replication tasks 12-13 from the task queue. In another example, the data to be synchronized, A, is data 2, and the m replication tasks corresponding to data A are replication tasks 22-23. Replication threads 1-k concurrently retrieve replication tasks 22-23 from the task queue. In yet another example, the data to be synchronized, A, is data 3, and the m replication tasks corresponding to data A are replication tasks 32-33. Replication threads 1-k concurrently retrieve replication tasks 32-33 from the task queue.

[0144] S106. The primary replication cluster concurrently synchronizes the data to be synchronized (A) to m slave regions based on the at least one replication task corresponding to the data to be synchronized (A) obtained from the task queue.

[0145] The primary replication cluster concurrently sends the data to be synchronized to the m slave regions based on at least one replication task corresponding to the data to be synchronized A obtained from the task queue, thereby concurrently synchronizing the data to be synchronized to the m slave regions. Each time the primary replication cluster sends the data to be synchronized to a slave region, that slave region can send a synchronization response to the primary replication cluster for the data to be synchronized to A.

[0146] In this embodiment of the application, the primary replication cluster concurrently synchronizing the data to be synchronized A to the m slave regions according to the at least one replication task may include: for each of the at least one replication task: the primary replication cluster sends the data to be synchronized A to the slave regions according to the replication task, and for each slave region to which the primary replication cluster sends the data to be synchronized A, the primary replication cluster does not wait for the slave region to send a synchronization response for the data to be synchronized A to the primary replication cluster before continuing to send the data to be synchronized A to the next slave region according to the replication task.

[0147] In a specific embodiment, the primary replication cluster includes multiple replication threads. In S105, these multiple replication threads concurrently obtain at least one replication task corresponding to the data A to be synchronized from the task queue. In S106, the replication node where the replication thread that obtained the at least one replication task is located concurrently synchronizes the data A to be synchronized to the m slave regions according to the at least one replication task.

[0148] In this embodiment, the primary replication cluster can be a single-node replication cluster or a multi-node replication cluster. When the primary replication cluster is a single-node cluster, it includes one replication node, and the multiple replication threads are the replication threads within that single replication node. When the primary replication cluster is a multi-node cluster, it includes multiple replication nodes, and the multiple replication threads are the replication threads within those multiple replication nodes. In the case of a multi-node replication cluster, if one replication node in the primary replication cluster fails, the replication threads in the other replication nodes can still obtain replication tasks from the task queue and synchronize data from the region. Therefore, the failure of a single replication node will not cause data synchronization failure or affect availability.

[0149] As mentioned earlier, the at least one replication task corresponding to the data A to be synchronized can be one replication task or m replication tasks. The following describes the two cases separately.

[0150] The first scenario (corresponding to the first scenario in S103 to S105): The at least one replication task corresponding to the data A to be synchronized is a replication task used to synchronize the data A to be synchronized to the m slave regions (i.e., to all slave regions among the m slave regions). The primary replication cluster concurrently retrieves the replication task from the task queue, and based on the replication task retrieved from the task queue, the primary replication cluster concurrently synchronizes the data A to be synchronized to the m slave regions.

[0151] Please continue to refer to this. Figure 12Data to be synchronized 1 corresponds to replication task 1, data to be synchronized 2 corresponds to replication task 2, and data to be synchronized 3 corresponds to replication task 3. Replication task 1 is used to synchronize data to be synchronized 1 to the m slave regions. Replication task 2 is used to synchronize data to be synchronized 2 to the m slave regions. Replication task 3 is used to synchronize data to be synchronized 3 to the m slave regions. In one example, data to be synchronized A is data to be synchronized 1, and the replication task corresponding to data to be synchronized A is replication task 1. The primary replication cluster concurrently retrieves replication task 1 from the task queue, and concurrently sends data to be synchronized 1 to the m slave regions to synchronize data to be synchronized 1. In another example, the data to be synchronized A is data to be synchronized 2, and the corresponding replication task is replication task 2. The primary replication cluster concurrently retrieves replication task 2 from the task queue and concurrently sends data to be synchronized to the m slave regions based on replication task 2 retrieved from the task queue to synchronize data to be synchronized to the m slave regions. In yet another example, the data to be synchronized A is data to be synchronized 3, and the corresponding replication task is replication task 3. The primary replication cluster concurrently retrieves replication task 3 from the task queue and concurrently sends data to be synchronized to the m slave regions based on replication task 3 retrieved from the task queue to synchronize data to be synchronized to the m slave regions. For example, the m slave regions are... Figures 1 to 8 In the database system shown, regions 2 and 3 are used for replication. Replication task 1 is used to synchronize data 1 to regions 2 and 3; replication task 2 is used to synchronize data 2 to regions 2 and 3; and replication task 3 is used to synchronize data 3 to regions 2 and 3. Please refer to [reference needed]. Figure 12In one example, the data to be synchronized, A, is data to be synchronized, 1. The corresponding replication task is replication task 1. The primary replication cluster concurrently retrieves replication task 1 from the task queue and concurrently sends data to be synchronized to regions 2 and 3 based on replication task 1 retrieved from the task queue. In another example, the data to be synchronized, A, is data to be synchronized, 2. The corresponding replication task is replication task 2. The primary replication cluster concurrently retrieves replication task 2 from the task queue and concurrently sends data to be synchronized to regions 2 and 3 based on replication task 2 retrieved from the task queue. In another example, the data to be synchronized A is the data to be synchronized 3, and the replication task corresponding to the data to be synchronized A is replication task 3. The primary replication cluster concurrently retrieves replication task 3 from the task queue, and the primary replication cluster concurrently sends the data to be synchronized 3 to region2 and region3 according to the replication task 3 retrieved from the task queue in order to synchronize the data to be synchronized 3 to region2 and region3.

[0152] In a specific embodiment, the primary replication cluster includes multiple replication threads. These multiple replication threads concurrently retrieve a replication task corresponding to the data A to be synchronized from the task queue. The replication node where the replication thread that retrieved the replication task resides concurrently synchronizes the data A to be synchronized to the m slave regions according to the replication task. For example, these multiple replication threads include replication threads 1 to k, where k is an integer greater than 1. Please refer to [further details omitted]. Figure 12In one example, the data to be synchronized, A, is data to be synchronized, and the corresponding replication task is replication task 1. Replication threads 1 through k concurrently retrieve replication task 1 from the task queue. The replication nodes where the replication threads that retrieve replication task 1 concurrently send data to be synchronized to the m slave regions to synchronize data to be synchronized. In another example, the data to be synchronized, A, is data to be synchronized, 2, and the corresponding replication task is replication task 2. Replication threads 1 through k concurrently retrieve replication task 2 from the task queue. The replication nodes where the replication threads that retrieve replication task 2 concurrently send data to be synchronized to the m slave regions to synchronize data to be synchronized. In another example, the data to be synchronized, A, is data to be synchronized, which is data 3. The corresponding replication task is replication task 3. Replication threads 1 to k concurrently retrieve replication task 3 from the task queue. The replication nodes where the replication threads that retrieve replication task 3 are located concurrently send data 3 to be synchronized to the m slave regions to concurrently synchronize data 3 to the m slave regions. For example, the m slave regions are... Figures 1 to 8 In the database system shown, regions 2 and 3 are used for replication. Replication task 1 is used to synchronize data 1 to be synchronized to regions 2 and 3; replication task 2 is used to synchronize data 2 to be synchronized to regions 2 and 3; and replication task 3 is used to synchronize data 3 to be synchronized to regions 2 and 3. Please continue to refer to [reference needed]. Figure 12In one example, the data to be synchronized, A, is data to be synchronized, 1. The replication task corresponding to data A is replication task 1. The replication nodes of replication threads 1 to k that have obtained replication task 1 concurrently send data to be synchronized to regions 2 and 3 to synchronize data to be synchronized to regions 2 and 3. For example, the replication node of the replication thread of replication threads 1 to k that has obtained replication task 1 sends data to be synchronized to regions 2 to synchronize data 1. After sending data to be synchronized to regions 2, the replication node sends data to be synchronized to regions 3 to synchronize data to be synchronized to regions 2 without waiting for a synchronization response from regions 2. In another example, the data to be synchronized, A, is data to be synchronized, 2. The replication task corresponding to data A is replication task 2. The replication nodes of replication threads 1 to k that have obtained replication task 2 concurrently send data to be synchronized to regions 2 and 3 to synchronize data to be synchronized to regions 2 and 3. For example, the replication node containing the replication thread that obtains replication task 2 in replication threads 1-k sends data to be synchronized 2 to region 2 according to replication task 2; after sending data to be synchronized 2 to region 2, the replication node sends data to be synchronized 2 to region 3 according to replication task 2 without waiting for region 2 to send a synchronization response for data to be synchronized 2. In another example, the data to be synchronized A is data to be synchronized 3, and the replication task corresponding to data to be synchronized A is replication task 3. The replication node containing the replication thread that obtains replication task 3 in replication threads 1-k concurrently sends data to be synchronized 3 to region 2 and region 3 according to replication task 3 to concurrently synchronize data to be synchronized 3 to region 2 and region 3. For example, the replication node containing the replication thread that obtains replication task 3 in replication threads 1-k sends data to be synchronized 3 to region 2 according to replication task 3; after sending data to be synchronized 3 to region 2, the replication node sends data to be synchronized 3 to region 3 according to replication task 3 without waiting for region 2 to send a synchronization response for data to be synchronized 3.

[0153] In an optional embodiment, in this first case, during the process of the primary replication cluster concurrently synchronizing the data to be synchronized (A) to m slave regions according to the replication task corresponding to the data A to be synchronized obtained from the task queue, the primary replication cluster counts the slave regions based on the transmitted data A to be synchronized; when the count of the slave regions reaches m, the primary replication cluster determines that it has completed sending the data A to be synchronized to the m slave regions. In a specific embodiment, when the primary replication cluster starts sending the data A to be synchronized to the m slave regions according to the replication task, the primary replication cluster starts a counter counting from 0. Each time the primary replication cluster sends the data A to be synchronized to a slave region, the primary replication cluster increments the counter by 1. When the count of the counter reaches m, the primary replication cluster determines that it has completed sending the data A to be synchronized to the m slave regions.

[0154] The second scenario (corresponding to the second scenario in S103 to S105): The at least one replication task corresponding to the data A to be synchronized consists of m replication tasks. These m replication tasks correspond one-to-one with the m slave regions. Each of the m replication tasks is used to synchronize the data A to be synchronized to the slave region corresponding to that replication task. The primary replication cluster concurrently retrieves the m replication tasks from the task queue. Based on each of the m replication tasks retrieved from the task queue, the primary replication cluster synchronizes the data A to be synchronized to the slave region corresponding to that replication task. This process of the primary replication cluster synchronizing the data A to be synchronized to the m slave regions based on the m replication tasks is parallel.

[0155] Please continue to refer to this. Figure 13Data to be synchronized 1 corresponds to replication tasks 12-13, and replication tasks 12-13 correspond one-to-one with the m slave regions. Data to be synchronized 2 corresponds to replication tasks 22-23, and replication tasks 22-23 correspond one-to-one with the m slave regions. Data to be synchronized 3 corresponds to replication tasks 32-33, and replication tasks 32-33 correspond one-to-one with the m slave regions. Replication tasks 12-13 are used to synchronize data to be synchronized 1 to the m slave regions. Replication tasks 22-23 are used to synchronize data to be synchronized 2 to the m slave regions. Replication tasks 32-33 are used to synchronize data to be synchronized 3 to the m slave regions. In one example, the data to be synchronized, A, is data 1. The m replication tasks corresponding to data A are replication tasks 12-13. The primary replication cluster concurrently retrieves replication tasks 12-13 from the task queue and concurrently sends data 1 to be synchronized to the m slave regions based on the replication tasks 12-13 retrieved from the task queue to synchronize data 1 to the m slave regions. In another example, the data to be synchronized, A, is data 2. The m replication tasks corresponding to data A are replication tasks 22-23. The primary replication cluster concurrently retrieves replication tasks 22-23 from the task queue and concurrently sends data 2 to be synchronized to the m slave regions based on the replication tasks 22-23 retrieved from the task queue to synchronize data 2 to the m slave regions. In another example, the data to be synchronized, A, is data 3. The m replication tasks corresponding to data A are replication tasks 32-33. The primary replication cluster concurrently retrieves replication tasks 32-33 from the task queue. Based on the replication tasks 32-33 retrieved from the task queue, the primary replication cluster concurrently sends data 3 to be synchronized to the m slave regions to synchronize data 3. For example, the m slave regions are... Figures 1 to 8The database system shown includes regions 2 and 3. In one example, the data to be synchronized, A, is data 1. The m replication tasks corresponding to data A are replication tasks 12-13. Replication task 12 corresponds to region 2, and replication task 13 corresponds to region 3. Replication task 12 is used to synchronize data 1 to region 2, and replication task 13 is used to synchronize data 1 to region 3. The primary replication cluster concurrently retrieves replication tasks 12-13 from the task queue. The primary replication cluster sends data 1 to region 2 based on replication task 12 to synchronize data 1 to region 2. The primary replication cluster also sends data 1 to region 3 based on replication task 13 to synchronize data 1 to region 3. The process of the primary replication cluster sending data 1 to region 2 and region 3 is parallel. In another example, the data to be synchronized, A, is data to be synchronized, which is data 2. The m replication tasks corresponding to data A are replication tasks 22 and 23. Replication task 22 corresponds to region 2, and replication task 23 corresponds to region 3. Replication task 22 is used to synchronize data 2 to region 2, and replication task 23 is used to synchronize data 2 to region 3. The primary replication cluster concurrently retrieves replication tasks 22 and 23 from the task queue. The primary replication cluster sends data 2 to region 2 to synchronize data 2 to region 2 according to replication task 22. The primary replication cluster sends data 2 to region 3 according to replication task 23 to synchronize data 2 to region 3. The process of the primary replication cluster sending data 2 to region 2 and region 3 is in parallel. In another example, the data to be synchronized, A, is data 3. The m replication tasks corresponding to data A are replication tasks 32 and 33. Replication task 32 corresponds to region 2, and replication task 33 corresponds to region 3. Replication task 32 is used to synchronize data 3 to region 2, and replication task 33 is used to synchronize data 3 to region 3. The primary replication cluster concurrently retrieves replication tasks 32 and 33 from the task queue. The primary replication cluster sends data 3 to region 2 to synchronize data 3 according to replication task 32. The replication cluster sends data 3 to region 3 according to replication task 33 to synchronize data 3 to region 3. The process of the primary replication cluster sending data 3 to region 2 and region 3 is parallel.

[0156] In a specific embodiment, the primary replication cluster includes multiple replication threads. These multiple replication threads concurrently retrieve m replication tasks corresponding to the data A to be synchronized from the task queue. The replication node where the replication thread that retrieved the m replication tasks resides concurrently synchronizes the data A to be synchronized to the m slave regions according to the m replication tasks. For example, the multiple replication threads include replication threads 1 to k, where k is an integer greater than 1, and the m slave regions are... Figures 1 to 8 The database system shown includes regions 2 and 3. Please refer to further details. Figure 13In one example, the data to be synchronized, A, is data to be synchronized 1. The m replication tasks corresponding to data to be synchronized A are replication tasks 12 to 13. Replication task 12 corresponds to region 2, and replication task 13 corresponds to region 3. Replication threads 1 to k concurrently retrieve replication tasks 12 to 13 from the task queue. Taking replication thread 1 retrieving replication task 12 from the task queue and replication thread 2 retrieving replication task 13 from the task queue as an example, the replication node where replication thread 1 is located sends data to be synchronized to region 2 to synchronize data to be synchronized based on replication task 12. The replication node where replication thread 2 is located sends data to be synchronized to region 3 to synchronize data to be synchronized based on replication task 13. Furthermore, the process of replication node where replication thread 1 is located sending data to be synchronized to region 2 and the process of replication node where replication thread 2 is located synchronizing data to be synchronized to region 3 are parallel. In another example, the data to be synchronized, A, is data to be synchronized, 2. The m replication tasks corresponding to data A are replication tasks 22-23. Replication task 22 corresponds to region 2, and replication task 23 corresponds to region 3. Replication threads 1-k concurrently retrieve replication tasks 22-23 from the task queue. Taking replication thread 1 retrieving replication task 22 from the task queue and replication thread 2 retrieving replication task 23 from the task queue as an example, the replication node where replication thread 1 is located sends data to be synchronized to region 2 according to replication task 22 to synchronize data to be synchronized to region 2. The replication node where replication thread 2 is located sends data to be synchronized to region 3 according to replication task 23 to synchronize data to be synchronized to region 3. Furthermore, the process of replication thread 1 sending data to be synchronized to region 2 to region 2 and the process of replication thread 2 synchronizing data to be synchronized to region 3 to region 2 are parallel.In another example, the data to be synchronized, A, is data to be synchronized, which is data 3. The m replication tasks corresponding to data A are replication tasks 32 and 33. Replication task 32 corresponds to region 2, and replication task 33 corresponds to region 3. Replication threads 1 to k concurrently retrieve replication tasks 32 and 33 from the task queue. Taking replication thread 1 retrieving replication task 32 from the task queue and replication thread 2 retrieving replication task 33 from the task queue as an example, the replication node where replication thread 1 is located sends data to be synchronized to region 2 based on replication task 32 to synchronize data to be synchronized to region 2. The replication node where replication thread 2 is located sends data to be synchronized to region 3 based on replication task 33 to synchronize data to be synchronized to region 3. Furthermore, the process of replication node where replication thread 1 is located sending data to be synchronized to region 2 and the process of replication node where replication thread 2 is located synchronizing data to be synchronized to region 3 are parallel.

[0157] In an optional embodiment, for each replication task in the task queue: after completing the replication task, the primary replication cluster removes the replication task from the task queue; or, after completing the replication task, the primary replication cluster marks the replication task as "done". For example, after completing the replication task, the primary replication cluster first marks the replication task as "done" and then removes it from the task queue. For each replication task in the task queue, the primary replication cluster can remove the replication task from the task queue immediately after marking it as "done", or it can remove it from the task queue within a preset time after marking it as "done". Removing completed replication tasks from the task queue by the primary replication cluster can avoid completed replication tasks occupying the queue resources of the task queue. In a specific embodiment, the status of a replication task includes a waiting state, a replicating state, or a completed state. For any replication task: When the primary replication cluster adds the replication task to the task queue (i.e., when the replication task is added to the task queue), the primary replication cluster sets the status of the replication task to the waiting state; when the primary replication cluster starts synchronizing the data to be synchronized to the slave region based on the replication task (e.g., when the primary replication cluster retrieves the replication task from the task queue), the primary replication cluster changes the status of the replication task to the replication state; when the primary replication cluster completes the replication task, the primary replication cluster changes the status of the replication task to the completed state. For example, Figure 14The diagram illustrates a state transition diagram for a replication task provided in an embodiment of this application. It shows that the replication task transitions from a waiting state to a replication state, and then from a replication state to a completed state. The primary replication cluster can retrieve replication tasks from the task queue based on their status. The primary replication cluster retrieves replication tasks in a waiting state from the task queue and synchronizes the data to be synchronized to the slave region based on these replication tasks, thereby avoiding duplicate synchronization.

[0158] In this embodiment, the primary replication cluster completing any replication task includes: when the replication task corresponds to multiple slave regions (e.g., the first case in S103 to S106), the primary replication cluster synchronizes the data to be synchronized corresponding to the replication task to the multiple slave regions according to the replication task (e.g., the primary replication cluster receives a synchronization response sent by all regions of the multiple slave regions for the data to be synchronized corresponding to the replication task); when the replication task corresponds to one slave region (e.g., the second case in S103 to S106), the primary replication cluster synchronizes the data to be synchronized corresponding to the replication task to the slave region corresponding to the replication task according to the replication task (e.g., the primary replication cluster receives a synchronization response sent by the slave region corresponding to the replication task for the data to be synchronized corresponding to the replication task).

[0159] In a specific embodiment, the primary replication cluster includes multiple replication threads that concurrently retrieve replication tasks from a task queue. Each replication thread, upon retrieving a task, modifies the status of the retrieved task to "replication status." After the replication node containing any replication thread completes data synchronization based on that task, it modifies the status of that replication task in the task queue to "completed status." For example, when replication thread 1 retrieves replication task 1 from the task queue, it modifies the status of replication task 1 to "replication status." After the replication node containing replication thread 1 concurrently sends data to be synchronized to the m regions (e.g., to regions 2 and 3), it modifies the status of replication task 1 to "completed status." When replication thread 2 retrieves replication task 2 from the task queue, it changes the status of replication task 2 to the replication state. After the replication node containing replication thread 2 concurrently sends the data to be synchronized 2 to the m slave regions (e.g., to region2 and region3), it changes the status of replication task 2 to the completed state. When replication thread 3 retrieves replication task 3 from the task queue, it changes the status of replication task 3 to the replication state. After the replication node containing replication thread 3 concurrently sends the data to be synchronized 3 to the m slave regions (e.g., to region2 and region3), it changes the status of replication task 3 to the completed state.

[0160] In an optional embodiment, each of the m slave regions includes a slave replication cluster. The master replication cluster concurrently sends the data to be synchronized (A) to the slave replication clusters in the m slave regions according to the at least one replication task corresponding to the data to be synchronized (A), so as to concurrently synchronize the data to be synchronized (A) to the m slave regions. Each slave replication cluster in the slave region sends a synchronization response for the data to be synchronized (A) to the master replication cluster. In a specific embodiment, each slave replication cluster in the slave region includes at least one replication node, and the replication node in the slave replication cluster sends a synchronization response for the data to be synchronized to the master replication cluster. For each of the m slave regions: after receiving the data A to be synchronized from the master replication cluster, the replication cluster in the slave region stores the data A in the storage pool of the slave region. The slave replication cluster also sends information about the data A (such as index information, version information, etc.) to the database nodes in the slave region so that the database nodes in the slave region can manage the information about the data A. The slave replication cluster generates a synchronization response for the data A and sends it to the master replication cluster. Thus, the master replication cluster synchronizes the data A to the slave region.

[0161] In an optional embodiment, the data to be synchronized carries a data identifier. The slave replication cluster filters the data to be synchronized sent by the master replication cluster based on the data identifier carried by the data to be synchronized, thereby avoiding duplicate synchronization. Specifically, after receiving the data to be synchronized from the master replication cluster, the slave replication cluster determines whether the data to be synchronized is stored in the slave region based on the data identifier carried by the data to be synchronized. If the data to be synchronized is stored in the slave region, the slave replication cluster discards the data. If the data to be synchronized is not stored in the slave region, the slave replication cluster stores the data to be synchronized in the slave region (specifically: the slave replication cluster stores the data to be synchronized in the storage pool in the slave region, sends the information of the data to be synchronized to the database node in the slave region, and generates a synchronization response for the data to be synchronized and sends the synchronization response for the data to be synchronized to the master replication cluster). This achieves filtering of the data to be synchronized, avoiding duplicate synchronization. The data identifier carried by the data to be synchronized is used to uniquely identify the data to be synchronized; for example, the data identifier of the data to be synchronized can be a log sequence number (LSN).

[0162] In optional embodiments, the size of the primary replication cluster can elastically scale with the load of data synchronization, and / or the size of the primary replication cluster can elastically scale with changes in the identity of the region where the primary replication cluster resides. The identity of the region where the primary replication cluster resides includes a primary region or a secondary region. The load of data synchronization by the primary replication cluster is characterized by at least one of the following: the utilization rate of the primary replication cluster's computing resources; the utilization rate of the primary replication cluster's transmission resources; and the transmission rate of the primary replication cluster's transmission resources. The implementation method for elastically scaling the size of the primary replication cluster can be referred to the description in the aforementioned application scenarios, and will not be repeated here.

[0163] It should be noted that this application embodiment uses the synchronization of data A to be synchronized from the primary replication cluster to the secondary regions as an example. In an optional embodiment, when the amount of data A to be synchronized is large, for example, when the amount of data A to be synchronized exceeds a data volume threshold, the primary replication cluster divides the data A to be synchronized into multiple data blocks, and synchronizes these multiple data blocks to the secondary regions. The implementation method of synchronizing any data block from the primary replication cluster to the secondary regions can refer to the description in S103 to S106, only needing to replace "data to be synchronized" with "data block" in S103 to S106, which will not be repeated here. When the amount of data A to be synchronized is large, if the primary replication cluster synchronizes the data A to be synchronized as a whole to m secondary regions, since the resources required to synchronize the data A to be synchronized may exceed the resources of the primary replication cluster (for example, the bandwidth required to synchronize the data A to be synchronized exceeds the bandwidth of the primary replication cluster), this may result in insufficient resources of the primary replication cluster to support timely synchronization of the data A to be synchronized to the m secondary regions. In this embodiment, the primary replication cluster can concurrently synchronize the data A to be synchronized to the m slave regions in small-granularity data blocks. The resources required for the primary replication cluster to concurrently synchronize data blocks to the m slave regions are small and will not exceed the resources of the primary replication cluster. Therefore, the resources of the primary replication cluster are sufficient to support the timely synchronization of the data block to the m slave regions. This can reduce the RPO of the slave regions and reduce the synchronization lag between the primary and slave regions (for example, if the data A to be synchronized is concurrently synchronized to the m slave regions in the granularity of data blocks, all or part of the data blocks of the data A to be synchronized will have been synchronized to the m slave regions when the primary region suffers a disaster. However, if the data A to be synchronized is synchronized to the m slave regions as a whole, the data A to be synchronized may not have been synchronized to the m slave regions when the primary region suffers a disaster).

[0164] In summary, the technical solution provided in this application embodiment includes a database system comprising a primary region and m secondary regions. The primary region includes a primary replication cluster and a primary database node. The primary replication cluster includes at least one replication node, which is a computational node logically different from the primary database node. After acquiring the data to be synchronized generated by the primary database node, the primary replication cluster generates at least one replication task corresponding to the data to be synchronized. The primary replication cluster adds the at least one replication task to a task queue. The primary replication cluster concurrently acquires the at least one replication task from the task queue and concurrently synchronizes the data to be synchronized to the m secondary regions according to the at least one replication task. This application embodiment sets up a primary replication cluster in the primary region, and the primary replication cluster concurrently synchronizes the data to be synchronized to the m secondary regions. Therefore, it can avoid the situation where insufficient resources of the primary database node in the primary region prevent the data to be synchronized from being synchronized to the secondary regions in a timely manner. This application embodiment can synchronize the data to be synchronized to the slave regions in a timely manner, reducing the RPO of the slave regions and the synchronization lag between the master region and the slave regions. It avoids backpressure on front-end services due to large RPO of the slave regions and / or large synchronization lag between the master and slave regions. It can synchronize the data to be synchronized to the m slave regions in a timely manner while ensuring service performance, guaranteeing a small RPO and a small synchronization lag between the master and slave regions. When the master replication cluster is a multi-node replication cluster, multiple replication nodes in the master replication cluster concurrently synchronize the data to be synchronized to the m slave regions according to at least one replication task. This allows multiple replication nodes to concurrently synchronize the data to be synchronized to the m slave regions, improving the throughput of the master replication cluster, thereby improving the throughput of the master region. It avoids the RPO increase caused by the resource limitations of a single node in data synchronization performance, and avoids damage to the service performance of the front-end services. Furthermore, it increases the number of incremental data regions that the master region can handle and the number of slave regions that the master region can support, making it suitable for database systems with a large number of slave regions.

[0165] This application provides a computing device, including a memory and a processor. The memory stores a computer program. The processor executes the computer program stored in the memory, causing the computing device to perform all or part of the steps of the data synchronization method provided in this application. The computer program includes an operating system and / or executable code (i.e., program instructions).

[0166] 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 be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0167] As an example, please refer to Figure 15 This illustration shows a schematic diagram of a computing device 500 provided in an embodiment of this application. The computing device 500 includes a processor 501, a memory 502, a communication interface 503, and a bus 504. The processor 501, memory 502, and communication interface 503 are communicatively connected via the bus 504. It should be understood that in other embodiments, the processor 501, memory 502, and communication interface 503 may be connected in other ways. This application does not limit the number of processors or the number of memories in the computing device 500.

[0168] The processor 501 may include a general-purpose processor and / or a dedicated processor. A general-purpose processor may be a processor that performs specific steps and / or operations by reading and executing a computer program stored in memory (e.g., memory 502). The general-purpose processor may use data stored in memory during the execution of these steps and / or operations. A general-purpose processor may include a central processing unit (CPU), a microprocessor (MP), or a graphics processing unit (GPU), etc. The CPU may be a single-core CPU or a multi-core CPU. A dedicated processor is a processor specifically designed to perform specific steps and / or operations. A dedicated processor is a high-performance hardware module, also known as a dedicated hardware chip. A dedicated processor may include a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a network processor (NP), etc. The processor 501 includes at least one circuit (e.g., an integrated circuit) and has signal processing capabilities. In the implementation process, some or all of the functions of the data synchronization method of this application can be accomplished by hardware integrated circuits or software program instructions in the processor 501.

[0169] The memory 502 can be various types of storage media. Memory 502 includes volatile memory and / or non-volatile memory. Volatile memory includes random access memory (RAM) or other types of static storage devices that can store static information and instructions. Non-volatile memory includes read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage (including read-only optical discs, optical disc storage, such as compressed optical discs, laser discs, optical discs, digital optical discs, Blu-ray discs, etc.), hard disk drives (HDDs), or solid-state drives (SSDs), etc. Memory 502 can exist independently and be connected to processor 501 via bus 504, or it can be integrated with processor 501. The memory 502 is used to store computer programs, including an operating system and / or executable code (i.e., program instructions). The processor 501 executes the executable code stored in the memory 502 to implement the data synchronization method provided in this embodiment. That is, the memory 502 stores program instructions for executing the data synchronization method. Optionally, the memory 502 may also include other software modules and data required by the operating system and other running processes, which is not limited in this embodiment.

[0170] The communication interface 503 may include input / output (I / O) interfaces, physical interfaces, and logical interfaces for interconnecting devices within the computing device 500, as well as interfaces for interconnecting the computing device 500 with other devices (e.g., computing devices, terminal devices, or network devices). The physical interface may be an Ethernet interface, which can be used to interconnect the computing device 500 with other devices. The logical interface is an internal interface of the computing device 500, which can be used to interconnect devices within the computing device 500. It is easy to understand that the communication interface 503 can be used for communication between the computing device 500 and other devices; for example, the communication interface 503 is used for sending and receiving data between the computing device 500 and other devices. The communication interface 503 can also use transceiver modules such as network interface cards or transceivers to enable communication between the computing device 500 and other devices or communication networks. For example, the communication interface 503 may be one or more combinations of the following devices: network interfaces (such as Ethernet interfaces), wireless network cards, and other devices with network access capabilities.

[0171] Bus 504 can be of any type, used to interconnect devices (e.g., processor 501, memory 502, communication interface 503) within the computing device 500, such as a system bus. Bus 504 can include pathways for transmitting information between devices within the computing device 500. For example, bus 504 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. Bus 504 can be categorized into address bus, data bus, control bus, etc. For ease of representation, Figure 15 The bus 504 is represented by only one line, but this does not mean that the bus 504 has only one bus or only one type of bus.

[0172] It should be noted that the aforementioned devices can be disposed on separate chips, or at least partially or entirely on the same chip. Whether to dispose of the devices independently on different chips or integrate them on one or more chips often depends on the needs of the product design. This application does not limit the specific implementation of the aforementioned devices.

[0173] Figure 15 The computing device 500 shown is merely an example, and may also include other components. The computing device 500 performs data synchronization by executing all or part of the steps of the data synchronization method provided in the above embodiments.

[0174] This application also provides a computing device cluster, which includes at least one computing device. Each of the at least one computing device includes a processor and a memory. The memory of the at least one computing device is used to store a computer program. The processor of the at least one computing device is used to execute the computer program stored in the memory of the at least one computing device, so that the computing device cluster performs all or part of the steps of the data synchronization method provided in this application. The computer program stored in the memory of the at least one computing device may include an operating system and / or executable code (i.e., program instructions), and the memories of one or more of the at least one computing device may store the same program instructions for executing the data synchronization method provided in this application. The at least one computing device may include a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the at least one computing device may also include a terminal device such as a desktop computer, a laptop computer, or a smartphone. The one or more computing devices in the at least one computing device are as follows: Figure 16 The computing device 500 shown.

[0175] As an example, please refer to Figure 16 This illustration shows a schematic diagram of a computing device cluster provided in an embodiment of this application. The computing device cluster includes multiple computing devices 500 ( Figure 16 (This is illustrated using four computing devices 500 as an example). These multiple computing devices 500 are connected via a network ( Figure 16 (Not shown in the diagram) Connection. The network can be a wide area network (WAN) or a local area network (LAN), etc. The structure of at least one computing device 500 in this computing device cluster can be found in [reference]. Figure 15 The structure of the computing device 500 is shown. The memory 502 of one or more computing devices 500 in this computing device cluster may store the same program instructions for implementing the data synchronization method provided in the embodiments of this application.

[0176] In some possible implementations, the memory 502 of at least one computing device 500 in the computing device cluster may also store partial program instructions for executing the data synchronization method. In other words, a combination of at least two computing devices 500 in the computing device cluster can jointly execute program instructions for implementing the data synchronization method provided in the embodiments of this application. It should be noted that the memory 502 of different computing devices 500 in the computing device cluster may store different program instructions, and each of these different computing devices 500 is used to implement a portion of the data synchronization method provided in the embodiments of this application.

[0177] As another example, please refer to Figure 17This illustrates a schematic diagram of another computing device cluster provided in an embodiment of this application. Figure 17 The following explanation uses computing device cluster 500A and computing device 500B as an example. The structures of computing device 500A and computing device 500B can be found in [reference needed]. Figure 15 The structure of the computing device 500 is shown. Computing device 500A and computing device 500B are connected via a network. Specifically, the communication interface 503 of computing device 500A and the communication interface 503 of computing device 500B are respectively connected to the network, thereby connecting computing device 500A and computing device 500B via the network. In this example, the memory 502 of computing device 500A may store program instructions for implementing a portion of the steps of the data synchronization method of the embodiments of this application, and the memory 502 of computing device 500B may store program instructions for implementing another portion of the steps of the data synchronization method of the embodiments of this application. Computing device 500A and computing device 500B jointly execute the program instructions for implementing the data synchronization method provided in this application.

[0178] Figure 17 The connection method between the computing device clusters shown can be such that, considering the data synchronization method provided in this application requires a large amount of data storage, some steps are delegated to computing device 500A, and other steps are delegated to computing device 500B. It should be understood that... Figure 17 The functions of computing device 500A shown can also be performed by multiple computing devices 500. Similarly, the functions of computing device 500B can also be performed by multiple computing devices 500. This application does not limit this aspect.

[0179] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium. This computer-readable storage medium stores a computer program that, when executed, implements all or part of the steps of the data synchronization method provided in embodiments of this application. For example, when the computer program is executed by a computing device, computing device cluster, virtual machine, container, data synchronization device, one or more processors, etc., it implements all or part of the steps of the data synchronization method provided in embodiments of this application.

[0180] The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center that contains one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives).

[0181] Based on the same inventive concept, embodiments of this application provide a computer program product containing program instructions, which, when executed, implement all or part of the steps of the data synchronization method provided in embodiments of this application. For example, when executed by a computing device, computing device cluster, virtual machine, container, data synchronization device, one or more processors, etc., the program instructions implement all or part of the steps of the data synchronization method provided in embodiments of this application. The computer program product may be a software or program product containing program instructions, capable of running on a computing device or stored on any usable medium.

[0182] Based on the same inventive concept, embodiments of this application provide a chip that includes programmable logic circuits and / or program instructions. When the chip is run, it is used to implement all or part of the steps of the data synchronization method provided in the above method embodiments.

[0183] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented entirely or partially as a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium, or a semiconductor medium (e.g., solid-state drive), etc.

[0184] It should be understood that the term "at least one" in this application refers to one or more, and "multiple" refers to two or more. In this application, unless otherwise stated, the symbol " / " generally means "or," for example, A / B can mean A or B. The term "and / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, for clarity, this application uses terms such as "first," "second," and "third" to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," and "third" do not limit the quantity or order of execution.

[0185] The different types of embodiments, such as the method embodiments and system embodiments provided in this application, can be referenced to each other. The order of operations in the method embodiments can be adjusted appropriately, and operations can be added or removed in response to the situation. Any variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be described in detail.

[0186] In the corresponding embodiments provided in this application, it should be understood that the disclosed devices, etc., can be implemented through other configurations. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed between devices or modules may be through some interfaces, or indirect coupling or communication connection between devices or modules, which may be electrical or other forms. Modules described as separate components may or may not be physically separate, and components described as modules may or may not be physical modules; they may be located in one place or distributed across multiple network nodes. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0187] The above description is merely an exemplary embodiment of this application, but the scope of protection of this application is not limited thereto. Any equivalent modifications or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data synchronization method, characterized in that, The method is applied to a database system, which includes a primary region and m secondary regions, where m is a positive integer. The primary region includes a primary replication cluster and a primary database node, where the primary database node is a compute node with a database instance deployed. The primary replication cluster includes at least one replication node, which is a compute node logically different from the primary database node. The master database node generates data to be synchronized. The primary replication cluster acquires the data to be synchronized. The primary replication cluster generates at least one replication task corresponding to the data to be synchronized, and the at least one replication task is used to synchronize the data to be synchronized to the m slave regions. The primary replication cluster adds the at least one replication task to the task queue; The primary replication cluster concurrently acquires the at least one replication task from the task queue; The primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions based on at least one replication task obtained from the task queue.

2. The method according to claim 1, characterized in that, The primary replication cluster generates at least one replication task corresponding to the data to be synchronized, including: the primary replication cluster generates m replication tasks corresponding to the data to be synchronized, and the m replication tasks correspond one-to-one with the m slave regions; The primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task obtained from the task queue, including: the primary replication cluster synchronizes the data to be synchronized to the slave region corresponding to each of the m replication tasks obtained from the task queue, wherein the process of the primary replication cluster synchronizing the data to be synchronized to the m slave regions according to the m replication tasks is parallel.

3. The method according to claim 1, characterized in that, The primary replication cluster generates at least one replication task corresponding to the data to be synchronized, including: the primary replication cluster generates one replication task corresponding to the data to be synchronized; The primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions based on at least one replication task obtained from the task queue, including: the primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions based on one replication task obtained from the task queue.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: For each copy task in the task queue: After completing each replication task, the primary replication cluster removes each replication task from the task queue; or, After completing each replication task, the primary replication cluster marks each replication task as completed.

5. The method according to any one of claims 1 to 4, characterized in that, The primary replication cluster includes multiple replication threads, which are distributed across at least one replication node. The primary replication cluster concurrently acquires the at least one replication task from the task queue, including: the plurality of replication threads concurrently acquire the at least one replication task from the task queue; The primary replication cluster concurrently synchronizes the data to be synchronized to the m slave regions based on the at least one replication task obtained from the task queue, including: the replication node where the replication thread that obtained the at least one replication task is located concurrently synchronizes the data to be synchronized to the m slave regions based on the at least one replication task.

6. The method according to any one of claims 1 to 5, characterized in that, The size of the primary replication cluster can be elastically scaled according to the load of data synchronization in the primary replication cluster.

7. The method according to claim 6, characterized in that, The load of the master replication cluster synchronizing data is characterized by at least one of the following information: The utilization rate of computing resources of the primary replication cluster; The utilization rate of transmission resources of the primary replication cluster; The transmission rate of the transmission resources of the primary replication cluster.

8. The method according to any one of claims 1 to 7, characterized in that, Each of the m slave regions includes a slave replication cluster. The master replication cluster concurrently synchronizes the data to be synchronized to the m slave regions according to the at least one replication task obtained from the task queue. This includes: the master replication cluster concurrently sending the data to be synchronized to the slave replication clusters in the m slave regions according to the at least one replication task obtained from the task queue.

9. The method according to claim 8, characterized in that, The first replication cluster is one of the replication clusters included in the primary replication cluster and the m slave regions; the second replication cluster is the other replication cluster included in the primary replication cluster and the m slave regions. The replication nodes in the first replication cluster and the replication nodes in the second replication cluster are fully connected in a point-to-point manner; or, The first replication cluster and the second replication cluster each include a replication agent node. The replication agent node in the first replication cluster is connected to the replication node in the first replication cluster, and the replication agent node in the second replication cluster is connected to the replication node in the second replication cluster.

10. A database system, characterized in that, The database system includes a primary region and m secondary regions, where m is a positive integer. The primary region includes a primary replication cluster and a primary database node. The primary database node is a computing node with a database instance deployed on it. The primary replication cluster includes at least one replication node, which is a computing node that is logically different from the primary database node. The master database node is used to: generate data to be synchronized; The primary replication cluster is used to: acquire the data to be synchronized; Generate at least one replication task corresponding to the data to be synchronized, the at least one replication task being used to synchronize the data to be synchronized to the m slave regions; add the at least one replication task to the task queue; The at least one copy task is concurrently obtained from the task queue; based on the at least one copy task obtained from the task queue, the data to be synchronized is concurrently synchronized to the m slave regions.

11. The database system according to claim 10, characterized in that, The master replication cluster is used for: Generate m replication tasks corresponding to the data to be synchronized, and the m replication tasks correspond one-to-one with the m slave regions; Based on each of the m replication tasks obtained from the task queue, the data to be synchronized is synchronized to the slave region corresponding to each replication task, wherein the process of the primary replication cluster synchronizing the data to be synchronized to the m slave regions based on the m replication tasks is parallel.

12. The database system according to claim 10, characterized in that, The master replication cluster is used for: Generate a replication task corresponding to the data to be synchronized; Based on the copy task obtained from the task queue, the data to be synchronized is concurrently synchronized to the m slave regions.

13. The database system according to any one of claims 10 to 12, characterized in that, The master replication cluster is also used for: For each copy task in the task queue: After each copy task is completed, each copy task is removed from the task queue; or, After each copy task is completed, each copy task is marked as completed.

14. The database system according to any one of claims 10 to 13, characterized in that, The primary replication cluster includes multiple replication threads, which are distributed across at least one replication node. The plurality of replication threads are used to: concurrently retrieve the at least one replication task from the task queue; The replication node where the replication thread that obtains the at least one replication task is located is used to: concurrently synchronize the data to be synchronized to the m slave regions according to the at least one replication task.

15. The database system according to any one of claims 11 to 14, characterized in that, The size of the primary replication cluster can be elastically scaled according to the load of data synchronization in the primary replication cluster.

16. The database system according to claim 15, characterized in that, The load of the master replication cluster synchronizing data is characterized by at least one of the following information: The utilization rate of computing resources of the primary replication cluster; The utilization rate of transmission resources of the primary replication cluster; The transmission rate of the transmission resources of the primary replication cluster.

17. The database system according to any one of claims 10 to 16, characterized in that, Each of the m slave regions includes a slave replication cluster, and the master replication cluster is configured to: concurrently send the data to be synchronized to the slave replication clusters in the m slave regions according to the at least one replication task obtained from the task queue.

18. The database system according to claim 17, characterized in that, The first replication cluster is one of the replication clusters included in the primary replication cluster and the m slave regions; the second replication cluster is the other replication cluster included in the primary replication cluster and the m slave regions. The replication nodes in the first replication cluster and the replication nodes in the second replication cluster are fully connected in a point-to-point manner; or, The first replication cluster and the second replication cluster each include a replication agent node. The replication agent node in the first replication cluster is connected to the replication node in the first replication cluster, and the replication agent node in the second replication cluster is connected to the replication node in the second replication cluster.

19. A computing device cluster, characterized in that, The system includes at least one computing device, each of the at least one computing device including a processor and a memory, wherein 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 to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 9.

20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 9.

21. A computer program product containing program instructions, characterized in that, When the program instructions are executed, they implement the method as described in any one of claims 1 to 9.