Database system updating method, device and system, medium and product

Under the separation of the deposit calculation, the main copy is replicated by the LSM tree change information to prepare a copy, and the method of loading and incrementing the increase of the increase in the amount of WAL is used to solve. The long problem realizes the rapid replication and low bandwidth occupation, which improves the availability of the storage system.

CN119376754APending Publication Date: 2025-01-28HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311687275.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-07-26
Filing Date
2023-12-08
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

Under the existing storage and computing separation architecture, the bandwidth consumes a lot of bandwidth when copying logs between multiple replicas. After the main replica fails, the complete LSM tree needs to be reloaded, resulting in a long recovery time target (RTO) and the consistency between multiple replicas is achieved through replication of data. Large amount of data will consume a lot of bandwidth.

Method used

Copy the copy information of the LSM tree by the main copy to prepare a copy of the data, and the copy of the copy is used to achieve the data consistency. The method of loading the metadata of the incremental file and the increase in the log back (WAL) is used. The copy is quickly promoted to the main copy.

Benefits of technology

The target of fast replication speed, low network bandwidth occupation, low recovery time targets improved the availability of the storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376754A_ABST
    Figure CN119376754A_ABST
Patent Text Reader

Abstract

The invention relates to an updating method, device and system for a database system, a computer readable storage medium and a computer program product. The method comprises the steps that a first computing node where a main copy in a database system is located receives a write request and writes new data carried by the write request into a storage layer, the database system is based on a storage and computation separation architecture and comprises a computing layer and the storage layer, and a plurality of computing nodes in the computing layer provide data computing and access services. The storage layer stores data of a plurality of computing nodes. The method further includes the first compute node sending change information to a second compute node where a backup copy in the database system is located, wherein the change information provides an indication of incremental data of the primary copy. The method further includes the second computing node obtaining incremental data of the primary copy from the storage layer based on the change information. The method further comprises the step that the second computing node uses the obtained incremental data to update the data of the standby copy, wherein the updated data of the standby copy is consistent with the data of the main copy. According to the embodiment of the invention, the change information of the main copy is transmitted to the standby copy, and the standby copy applies the change information to realize the consistency of the main copy and the standby copy, so that the copying speed is high, the network bandwidth occupation can be reduced, the recovery time target can be reduced, and the availability of the storage system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly to an updating method, device, system, computer-readable storage medium, and computer program product for a database system. Background Art

[0002] Database computing integration is a traditional database architecture. In this architecture, the database analyzer, database optimizer, and database executor are usually referred to as database computing nodes, while the database storage serves as the database storage node. When computing and storage programs are deployed on the same physical machine, it is usually called a storage-computing integration deployment mode. Taking the database with one master and two slaves (backups) as an example, each master and slave node has its own computing unit (CPU) and storage (hard disk), which are deployed on different machines.

[0003] Database computing separation is another database architecture in which computing and storage are separated, and the storage space is shared for access by all database computing nodes, such as through a high-speed network. In a database architecture with storage and computing separation, only one copy of the storage space is required, the storage space is shared between computing nodes, and the storage nodes ensure high availability of the storage. This architecture is widely used in cloud storage. Summary of the invention

[0004] A scheme for updating a database system is provided. Through this scheme, change information (e.g., change information based on a log structured merge (LSM) tree) can be copied to a backup copy through a primary copy, and the backup copy uses the LSM tree change information to achieve consistency of data in the primary copy and the backup copy, with fast copying speed and low network bandwidth usage. In some embodiments, when the primary copy fails, the backup copy can be quickly upgraded to the primary copy by incremental file metadata loading and incremental write ahead log (WAL) playback, thereby reducing the recovery time objective (RTO).

[0005] In the first aspect of the present disclosure, an update method for a database system is provided. The method includes: a first computing node where a primary copy of the database system is located receives a write request, and writes the new data carried by the write request to a storage layer. The database system is based on a storage-computing separation architecture, including a computing layer and a storage layer. Multiple computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of multiple computing nodes. The method also includes the first computing node sending change information to a second computing node where a backup copy is located in the database system, wherein the change information provides an indication of the incremental data of the primary copy. The method also includes the second computing node obtaining the incremental data of the primary copy from the storage layer based on the change information. The method also includes the second computing node using the obtained incremental data to update the data of the backup copy, wherein the data of the updated backup copy is consistent with the data of the primary copy. According to the method for a database system in the first aspect of the present disclosure, by transmitting the change information of the primary copy to the backup copy, the backup copy applies the change information to achieve consistency between the primary and backup copies, thereby achieving fast replication speed, reducing network bandwidth occupancy, reducing recovery time objectives, and improving the availability of the storage system.

[0006] In an implementation of the first aspect, the first computing node where the primary copy in the database system is located sends change information to the second computing node where the backup copy in the database system is located, which may include: the first computing node detects a change event associated with the primary copy, wherein the change event may include a write data event, or a disk flush event, or a compress data event; based on the change event, the first computing node determines the change information associated with the change event; and the first computing node sends the change information associated with the change event to the second computing node. In this way, by setting the change event and the corresponding response mode, the change information can be processed faster, so that the primary copy and the backup copy can be synchronized quickly.

[0007] In an implementation scheme of the first aspect, the change event can be associated with a change in a log structure merge (LSM) tree, and the method can also include: in response to the first computing node detecting a change indication of the LSM tree, a write data event: the second computing node reads a log from the last applied log sequence number (LSN) to the LSN corresponding to the change event; and the second computing node replays the read log to the memory. The method can also respond to the first computing node detecting a change indication of the LSM tree, a disk flushing event: the second computing node adds the data indicated in the change information. The method can also respond to the first computing node detecting a change indication of the LSM tree, a compression event: the second computing node deletes the data indicated in the change information. In this way, the primary copy can copy the LSM tree change information to the standby copy based on the change information of the LSM tree, and the standby copy applies the LSM tree change to achieve master-standby consistency, thereby fast replication speed and low network bandwidth occupancy. By setting the change event and the corresponding response mode, the change information can be processed faster, so that the primary copy and the standby copy are synchronized more quickly.

[0008] In an implementation of the first aspect, the method may further include the first computing node receiving the configuration of the newly added replica from the second computing node; based on the configuration of the newly added replica, the first computing node registering the newly added replica; and the first computing node subscribing to the change information of the newly added replica. The method may also include the first computing node sending a snapshot of the newly added replica at the time of registration to the second computing node; and the second computing node adding corresponding metadata based on the snapshot. Through the subscription operation, the latest snapshot of the current LSM tree file can be sent to the subscriber, and support can be provided to send subsequent changes to the LSM tree to the subscriber, so as to better achieve the consistency of the primary and backup replicas.

[0009] In an implementation of the first aspect, the method may further include the first computing node receiving a request from the second computing node to delete a specific copy; based on the request, the first computing node deleting subscription information for the specific copy; and the first computing node subtracting one from a reference count of a file referenced by the specific backup copy. The method may further include the second computing node shutting down an instance of the specific backup; and the second computing node deleting metadata of the specific copy. Through the deletion operation, the backup copy can be deleted and the corresponding instance can be shut down, releasing storage resources, thereby better achieving consistency between the primary and backup copies and saving storage resources.

[0010] In an implementation of the first aspect, the method may further include the first computing node maintaining the oldest LSN of the master copy, the oldest indicating that all data before the oldest LSN are written to the storage layer; and the first computing node deleting the log whose largest LSN is smaller than the oldest LSN. The method may further include the first computing node receiving the oldest LSN maintained by the backup copy; and the first computing node subtracting one from the reference count of the file smaller than the oldest LSN maintained by the backup copy; and in response to the reference count being zero, the first computing node deleting the file. In this way, by maintaining the LSN to manage the data that needs to be written to the storage layer, faster read and write operations can be achieved.

[0011] In an implementation scheme of the first aspect, the granularity of the replica in the database system is at the node level, the node level means that multiple computing nodes are used to form multiple replicas, wherein the primary computing node among the multiple computing nodes can read and write data, and the backup computing node among the multiple computing nodes can read data; or the granularity of the replica in the database system is at the shard level, the shard level means that one shard constitutes a replication group, one computing node includes a primary shard and a backup shard, and both the primary computing node and the backup computing node can read and write data. The method may also include that in response to a failure of the primary computing node, the backup computing node takes over the primary computing node; and the backup computing node determines the backup replica as the primary replica by means of incremental playback logs. In this way, when the primary replica fails, the backup replica can be promoted to the primary replica by means of incremental file metadata loading and incremental WAL playback, thereby reducing RTO.

[0012] In the second aspect of the present disclosure, an update device for a database system is provided. The device includes: a write module, configured to receive a write request from a first computing node where a primary copy of the database system is located, and write the new data carried by the write request into a storage layer, the database system is based on a storage-computing separation architecture, including a computing layer and a storage layer, multiple computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of multiple computing nodes; a sending module, configured to send change information from a first computing node where a primary copy of the database system is located to a second computing node where a backup copy of the database system is located, wherein the change information provides an indication of the incremental data of the primary copy; an acquisition module, configured to obtain the incremental data of the primary copy from the storage layer based on the change information by the second computing node; and an update module, configured to update the data of the backup copy using the acquired incremental data by the second computing node, wherein the data of the updated backup copy is consistent with the data of the primary copy. According to the device for a database system in the second aspect of the present disclosure, the change information (for example, change information based on an LSM tree) can be copied to the backup copy through the primary copy, and the backup copy applies the LSM tree change information to achieve master-backup consistency, with fast replication speed and low network bandwidth occupancy. In some embodiments, when the primary copy fails, the backup copy can be promoted to the primary copy by incremental file metadata loading and incremental WAL playback, thereby reducing the RTO.

[0013] According to a third aspect of the present disclosure, a database system is provided. The database system is based on a storage-computing separation architecture, and includes a computing layer and a storage layer, wherein multiple computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of multiple computing nodes. The database system includes at least one computing device, each computing device includes a processor and a memory, and the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method according to the first aspect.

[0014] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions, which, when executed by a computing device, cause the computer to execute the method according to the first aspect of the present disclosure. In some implementations, the computer-readable storage medium may be non-transient. The computer-readable storage medium includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., flash memory, hard disk (Hard Disk Drive, HDD), solid state disk (Solid State Drive, SSD), etc.).

[0015] According to a fifth aspect of the present disclosure, a computer program product is provided. The computer program product includes instructions, which, when executed by a computing device, cause the computing device to perform the method according to the first aspect of the present disclosure. In some implementations, the computer program product may include one or more software installation packages, and when the method provided by the first aspect or its possible variations is required, the software installation packages may be downloaded or copied and executed on the computing device.

[0016] It should be understood that the database system according to the third aspect of the present disclosure, the computer-readable storage medium according to the fourth aspect, or the computer program product according to the fifth aspect is used to execute the method described in the first aspect. Therefore, the explanation or description of the first aspect is also applicable to the third aspect, the fourth aspect, and the fifth aspect. In addition, the beneficial effects that can be achieved in the third aspect, the fourth aspect, and the fifth aspect can refer to the beneficial effects in the corresponding method, which will not be repeated here.

[0017] Please note that the invention summary is provided to introduce a series of concepts in a simplified form, which will be further described in the detailed description below. The invention summary is not intended to identify key features or essential features of the present disclosure, nor is it intended to limit the scope of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings.

[0019] In the accompanying drawings, the same or similar reference numerals denote the same or similar elements, wherein:

[0020] Figure 1 A schematic diagram schematically illustrates an example environment in which exemplary embodiments of the present disclosure can be implemented;

[0021] Figure 2 A schematic diagram schematically illustrates an LSM tree related to an exemplary embodiment of the present disclosure;

[0022] Figure 3 A schematic diagram schematically shows a database system with storage and computing separation according to an exemplary embodiment of the present disclosure;

[0023] Figure 4 A schematic diagram schematically illustrates a process of adding a replica according to an exemplary embodiment of the present disclosure;

[0024] Figure 5 A schematic diagram schematically illustrates a process of deleting a copy according to an exemplary embodiment of the present disclosure;

[0025] Figure 6A schematic diagram schematically illustrates a change event related to an exemplary embodiment of the present disclosure;

[0026] Figure 7 A schematic diagram schematically illustrates a process of LSM tree change replication according to an exemplary embodiment of the present disclosure;

[0027] Figure 8 A schematic diagram schematically illustrates a process of file cleaning according to an exemplary embodiment of the present disclosure;

[0028] Fig. 9 A schematic diagram schematically shows an architecture of shard-level multiple copies according to an exemplary embodiment of the present disclosure;

[0029] Fig.10 A schematic diagram schematically illustrates a shard-level multi-copy failover according to an exemplary embodiment of the present disclosure;

[0030] Fig.11 A schematic diagram schematically shows another failover of shard-level multiple replicas according to an exemplary embodiment of the present disclosure;

[0031] Fig.12 A schematic diagram schematically illustrates a comparison between two copies and a single copy according to an exemplary embodiment of the present disclosure;

[0032] Fig.13 A flowchart of an updating method for a database system according to an exemplary embodiment of the present disclosure is schematically shown;

[0033] Fig.14 A block diagram schematically illustrates an updating device for a database system according to an exemplary embodiment of the present disclosure;

[0034] Fig.15 A schematic diagram of the structure of a computing device provided in an embodiment of the present application is shown;

[0035] Fig.16 A schematic diagram showing the structure of a computing device cluster provided in an embodiment of the present application is shown; and

[0036] Fig.17 A schematic diagram of a structure in which a computing device cluster provided by an embodiment of the present application is connected via a network is shown.

[0037] Throughout the drawings, the same or similar reference numbers denote the same or similar elements. DETAILED DESCRIPTION

[0038] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0039] In the description of the embodiments of the present disclosure, the term "including" and its variations should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects, unless explicitly indicated to be different.

[0040] As mentioned above, if the database adopts the traditional storage-computing integrated architecture, it is usually composed of several parts: database analyzer, optimizer, executor, and storage. These analyzers, optimizers, and executors are the computing nodes of the database, while storage is the storage node of the database. When the computing and storage programs are deployed on the same physical machine, it can be called the storage-computing integrated deployment mode. Each node has its own CPU and storage resources, and different nodes are independent of each other. If the storage-computing separation deployment method is adopted, the storage space can be shared, and all database computing nodes can access the storage space, while the computing and storage space are accessed through high-speed network connections. This architecture only requires one storage space, which is shared by computing nodes to ensure high availability. The storage nodes ensure the high availability of data. This storage-computing separation architecture is more common in cloud storage architecture.

[0041] There are problems in the multi-copy solution under the traditional storage and computing separation architecture, such as: high bandwidth consumption when copying logs between multiple copies; after the primary copy fails, the complete LSM tree needs to be reloaded, so the RTO is long; the final consistency between multiple copies is achieved by copying data, and a large amount of bandwidth will be consumed when the data volume is large; and after the primary copy fails, a new primary copy needs to be reallocated to the active server to resume the write business, which has a long RTO.

[0042] In view of this, in order to solve at least one of the above problems and other potential problems, a solution for database update according to an embodiment of the present disclosure is proposed. The solution proposed in the present disclosure is different from the traditional solution. Instead, it can copy the LSM tree change information to the backup copy through the master copy based on the LSM tree storage engine. The backup copy applies the LSM tree changes to achieve master-slave consistency. Therefore, compared with the traditional replication operation log, the embodiment of the present disclosure has a fast replication speed and reduces network bandwidth usage. In some embodiments, compared with the single copy fault takeover under the traditional storage and computing separation architecture, RTO is reduced and availability is improved.

[0043] Reference below Figures 1 to 17 It should be understood that these exemplary embodiments are provided only to enable those skilled in the art to better understand and implement the embodiments of the present disclosure, and are not intended to limit the scope of the present disclosure in any way.

[0044] Figure 1 1 is a schematic diagram illustrating an example environment 100 in which methods and / or processes according to embodiments of the present disclosure may be implemented. Figure 1 As exemplarily shown in , the example environment 100 may represent a database system, which includes a computing node 102 (also referred to as a first computing node) and a computing node 104 (also referred to as a second computing node), and a storage node 106. Figure 1 The number and arrangement of components shown are provided as examples. Figure 1 The example environment 100 may include additional components, fewer components, different components, or differently arranged components than those shown in . For example, the example environment 100 may include more computing nodes or storage nodes.

[0045] As an example, computing node 102 can communicate with storage node 106, and computing node 104 can communicate with storage node 106. As the node where the primary backup is located, computing node 102 can write data to storage node 106. For computing node 104 where the backup copy is located, it is necessary to synchronize the data of the primary node to achieve consistency between the primary and backup copies. Unlike traditional technologies, when data is updated, computing node 102 does not directly send the updated data to computing node 104 where the backup copy is located, but computing node 104 receives change information from computing node 102 and obtains updated data from storage node 106 based on the change information. In order to better understand the concept of the present disclosure, some concepts associated with or used in the present disclosure are introduced below. Shared-storage architecture is a shared storage architecture under a storage-computing separation architecture, which replaces local disk storage with distributed shared storage. Distributed shared memory is a system that connects distributed storage systems through a network. It has the advantages of easy programming of tightly coupled distributed systems and easy expansion of loosely coupled distributed systems. It does not need to consider data allocation, process migration and dynamic allocation are simple to implement, and the system scale can be expanded like loose coupling, and there is no need to consider the communication between CPUs when the number of processors is increased. The example environment 100 can be regarded as an example of a shared memory architecture.

[0046] LSM Tree is a multi-level data structure that combines the advantages of ordered lists and tree structures. Compared with other ordered data structures, LSM Tree has the characteristics of fast update and high memory access efficiency. In LSM Tree, data is stored in order according to the number of layers. As the number of layers increases, the size of the ordered array of each layer will also expand exponentially. LSM Tree has two structures: Leveled and Tiered. The Leveled structure stores data in each layer in order of size, while the Tiered structure stores data in different layers in order of size. LSM Tree usually stores the main data structure in secondary storage, such as SSD hard disk. The application scenarios of LSM Tree include a large number of scenarios that require storage access and update, such as distributed databases, cache systems, search engines, etc. It improves storage and access efficiency by storing and managing data in layers, while also reducing the read / write (I / O) load of storage devices. LSM Tree also has good scalability and fault tolerance in distributed systems, and can support large-scale data storage and processing. In short, LSM Tree is a data structure and storage system theoretical model designed for the characteristics of block storage devices. It has the advantages of high efficiency, speed, and scalability, and is widely used in distributed storage and cache systems.

[0047] RTO stands for Recovery Time Objective. It is expressed in time units and indicates the time required for an information system or business function to be restored from being stopped after a disaster occurs. RTO is an important indicator for measuring business recovery capabilities. It can help organizations determine the required backup and recovery strategies, as well as the resources and technologies required to ensure business continuity. The smaller the RTO value, the lower the tolerance of the organization for business interruptions, and the faster recovery time and more efficient backup and recovery strategies are needed. Therefore, RTO can be used as an important indicator for evaluating business continuity plans and disaster recovery plans. In order to meet the requirements of RTO, organizations need to ensure that their backup and recovery strategies can quickly detect disasters and quickly restore data and systems. This may require the use of technologies such as real-time backup, mirror replication, virtualization, and the development of detailed disaster recovery plans and drills. In addition, RTO can also be used together with other business continuity indicators such as RPO (Recovery Point Objective). RPO indicates the point in time that must be restored after a disaster occurs. Together with RTO, it determines the integrity and availability of the disaster recovery plan. In short, RTO is an important indicator for measuring business continuity. It can help organizations determine the required backup and recovery strategies to ensure that data and systems can be quickly restored after a disaster and maintain business continuity.

[0048] The Gossip protocol is a distributed protocol based on the rumor propagation mechanism. It is widely used in distributed systems to achieve information exchange and state synchronization between nodes. In the Gossip protocol, each node maintains a state, such as a data copy or configuration information. Nodes update and maintain their own states by exchanging messages. The way messages are propagated is similar to the spread of rumors in social networks. Some nodes are randomly selected as propagators, and the messages are sent to their adjacent nodes. The adjacent nodes continue to propagate the messages to their adjacent nodes until the messages spread throughout the network. The Gossip protocol has the following characteristics: Decentralization: The Gossip protocol has no central node or coordinator. Each node is equal. They synchronize their states and propagate information by exchanging messages. Reliability: Since the propagation of messages is random, the Gossip protocol has a certain degree of reliability. Even if some nodes fail or the network fails, the message still has a chance to propagate to other nodes. Scalability: The Gossip protocol has good scalability and can support large-scale distributed systems. As the number of nodes increases, the propagation speed of messages may slow down, but there will be no bottlenecks or blockages. Adaptability: The Gossip protocol has a certain degree of adaptability and can adapt to changes in the network and the dynamic joining or leaving of nodes. When new nodes join, they can synchronize their states by exchanging messages with other nodes; when nodes leave, their messages will gradually be replaced by messages from other nodes. In short, the Gossip protocol is a simple, reliable, and scalable distributed protocol suitable for state synchronization and information dissemination in distributed systems.

[0049] WAL (write ahead log) is a logging technology used in databases and file systems. In WAL, data is written to a log file before it is actually written to the main storage area. This write-ahead logging method ensures that even if the system crashes or data is lost, the previous state can be restored through WAL. The main functions of the write-ahead log are as follows: Data recovery: When the system fails or crashes, the data can be restored to a consistent state by replaying the WAL file. Since the data is recorded in the log before it is written to the main storage area, the consistency and integrity of the data can be guaranteed. Transaction persistence: WAL is the key to achieving transaction persistence. In the database, when a transaction is executed, the modified data is first written to WAL. Only when all modifications are written to WAL will these modifications be applied to the main storage area. This ensures that even if the system crashes, the committed transactions will not be lost.

[0050] Log compression (compaction): In order to reduce the storage space occupied by log files, WAL is usually compressed. By removing duplicate data and retaining only the incremental data modification, the storage space requirements of log files can be greatly reduced. Log rotation: In order to prevent the log file from being too large and causing management difficulties, WAL is usually rotated. When the log file reaches a certain size or time, a new log file is automatically created, and the currently active log file is archived and backed up. In short, WAL is an important data persistence and recovery technology, widely used in databases and file systems. It can provide data consistency and transaction persistence, and help protect data from system failures and crashes.

[0051] OLDESTLSN (Oldest LSN) is a term used in log systems, which refers to the oldest sequence number still in use by the system. This sequence number is usually used to mark the location of data on disk so that when the log system and data files are cleaned and archived, it can be determined which data has been written to disk and can be safely deleted. In the log system, every time new data is written, a new log entry is generated, and this entry has a unique sequence number. OLDESTLSN refers to the minimum value in this sequence number, that is, the sequence number of the oldest entry. Therefore, if the sequence number of an entry is less than OLDESTLSN, then this entry is data that has been written to disk and can be cleaned and deleted. This term is often used in database and file system logging to manage the storage and use of log files and data files.

[0052] In addition to OLDESTLSN, there are some other terms in the log system that can help understand how it works. For example: CURRENTLSN: The currently used sequence number, used to track the latest activity in the system. CURRENTLSN always points to the last active entry in the log file. LOGFILE: Log file, used to store log entries. Log files are generally divided into online log files and archived log files. Online log files are log files that are currently being used by the system, while archived log files are log files that have been archived and are no longer in use. SNAPSHOT: Snapshot, used to capture the state of the database at a specific point in time. SNAPSHOT can be used for data backup and recovery, as well as consistency checks before performing database operations. In short, these terms and concepts are the key to understanding how database systems work. By using the above terms in this disclosure, data consistency and integrity in distributed systems can be better managed and maintained.

[0053] Figure 2Schematic diagram 200 of an LSM Tree related to an exemplary embodiment of the present disclosure is schematically shown. LSMTree is a hierarchical, ordered, disk-oriented data structure. Its core idea is to make full use of the fact that the sequential write performance of the disk is much higher than the random write performance, and convert batch random writes into one-time sequential writes. Its overall structure is as follows: Figure 2 As shown, when writing data, the C0 structure in memory is written first. When a certain threshold is reached, it is flushed to the disk C1 structure. On the disk, each level is merged into the next level after reaching a certain number. The reason for writing (206 and 208) WAL in the figure is to ensure the recovery of the C0 structure after a node failure. LSM Tree has high write performance, and many databases use LSM Tree as the data structure of the storage engine.

[0054] C0, C1, C2...CN represent files respectively, which can be understood as a file in the memory 202 (also known as the memory). In some embodiments, data will first be written to the C0 file in the memory, and then after the C0 file is full, it will first be merged (210) to the C1 file in the disk 204 (for example, the disk). These files in the disk are in the structure of the LSM tree, which is stored in layers. If layer 1 is full, it will be merged (212) to layer 2. In some embodiments, merging is also called dropping to disk or flushing. If C1 (layer 1) is full, it will be merged to C2 (layer 2), and so on, such as merging 214 and 216. After the merge, the duplicate data in C1 and C0 will be deleted. For example, if file 1, file 2, and file 3 are merged into file 4, and file 4 is in layer 2, then file 1, file 2, and file 3 will be deleted.

[0055] In some traditional technologies, multiple replicas are usually used to ensure data reliability, enhance database availability, and expand database read capabilities. Under the storage-computing separation structure, HBase is a typical representative of multiple replicas based on LSM Tree. Hbase replicas are at the Region (shard) level. Creating replicas can improve read availability. The overall solution of Hbase Region replicas is: the master region copies WAL to the shard replica (Region Replica), and the Region Replica writes data to the local write buffer (memstore); when the master region flushes, it sends a flush marker command to the Region Replica. After receiving the command, the Region Replica deletes the corresponding data in the local memstore and refreshes the Hadoop distributed file system (HDFS) file list. In order to ensure that the master region does not delete the file being read by the Region Replica, you need to set the timer field hbase.master.hfilecleaner.ttl. If a read request time exceeds the set timer, it may be because the master region deleted the HFile being read and an error is reported. After the region server where the primary region is located fails, the region needs to be reallocated to other region servers to restore the write service, and this process can take more than 1 minute. Therefore, it can be seen that the multi-copy protocol based on LSM Tree in the storage and computing separation architecture has the following problems: (1) The final consistency between multiple copies is achieved by copying data, which consumes a lot of bandwidth when the data volume is large; and (2) After the primary copy fails, the new primary copy needs to be reallocated to the active server to restore the write service, and the RTO is long.

[0056] Figure 3 A schematic diagram of a database system 300 with storage and computing separation according to an exemplary embodiment of the present disclosure is schematically shown. Under the storage and computing separation architecture proposed in the present disclosure, the multi-copy protocol based on LSM Tree can solve the problem of large bandwidth consumption in copying logs between multiple copies in the multi-copy scheme under the existing storage and computing separation architecture. In some embodiments, it can also solve the problem of long RTO due to the need to reload the complete LSM Tree after the primary copy fails. The change information of the LSM Tree proposed in the present disclosure may include which file is added, which file is deleted, where the WAL is written from and to, that is, an offset of a file on a directory, etc., and then the backup copy part applies this change information, and then achieves master-slave consistency, so that the copy speed will be faster and the bandwidth occupied will be smaller.

[0057] like Figure 3 As described above, the present disclosure is applied under the storage and computing separation architecture, and the overall architecture can be divided into a computing layer 302 and a storage layer 304. Among them, the computing layer 302 includes a multi-copy protocol (layer) 304 and an LSM Tree storage engine 312. The storage layer 330 includes a distributed file storage 332. The multi-copy protocol layer 304 in the computing layer 302 includes a replication group metadata management module 306, a replication module 308, and a heartbeat module 310.

[0058] The replication group metadata management module 306 is responsible for adding replicas, deleting replicas, and performing other tasks related to replica management. Typically, the replication group metadata management module 306 implements data redundancy and fault recovery functions. By adding replicas, the availability and reliability of data can be increased, because even if a data replica is lost or damaged, there are other replicas that can be used to recover the data. Deleting replicas that are no longer needed can reduce the use of storage space to avoid storing outdated or no longer needed data. The replication group metadata management module 306 may also need to process various metadata related to data replicas, such as the creation time, location, size, and other information of the replica. This helps the system understand the effectiveness of its data storage and recovery strategies and adjust them as needed. In distributed systems or cloud storage environments, this replication management strategy is usually more important because the data in these environments may be distributed across multiple nodes or servers, and the integrity and availability of the data need to be ensured.

[0059] The replication module 308 can be used to send the change information of the LSM Tree from the primary copy to the backup copy, and the backup copy is responsible for applying the LSM Tree changes after receiving the information. In other words, the change information of the LSM Tree is sent to the backup copy. After receiving the change information, the backup copy will apply the changes of the LSM Tree. The heartbeat module 310 can be used to promote the oldest local LSN for cleaning up log files and data files. That is, to promote the oldest used local LS (that is, LSN). LSN can be understood as a time point, that is, where the oldest time point is. All files before the LSN can be cleaned up. That is, after setting the LSN, files earlier than this time can be cleaned up, and files later than this time need to be retained.

[0060] The LSM Tree storage engine 312 in the computing layer 302 includes a subscription module 314, a snapshot module 316, an LSM Tree change management module 318, and a garbage collection (GC) module 320. The subscription module 314 can send the latest LSM Tree file snapshot to the subscriber, and supports sending subsequent LSM Tree changes to the subscriber. The subscription module 314 can send the latest LSM Tree file snapshot to the subscriber. For example, a newly added sst file is a new subscriber, and a newly added part is a new subscription. The subscription module 314 will send all the current files to the storage node, and then the storage node will load data from the distributed storage 332. The snapshot module 316 can be used to manage LSM Tree file snapshots, including the generation of new file snapshots and the deletion of old file snapshots. The snapshot module 316 can be used to manage file snapshots, that is, which sst files are currently available, including which are new file snapshots, which are old files, which should be deleted, and the files and data to be added or deleted can all be included in the snapshot.

[0061] The LSM Tree change management module 318 can be responsible for the change management of the LSM Tree, such as saving the changes of the LSM Tree to each subscriber's memory variables when writing data, compressing (compaction), and flushing the disk. After the backup copy receives the primary copy change event, it can apply the change locally. The LSM Tree change management module 318 can be used to manage the changes in the WAL when writing data. For example, when flushing the disk, there will be changes in the data file, and the change information will be saved in the memory of each subscriber. The memory variable records the corresponding LSM Tree change information that needs to be synchronized for each subscriber. After the subscriber receives the change information, it will apply it locally to perform the actions it should do, such as which files to load, or which files to delete, or which time point to replay the WAL.

[0062] The GC module 320 can be used to clean up files. For example, after all data is flushed to disk, the log file needs to be cleaned up. When a certain file is not referenced, the data file is deleted. After all data is flushed to disk, that is, all log files have been flushed to sst files, the data file is useless and the log file can be cleaned up. Alternatively, when the data file is not referenced, the log file can also be cleaned up. In short, after all data is flushed to disk, the log file is cleaned up; when a certain data file is not referenced, the data file is deleted.

[0063] In the multi-copy protocol, the master-slave consistency can be achieved by replicating the LSM Tree change information, passing the change information of the master copy to the backup copy, and the backup copy applies the change information to achieve the consistency of the master and backup copies, so that the replication speed is fast, the network bandwidth usage can be reduced, the recovery time target can be reduced, and the availability of the storage system can be improved. The multi-copy protocol includes adding and deleting copies, LSM Tree change replication, file cleanup, etc.

[0064] The following will be combined Figure 4-Figure 8 To describe the multi-copy protocol. Figure 4 FIG. 4 schematically shows a process 400 of adding a replica according to an exemplary embodiment of the present disclosure. Figure 4 As shown, the primary copy 404 includes a multi-copy protocol (layer) 408. The multi-copy protocol 408 includes a configuration management module 412 and a replication group metadata management module 414. The primary copy 404 also includes an LSM Tree storage engine 420. The LSM Tree storage engine 420 includes a subscription module 422 and a snapshot module 424. It will be appreciated that for the sake of simplicity, other modules are not shown. The backup copy 406 includes a multi-copy protocol (layer) 410. The multi-copy protocol (layer) 410 includes a configuration management module 416 and a replication group metadata management module 418. The backup copy 406 also includes an LSM Tree storage engine 426. The LSM Tree storage engine 426 includes a change application module 428. The storage layer 430 includes a distributed storage 432. The distributed storage 432 includes 1.log 434 and 1.data 436. It will be appreciated that for the sake of simplicity, other modules are not shown.

[0065] In the process 400 of adding a replica, the multi-replica protocol may include the following actions: (1) registering a replica on the primary replica according to the replica configuration. (2) The newly registered replica subscribes to the LSM Tree changes on the primary replica on the LSM Tree engine; (3) When subscribing for the first time, the primary replica returns the snapshot of the LSM Tree at this time to the backup replica; and (4) After receiving the backup replica, the LSM Tree snapshot is applied to load the file metadata. For example, the replication group metadata management module 418 can send an addpeer message to the replication group metadata management module 414. The replication group metadata management module 414 can register the backup replica 406 on the LSM Tree engine according to the addpeer message. Then, the replication group metadata management module 414 can send a response message to the replication group metadata management module 418, indicating that the registration has been successful and which files currently need to be loaded into the backup replica 406, for example, 1.data 436 needs to be loaded into the backup replica 406.

[0066] The replication group metadata management module 414 can communicate with the subscription module 422 through the registerlistner message, send the latest LSM Tree file snapshot to the subscriber, and support sending subsequent LSM Tree changes to the subscriber. The subscription module 422 can communicate with the snapshot module 424 through the dumpdatafile message. The snapshot module 424 can flush the data to 1.data 436 through the flush message. The replication group metadata management module 418 can send an applyTree message to the change application module 428 in the LSM Tree storage engine 426. The change application module 428 in the LSM Tree storage engine 426 can know which data files need to be loaded according to the applyTree message, and add the data files (e.g., 1.data 436) from the distributed storage 432 to the memory.

[0067] In some embodiments, before adding to the subscription module 422, it is necessary to know the current snapshot properties, but in order to avoid replaying WAL, which is time-consuming, a new file can be generated, that is, a flash is made to flush the current log to the storage, for example, if it is originally 1.log 434, then 1.data can be generated. Then, 1.data can be sent to the backup copy 406. After receiving it, the backup copy 406 can apply the change, that is, load 1.data.

[0068] Figure 5 Schematically shows a schematic diagram of a process 500 for deleting a copy according to an exemplary embodiment of the present disclosure. Figure 5 As shown, the primary copy 504 includes a multi-copy protocol (layer) 508. The multi-copy protocol (layer) 508 includes a configuration management module 512 and a replication group metadata management module 514. The primary copy 504 also includes an LSM Tree storage engine 520. The LSM Tree storage engine 520 includes a subscription module 522 and a snapshot module 524. It can be understood that for the sake of simplicity, other modules are not shown. The backup copy 506 includes a multi-copy protocol (layer) 510. The multi-copy protocol (layer) 510 includes a configuration management module 516 and a replication group metadata management module 518. The backup copy 506 also includes an LSM Tree storage engine 526. The storage layer 530 includes a distributed storage 532. The distributed storage 532 includes 1.log 534 and 1.data 536. It can be understood that for the sake of simplicity, other modules are not shown.

[0069] In the process 500 of deleting a replica, the multi-replica protocol may include the following actions: (1) the backup replica sends a removePeer message to the primary replica. After receiving the message, the primary replica deletes the subscription information of the backup replica from the storage engine and reduces the reference count of the snapshot referenced by the backup replica. (2) The backup replica closes the engine instance of the replica to be deleted; and (3) the node where the backup replica is located deletes the replica metadata. For example, the replication group metadata management module 518 may send a removePeer message to the replication group metadata management module 514. The replication group metadata management module 514 may unregister (Unregisterlinstner) the backup replica 506 in the subscription module 522 on the LSMTree storage engine 520 according to the removePeer message, and cancel the reference to it in the snapshot module 524 (via the unrefsnapshot message). Then, the replication group metadata management module 514 may send a response message to the replication group metadata management module 518, indicating that the deletion has been successful. The replication group metadata management module 518 can notify the LSM Tree storage engine 526 to close the engine instance of the replica to be deleted (through the closestorage instance message). Through the deletion operation, the backup copy can be deleted and the corresponding instance can be closed to release storage resources, thereby better achieving the consistency of the primary and backup copies and saving storage resources.

[0070] Figure 6 A schematic diagram 600 of a change event related to an exemplary embodiment of the present disclosure is schematically shown. When a database based on the LSM Tree storage engine writes data, flushes disks, and compresses files, an LSM Tree change event is generated. Figure 6 As shown, when writing data, a WAL event (walEvent) 602 is generated. As an example, WAL event 602 indicates that the current data writing needs to start reading the log from the position where the last reading of log file 1.log ended and replay until the LSN is 100.

[0071] When the memory data is flushed to disk, a flush event 604 (also called manifestEvent) may be generated. As an example, flush event 604 indicates that the data file has changed, and a new file 3.data has been added. At this time, the LSN is 200. The LSN in flush event 604 indicates the order in which the events are generated on the primary copy. Compression also generates a manifestEvent, which is called a compression event. As an example, in compression event 606, the event generated by compaction indicates that this compaction compresses the 1.data and 2.data files into 4.data, 5.data, and 6.data, and deletes the 1.data and 2.data files.

[0072] In some embodiments, different change events may correspond to different subsequent actions. For example, for WAL event 602, the file may be read and then played back to the location where LSN is 100. For disk flushing event 604, the corresponding data or file metadata, such as the metadata of file 3, may be added or deleted. For compression event 606, file 1 and file 2 may be deleted to load files 4-6. In short, the subscription module may obtain what changes have occurred and then send the changes in the event to the backup copy. The backup copy may apply the changes after receiving the changes. In this way, by setting the change event and the corresponding response mode, the change information may be processed more quickly, so that the primary copy and the backup copy may be synchronized quickly.

[0073] Figure 7 FIG. 7 schematically shows a process 700 of LSM Tree change replication according to an exemplary embodiment of the present disclosure. Figure 7 As shown, the master copy 704 includes a multi-copy protocol (layer) 708. The multi-copy protocol (layer) 708 includes a configuration management module 712 and a replication module 714. The master copy 704 also includes an LSM Tree storage engine 720. The LSM Tree storage engine 720 includes a subscription module 722 and an LSM Tree change management module 724. It can be understood that for the sake of simplicity, other modules are not shown. The backup copy 706 includes a multi-copy protocol (layer) 710. The multi-copy protocol (layer) 710 includes a configuration management module 716 and a replication module 718. The backup copy 706 also includes an LSM Tree storage engine 726. The LSM Tree storage engine 726 includes a change application module 728. The storage layer 730 includes a distributed storage 732. The distributed storage 732 includes 1.log 734, 2.log 736 and 2.data738. It can be understood that for the sake of simplicity, other modules are not shown.

[0074] In the LSM Tree change replication process 700, the multi-copy protocol may include the following actions: (1) After the primary copy replication module discovers the LSM Tree change, it sends it to the corresponding backup copy. (2) The backup copy replication module receives the LSM Tree change event and applies the change event. If it is a WAL event, it reads the log from the log file from the LSN of the last application to the LSN of this event and replays it into the memory. If it is a disk flushing event, it adds or deletes the corresponding data file metadata. For example, the subscription module 722 discovers or obtains the change event (through the getchangeevents message) and can notify the replication module 714. For example, the replication module 714 can send a sendchangeevent message to the replication module 718. The replication module 718 can apply the change event on the change application module 728 of the LSM Tree storage engine 726 according to the sendchangeevent message, for example, reading the file from 2.data 738 in the distributed storage 732 and applying or adding the file metadata to the memory.

[0075] In this way, the primary copy can copy the LSM tree change information to the backup copy based on the LSM tree change information, and the backup copy applies the LSM tree change to achieve the consistency between the primary and backup copies, so that the replication speed is fast and the network bandwidth is low. Through the subscription operation, the latest LSM tree file snapshot can be sent to the subscriber, and the subsequent LSM tree changes can be sent to the subscriber, so as to better achieve the consistency of the primary and backup copies.

[0076] Figure 8 Schematically shows a schematic diagram of a file cleaning process 800 according to an exemplary embodiment of the present disclosure. Figure 8 As shown, the master copy 804 includes a multi-copy protocol (layer) 808. The multi-copy protocol (layer) 808 includes a heartbeat module 812. The master copy 804 also includes an LSM Tree storage engine 816. The LSM Tree storage engine 816 includes a subscription management module 818, a snapshot management module 820, and a log management module 822. It is understood that for the sake of simplicity, other modules are not shown. The backup copy 806 includes a multi-copy protocol (layer) 810. The multi-copy protocol (layer) 810 includes a heartbeat module 814. The backup copy 806 also includes an LSM Tree storage engine 824. The LSM Tree storage engine 824 includes a snapshot management module 826. The storage layer 830 includes a distributed storage 832. The distributed storage 832 includes 1.log 834, 3.log 836, 2.data 838, and 4.data840. It is understood that for the sake of simplicity, other modules are not shown.

[0077] In the file cleaning process 800, there are log cleaning actions and data file cleaning actions. In the log cleaning action, when the master copy updates the oldestLSN, it deletes the log whose maximum LSN is less than the oldestLSN. For example, the log management module 822 in the master copy 804 can delete the log (for example, 1.log834) when the MaxLSN is less than the oldestLSN.

[0078] In the data file cleanup action, after the primary copy 804 receives the oldestLSN pushed by the backup copy 806, it decrements the reference count of the snapshot file that is less than the oldestLSN, and when the reference count is reduced to 0, the file is deleted. For example, the heartbeat module 814 in the backup copy 806 can send the oldestLSN to the heartbeat module 812 in the primary copy (via the sendOldestLSN message). The heartbeat module 812 can forward the oldestLSN to the subscription management module 818 (via the forwardOldestLSN message). The subscription management module 818 can decrement the reference count of the log by one (via the unRef message). The snapshot management module 820 can delete the log (for example, 2.data838) when the reference count of the log is 0. By maintaining the LSN to manage the data that needs to be written to the storage layer, faster read and write operations can be achieved.

[0079] Fig. 9 The schematic diagram of the architecture 900 of the shard-level multi-copy according to the exemplary embodiment of the present disclosure is schematically shown. The structure of the master and backup copies can be at the node level or at the shard level. The master node can read and write, and the backup node is read-only. Fig. 9 In the shard-level architecture shown, a node can have a primary shard and a backup shard. Figure 902 shows a primary shard, and Figure 904 shows a backup shard. Figure 906 shows the connection relationship of replication group 1. Figure 908 shows the connection relationship of replication group 2. Figure 910 shows the connection relationship of replication group 3. The nodes of a replication group use a multi-copy protocol to form a replication group.

[0080] The scheme disclosed in the present invention can not only perform failover between multiple replicas, but also perform failover by loading the replica data on the failed node through other normal nodes when all nodes in a replication group fail. For example, when node 1 fails, the shard 914 of the primary replica on node 1 (hereinafter referred to as the primary shard) corresponds to the shard 920 of the backup replica (hereinafter referred to as the backup shard), and the backup shard 920 is normal, then the backup shard 920 on node 2 is upgraded to the primary shard by incrementally replaying WAL and incrementally loading file metadata; the backup shard 916 on node 1 fails and is not processed. The primary shard 928 on node 3 can continue to receive the read and write services of the primary shard 928. When nodes 1 and 2 fail at the same time, node 3 loads the file metadata of the primary shard 914, and replays WAL to generate the primary shard of shard 914, and receives the read and write services of the primary shard 914.

[0081] In the shard-level architecture, there may be a combination of primary shards and backup shards. For example, there is a primary shard 914 on node 1, which forms replication group 1 with backup shard 918 on node 2. There is a backup shard 916 on node 1, which forms replication group 3 with primary shard 928 on node 3. There is a primary shard 922 on node 2, which forms replication group 2 with backup shard 926 on node 3. The solution proposed in the present disclosure is not only capable of performing failover between multiple replicas, for example, assuming that after node 1 fails, backup shard 920 can be upgraded to a primary shard through incremental playback. For example, if node 2 fails again, but the node has shared storage below, so both primary shard 914 in node 1 and primary shard 922 in node 2 can be restored on node 3. When the primary replica fails, the backup replica can be upgraded to the primary replica through incremental file metadata loading and incremental WAL playback, thereby reducing RTO.

[0082] Fig.10 Schematically shows a schematic diagram of a shard-level multi-copy failover 1000 according to an exemplary embodiment of the present disclosure. Fig.10 As shown, figure 1002 shows the primary shard, figure 1004 shows the backup shard. Figure 1006 shows the connection relationship of replication group 1. Figure 1008 shows the connection relationship of replication group 2. Figure 1010 shows the connection relationship of replication group 3. Fig.10 In the example, node 1 fails, so the primary shard 1014 on node 1 needs to be processed. Since the backup shard 1020 of replication group 1 that is coexisting with shard 1014 is on node 2, the backup shard 1020 can be set as the primary shard. The backup shard 1020 can be upgraded to the primary shard through incremental playback. The backup shard 1016 on node 1 does not need to be processed.

[0083] Fig.11Schematically shows another schematic diagram of a shard-level multi-copy failover 1100 according to an exemplary embodiment of the present disclosure. Fig.11 As shown, figure 1102 shows the primary shard, figure 1104 shows the backup shard. Figure 1106 shows the connection relationship of replication group 1. Figure 1108 shows the connection relationship of replication group 2. Figure 1110 shows the connection relationship of replication group 3. Fig.11 In the process, Node 1 and Node 2 fail, so the primary shard 1114 on Node 1 and the primary shard 1122 on Node 2 need to be processed. Since the backup shard 1120 of replication group 1 that is coexisting with the primary shard 1114 is on Node 2, the backup shard 1120 in Node 2 cannot be upgraded to the primary shard. A new shard 1130 can be set on Node 3 as the new primary shard of the original primary node 1114. Since the backup shard 1126 of replication group 2 that is coexisting with shard 1122 is on Node 3, the backup shard 1132 can be set as the primary shard. Both the new primary shard 1130 and the original backup shard 1132 can be set as primary shards through incremental playback.

[0084] Fig.12 A schematic diagram 1200 of a comparison of two copies with a single copy according to an exemplary embodiment of the present disclosure is schematically shown. Fig.12 The test database shown is Cassandra, and the engine used is RocksDB. The test scenario is to write 100,000 data each time, for a total of 10 million data. Each data is 8KB, and 32M data is flushed to the disk once. After writing the data, the node where the primary copy is located fails to verify the RTO effect. Fig.12 shown. Fig.12 A single copy refers to one copy for one shard. After a failure, the node failure is detected through gossip, and the copy on the failed node is taken over by other active nodes, that is, the RocksDB corresponding to the shard is opened for writing. Two copies refer to two copies built by applying the multi-copy protocol disclosed in this disclosure. After gossip detects a node failure, its backup copy becomes the primary copy by replaying the incremental log. Fig.12 The RTO time is composed of gossip detection time, manifest playback time, and log playback time. The manifest records the change information of the LSM Tree data file. In this scenario, the RTO of the two replicas is shortened to one third of the original.

[0085] Fig.13A flowchart of an update method 1300 for a database system according to an exemplary embodiment of the present disclosure is schematically shown. The database system is based on a storage-computing separation architecture, including a computing layer and a storage layer, wherein multiple computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of multiple computing nodes. Method 1300 includes: at box 1302, a first computing node where a primary copy of the database system is located receives a write request, and writes new data carried by the write request to the storage layer. At box 1304, the first computing node where the primary copy of the database system is located sends change information to a second computing node where a backup copy of the database system is located, wherein the change information provides an indication of the incremental data of the primary copy. At box 1306, the second computing node obtains the incremental data of the primary copy from the storage layer based on the change information. At box 1308, the second computing node uses the obtained incremental data to update the data of the backup copy, wherein the updated data of the backup copy is consistent with the data of the primary copy. By executing method 1300, the change information of the primary copy is transmitted to the backup copy, and the backup copy applies the change information to achieve consistency between the primary and backup copies, thereby increasing the replication speed, reducing network bandwidth usage, reducing the recovery time target, and improving the availability of the storage system.

[0086] In some embodiments, the sending of change information from a first computing node where a primary copy in a database system is located to a second computing node where a backup copy in a database system is located may include: the first computing node detecting a change event associated with the primary copy, wherein the change event includes a write data event, or a disk flush event, or a compress data event; based on the change event, the first computing node determines the change information associated with the change event; and the first computing node sends the change information associated with the change event to the second computing node. In this way, by setting the change event and the corresponding response mode, the change information can be processed faster, so that the primary copy and the backup copy can be synchronized quickly.

[0087] In some embodiments, the change event is associated with a change in a log structured merge (LSM) tree, and method 1300 may also respond to the first computing node detecting a change in the LSM tree indicating a write data event: the second computing node reads the log starting from the log sequence number LSN of the last application to the LSN corresponding to the change event; and the second computing node plays the read log back to the memory. Method 1300 may also respond to the first computing node detecting a change in the LSM tree indicating a disk flush event: the second computing node adds the data indicated in the change information. Method 1300 may also respond to the first computing node detecting a change in the LSM tree indicating a compression event: the second computing node deletes the data indicated in the change information. In this way, by setting the change event and the corresponding response mode, the change information can be processed more quickly, so that the primary copy and the backup copy can be synchronized more quickly.

[0088] In some embodiments, method 1300 may also include the first computing node receiving the configuration of the newly added replica from the second computing node; based on the configuration of the newly added replica, the first computing node registering the newly added replica; and the first computing node subscribing to the change information of the newly added replica. In some embodiments, method 1300 may also include the first computing node sending a snapshot of the newly added replica at the time of registration to the second computing node; and the second computing node adding corresponding metadata based on the snapshot. Through the subscription operation, the latest snapshot of the current LSM tree file can be sent to the subscriber, and the subsequent changes to the LSM tree can be sent to the subscriber, so as to better achieve the consistency of the primary and backup replicas.

[0089] In some embodiments, method 1300 may also include the first computing node receiving a request from the second computing node to delete a specific copy; based on the request, the first computing node deleting subscription information for the specific copy; and the first computing node subtracting one from a reference count of a file referenced by the specific backup copy. Method 1300 may also include the second computing node shutting down an instance of the specific backup; and the second computing node deleting metadata of the specific copy. Through the deletion operation, the backup copy can be deleted and the corresponding instance can be shut down, releasing storage resources, thereby better achieving consistency between the primary and backup copies and saving storage resources.

[0090] In some embodiments, method 1300 may also include the first computing node maintaining the oldest LSN of the master copy, where the oldest means that all data before the oldest LSN are written to the storage layer; and the first computing node deleting the log whose largest LSN is smaller than the oldest LSN. Method 1300 may also include the first computing node receiving the oldest LSN maintained by the backup copy; and the first computing node subtracting one from the reference count of the file smaller than the oldest LSN maintained by the backup copy; and in response to the reference count being zero, the first computing node deleting the file. In this way, by maintaining the LSN to manage the data that needs to be written to the storage layer, faster read and write operations can be achieved.

[0091] In some embodiments, the granularity of the replica in the database system is at the node level, and the node level means that multiple computing nodes are used to form multiple replicas, wherein the primary computing node among the multiple computing nodes can read and write data, and the backup computing node among the multiple computing nodes can read data; or the granularity of the replica in the database system is at the shard level, and the shard level means that one shard constitutes a replication group, and one computing node includes a primary shard and a backup shard, and both the primary computing node and the backup computing node can read and write data. Method 1300 may also include that in response to a failure of the primary computing node, the backup computing node takes over the primary computing node; and the backup computing node determines the backup replica as the primary replica by means of incremental playback logs. In this way, when the primary replica fails, the backup replica can be promoted to the primary replica by means of incremental file metadata loading and incremental WAL playback, thereby reducing RTO.

[0092] Fig.14 The block diagram of an updating device 1400 for a database system according to an exemplary embodiment of the present disclosure is schematically shown. The database system is based on a storage-computation separation architecture, including a computing layer and a storage layer, wherein a plurality of computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of a plurality of computing nodes. The device 1400 includes a writing module 1401, which is configured to receive a write request from a first computing node where a primary copy of the database system is located, and write the new data carried by the write request into the storage layer. The device 1400 also includes a sending module 1402, which is configured to send change information from a first computing node where a primary copy of the database system is located to a second computing node where a backup copy of the database system is located, wherein the change information provides an indication of the incremental data of the primary copy. The device 1400 also includes an acquisition module 1404, which is configured to acquire the incremental data of the primary copy from the storage layer based on the change information by the second computing node. The device 1400 also includes an updating module 1406, which is configured to update the data of the backup copy using the acquired incremental data by the second computing node, wherein the updated data of the backup copy is consistent with the data of the primary copy. By implementing the device 1400, the change information (e.g., change information based on the LSM tree) can be copied to the backup copy through the primary copy, and the backup copy uses the LSM tree change information to achieve master-backup consistency, with fast copy speed and low network bandwidth usage. In some embodiments, when the primary copy fails, the backup copy can be upgraded to the primary copy by incremental file metadata loading and incremental WAL playback, thereby reducing RTO.

[0093] In some embodiments, the sending module 1402 also includes a detection module 1407, which is configured for the first computing node to detect a change event associated with the primary copy; a determination module 1408, which is configured for the first computing node to determine the change information associated with the change event based on the change event; and the sending module 1402 is also configured for the first computing node to send the change information associated with the change event to the second computing node. In some embodiments, the change event may include: a write data event; a disk flush event; or a compress data event. In this way, by setting the change event and the corresponding response mode, the change information can be processed faster, so that the primary copy and the backup copy can be synchronized quickly.

[0094] In some embodiments, the detection module 1407 is further configured to detect changes in the LSM tree at the first computing node; and the determination module 1408 is further configured to determine the change event at the first computing node based on the changes in the LSM tree. In this way, the primary copy can copy the LSM tree change information to the backup copy based on the change information of the LSM tree, and the backup copy applies the LSM tree changes to achieve master-backup consistency, thereby fast replication speed and low network bandwidth occupancy.

[0095] In some embodiments, the device 1400 may further include a read module 1410, configured to respond to a change in the LSM tree indicating a write data event, and the second computing node reads the log starting from the log sequence number LSN of the last application to the LSN corresponding to the change event; and the device 1400 may further include a playback module 1412, configured to respond to the second computing node replaying the read log to the memory. The device 1400 may further include an add module 1414, configured to respond to a change in the LSM tree indicating a disk flush event, and the second computing node adds the data indicated in the change information. The device 1400 may further include a delete module 1416, configured to respond to a change in the LSM tree indicating a compression event, and the second computing node deletes the data indicated in the change information. In this way, by setting the change event and the corresponding response mode, the change information can be processed more quickly, so that the primary copy and the backup copy are synchronized more quickly.

[0096] In some embodiments, the device 1400 may also include a receiving module 1420, which is configured so that the first computing node receives the configuration of the newly added replica from the second computing node; the device 1400 may also include a registration module 1418, which is configured so that the first computing node registers the newly added replica based on the configuration of the newly added replica; and the device 1400 may also include a subscription module 1422, which is configured so that the first computing node subscribes to the change information of the newly added replica. In some embodiments, the sending module 1402 is also configured so that the first computing node sends the snapshot of the newly added replica at the time of registration to the second computing node; and the adding module 1414 is also configured so that the second computing node adds corresponding metadata based on the snapshot. Through the subscription operation, the latest snapshot of the LSM tree file can be sent to the subscriber, and the subsequent changes of the LSM tree can be sent to the subscriber, so as to better achieve the consistency of the master and backup replicas.

[0097] In some embodiments, the receiving module 1420 is further configured so that the first computing node receives a request from the second computing node to delete a specific copy; the deleting module 1416 is further configured so that, based on the request, the first computing node deletes the subscription information for the specific copy; and the subscription module 1422 is further configured so that the first computing node subtracts one from the reference count of the file referenced by the specific backup copy. The device 1400 may also include a closing module 1426, which is configured so that the second computing node closes the instance of the specific backup; and the deleting module 1416 is further configured so that the second computing node deletes the metadata of the specific copy. Through the deletion operation, the backup copy can be deleted and the corresponding instance can be closed, releasing storage resources, thereby better achieving the consistency of the primary and backup copies and saving storage resources.

[0098] In some embodiments, the device 1400 may also include a maintenance module 1424, which is configured for the first computing node to maintain the oldest LSN of the master copy, where the oldest means that all data before the oldest LSN are written to the storage layer; and the deletion module 1416 is also configured for the first computing node to delete the log whose largest LSN is smaller than the oldest LSN. The receiving module 1420 is also configured for the first computing node to receive the oldest LSN maintained by the backup copy; and the maintenance module 1424 is also configured for the first computing node to subtract one from the reference count of the file smaller than the oldest LSN maintained by the backup copy; and the deletion module 1416 is also configured for the first computing node to delete the file in response to the reference count being zero. In this way, by maintaining the LSN to manage the data that needs to be written to the storage layer, faster read and write operations can be achieved.

[0099] In some embodiments, the granularity of the replica in the database system is at the node level, and the node level means that multiple computing nodes are used to form multiple replicas, wherein the primary computing node among the multiple computing nodes can read and write data, and the backup computing node among the multiple computing nodes can read data; or the granularity of the replica in the database system is at the shard level, and the shard level means that one shard constitutes a replication group, and one computing node includes a primary shard and a backup shard, and both the primary computing node and the backup computing node can read and write data. The device 1400 may also include a takeover module 1428, which is configured to include a backup computing node taking over the primary computing node in response to a failure of the primary computing node; and the backup computing node determines the backup replica as the primary replica by means of incremental playback logs. In this way, when the primary replica fails, the backup replica can be promoted to the primary replica by means of incremental file metadata loading and incremental WAL playback, thereby reducing the RTO.

[0100] Fig.15 1 shows a schematic block diagram of an example computing device 1500 that can be used to implement an example implementation of the present disclosure. Fig.15 As shown, computing device 1500 includes: bus 1502, processor 1504, memory 1506 and communication interface 1508. Processor 1504, memory 1506 and communication interface 1508 communicate through bus 1502. Computing device 1500 can be a server, a storage device with computing capabilities, or a terminal device. It should be understood that the present disclosure does not limit the number of processors and memories in computing device 1500.

[0101] The bus 1502 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.15 The bus 1502 may include a path for transmitting information between various components of the computing device 1500 (eg, the memory 1506, the processor 1504, and the communication interface 1508).

[0102] The processor 1504 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

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

[0104] The memory 1506 stores executable program codes, and the processor 1504 executes the executable program codes to respectively implement the functions of one or more of the aforementioned writing module 1401, sending module 1402, obtaining module 1404, and updating module 1406, thereby implementing the updating method for the database system according to the embodiment of the present disclosure. That is, the memory 1506 stores instructions for executing the updating of the database system according to the embodiment of the present disclosure.

[0105] Alternatively, the memory 1506 stores executable codes, and the processor 1504 executes the executable codes to respectively implement the functions of the aforementioned device 1400, thereby implementing the update method for the database system according to the embodiment of the present disclosure. That is, the memory 1506 stores instructions for executing the update method for the database system according to the embodiment of the present disclosure.

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

[0107] The disclosed embodiments also provide a computing device cluster, such as a database system. Fig.16A schematic block diagram of an example computing device cluster 1600 that can be used to implement an exemplary implementation of the present disclosure is shown. The computing device cluster 1600 includes at least one computing device. The computing device can be a server, such as a central server, an edge server, a storage device with computing capabilities, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.

[0108] like Fig.16 As shown, the computing device cluster 1600 includes at least one computing device 1500. The memory 1506 in one or more computing devices 1500 in the computing device cluster 1600 may store the same instructions for executing the updating method for a database system according to an embodiment of the present disclosure.

[0109] In some possible implementations, the memory 1506 of one or more computing devices 1500 in the computing device cluster 1600 may also respectively store partial instructions for executing the updating method for the database system according to the embodiment of the present disclosure. In other words, the combination of one or more computing devices 1500 may jointly execute the instructions for executing the updating method for the database system according to the embodiment of the present disclosure.

[0110] It should be noted that the memory 1506 in different computing devices 1500 in the computing device cluster 1600 may store different instructions, which are respectively used to execute part of the functions of the apparatus 1400. That is, the instructions stored in the memory 1506 in different computing devices 1500 may implement the functions of one or more of the aforementioned writing module 1401, sending module 1402, obtaining module 1404, and updating module 1406.

[0111] In some possible implementations, one or more computing devices in the computing device cluster 1600 may be connected via a network, which may be a wide area network or a local area network. Fig.17 A possible implementation is shown. Fig.17 As shown, two computing devices 1500A and 1500B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 1506 in the computing device 1500A stores instructions for executing the functions of the sending module 1402, the acquisition module 1404, and the update module 1406. The memory 1506 in the computing device 1500B stores instructions for executing the functions of the sending module 1402, the acquisition module 1404, and the update module 1406.

[0112] It should be understood that Fig.17The functionality of the computing device 1500A shown in FIG. 1 may also be implemented by multiple computing devices 1500. Similarly, the functionality of the computing device 1500B may also be implemented by multiple computing devices 1500.

[0113] The present disclosure also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Fig.15 and Fig.16 The connection mode of the computing device cluster 1600. The difference is that the memory 1506 in one or more computing devices 1500 in the computing device cluster may store the same instructions for executing the updating method for the database system according to the embodiment of the present disclosure.

[0114] In some possible implementations, the memory 1506 of one or more computing devices 1500 in the computing device cluster may also respectively store partial instructions for executing the updating method for the database system according to the embodiment of the present disclosure. In other words, the combination of one or more computing devices 1500 may jointly execute the instructions for executing the updating method for the database system according to the embodiment of the present disclosure.

[0115] The embodiments of the present disclosure also provide a computer program product including instructions, which may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the method and function of any of the above embodiments.

[0116] The embodiments of the present disclosure also provide a computer-readable storage medium, which may be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to execute the method and function of any of the above embodiments.

[0117] In general, various embodiments of the present disclosure may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects may be implemented in hardware, while other aspects may be implemented in firmware or software, which may be performed by a controller, microprocessor, or other computing device. Although various aspects of the embodiments of the present disclosure are shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that the blocks, devices, systems, techniques, or methods described herein may be implemented as, by way of non-limiting example, hardware, software, firmware, dedicated circuits or logic, general purpose hardware or controllers or other computing devices, or some combination thereof.

[0118] The present disclosure also provides at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes computer executable instructions, such as instructions included in a program module, which are executed in a device on a real or virtual processor of the target to perform the process / method as described above with reference to the accompanying drawings. Typically, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functions of program modules can be combined or divided between program modules as needed. Machine executable instructions for program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.

[0119] The computer program code for realizing the method of the present disclosure can be written in one or more programming languages. These computer program codes can be provided to the processor of general-purpose computer, special-purpose computer or other programmable data processing device, so that the program code, when being executed by computer or other programmable data processing device, causes the function / operation specified in flow chart and / or block diagram to be implemented. The program code can be executed completely on computer, partly on computer, as independent software package, partly on computer and partly on remote computer or completely on remote computer or server.

[0120] In the context of the present disclosure, computer program codes or related data may be carried by any appropriate carrier to enable a device, apparatus or processor to perform the various processes and operations described above. Examples of carriers include signals, computer readable media, and the like. Examples of signals may include electrical, optical, radio, acoustic or other forms of propagation signals, such as carrier waves, infrared signals, and the like.

[0121] A computer-readable medium may be any tangible medium containing or storing a program for or related to an instruction execution system, apparatus or device, or a data storage device such as a data center containing one or more available media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared or semiconductor system, apparatus or device, or any suitable combination thereof. More detailed examples of computer-readable storage media include an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0122] In addition, although the operation of the method of the present disclosure is described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flow chart can change the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of a device described above can be further divided into being embodied by multiple devices.

[0123] The various implementations of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed implementations. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those of ordinary skill in the art that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the various embodiments of the present invention. Without departing from the scope and spirit of the various implementations described, many modifications and changes are obvious to those of ordinary skill in the art. The choice of terms used in this article is intended to explain the principles of each implementation, practical application or improvement of technology in the market, or to enable other ordinary skill in the art to understand the various implementations disclosed herein.

Claims

1. A method for updating a database system, characterized in that: The database system is based on a storage-computing separation architecture and includes a computing layer and a storage layer. Multiple computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of the multiple computing nodes. The method includes: The first computing node where the primary copy in the database system is located receives the write request, and writes the new data carried in the write request into the storage layer; The first computing node sends change information to a second computing node in the database system where the backup copy is located, wherein the change information provides an indication of incremental data of the primary copy; The second computing node obtains the incremental data of the primary copy from the storage layer based on the change information; and The second computing node uses the acquired incremental data to update the data of the backup copy, wherein the updated data of the backup copy is consistent with the data of the primary copy.

2. The method according to claim 1, characterized in that The sending of change information by a first computing node where a primary copy in the database system is located to a second computing node where a backup copy in the database system is located includes: The first computing node detects a change event associated with the primary copy, wherein the change event includes a data write event, a disk flush event, or a data compression event; Based on the change event, the first computing node determines the change information associated with the change event; and The first computing node sends the change information associated with the change event to the second computing node.

3. The method according to claim 2, characterized in that wherein the change event is associated with a change of a log structure merge (LSM) tree, and the method further comprises: In response to the first computing node detecting a change in the LSM tree indicating the write data event: The second computing node reads the log starting from the last applied log sequence number (LSN) to the LSN corresponding to the change event; and The second computing node plays back the read log to the storage; In response to the first computing node detecting a change in the LSM tree indicating the disk flushing event: The second computing node adds the data indicated in the change information; In response to the first computing node detecting a change in the LSM tree indicating the compaction event: The second computing node deletes the data indicated in the change information.

4. The method according to claim 1, characterized in that: Also includes: The first computing node receives the configuration of the newly added replica from the second computing node; Based on the configuration of the newly added replica, the first computing node registers the newly added replica; as well as The first computing node subscribes to change information of the newly added replica.

5. The method according to claim 4, characterized in that Also includes: The first computing node sends a snapshot of the newly added replica at the time of registration to the second computing node; as well as The second computing node adds corresponding metadata based on the snapshot.

6. The method according to claim 1, characterized in that Also includes: The first computing node receives a request from the second computing node to delete a specific replica; Based on the request, the first computing node deletes subscription information for the specific replica; as well as The first computing node decrements a reference count of the file referenced by the specific backup copy by one.

7. The method according to claim 6, characterized in that Also includes: The second computing node shuts down the specific backup instance; as well as The second computing node deletes metadata of the specific replica.

8. The method according to claim 1, characterized in that Also includes: The first computing node maintains the oldest LSN of the primary copy, where the oldest means that all data before the oldest LSN are written into the storage layer; as well as The first computing node deletes the log whose largest LSN is smaller than the oldest LSN.

9. The method according to claim 8, characterized in that Also includes: The first computing node receives the oldest LSN maintained by the backup replica; The first computing node decrements a reference count of a file that is less than the oldest LSN maintained by the standby replica by one; and In response to the reference count being zero, the first computing node deletes the file.

10. The method according to claim 1, characterized in that The granularity of the replicas in the database system is at the node level, and the node level means that multiple computing nodes are used to form multiple replicas, wherein the primary computing node among the multiple computing nodes can read and write data, and the backup computing nodes among the multiple computing nodes can read data; or the granularity of the replicas in the database system is at the shard level, and the shard level means that one shard constitutes one replication group, one computing node includes a primary shard and a backup shard, and both the primary computing node and the backup computing node can read and write data.

11. The method according to claim 10, characterized in that Also includes: In response to a failure of the primary computing node, the backup computing node takes over the primary computing node; as well as The standby computing node determines the standby copy as the primary copy by incrementally replaying the log.

12. A device for a database system, characterized in that: The database system is based on a storage-computing separation architecture, including a computing layer and a storage layer, wherein a plurality of computing nodes in the computing layer provide data computing and access services, and the storage layer stores data of the plurality of computing nodes, and the device includes: A writing module is configured to receive a write request at a first computing node where a primary copy in the database system is located, and write new data carried in the write request into the storage layer; A sending module, configured so that the first computing node sends change information to a second computing node where the backup copy in the database system is located, wherein the change information provides an indication of incremental data of the primary copy; an acquisition module, configured so that the second computing node acquires the incremental data of the primary copy from the storage layer based on the change information; and An update module is configured so that the second computing node uses the acquired incremental data to update the data of the backup copy, wherein the updated data of the backup copy is consistent with the data of the primary copy.

13. A computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory, the processor of the at least one computing device being configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1-11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed by a computing device, cause the computing device to perform the method according to any one of claims 1-11.

15. A computer program product, characterized in that The computer program product comprises instructions which, when executed by a computing device, cause the computing device to perform a method according to any one of claims 1-11.