Data recovery method and device

By using memory relay in the database management system, the problem of low data recovery speed and efficiency in the existing technology is solved, and a faster and more efficient data recovery process is achieved.

CN119645722APending Publication Date: 2025-03-18HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410353601.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-09-18
Filing Date
2024-03-26
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In the case of database failure or data corruption, the speed and efficiency of data recovery process are low, which affects the speed and success rate of data recovery.

Method used

By using memory relay in the database management system, data recovery information entered by users is obtained, the time node for data backup is determined, the data is stored in memory, and data slices are stored and restored in parallel by multi-threading, the speed and efficiency of data recovery are improved.

Benefits of technology

The data recovery process is achieved faster and more efficiently, reducing the impact on the original instance business, and improving the success rate of data recovery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645722A_ABST
    Figure CN119645722A_ABST
Patent Text Reader

Abstract

The invention provides a data recovery method and device.The method is applied to a management system of a database, the database comprises a first instance of to-be-recovered data, and the method comprises the steps that data recovery information, input by a user, of the first instance is obtained, the data recovery information comprises a first time node determined by a user from a plurality of time nodes subjected to data backup of the first instance; according to the data recovery information, first data of the first instance subjected to data backup at the first time node is stored in a memory, and the first data comprises data to be recovered in the first instance; and recovering the first data stored in the memory to the first instance. According to the technical scheme, the speed and efficiency of the data recovery process of the database are improved.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on September 18, 2023, with application number 202311201439.6, and priority to the Chinese patent application with the invention name “A data replication method, device and computing device cluster”, all contents of which are incorporated by reference in this application. Technical Field

[0002] The present application relates to the field of information technology, and more specifically, to a method and device for data recovery. Background Art

[0003] Data recovery refers to the technology that, when a computer storage medium such as a database fails or data is damaged, part or all of the data cannot be accessed and read, and certain methods and means are needed to retrieve the data so that the data information can be regenerated. At present, when a database fails or data is damaged, the data in the database can be restored through backup files to ensure data reliability. For example, by creating a temporary instance, using backup files to copy the data to be restored to the temporary instance, and then copying or restoring the data in the temporary instance to the original instance, the impact on the business on the original instance can be reduced during the data recovery process.

[0004] The speed and efficiency of data replication affect the speed and success rate of data recovery. Therefore, how to replicate data efficiently, quickly and accurately has become an urgent problem to be solved. Summary of the invention

[0005] The present application provides a data recovery method and device, which improve the speed and efficiency of the data recovery process of a database.

[0006] In a first aspect, a data recovery method is provided. The method is applied to a management system of a database, wherein the database includes a first instance of data to be recovered, and comprises: obtaining data recovery information of the first instance input by a user, the data recovery information including a first time node determined by the user from multiple time nodes of data backup of the first instance; storing first data of the first instance at the first time node after data backup in a memory according to the data recovery information, the first data including the data to be recovered in the first instance; and restoring the first data stored in the memory to the first instance.

[0007] In the embodiment of the present application, the data used to restore the database or table is not stored in the disk, but in the memory. The speed of the memory is much higher than the disk, and data can be read and written quickly, making the program run more smoothly. Therefore, the data recovery process based on the memory transfer method is faster and more efficient.

[0008] In combination with the first aspect, in certain implementations of the first aspect, storing the first data of the first instance at the first time node after data backup into the memory includes: storing the first data in a temporary instance; and storing the first data in the temporary instance into the memory.

[0009] Based on the above solution, the data backup tool can create a temporary instance and copy the sub-database to be restored or the backed-up data or backup files to the temporary instance. A temporary instance is a temporary environment created for data recovery needs, which is isolated from the original instance, thereby reducing the impact on the business on the original instance.

[0010] In combination with the first aspect, in certain implementations of the first aspect, the data recovery information also includes one or more tables of data to be recovered selected by the user from the first instance, and the first data is the data of the one or more tables of data to be recovered after data backup at the first time node.

[0011] In combination with the first aspect, in certain implementations of the first aspect, restoring the first data stored in the memory to the first instance includes: renaming the name of the one or more tables of data to be restored; generating one or more new tables corresponding to the one or more tables of data to be restored in the first instance, wherein the name of each new table in the one or more new tables is the same as the original name of the corresponding table of data to be restored; and restoring the first data to the one or more new tables in the first instance.

[0012] Based on the above solution, it is possible to avoid duplication of names between newly created tables and tables in the original instance during data recovery.

[0013] In combination with the first aspect, in certain implementations of the first aspect, storing the first data of the first instance at the first time node after data backup into the memory includes: storing multiple data slices of the first data into the memory through multiple first threads, each data slice of the multiple data slices includes at least one row of data in the first data, and each first thread of the multiple first threads is used to transmit at least one of the multiple data slices; restoring the first data stored in the memory to the first instance includes: restoring the multiple data slices stored in the memory to the first instance through multiple second threads, and each second thread of the multiple second threads is used to transmit at least one of the multiple data slices.

[0014] Based on the above solution, the data to be recovered is segmented at the row level in fine granularity, so that parallel storage and parallel recovery of multiple row-level data can be achieved.

[0015] In combination with the first aspect, in some implementations of the first aspect, at least one first thread among the multiple first threads and at least one second thread among the multiple second threads run in parallel.

[0016] Based on the above solution, the process of storing data in the memory and the process of restoring data from the memory to the original instance are parallelized, thereby improving the efficiency of data recovery.

[0017] In combination with the first aspect, in certain implementations of the first aspect, the multiple data slices are divided according to a primary key index and / or a unique index of the table.

[0018] In combination with the first aspect, in certain implementations of the first aspect, the multiple data slices include the same number of rows of data.

[0019] Based on the above solution, the size of each data slice is close, which can save data recovery time and improve the efficiency of the data recovery process.

[0020] In a second aspect, a data recovery device is provided, which is applied to a management system of a database, wherein the database includes a first instance of data to be recovered, and includes: an acquisition module, used to: obtain data recovery information of the first instance input by a user, the data recovery information including a first time node determined by the user from multiple time nodes of the first instance after data backup; a storage module, used to: store first data of the first instance after data backup at the first time node into a memory according to the data recovery information, the first data including the data to be recovered in the first instance; a recovery module, used to: restore the first data stored in the memory to the first instance.

[0021] In combination with the second aspect, in certain implementations of the second aspect, the storage module is specifically used to: store the first data in a temporary instance; and store the first data in the temporary instance in the memory.

[0022] In combination with the second aspect, in certain implementations of the second aspect, the data recovery information also includes one or more tables of data to be recovered selected by the user from the first instance, and the first data is the data of the one or more tables of data to be recovered after data backup at the first time node.

[0023] In combination with the second aspect, in certain implementations of the second aspect, the device also includes a processing module, which is used to: rename the name of the one or more tables of data to be recovered; generate one or more new tables corresponding to the one or more tables of data to be recovered in the first instance, wherein the name of each new table in the one or more new tables is the same as the original name of the corresponding table of data to be recovered; the recovery module is specifically used to: restore the first data to the one or more new tables in the first instance.

[0024] In combination with the second aspect, in certain implementations of the second aspect, the storage module is specifically used to: store multiple data slices of the first data in the memory through multiple first threads, each of the multiple data slices includes at least one row of data in the first data, and each of the multiple first threads is used to transmit at least one of the multiple data slices; the recovery module is specifically used to: restore the multiple data slices stored in the memory to the first instance through multiple second threads, and each of the multiple second threads is used to transmit at least one of the multiple data slices.

[0025] In combination with the second aspect, in some implementations of the second aspect, at least one first thread among the multiple first threads and at least one second thread among the multiple second threads run in parallel.

[0026] In combination with the second aspect, in certain implementations of the second aspect, the multiple data slices are divided according to a primary key index and / or a unique index of the table.

[0027] In combination with the second aspect, in certain implementations of the second aspect, the multiple data slices include the same number of rows of data.

[0028] The specific scheme description and beneficial effects of the device shown in the second aspect can be referred to the first aspect and will not be repeated here.

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

[0030] In a fourth aspect, a computing device cluster is provided, comprising at least two computing devices, each computing device comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the computing device cluster executes the method in the first aspect or any possible implementation of the first aspect.

[0031] Optionally, the processor may be a general-purpose processor, which may be implemented by hardware or software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor may be a general-purpose processor, which is implemented by reading software codes stored in a memory, which may be integrated in the processor or may be located outside the processor and exist independently.

[0032] In a fifth aspect, a chip is provided, which obtains instructions and executes the instructions to implement the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0033] Optionally, as an implementation, the chip includes a processor and a data interface, and the processor reads instructions stored in the memory through the data interface to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect.

[0034] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method in the above-mentioned first aspect or any possible implementation method of the first aspect.

[0035] In a sixth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device or a computing device cluster, the computing device or the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0036] In the seventh aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer instructions are executed by a computing device or a computing device cluster, the computing device or the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0037] By way of example, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), Flash memory, electrically EPROM (EEPROM), and hard drive.

[0038] Optionally, as an implementation manner, the above-mentioned storage medium may specifically be a non-volatile storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a schematic diagram of a cloud environment provided in an embodiment of the present application.

[0040] Figure 2 It is a schematic diagram of a current data recovery method provided by an embodiment of the present application.

[0041] Figure 3 It is a schematic flow chart of a data recovery method provided in an embodiment of the present application.

[0042] Figure 4 It is a schematic diagram of an interactive interface of a database instance provided in an embodiment of the present application.

[0043] Figure 5 It is a schematic diagram of a data recovery method provided in an embodiment of the present application.

[0044] Figure 6 It is an interactive schematic diagram of a data recovery method provided in an embodiment of the present application.

[0045] Figure 7 It is a schematic structural block diagram of a data recovery device provided in an embodiment of the present application.

[0046] Figure 8 It is a schematic structural block diagram of a computing device provided in an embodiment of the present application.

[0047] Fig. 9 It is a schematic structural block diagram of a computing device cluster provided in an embodiment of the present application.

[0048] Fig.10 It is a schematic structural block diagram of another computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0050] At present, with the development of the Internet and the advent of the era of big data, the Internet is flooded with a large amount of data, including text data, image data, sound data, etc. A database with a large storage space can be used to store a large amount of data in a regular manner, so that users who use the database can quickly query the data. The database can be an external hardware, such as a local computer or local server that stores data, or a database deployed in a cloud environment, such as a cloud database deployed in a cloud server. For example, with the development of cloud computing technology, cloud databases are gradually being used by enterprises in large quantities. Cloud databases aim to integrate a large number of existing database resources located in the network background through cloud computing, and provide database resource access at the infrastructure level for cloud computing applications, thereby reducing enterprise operating costs and improving the utilization rate of enterprise database resources.

[0051] To understand the cloud environment, Figure 1 A schematic diagram of a cloud server system is shown. Figure 1 As shown, the cloud management platform 110 is used to manage the infrastructure that provides multiple cloud services, the infrastructure includes multiple cloud data centers, each cloud data center includes multiple servers, each server includes cloud service resources, and provides corresponding cloud services for tenants. The cloud database can be deployed on the server in the cloud data center.

[0052] The cloud management platform 110 provides an access interface (such as an interface or an application program interface (API)). The tenant can operate the client remote access access interface to register a cloud account and password on the cloud management platform and log in to the cloud management platform. After the cloud management platform successfully authenticates the cloud account and password, the tenant can further pay to select and purchase a virtual machine with specific specifications (processor, memory, disk) on the cloud management platform. After the payment is successful, the cloud management platform provides the remote login account and password of the purchased virtual machine. The client can remotely log in to the virtual machine and install and run the tenant's application in the virtual machine. The tenant of the cloud service can be an individual, enterprise, school, hospital, administrative agency, etc.

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

[0054] For example, in an embodiment of the present application, the tenant inputs data recovery information of the original instance, such as the recovery time node, etc., into the database management system through the cloud management platform 110, and then the cloud database determines the data to be recovered based on the data recovery information, and copies the data to be recovered to the original instance through memory transfer.

[0055] It should be understood that a database is a medium for storing data, such as a collection of physical operating system files or disk data blocks, including data files, index files, structure files, etc. A database instance is a group of database files and structure objects managed by a database engine, including data, storage space, control files, and other instance-specific files running under a database management system. For example, a database instance may include a sub-library of a database (i.e., a smaller database further divided by the user) or data of a table. A database can be loaded and opened by multiple instances, and an instance may include a group of related files in the database, such as a sub-library or a group of tables in the database.

[0056] Any operation that a user performs on the data in the database, including data definition, data query, data maintenance, database operation control, etc., is performed under the database instance. For example, a database may include instance #1 and instance #2, and instance #1 includes table 1 in the database. Furthermore, a user can query and modify data in table 1 in instance #1 in the database management system, thereby querying and modifying data in table 1 in the database.

[0057] It should be understood that data recovery refers to the technology that when a computer storage medium such as a hard disk fails or data is damaged, part or all of the data cannot be accessed and read, and then certain methods and means are needed to retrieve the data so that the data information can be regenerated. At present, when a database fails or data is damaged, the data in the database can be restored through backup files to ensure data reliability. In other words, before the data recovery process, the data in the database is generally backed up.

[0058] Exemplarily, during the data backup process, the data backup tool backs up the data in the database into one or more files by means of physical backup or logical backup, and stores the one or more files in a disk. Taking logical backup as an example, the file is one or more text files, which store the structure of the table in the database and the data in the table. For example, the data backup tool can first query the structure of the table to be backed up, generate a create statement in the text file, which is used to generate a text description of the structure of the table, and then query the records in the table to be backed up, convert all the records in the table into an insert statement, which is used to insert the data records in the table into the text file. The data backup tool can back up the data once every period of time, for example, back up the data once every hour. When a database fails or there is data corruption, the damaged data can be recovered based on the backed up data or the text file stored in the disk.

[0059] During the data recovery process, the user or tenant of the database can select the sub-library or table to be restored in the instance through an interactive interface or an application programming interface (API). The data backup tool can copy the backed-up data or backup files of the sub-library or table to be restored to the temporary instance by creating a temporary instance. A temporary instance is a temporary environment created for data recovery needs, which is isolated from the original instance, thereby reducing the impact on the business on the original instance. During the data recovery process, the temporary instance stores the backed-up data of the sub-library or table to be restored. For example, if the data of Table A in the original instance #1 is damaged, the data backup tool can only import the backed-up data of Table A into the temporary instance without processing other tables in the original instance #1, so as to subsequently restore only the data of Table A stored in the temporary instance to the original instance.

[0060] Figure 2 A schematic diagram of a current data recovery method is shown. First, Figure 2 In the data recovery process shown, the user needs to input data recovery information, such as the recovery time node, into the database management system. The database management system can determine the data of the table to be restored in the backup file based on the data recovery information. Secondly, the database management system generates a temporary instance in the database and copies the backup data of the table to be restored to the temporary instance. Since the temporary instance and the original instance can both be regarded as a subsystem for managing data, the two cannot directly transfer data of some tables. Therefore, it is necessary to extract the data in the temporary instance and store it, and then copy or restore the extracted and stored data to the original instance. For example, Figure 2 As shown, the data recovery step can be implemented by a data backup tool, or in other words, the data backup tool can implement both data backup and data recovery. Since the main function of the data backup tool is to back up data into a text file and save it to the disk, the data extracted from the temporary instance by the data backup tool will also be saved on the disk, or in other words, the data backup tool saves the data in the temporary instance as one or more files on the disk. Finally, the data backup tool copies the file of the data to be recovered saved on the disk to the original instance, for example, creates a new table in the original instance and inserts the data in the temporary instance into the new table, to implement the data recovery process.

[0061] Optionally, Figure 2 The process of storing data to disk as shown can also be implemented by using the data import command of the data backup tool, and the process of restoring data from disk to the original instance can also be implemented by using the data export command of the data backup tool or the data export tool, such as the source command. Alternatively, the data import command and the data export command of the data backup tool can be implemented Figure 2 The data recovery process is shown.

[0062] However, in Figure 2 In the data recovery process shown, the data backup tool saves the data to be recovered on the disk. The data to be recovered needs to be transferred based on the disk before it can be restored to the original instance. However, the read and write speed of the disk is slow, and a physical read head is required. It can only access one data block at a time, so Figure 2 The speed and efficiency of the data recovery process shown are not high. Moreover, the data to be recovered is temporary data rather than data that needs to be stored for a long time. Figure 2 The data recovery process shown will occupy disk storage space.

[0063] In order to solve the above technical problems, the present application shows a data recovery method 300. In the method 300, it is not necessary to write the data to be recovered to the disk, but the data recovery process is implemented based on the memory transfer method. Figure 3 A schematic diagram of a data recovery method 300 is shown. The data recovery method 300 can be applied to a database management system, for example, Figure 1 The cloud management platform or database management system on the server is shown.

[0064] It should be understood that disk and memory are two different storage devices in the computer, each with different characteristics and usage scenarios. Memory is the temporary storage of the computer, mainly responsible for storing running programs and data. Since memory is volatile, once the computer is powered off, the data in the memory will be lost. Therefore, memory cannot guarantee the long-term accuracy of the data. However, the data to be recovered in the database is not long-term data, but temporary data used for data recovery, which can be deleted when the data recovery process is completed. In addition, the speed of memory is much higher than that of disk. This is because memory is a random access memory that can read and write multiple addresses at the same time, while the disk needs to physically move the read head and can only access one data block at a time. For users, it takes a certain amount of time to wait to access data on the disk, because the read and write speed of the disk is slow, while the memory can read and write data quickly, making the program run more smoothly. Therefore, the data recovery process based on the memory transfer method is faster and more efficient.

[0065] like Figure 3 As shown, method 300 includes steps 310 to 330 .

[0066] Step 310: Acquire data recovery information of the first instance input by the user.

[0067] The first instance is an instance of data to be restored in the database. The data restoration information may include a first time node determined by the user from multiple time nodes of data backup of the first instance. For example, the backup cycle of the first instance is to back up once every hour or once every hour, and the user can select 12 noon as the first time node from the hourly time of each day, that is, the user wants to restore the data of the first instance to the data at 12 noon.

[0068] It should be understood that, according to the above, the data recovery process is applied after the data backup process, in other words, the data recovery process needs to be based on the backed-up data in the database. Step 310 can be used to determine which backed-up data needs to be used in the data recovery process.

[0069] For example, Figure 4 A schematic diagram of an interactive interface of a data recovery tool is shown. Figure 4 As shown, the user can determine the first instance of the data to be restored in the interactive interface provided by the database management system, for example, select the first instance according to the instance name and / or instance ID (an identification string that uniquely identifies the instance in the system). Then, the user can select the recovery time node, for example, the user can select the recovery date, recovery time interval, recovery time point and other information.

[0070] Optionally, the data recovery information may also include a table of data to be recovered in the first instance. In other words, some tables in the first instance need to recover data, while some tables do not need to recover data, so the user can select some tables of data to be recovered, such as Figure 4 Table 1 shown. Furthermore, the database management system determines that only the data in Table 1 needs to be restored.

[0071] Optionally, in the part of selecting the table of data to be restored, the user can also select one or more sub-libraries of the data to be restored, that is, the user selects the sub-library of the data to be restored from the multiple sub-libraries defined by the user, and the sub-library includes one or more tables. For example, sub-library #1 includes tables 1 to 3, and sub-library #2 includes tables 4 to 6. The user can select sub-library #1, and then the management system of the database determines that only the data of tables 1 to 3 need to be restored. Optionally, the user selects the table of data to be restored from the sub-library defined by the user, for example, selects Table 1 from Sub-library #1, and then the management system of the database determines that only Table 1 in Sub-library #1 needs to be restored, and Tables 2 and 3 are not restored.

[0072] Step 320: According to the data recovery information, the first data of the first instance after data backup at the first time node is stored in the memory.

[0073] The first data includes the data to be restored in the first instance. For example, the first data may be all the data included in the first instance, that is, all the data in the first instance needs to be restored. For another example, the first data may be the data of one or more tables of data to be restored selected by the user from the first instance after data backup at the first time node, such as the data of the table selected by the user through Figure 4 The interactive interface shown selects the data in Table 1 after data backup at 15:00 on the time node 2000 / 1 / 1.

[0074] Optionally, in an embodiment of the present application, step 320 can be implemented by the temporary instance mentioned above. Specifically, the management system of the database can determine the above-mentioned first data based on the data recovery information and create a temporary instance. Then, the first data is stored in the temporary instance, and then the first data in the temporary instance is stored in the memory to prevent affecting the business processing of the original instance. For example, the data backup process can be a physical backup, and the process of storing the backup data in the temporary instance can be storing the full amount of the backup data in the temporary instance.

[0075] Optionally, in some other embodiments of the present application, step 320 may also be to directly store the first data in the memory. For example, in a scenario where the original instance has no business processing, the database management system may not generate a temporary instance.

[0076] Optionally, the present application may store the first data in a memory through one or more first threads, and the one or more first threads may be used to store multiple data slices of the first data in the memory, each of the multiple data slices including at least one row of data of the first data. The embodiment of step 320 will be specifically introduced below, and will not be described in detail herein.

[0077] Optionally, when step 320 uses multiple first threads, the multiple first threads can be executed in parallel. For example, when the sub-library of the data to be recovered includes N tables, step 320 can use N first threads to store the N tables in parallel, and each first thread can be used to import a table into the memory. For another example, when the data to be recovered is a table, step 320 can use N first threads to store the table in parallel, and each first thread can be used to store the data of some rows in the table into the memory. For example, the first thread A can be used to store a table in the memory, the first thread B can be used to store two tables in the memory, and the first thread C can be used to store the data of some rows in a table in the memory, and the above-mentioned first thread A, first thread B and first thread C can be executed in parallel.

[0078] Step 330: restore the first data stored in the memory to the first instance.

[0079] Optionally, in an embodiment of the present application, the first data can be copied or restored to the first instance through one or more second threads, and the one or more second threads can be used to copy multiple data slices of the first data stored in the memory to the first instance.

[0080] Optionally, similarly, when step 330 uses multiple second threads, the multiple second threads can be executed in parallel. For example, when the memory includes N tables, step 330 can use N second threads to copy the N tables in parallel, and each second thread can be used to copy or restore a table in the memory to the original instance. For another example, when the memory includes one table, step 330 can use N second threads to copy the one table in parallel, and each second thread is used to copy or restore data of a portion of rows in the table from the memory to the original instance.

[0081] Optionally, at least one of the one or more first threads and at least one of the one or more second threads are run in parallel. In other words, step 320 and step 330 can be run in parallel, which greatly improves the efficiency of data recovery. The thread running process will be described in detail below and will not be described here.

[0082] It should be understood that the above-mentioned process of executing the first thread and the second thread in parallel is only an example, and the present application does not limit the number of tables to be restored and the number of first threads and second threads. Each of the multiple first threads can be used to store data of different sizes, and each of the multiple second threads can be used to copy data of different sizes.

[0083] Exemplarily, taking the case where multiple first threads simultaneously import data from a table, each of the multiple first threads can be used to import a row of data or a data block (chunk) or a data slice consisting of multiple rows of data in the table. For example, the database management system can divide the table into multiple data slices, each data slice can include a row of data or multiple rows of data in the table, and each of the multiple first threads can be used to store at least one data slice in the memory. Similarly, each of the multiple second threads can be used to copy or restore at least one data slice from the memory to the original instance.

[0084] Optionally, when each of the multiple first threads is used to import at least one data slice, the size and number of the data slices stored by each first thread may be the same. Similarly, the size and number of the data slices copied by each second thread may be the same. Thus, the parallel efficiency of the data storage process of the multiple first threads or the data copying process of the multiple second threads is higher.

[0085] Optionally, the database management system can divide the table into data slices according to the primary key value or unique index in the table. For example, the primary key of table D is defined as ID when it is created, and then the data rows within a predefined range (such as ID a to c, d to f) can be divided into the same data slice. For another example, the unique index defined as price when table D is created, and then the data rows within a predefined range (such as price ranges of 1 to 10, 10 to 20, 20 to 30) can be divided into the same data slice.

[0086] Optionally, the data storage process of the above-mentioned multiple first threads and the data recovery process of the multiple second threads can be performed simultaneously, that is, when one or more first threads store the first data into the memory, one or more second threads can copy part of the first data stored in the memory to the first instance. For example, when multiple first threads have stored the data of table A stored in the temporary instance into the memory and are preparing to store the data of table B into the memory, the one or more second threads can copy the data of table A from the memory to the original instance, i.e., the first instance, upon detecting that the memory contains the data of the table, thereby realizing the parallel execution of the data import process and the data export process. And Figure 2 In the data recovery process shown, the process of storing data to disk and the process of restoring data to the instance by the data backup tool are separate and cannot be performed at the same time. In other words, the data in the disk can be copied to the original instance only after the data backup tool stores the data to disk. In this way, in the embodiment of the present application, on the basis of realizing parallel data storage to memory and parallel data copying to the original instance, the process of storing data to memory and the process of copying data to the original instance can also be performed in parallel, thereby improving the speed and efficiency of the data recovery process.

[0087] Figure 5 A schematic flow chart of a data recovery method provided in an embodiment of the present application is shown, which includes the above-mentioned step 320 and step 330.

[0088] First, if Figure 5 As shown, in order to achieve row-level parallelism of data in a table, the present application can segment the table by the primary key or unique index of the table mentioned above to obtain N sub-tables or N data slices, that is, Figure 7Subtable 1-1 to subtable 1-N, or data slice 1-1 to data slice 1-N shown. After the table is divided, a job queue needs to be created for each subtable or data slice to import multiple subtables or data slices into the memory in parallel. Each job is a select statement used to obtain data from a temporary instance. For example, "select table1-1 fromtable1" can be used to obtain the segmented subtable 1-1 from table 1 of the temporary instance. For another example, "select data_row1-100 from table1" can be used to obtain data from rows 1 to 100 from table 1. Finally, the jobs corresponding to the N subtables are stuffed into the job queue to obtain the complete table 1 from the temporary instance.

[0089] Afterwards, if Figure 5 As shown, the main thread creates one or more first threads such as import (dump) threads, which are used to store the data in the temporary instance into the memory. Taking multiple import threads as an example, the multiple import threads are used as an import thread group to obtain jobs from the job queue, connect to the temporary instance, and execute the operation of reading data from the temporary instance in the job. Each of the multiple import threads can be used to execute one or more jobs in the job queue. For example, when the import thread obtains a job with an execution statement of "select table1-3 from table1", the import thread reads subtable 1-3 from the temporary instance by connecting to the temporary instance. After reading the data from the temporary instance, each import thread can form an insert statement based on the read data to store the read data into the memory, for example, "inserttable1-3 into buffer" means storing subtable 1-3 into the memory (buffer). Through the execution of multiple jobs in the job queue by the above-mentioned multiple import threads, the process of parallel import of table data into the memory by multiple import threads is realized.

[0090] Finally, if Figure 5As shown, the main thread creates one or more second threads such as an export (load) thread, which is used to restore the data in the memory to the original instance. Taking multiple export threads as an example, the multiple export threads are used as an export thread group to construct an insert statement to restore the data in the memory to the original instance. For example, the export thread connects to the memory, and when the data in the memory is not empty, it constructs an insert statement "insert table1-3from buffer into abc" according to the data read from the memory, and "abc" is the ID of the original first instance, and then the sub-tables 1-3 stored in the memory are exported to the original instance. By reading the data in the memory through multiple export threads, parallel recovery of the data in the memory is achieved.

[0091] exist Figure 5 In the process shown, the import thread group and the export thread group can run in parallel. For example, when the import thread group has imported subtables 1-1 and 1-2 into the memory and is about to start importing subtable 1-3, the export thread group can read subtables 1-1 and 1-2 stored in the memory and export them to the original instance. Based on the parallel import and export of data, the parallel execution of the data import process and the data export process is further realized, which improves the speed and efficiency of the data recovery process.

[0092] Optionally, in some other embodiments of the present application, in order to ensure the accuracy of the backup data, the management system of the database may rename the table in the original first instance where the data is damaged, for example, from "Table 1" to "Table 1.1", or add a random number after the table name, before restoring the data in the memory to the first instance. Then, a new table is created and named "Table 1", and the first data stored in the memory is restored to the newly created Table 1. In other words, the embodiment of the present application creates a new table in the original instance based on the table name of the table with damaged data. In this way, on the one hand, the data is restored to the newly created new table, which avoids the problem of confusion between the new and old data when restoring to the table with damaged data, and ensures the accuracy and integrity of the data; on the other hand, the naming distinction between the table with damaged data and the undamaged table can prevent the problem of data copying errors due to the duplicate names of the new table and the old table during the data recovery process.

[0093] Figure 6 Schematic diagram of the interaction process of method 300 is shown. Figure 6As shown in (a), when the data to be recovered is the entire database or the sub-database mentioned above, the database management system can create a new database or sub-database to distinguish it from the original damaged database and sub-database, and then execute the data recovery command on the temporary instance, that is, copy all the data in the temporary instance to the newly created database or sub-database. The new database and sub-database are different from the database and sub-database in the original instance, so there is no need to rename the tables in the database or sub-database of the original instance. Figure 6 As shown in (b) of FIG. 1 , when the data to be restored is one or more tables, the database management system can provide the user or tenant with the following information: Figure 4 The interactive interface shown in the figure is used to obtain the recovery time node in the data recovery information selected by the user or tenant. Subsequently, the database management system can create a temporary instance and store the data to be recovered in the temporary instance, modify the table name of one or more tables of the data to be recovered, and then create a new table with the same table name as the one or more tables, and finally execute the data recovery command on the temporary instance, that is, restore the data in the temporary instance to the new table through steps 320 and 330.

[0094] Combined with the following Figure 7 The data recovery device of the embodiment of the present application is introduced. It should be noted that: Figure 7 The data recovery device shown can perform Figure 3 It should be understood that the device described below can execute the method of the aforementioned embodiment of the present application, and in order to avoid unnecessary repetition, repeated descriptions are appropriately omitted when introducing the database of the embodiment of the present application.

[0095] Figure 7 is a schematic diagram of a data recovery device according to an embodiment of the present application, Figure 7 The data recovery device 700 shown includes: an acquisition module 710, a storage module 720 and a recovery module 730. Optionally, the data recovery device 800 may be a management system of a cloud database or Figure 1 The cloud management platform shown.

[0096] Specifically, the acquisition module 710 is used to: acquire data recovery information of the first instance input by a user.

[0097] Specifically, the storage module 720 is used to: store first data of the first instance after data backup at a first time node into the memory according to the data recovery information, where the first data includes the data to be recovered in the first instance.

[0098] Specifically, the recovery module 730 is used to restore the first data stored in the memory to the first instance.

[0099] Optionally, the data recovery device 700 may further include a processing module 740, which is used to: rename the names of one or more tables of data to be recovered; and generate one or more new tables corresponding to the one or more tables of data to be recovered in the first instance, wherein the name of each new table in the one or more new tables is the same as the original name of the corresponding table of data to be recovered.

[0100] The specific functions and beneficial effects of the acquisition module 710, the storage module 720 and the recovery module 730 are described in the above embodiments, and will not be repeated here for the sake of brevity.

[0101] The above modules can be implemented by software or hardware. For example, the implementation of the storage module 720 is described below by taking the storage module 720 as an example. Similarly, the implementation of the acquisition module 710 and the recovery module 730 can refer to the implementation of the processing module 820.

[0102] As an example of a software functional unit, the storage module 720 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the storage module 720 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.

[0103] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.

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

[0105] The multiple computing devices included in the storage module 720 can be distributed in the same region or in different regions. The multiple computing devices included in the storage module 720 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the storage module 720 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices included in the storage module 720 can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0106] The present application also provides a computing device 800. Figure 8 As shown, the computing device 800 includes: a bus 802, a processor 804, a memory 806, and a communication interface 808. The processor 804, the memory 806, and the communication interface 808 communicate through the bus 802. The computing device 800 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 900.

[0107] The bus 802 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus 802 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 802 may include a path for transmitting information between various components of the computing device 800 (eg, the memory 806, the processor 804, and the communication interface 808).

[0108] The processor 804 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).

[0109] The memory 806 may include a volatile memory, such as a random access memory (RAM). The processor 804 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).

[0110] The memory 806 stores executable program codes, and the processor 804 executes the executable program codes to respectively implement the functions of the pre-acquisition module 710, the storage module 720 and the recovery module 730, thereby implementing the above method. That is, the memory 806 stores instructions for executing the above data recovery method.

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

[0112] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least two computing devices. 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.

[0113] like Fig. 9 As shown, the computing device cluster includes at least two computing devices 800. The memory 806 in the multiple computing devices 800 in the computing device cluster may store the same instructions for executing the above data recovery method.

[0114] In some possible implementations, the memory 806 of the plurality of computing devices 800 in the computing device cluster may also respectively store partial instructions for executing the above data recovery method. In other words, a combination of one or more computing devices 800 may jointly execute instructions for executing the above data recovery method.

[0115] It should be noted that the memory 806 in different computing devices 800 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the above database. That is, the instructions stored in the memory 806 in different computing devices 800 can implement the functions of one or more modules among the acquisition module, the rewriting module and the execution module.

[0116] In some possible implementations, multiple computing devices in a computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.10 A possible implementation is shown. Fig.10 As shown, two computing devices 800A and 800B 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 806 in the computing device 800A stores instructions for the functions of the acquisition module. At the same time, the memory 806 in the computing device 800B stores instructions for executing the functions of the storage module and the recovery module.

[0117] It should be understood that Fig.10 The functions of the computing device 800A shown in FIG. 8 may also be completed by multiple computing devices 800. Similarly, the functions of the computing device 800B may also be completed by multiple computing devices 800.

[0118] An embodiment of the present application also provides a chip, which includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute the above-mentioned data recovery method.

[0119] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above data recovery method.

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

[0121] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0122] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.

[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0124] In the several embodiments provided in the present application, it should be understood that the disclosed systems, 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 is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, 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 modules, which can be electrical, mechanical or other forms.

[0125] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0126] In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0127] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of 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 codes.

[0128] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data recovery method, characterized in that: The method is applied to a management system of a database, wherein the database includes a first instance of data to be restored, including: Acquire data recovery information of the first instance input by a user, where the data recovery information includes a first time node determined by the user from a plurality of time nodes during which data of the first instance is backed up; According to the data recovery information, first data of the first instance after data backup at the first time node is stored in a memory, where the first data includes data to be recovered in the first instance; The first data stored in the memory is restored to the first instance.

2. The method according to claim 1, characterized in that The storing the first data of the first instance after data backup at the first time node into the memory includes: storing the first data in a temporary instance; The first data in the temporary instance is stored in the memory.

3. The method according to claim 1 or 2, characterized in that: The data recovery information also includes one or more tables of data to be recovered selected by a user from the first instance, and the first data is data of the one or more tables of data to be recovered after data backup at the first time point.

4. The method according to claim 3, characterized in that The restoring the first data stored in the memory to the first instance includes: Rename the one or more tables of data to be restored; In the first instance, one or more new tables corresponding to the one or more tables of data to be restored are generated, wherein the name of each new table in the one or more new tables is the same as the original name of the corresponding table of data to be restored; The first data is restored to the one or more new tables in the first instance.

5. The method according to any one of claims 1 to 4, characterized in that The storing the first data of the first instance after data backup at the first time node into the memory includes: storing a plurality of data slices of the first data in the memory through a plurality of first threads, each of the plurality of data slices comprising at least one row of data in the first data, and each of the plurality of first threads being used to transmit at least one of the plurality of data slices; The restoring the first data stored in the memory to the first instance includes: The multiple data slices stored in the memory are restored to the first instance through multiple second threads, and each of the multiple second threads is used to transmit at least one of the multiple data slices.

6. The method according to claim 5, characterized in that At least one first thread of the plurality of first threads and at least one second thread of the plurality of second threads are executed in parallel.

7. The method according to claim 5 or 6, characterized in that: The multiple data slices are divided according to the primary key index and / or unique index of the table.

8. The method according to any one of claims 5 to 7, characterized in that The multiple data slices include the same number of rows of data.

9. A data recovery device, characterized in that: The method comprises means for implementing the method as claimed in any one of claims 1 to 8.

10. A computing device cluster, characterized in that: include: 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 8.

11. 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 8.

12. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and 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 8.