Data recovery method and data processing device

By selectively loading and replaying pre-written log files, asynchronously replaying WAL, and merging database files, the problem of uncontrollable cloud database service startup time caused by the increase in data sharding in the time series database is solved, and fast startup and business continuity are achieved. sex.

CN118535378APending Publication Date: 2024-08-23HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202310114333.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-14
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In time series databases, as data sharding increases, the startup time of cloud database services becomes uncontrollable, resulting in longer service startup times and affecting business continuity.

Method used

Quickly restore target data fragments by selectively loading and replaying write-ahead log (WAL) files on the server side, avoiding loading and replaying other data fragments, using memory to replay WAL asynchronously to reduce startup time, and setting load flags To avoid repeated loading, database files are merged to optimize data access.

Benefits of technology

It achieves rapid startup of cloud database services, reduces service startup time, reduces the impact on business, and avoids the problem of uncontrollable service startup time caused by excessive data sharding without increasing hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535378A
    Figure CN118535378A
Patent Text Reader

Abstract

The invention discloses a data recovery method and a data processing device, and relates to the technical field of cloud. The method comprises the steps that after a cloud database service is restarted, a data processing device selectively obtains a target WAL from a memory; replaying the target WAL in a memory to recover the target data fragment; receiving a data access request from a client, wherein the data access request indicates a first data fragment to be accessed; if the target data fragment comprises the first data fragment, the data processing device processes and responds to the data access request in the memory; and if the target data fragment does not include the first data fragment, the data processing device firstly recovers the first data fragment in the memory. According to the method, logs are selectively loaded and replayed to recover data, so that quick starting of cloud database services is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud technology, and in particular to a data recovery method and a data processing device. Background Art

[0002] In a time series database, data is usually divided into different shards based on time, so that different data shards can be stored in a hierarchical manner, thereby optimizing the overall performance of the storage system. As time goes by, the number of shards will continue to increase. Since the shards need to be reloaded when the cloud database service is started (including restarts caused by fault recovery or other reasons), the total time required to load the shards will increase as the number of shards increases, resulting in uncontrollable startup time of the cloud database service. Therefore, how to quickly start the cloud database service is still an important issue that needs to be solved urgently. Summary of the invention

[0003] The embodiments of the present application provide a data recovery method and a data processing device for quickly starting a cloud database service.

[0004] In a first aspect, an embodiment of the present application provides a data recovery method, which may include a data processing device that can be deployed on a server side, the data processing device including a memory and a storage device that provide cloud database services for a client, the storage device being used to persistently store business data from the client, and the memory being used to temporarily store the business data before the business data is written to the storage device, the method may include: after the cloud database service is restarted, the data processing device selectively obtains a target write-ahead log WAL from the storage device; the data processing device replays the target WAL in the memory to restore a target data shard; the data processing device receives a data access request from the client, the data access request indicating a first data shard to be accessed; if the target data shard includes the first data shard, the data processing device processes and responds to the data access request in the memory; if the target data shard does not include the first data shard, the data processing device first restores the first data shard in the memory.

[0005] Through the above method, the server can selectively load and replay WAL files when the service is started, without loading and replaying other data shards. In this way, the server can quickly recover during data recovery to provide normal external write services, reduce the time consumption of service startup without increasing hardware costs, and to a certain extent avoid the problem of uncontrollable service startup time due to too many data shards, while also reducing the impact on the business.

[0006] In combination with the first aspect, in a possible design, the data processing device selectively obtains a target WAL from a memory after the cloud database service is restarted, including: after the cloud database service is restarted, the data processing device determines a first data shard that belongs to the same time range as the startup time of the cloud database service; and obtains a WAL corresponding to the second data shard from the memory as the target WAL.

[0007] Through the above design, the server can, based on the characteristic of time series database scenarios where less data is written in the past, usually only load the data shard corresponding to the current time to meet the current data writing needs, so as to quickly provide write services.

[0008] In combination with the first aspect, in a possible design, the cloud database service restart includes providing restart of the cloud database service after recovery from a fault of the memory, where the fault includes power failure of the memory.

[0009] Through the above method, whether it is a service startup caused by a fault or a normal startup, the startup can be accelerated, the waiting time can be reduced, and the impact on the business can be reduced.

[0010] In combination with the first aspect, in a possible design, after the data processing device replays the target WAL in the memory to restore the target data shard, the method further includes: the data processing device sets a loading identifier for the target data shard, wherein the loading identifier indicates that the target data shard is a data shard restored by replaying the target WAL; and the data processing device determines whether the target data shard includes the first data shard based on whether there is a loading identifier associated with the first data shard in the memory.

[0011] Through the above method, the server can confirm whether the shard has been loaded by setting the loading flag to avoid repeated loading and reduce unnecessary consumption.

[0012] In combination with the first aspect, in a possible design, the memory providing the cloud database service for the client includes a first memory and a second memory, and the data processing device replays the target WAL in the memory to restore the target data shard, including: asynchronously replaying the target WAL in the first memory to restore the target data shard, wherein the first memory is a temporary memory independent of the second memory, and the second memory is used to perform write operations associated with the cloud database service.

[0013] Through the above method, the server can recover data by asynchronously replaying WAL to avoid the WAL file process causing the service startup time to be uncontrollable.

[0014] In combination with the first aspect, in a possible design, the method also includes: the data processing device refreshes the restored target data slice to a first database file, and the first database file is marked with the startup time of the cloud database service; in response to a read request from a terminal device, obtains target data from the first database file or the second database file according to time information associated with the first data file or the second database file, wherein the second database file is associated with a third data slice written through the second memory, and the third data slice and the target data slice belong to the same time range.

[0015] In combination with the first aspect, in a possible design, the method further includes: the data processing device merges the first database file and the second database file.

[0016] In a second aspect, an embodiment of the present application provides a data processing device, comprising: an acquisition unit, used to selectively acquire a target write-ahead log WAL from a memory after a cloud data service is restarted; a data recovery unit, used to replay the target WAL in a memory to restore a target data shard; a communication interface, used to receive a data access request from the client, the data access request indicating a first data shard to be accessed; a processing unit, used to process and respond to the data access request in the memory if the target data shard includes the first data shard; if the target data shard does not include the first data shard, first restore the first data shard in the memory.

[0017] In combination with the second aspect, in a possible design, the data processing device selectively obtains the target WAL from the memory after the cloud database service is restarted, including: after the cloud database service is restarted, determining a second data shard that belongs to the same time range as the startup time of the cloud database service; obtaining the WAL corresponding to the second data shard from the memory as the target WAL.

[0018] In combination with the second aspect, in a possible design, the cloud database service restart includes providing the cloud database service with a restart after a fault of the memory is recovered, and the fault includes power failure of the memory.

[0019] In combination with the second aspect, in a possible design, after the data processing device replays the target WAL in the memory to restore the target data shard, it is also used to: set a loading identifier for the target data shard, wherein the loading identifier indicates that the target data shard is a data shard restored by replaying the target WAL; and determine whether the target data shard includes the first data shard based on whether there is a loading identifier associated with the first data shard in the memory.

[0020] In combination with the second aspect, in a possible design, the memory providing the cloud database service for the client includes a first memory and a second memory, and the data processing device replays the target WAL in the memory to restore the target data shard, including: asynchronously replaying the target WAL in the first memory to restore the target data shard, wherein the first memory is a temporary memory independent of the second memory, and the second memory is used to perform write operations associated with the cloud database service.

[0021] In combination with the second aspect, in a possible design, the data processing device is also used to: refresh the restored target data slice to a first database file, wherein the first database file is marked with the startup time of the cloud database service; in response to a read request from a terminal device, obtain target data from the first database file or the second database file according to time information associated with the first database file or the second database file, wherein the second database file is associated with a third data slice written through the second memory, and the third data slice and the target data slice belong to the same time range.

[0022] In combination with the second aspect, in a possible design, the data processing device is also used to: merge the first database file and the second database file.

[0023] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute the method described in the first aspect and any possible design of the first aspect.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method described in the first aspect and any possible design of the first aspect.

[0025] In a fifth aspect, an embodiment of the present application provides 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 is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method described in the first aspect above and any possible design of the first aspect.

[0026] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable medium stores a program code. When the program code runs on a computer, the computer executes the method described in the first aspect and any possible design of the first aspect.

[0027] In a seventh aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any possible design of the first aspect.

[0028] Based on the implementations provided in the above aspects, the embodiments of the present application can be further combined to provide more implementations.

[0029] The technical effects that can be achieved by any possible implementation method in any of the second to seventh aspects mentioned above can be correspondingly referred to the description of the technical effects that can be achieved by any possible implementation method in any of the first to second aspects mentioned above, and the repetitions will not be discussed here. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 A schematic diagram showing the principle of a data recovery method is shown;

[0031] Figure 2 A schematic diagram showing an application scenario to which the embodiments of the present application are applicable;

[0032] Figure 3 A schematic diagram showing the structure of the server in an embodiment of the present application is shown;

[0033] Figure 4 A schematic diagram showing a flow chart of a data recovery method according to an embodiment of the present application is shown;

[0034] Figure 5 A schematic diagram of data slicing in an embodiment of the present application is shown;

[0035] Figure 6 A schematic diagram of asynchronous replay of WAL in an embodiment of the present application is shown;

[0036] Figure 7 A schematic diagram of a computing device cluster according to an embodiment of the present application is shown;

[0037] Figure 8 A schematic diagram of another computing device cluster according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0038] In order to better explain the embodiments of the present application, some of the terms or technologies mentioned in the embodiments of the present application are introduced below.

[0039] 1. Time series data:

[0040] Time series data refers to time series data, which is a data column recorded in chronological order. Each data in the same data column must be of the same caliber and must be comparable. Time series data can be a period number or a time point number. The purpose of time series analysis is to find out the statistical characteristics and development regularity of the time series within the sample, build a time series model, and perform out-of-sample predictions. It is commonly found in IT infrastructure, operation and maintenance monitoring systems, and the Internet of Things.

[0041] In the embodiment of the present application, the database used to store time series data can be called a time series database (time series DB). The time series database can adopt a single-machine storage method or a distributed storage method, which is not limited in the embodiment of the present application.

[0042] 2. Sharding:

[0043] Sharding is a processing technology for time series data. After dividing the data into different shards according to time (for example, by hour, date, day, month, etc.), different data shards can be stored in a hierarchical manner to achieve uniform distribution, load balancing, capacity expansion, etc., thereby improving the overall performance of the storage system.

[0044] 3. Write-ahead logging (WAL):

[0045] A common method in database systems to ensure the atomicity and persistence of data operations.

[0046] The principles of the WAL mechanism include: modifications are not written directly to the database file (such as the TSM file), but to another file called WAL. If the data in the memory is refreshed to the disk, the records in the WAL will be cleared; if the data in the memory is not refreshed to the disk, it will be loaded and replayed and restored later so that it can be written back to the database file for persistent storage.

[0047] 4. Log-structured-merge-tree (LSM-tree):

[0048] It is a hierarchical, ordered, hard disk-based data structure.

[0049] The implementation principle of the LSM-tree is: first write the data into the memory (cache), and do not need to write the data to the disk every time there is a data update. After accumulating to a certain threshold (such as time threshold, data volume threshold, etc.), use merge sort to merge the data in the memory and append it to the end of the disk queue (because all the trees to be sorted are ordered, they can be quickly merged together through merge sort).

[0050] If both LSM-tree and WAL mechanisms are used in a time series database, such as Figure 1 As shown in the figure, the time series database routes the business data of the application (APP) to different shards according to the timestamp range of the business data, and performs data access operations, including read operations and / or write operations, in the memory (cache), WAL files, and TSM files associated with the corresponding shard.

[0051] For example, for a write operation, the time series database will determine the range of the timestamp of the data to be written, determine the shard to which it belongs, and write the data to the memory and WAL file of the shard at the same time, and return a successful write after the WAL file is written. When the data in the memory accumulates to a certain threshold, the data in the memory is flushed to the TSM file for persistent storage.

[0052] Since there is a time difference between writing data into memory and writing data into TSM files, if the time series database is abnormal (such as power failure, failure, etc.), the data in the memory has not been refreshed to the corresponding TSM file, and the data in the memory will be lost. When starting the database service after abnormal recovery, you need to load the WAL files of each shard and restore the lost data by replaying the WAL files of each shard.

[0053] As time goes by, the number of shards increases. When the service starts and reloads the shards, the service startup time will become longer and longer as the number of shards increases. In addition, in scenarios with high data writing pressure, the WAL files corresponding to each shard may also be very large, and the WAL replay process may last for several minutes or even longer. Therefore, whether the number of shards is large or the WAL file is large, the service startup time will be uncontrollable.

[0054] In response to the above problems, the embodiments of the present application provide a data recovery method and a data processing device for quickly starting a cloud database service. Among them, the method and the device are based on the same technical concept. Since the principles of solving the problem by the method and the device are similar, the implementation of the device and the method can refer to each other, and the repeated parts will not be repeated. In addition, in each embodiment of the present application, if there is no special explanation and logical conflict, the terms and / or descriptions between the various embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form a new embodiment according to their internal logical relationship.

[0055] It should be noted that in the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0056] Furthermore, unless otherwise specified, the ordinal numbers such as "first" and "second" mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the priority or importance of multiple objects. For example, the first data slice and the second data slice are only used to distinguish different data slices, rather than indicating the difference in priority or importance of the two data slices.

[0057] For ease of understanding, a detailed description is given below in conjunction with the accompanying drawings and embodiments.

[0058] Figure 2 1 shows a schematic diagram of an application scenario of an embodiment of the present application. The application scenario shows a client 100 and a cloud service system 200, wherein the cloud service system 200 may include one or more server terminals 201 ( Figure 2 One is shown, but this application is not limited to this).

[0059] The client 100 is deployed on the user side and can be a virtual machine or a physical machine. The physical machine can be a desktop computer, a desktop computer, a laptop computer, a server, etc. The client 100 can also be software deployed on the user side device (such as a database client), which is not limited in this application. The client 100 can communicate with the server 201 through the network 150, wherein the network 150 generally represents any telecommunications or computer network, including, for example, an intranet, a wide area network (WAN), a local area network (LAN), a personal area network (PAN), or the Internet. Alternatively, the client 100 can also communicate through a fiber optic switch ( Figure 2 However, the fiber optic switch is only an optional device, and the fiber optic switch can also be replaced by an Ethernet switch, an InfiniBand switch, a RoCE (RDMA over Converged Ethernet) switch, etc.

[0060] The server 201 can be an independent physical server, a desktop computer, a laptop computer, etc., or a server cluster composed of multiple physical servers or a computing node or storage node (also referred to as a data processing device) in a distributed system, which can provide services for the client 100, such as cloud database services. Specifically, the server 201 can run a database, such as PostgreSQL, MySQL, Oracle Database, GaussDB (for Influx), etc., for data storage and data management, and can more conveniently add, delete, view, modify, and other operations on data. By way of example, the cloud database service may include a time series database service, such as a GaussDB (for Influx) service.

[0061] The user may send a data access request to the server 201 through the client 100 to access the data in the server 201. The process in the server 201 may perform a series of read operations and / or write operations in response to the received data access request to implement data storage and data management.

[0062] In an optional implementation, the server 201 may adopt an LSM-tree structure, that is, the database process first writes the data into the memory, and does not need to write the data to the disk every time the data is updated. After accumulating to a certain threshold (such as a time threshold, a data volume threshold, etc.), a merge sort is used to merge the data in the memory and append it to the end of the disk queue.

[0063] In another optional implementation, the server 201 may also adopt a WAL mechanism, that is, before the database process modifies the data item of the database stored in the hard disk, it first records the modification operation of the data item in the WAL log, and stores the WAL log in a non-volatile memory (such as a hard disk). In this way, even if the database process loses power or restarts due to a fault, the progress of data processing before the restart can still be restored through these WAL logs, thereby ensuring data consistency.

[0064] In the embodiment of the present application, the server 201 can simultaneously adopt the LSM-tree structure and the WAL mechanism, that is, before the database process modifies the data items of the database stored in the hard disk, it will first write the data into the memory, and record the modification operation of the data item into the WAL log, store the WAL log persistently, and return the write success after the WAL log is written. After the data in the memory accumulates to a certain threshold, the data in the memory is merged and appended to the end of the disk queue using a merge sort method. When the database process loses power or fails to restart, the progress of data processing before the restart can still be restored through these WAL logs.

[0065] Figure 3 A hardware structure diagram of a server 201 provided in an embodiment of the present application is shown. Figure 3 As shown, at the hardware level, the server 201 includes at least a processor 212, a memory 213, a network card 214, and a hard disk 215. Among them, the processor 212, the memory 213, the hard disk 215, and the network card 214 are connected through a bus 216. The bus 216 includes, but is not limited to: peripheral component interconnect express (PCIe), extended industry standard architecture (EISA) bus, unified bus (Ubus or UB), computer express link (Compute Express Link, CXL), cache coherent interconnect for accelerators (CCIX), generation Z (GENZ), open coherent accelerator processor interface (OpenCAPI), NVIDIA link (NVlink), and interconnect bus supporting multiple protocols, which is not limited in this application.

[0066] The processor 212 may be a central processing unit (CPU) for processing requests from the client 100. It should be noted that Figure 3 Only one CPU 212 is shown. In actual applications, there are often multiple CPUs 212, wherein one CPU 212 has one or more CPU cores. This embodiment does not limit the number of CPUs and the number of CPU cores. In addition, the processor 212 may also be a graphics processing unit (GPU), a data processing unit (DPU), an application specific integrated circuit (ASIC), a system on chip (SOC), a field programmable gate array (FPGA), an embedded neural network processor (NPU) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, artificial intelligence chips, chips on chips, etc.

[0067] Memory 213 refers to an internal memory that directly exchanges data with processor 212. It can read and write data at any time, and the speed is very fast. It serves as a temporary data storage for the operating system or other running programs. Memory 213 includes multiple types of memory, such as random access memory (RAM) and read-only memory (ROM). Random access memory includes but is not limited to: dynamic random access memory (DRAM), double data rate synchronous dynamic random access memory (DDR), static random access memory (SRAM), etc. Read-only memory includes but is not limited to: programmable read only memory (PROM), erasable programmable read only memory (EPROM), etc. In actual applications, multiple memories 213 and different types of memories 213 can be configured in the server 201, and different memories 213 can be used to store data of different slices. This embodiment does not limit the number and type of memory 213.

[0068] The network card 214 is used to communicate with external devices, such as receiving a data access request sent by the client 100, and sending a data processing result (such as a read success or a read failure) to the client 100. It is also used to communicate with components inside the server 201, such as sending a received data access request sent by the client 100 to the processor 212.

[0069] The hard disk 215 may also be referred to as an auxiliary memory. The hard disk 215 may be a non-volatile memory, such as a read-only memory (ROM), a hard disk drive (HDD) or a solid state drive (SSD). The difference between the hard disk 215 and the memory 213 is that the data in the memory 213 is usually volatile upon power failure, while the hard disk 215 may be used to store data persistently, including the data of the database run by the server 201.

[0070] In the present application, the hard disk 215 can be logically divided into an area for storing log files (for example, referred to as the log area) and an area for storing database files (for example, referred to as the data area). For example, the log file can include a WAL file, and the database file can include a TSM file.

[0071] like Figure 3 The server 201 shown adopts the LSM-tree and WAL mechanism described above. Since there is a time difference between writing data into the memory and writing data into the database file (such as TSM file), and the memory data is easily lost when the power is off, if the data in the memory has not been written to the database file and the device / system loses power or the device / system fails, the data in the memory will be cleared. After the cloud database service is restarted, the server 201 needs to scan the WAL directory, load and replay the WAL file, so as to recover the data that has not been written to the database file (that is, the data that has not been persistently stored).

[0072] Among them, in order to solve the problem that the number of shards in the time series database increases over time and to ensure the rapid startup of the cloud database service, the server 201 of the embodiment of the present application is configured to execute the data recovery method shown in the embodiment of the present application when providing the cloud database service, such as Figure 4 As shown, the following steps are included:

[0073] S410: After the cloud database service is restarted, the server 201 selectively obtains the target write-ahead log WAL from the storage.

[0074] In the embodiment of the present application, the restart of the cloud database service may include providing the service device / apparatus with normal power-on startup, or may include providing the service device / apparatus with a restart after fault recovery, and the fault may include but is not limited to memory power failure. It should be understood that in the embodiment of the present application, the memory fault may be caused by a fault of the memory itself, or by a fault of the server 201 where the memory is located, and the embodiment of the present application does not limit this fault mode.

[0075] The memory mentioned in S410 may be a non-volatile memory, for example Figure 3 The hard disk is shown. In other embodiments, the memory may also be in other forms, such as the ROM or SDD described above, etc., which is not limited in the embodiments of the present application.

[0076] Since data from the past is rarely written in time series scenarios, usually only the data shards corresponding to the current time are loaded to meet the current data writing needs. Therefore, when S410 is specifically implemented, the selection method of the target WAL can be associated with the current time.

[0077] For example, after the cloud database service is restarted, the server 201 may determine a second data shard that is in the same time range as the startup time of the cloud database service, and obtain the WAL corresponding to the second data shard from the memory as the labeled WAL. The duration of the time range may be the same as the duration of a single shard, or the duration of the time range may be the same as the total duration of two or more shards, for example, the two or more shards include a second data shard that is in the same time range as the startup time of the cloud database service, and at least one continuous data shard before the second data shard. The embodiment of the present application does not limit the specific range of the time range or the second data shard.

[0078] For example, Figure 5As shown, the time series data is divided into shards by taking the date as an example, and the time series data within the same day is divided into the same shard, for example, the data shard of 20220901 is represented as shard 1, the data shard of 20220902 is represented as shard 2, the data shard of 20220903 is represented as shard 3, the data shard of 20220904 is represented as shard 4, and the data shard of 20220905 is represented as shard 5. The current time (now) represents the startup time of the cloud database service. When the cloud database service is started, if the current time "20220904, 12:30" falls within the time range of 20220904, the server 201 can use the shard 4 corresponding to the current time as the target data shard. When implementing S410, it is necessary to obtain the WAL associated with shard 4 from the memory as the target WAL. Or, in another example, when implementing S410, the server 201 may obtain the WAL associated with shard 4 or shard 3 from the memory as the target WAL.

[0079] It should be understood that this is only an example of the division method of time series data shards and the time range of the target data shards, and it is not any limitation. In other embodiments, time series data shards can also be divided according to hours, weeks, ten days, months, quarters, years, etc., and logs can be selectively replayed according to the granularity of the shards to restore the required data. This will not be repeated here. For other data shards that have not been loaded and replayed, the server 201 can load and replay them as needed later, and the embodiments of the present application do not limit this.

[0080] S420: The server 201 replays the target WAL in memory to restore the target data segment.

[0081] In a specific implementation, the server 201 may read the selected target WAL from the storage into the memory, and the memory may be configured with a tool for realizing data recovery, and the tool may recover the target data shard by replaying the target WAL in the memory.

[0082] In an optional implementation, after the server 201 replays the target WAL to restore the target data shard, it can also set (or record) a loading mark for the target data shard, wherein the loading mark indicates that the target data shard is a data shard restored by replaying the target WAL, that is, the target data shard has been loaded and can be used directly without loading again. For data shards that do not have a loading mark, they still need to be loaded and replayed to restore the corresponding data. The detailed implementation of the recovery process can refer to the processing method for the target data shard in S410 and S420, which will not be repeated here.

[0083] S430: The server 201 receives a data access request from the client, where the data access request indicates a first data slice to be accessed.

[0084] S440: The server 201 may determine how to provide the cloud database service according to whether the data of the first data slice has been loaded into the memory.

[0085] For example, if the target data shard restored in memory by replaying the log includes the first data shard, the server 201 can directly process and respond to the data access request in the memory, for example, using the first data shard (that is, the target data shard after restoration) to provide the client with read operations and / or write operations associated with the cloud database service. If the data access request is a read request, the server 201 can return the data of the restored target data shard to the terminal device. If the data access request is a write request, which is used to request to add, change or delete data in the second data shard, the server 201 performs a write operation on the target data shard restored in the memory, and records the write operation in the corresponding WAL file, which will not be repeated here.

[0086] If the target data shard restored by replaying the log in the memory does not include the first data shard, that is, the first data shard has not been loaded and restored, it is necessary to restore the first data shard in the memory first. The detailed loading and recovery process can be found in S410-S420 and will not be repeated here.

[0087] Through the above method, according to the data characteristics of the time series database, the server 201 only needs to load and replay the data shards within the current time range, without loading and replaying other data shards. In this way, the cloud database service can be quickly started, and the server 201 can provide external write services during data recovery. Without increasing hardware costs, the recovery time, that is, the recovery time object (RTO), is reduced, and the problem of uncontrollable service startup time due to too many data shards is avoided to a certain extent, while also reducing the impact on the business.

[0088] It is worth noting that in the time series database scenario, when writing two pieces of data at the same time point or with the same identifier, the data written later will still be an update of the data written earlier. When the server 201 merges different data at the back end, it determines which data is the latest written based on the time when the data was written. Therefore, Figure 6 In the asynchronous replay WAL scenario shown, if new data is written during the replay process, the time when the restored data is written to the TSM file may be later than the time when the new data is written, resulting in read and write errors in the system update scenario.

[0089] Therefore, in order to reduce data conflicts, in an embodiment of the present application, when S420 is implemented in the above-mentioned data recovery method, it can be specifically designed to asynchronously replay WAL, and the first TSM file is used to represent the first database file storing the recovered data. The server 201 can add a time stamp to the first TSM file to distinguish the first TSM file from the second TSM file (an example of a second database file) obtained by normally performing read operations and / or write operations.

[0090] Exemplarily, the first TSM file may be marked with the startup time of the cloud database service.

[0091] like Figure 6 As shown, before replaying the WAL log, the write service can be accessed, the normal write process is executed, and the write operation is performed in a memory (for example, represented as the second memory). At the same time, an independent temporary memory (for example, represented as the first memory) is designed, and the target WAL is asynchronously replayed in the first memory to restore the target data shard. The first memory is a temporary memory independent of the second memory, and the second memory is used to perform write operations associated with the cloud database service. After the restored target data shard can be refreshed to an independent database file (for example, the first database file), the replay is considered to be completed. At this time, the client is allowed to perform read operations associated with the cloud database service through the second memory.

[0092] Afterwards, when accessing the client's read service, in response to a read request from the client, the server 201 can obtain data with an earlier time from the first database M file or the second database file as target data based on the time information associated with the first database file or the second database file, wherein the second database file is associated with a third data shard written through the second memory (for example, new data written after the service is started), and the third data shard and the target data shard belong to the same time range.

[0093] In this way, the service startup time associated with the replayed and restored data can be guaranteed before the execution time of the new write operation, avoiding the replayed and restored data being later than the new write time and avoiding data update conflicts.

[0094] Furthermore, the server 201 may also merge the first database file with the second database file. For example, the data in the first TSM file may be merged and appended to the corresponding position of the second TSM file using a merge sort method. The server 201 may release temporary memory.

[0095] Therefore, through the above method, when the cloud database service is started, there is no need to wait for the WAL log to be loaded before providing services to the outside world, thus avoiding service unavailability caused by too long WAL log replay time, and avoiding update conflicts between replayed data and newly written data.

[0096] It is worth noting that in the embodiment of the present application, the first database file and the second database file may be merged before the server accesses the client's read service, or before the server accesses the client's read service, and the embodiment of the present application does not limit this. Among them, if the first database file and the second database file are merged before the server accesses the client's read service, for example, the first database file is merged into the first database file, because the data in different database files have been sorted according to the time sequence during the merge process, then in response to the read request from the client, the server can directly obtain the target data to be read from the database file obtained after the merge process, which will not be repeated here.

[0097] In combination with the above method embodiment, the embodiment of the present application also provides a computer device, which can be used to execute the method executed by the server 201 and its various sub-modules in the above method embodiment.

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

[0099] like Figure 7 As shown, the computing device cluster includes at least one computing device 700. The memory 706 in one or more computing devices 700 in the computing device cluster may store the same instructions for executing the data recovery method of the embodiment of the present application.

[0100] In some possible implementations, the memory 706 of one or more computing devices 700 in the computing device cluster may also store partial instructions for executing the data recovery method of the embodiment of the present application. In other words, the combination of one or more computing devices 700 can jointly execute the instructions for executing the data recovery method of the embodiment of the present application.

[0101] It should be noted that the memory 706 in different computing devices 700 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the cloud service system or the server. That is, the instructions stored in the memory 706 in different computing devices 700 can implement the functions of one or more modules that execute the data recovery step.

[0102] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Figure 8A possible implementation is shown. Figure 8 As shown, two computing devices 700A and 700B 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 706 in the computing device 700A stores instructions for executing the functions of the cloud management platform. At the same time, the memory 706 in the computing device 700B stores instructions for executing the functions of the data processing device and the computing device.

[0103] Figure 8 The connection method between the computing device clusters shown may be based on the consideration that the data recovery method provided in the present application requires the user to customize the functional configuration (such as storing a large amount of data) and implement the computing functions, so it is considered that the functions implemented by the data processing device and the computing device are handed over to the computing device 700B for execution.

[0104] It should be understood that Figure 8 The functions of the computing device 700A shown in FIG. 7 may also be completed by multiple computing devices 700. Similarly, the functions of the computing device 700B may also be completed by multiple computing devices 700.

[0105] The present application embodiment also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Figure 7 and Figure 8 The connection mode of the computing device cluster is different in that the memory 706 in one or more computing devices 700 in the computing device cluster may store the same instructions for executing the data processing method.

[0106] In some possible implementations, the memory 706 of one or more computing devices 700 in the computing device cluster may also store partial instructions for executing the data processing method. In other words, the combination of one or more computing devices 700 may jointly execute instructions for executing the data processing method.

[0107] The present application also provides a computer storage medium in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the above-mentioned related method steps to implement the method executed by the server 201 / computing device 700 in the above-mentioned embodiment. Figure 4 The description of each step is not repeated here.

[0108] The present application also provides a computer program product. When the computer program product is run on a computer, the computer executes the above-mentioned related steps to implement the method executed by the server 201 / computing device 700 in the above-mentioned embodiment. Figure 4The description of each step is not repeated here.

[0109] In addition, an embodiment of the present application further provides a device, which may be a chip, a component or a module, and the device may include a connected processor and a power supply circuit; wherein the power supply circuit is used to provide power for the processor to run, and when the device is running, the processor may execute computer execution instructions to enable the chip to execute the method executed by the server 201 / computing device 700 in the above-mentioned method embodiments, see Figure 4 The description of each step is not repeated here.

[0110] Among them, the computer storage medium, computer program product or chip provided in the embodiments of the present application are used to execute the methods corresponding to the server 201 / computing device 700 provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0111] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0112] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0113] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0114] In addition, each functional unit (or module) in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0115] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0116] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, which is not specifically limited in the embodiments of the present application.

[0117] Those of ordinary skill in the art will appreciate that the various digital numbers such as the first and second involved in this application are only for the convenience of description, and are not used to limit the scope of the embodiments of this application, and also represent the order of precedence. "And / or" describes the association relationship of the associated objects, indicating that there may be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one" refers to one or more. At least two refers to two or more. "At least one", "any one" or similar expressions refer to any combination of these items, including any combination of single items (individuals) or plural items (individuals). For example, at least one item (individuals, kinds) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. "Multiple" refers to two or more, and other quantifiers are similar. In addition, when the singular forms “a,” “an,” and “the” appear, they do not mean “one or only one,” but rather “one or more than one,” unless the context clearly dictates otherwise. For example, “a device” means one or more of such devices.

[0118] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. that includes one or more available media integrated. 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 drive (SSD)), etc.

[0119] The various illustrative logic units and circuits described in the embodiments of the present application can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or the design of any combination of the above functions. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any traditional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration to implement.

[0120] The steps of the method or algorithm described in the embodiments of the present application can be directly embedded in the software unit executed by the hardware, the processor, or a combination of the two. The software unit can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Alternatively, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC.

[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0122] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, a person skilled in the art may make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data recovery method, characterized in that: Applied to a data processing device, the data processing device includes a memory and a storage device that provide a cloud database service for a client, the storage device is used to persistently store business data from the client, and the memory is used to temporarily store the business data before the business data is written to the storage device, the method includes: The data processing device selectively obtains the target write-ahead log WAL from the memory after the cloud database service is restarted; The data processing device replays the target WAL in the memory to restore the target data fragment; The data processing device receives a data access request from the client, wherein the data access request indicates a first data slice to be accessed; If the target data slice includes the first data slice, the data processing device processes and responds to the data access request in the memory; If the target data slice does not include the first data slice, the data processing device first restores the first data slice in the memory.

2. The method according to claim 1, characterized in that After the cloud database service is restarted, the data processing device selectively obtains the target WAL from the memory, including: The data processing device determines, after the cloud database service is restarted, a second data shard that belongs to the same time range as the startup time of the cloud database service; The data processing device obtains the WAL corresponding to the second data shard from the memory as the target WAL.

3. The method according to claim 2, characterized in that The restarting of the cloud database service includes restarting the cloud database service after recovery from a fault of the memory, wherein the fault includes power failure of the memory.

4. The method according to any one of claims 1 to 3, characterized in that After the data processing device replays the target WAL in the memory to restore the target data fragment, the method further includes: The data processing device sets a loading flag for the target data shard, wherein the loading flag indicates that the target data shard is a data shard restored by replaying the target WAL; The data processing device determines whether the target data slice includes the first data slice according to whether a loading identifier associated with the first data slice exists in the memory.

5. The method according to any one of claims 1 to 4, characterized in that The memory providing the cloud database service for the client includes a first memory and a second memory, and the data processing device replays the target WAL in the memory to restore the target data shard, including: The data processing device asynchronously replays the target WAL in the first memory to restore the target data shard, wherein the first memory is a temporary memory independent of a second memory, and the second memory is used to perform write operations associated with the cloud database service.

6. The method according to claim 5, characterized in that The method further comprises: The data processing device refreshes the restored target data slice to a first database file associated with the first memory, where the first database file is marked with the start time of the cloud database service; If the data access request is a read request, the data processing device obtains target data from the first database file or the second database file according to time information associated with the first database file or the second database file, wherein the second database file is associated with a third data slice written through the second memory, and the third data slice and the target data slice belong to the same time range.

7. The method according to claim 5 or 6, characterized in that: The method further comprises: The first TSM file is merged with the second TSM file.

8. A data processing device, characterized in that: include: An acquisition unit, configured to selectively acquire a target write-ahead log WAL from a storage device after the cloud data service is restarted; A data recovery unit, used to replay the target WAL in memory to recover the target data shard; A communication interface, configured to receive a data access request from the client, wherein the data access request indicates a first data slice to be accessed; A processing unit is used to process and respond to the data access request in the memory if the target data slice includes the first data slice; if the target data slice does not include the first data slice, first restore the first data slice in the memory.

9. The device according to claim 8, characterized in that After the cloud database service is restarted, the data processing device selectively obtains the target WAL from the memory, including: After the cloud database service is restarted, determining a second data shard that belongs to the same time range as the startup time of the cloud database service; The WAL corresponding to the second data shard is obtained from the memory as the target WAL.

10. The device according to claim 9, characterized in that The cloud database service startup includes starting the cloud database service after a memory failure is recovered, and the failure includes power failure of the memory.

11. The device according to any one of claims 8 to 10, characterized in that After replaying the target WAL in the memory to restore the target data fragment, the data processing device is further used to: Setting a loading flag for the target data shard, wherein the loading flag indicates that the target data shard is a data shard restored by replaying the target WAL; It is determined whether the target data slices include the first data slice according to whether the loading identifier associated with the first data slice exists in the memory.

12. The device according to any one of claims 8 to 11, characterized in that The memory providing the cloud database service for the client includes a first memory and a second memory, and the data processing device replays the target WAL in the memory to restore the target data shard, including: The target WAL is asynchronously replayed in the first memory to restore the target data shard, wherein the first memory is a temporary memory independent of a second memory, and the second memory is used to perform write operations associated with the cloud database service.

13. The device according to claim 12, characterized in that The data processing device is also used for: Refresh the restored target data slice to a first database file associated with the first memory, where the first database file is marked with the start time of the cloud database service; If the data access request is a read request, target data is obtained from the first database file or the second database file according to time information associated with the first database file or the second database file, wherein the second database file is associated with a third data slice written through the second memory, and the third data slice and the target data slice belong to the same time range.

14. The device according to claim 12 or 13, characterized in that The data processing device is also used for: The first TSM file is merged with the second TSM file.

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

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

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

Citation Information

Cited By

  • Disk abnormality processing method, device, equipment and storage medium

    CN119782031A

  • Hot data management method, system, equipment, medium and product

    CN121658490A

  • Data recovery method, apparatus and computing device

    WO2026194625A1