Database recovery method and apparatus, storage medium, and electronic device
By obtaining the object identification set of multiple applications and determining the recovery order based on the key index, the database object subset is restored in a hierarchical manner, and the problem of low database recovery efficiency in the existing technology is solved, and sequential recovery and efficient recovery of multiple applications are realized.
Patent Information
- Application Number
- PCT/CN2024/116223
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-13
- Filing Date
- 2024-09-02
- Publication Date
- 2025-03-20
AI Technical Summary
The existing database recovery technology has the problem of low recovery efficiency because it can only establish recovery points for the entire database, resulting in too long recovery time for critical businesses.
By obtaining the object identification set of multiple applications and determining the recovery order based on the key indices of each application, the database object subset is restored in hierarchical ways, thereby realizing sequential recovery of multiple applications.
The efficiency of database recovery is improved, and multiple applications are restored and run in sequence, solving the problem of long restart time for applications in the existing technology.
Smart Images

Figure CN2024116223_20032025_PF_FP_ABST
Abstract
Description
Database recovery method and device, storage medium and electronic device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on September 13, 2023, with application number 2023111783860 and application name “Database recovery method and device, storage medium and electronic device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present invention relates to the field of computers, and in particular to database recovery technology. Background Art
[0003] Database high availability is crucial for the operation of business applications, and database fault recovery is a key manifestation of database high availability. In other words, in the event of a database failure, how to efficiently and quickly recover the database is crucial to the operation of business applications.
[0004] Current database recovery technologies all establish database recovery points based on the entire database. Therefore, multiple applications using the same database can only be recovered together, which results in a long recovery time for critical business. In other words, existing database recovery technologies suffer from low recovery efficiency.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a database recovery method and device, a storage medium, and an electronic device, which can improve the recovery efficiency of the database.
[0007] According to one aspect of an embodiment of the present application, a database recovery method is provided, comprising: obtaining a database recovery request, wherein the database recovery request is used to request data recovery of a set of database objects corresponding to a plurality of applications; obtaining a set of object identifiers corresponding to each of the plurality of applications, wherein the set of object identifiers includes object identifiers corresponding to a plurality of database objects called by the corresponding application during runtime; determining a key index for each of the plurality of applications, and determining a recovery order of a subset of database objects corresponding to each of the plurality of object identifier sets according to the order indicated by the key indexes, wherein the key index is used to indicate the importance of the application, and the database object subset is determined according to the database object corresponding to the object identifier in the set of object identifiers corresponding to the application; and performing data recovery on the plurality of database object subsets in sequence according to the recovery order.
[0008] According to another aspect of an embodiment of the present application, a database recovery device is further provided, including: a first acquisition unit, used to obtain a database recovery request, wherein the database recovery request is used to request data recovery of a database object set corresponding to multiple applications; a second acquisition unit, used to obtain an object identification set corresponding to each of the multiple applications, wherein the object identification set includes object identifications corresponding to multiple database objects called by the corresponding application during runtime; a determination unit, used to determine a key index of each of the multiple applications, and determine a recovery order of database object subsets corresponding to each of the multiple object identification sets according to the order indicated by the key indexes, wherein the key index is used to indicate the importance of the application, and the database object subset is determined based on the database object corresponding to the object identifier in the corresponding object identification set; and a recovery unit, used to sequentially recover data for the multiple database object subsets according to the recovery order.
[0009] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned database recovery method when running.
[0010] According to another aspect of the embodiments of the present application, a computer program product is provided, comprising a computer program / instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program / instructions from the computer-readable storage medium and executes the computer program / instructions, causing the computer device to perform the above database recovery method.
[0011] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the database recovery method through the computer program.
[0012] In the above-mentioned embodiment of the present application, when a database recovery request for a database object set corresponding to multiple applications is obtained, the object identification set corresponding to each application can be obtained first, and then the recovery order of the database object subset corresponding to each object identification set can be determined according to the key index of each application, and then the different database object subsets in the database object set can be restored according to the recovery order. Therefore, when restoring the database object subset corresponding to an application, the application can be restored to operation first, thereby realizing the sequential recovery of multiple applications, solving the technical problem that the existing database recovery method can only restore data of the entire database, thereby making the application restart time longer. The present application realizes the sequential recovery of multiple applications by performing hierarchical recovery of database objects, thereby solving the technical problem of low recovery efficiency of the existing database recovery method. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0014] FIG1 is a schematic diagram of a hardware environment of an optional database recovery method according to an embodiment of the present application;
[0015] FIG2 is a flowchart of an optional database recovery method according to an embodiment of the present application;
[0016] FIG3 is a schematic diagram of an optional database recovery method according to an embodiment of the present application;
[0017] FIG4 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0018] FIG5 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0019] FIG6 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0020] FIG7 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0021] FIG8 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0022] FIG9 is a schematic diagram of another optional database recovery method according to an embodiment of the present application;
[0023] FIG10 is a schematic structural diagram of an optional database recovery device according to an embodiment of the present application;
[0024] FIG11 is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] According to one aspect of an embodiment of the present application, a database recovery method is provided. As an optional implementation, the above-mentioned database recovery method can be, but is not limited to, applied to a database recovery system in the hardware environment shown in FIG1 , wherein the database recovery system can include, but is not limited to, a terminal device 102, a network 104, a server 106, and a database 108. A target client is running in the terminal device 102 (as shown in FIG1 , the target client is taken as an example of a client that can manage a database). The above-mentioned terminal device 102 includes a human-computer interaction screen, a processor, and a memory. The human-computer interaction screen is used to display a database recovery operation interface, and is also used to provide a human-computer interaction interface to receive operation control instructions for instructing database operations. The processor is used to generate an interaction instruction in response to the above-mentioned human-computer interaction operation, and send a data operation request corresponding to the interaction instruction to the server 106. The memory is used to store the processing results returned by the server 106.
[0028] In addition, the server 106 includes a processing engine that is used to perform storage or reading operations on the database 108, including but not limited to recovery operations on database objects. Specifically, the processing engine reads each database object to be recovered from the database 108 and performs data recovery based on the recovery log.
[0029] Assuming that a client for initiating a database recovery request is running in the terminal device 102 in FIG1 , the specific process of this embodiment is as follows: In step S102 , the terminal device 102 initiates a database recovery request;
[0030] Then, as in step S104, the terminal device 102 sends a database recovery request to the server 106 through the network 104, and the server 106 executes steps S106 to S112 to obtain the database recovery request, wherein the database recovery request is used to request data recovery of a database object set corresponding to multiple applications; obtain object identification sets corresponding to each of the multiple applications, wherein the object identification sets include object identifications corresponding to multiple database objects called by the corresponding applications during operation; determine the key indexes of each of the multiple applications, and determine the recovery order of the database object subsets corresponding to each of the multiple object identification sets according to the order indicated by the key indexes, wherein the key index is used to indicate the importance of the application, and the database object subset is determined according to the database object corresponding to the object identifier in the corresponding object identification set; and perform data recovery on the multiple database object subsets in sequence according to the recovery order.
[0031] Then, as shown in step S114, each time a subset of database objects corresponding to an application is restored, the server 106 can send recovery prompt information to the terminal device 102 in sequence according to the recovery order through the network 104; finally, as shown in step S116, the terminal device 102 displays the recovery prompt information in sequence, wherein the recovery prompt information is used to indicate that the current application has completed the recovery of the relevant database objects and is in a state where it can be run.
[0032] Optionally, in this embodiment, the terminal device 102 may be a terminal device configured with a target client, which may include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, an MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, a smart speaker, a smart watch, etc. The target client may be a video client, an instant messaging client, a browser client, an education client, or other client that supports initiating a database recovery request. The network may include but is not limited to a wired network and a wireless network, wherein the wired network includes a local area network, a metropolitan area network, and a wide area network, and the wireless network includes Bluetooth, WIFI, and other networks that implement wireless communication. The server may be a single server, or a server cluster consisting of multiple servers, or a cloud server. The above is only an example, and this embodiment does not impose any limitation on this.
[0033] The server 106 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal 102 and the server 106 can be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
[0034] In an embodiment of the present application, a database recovery request is obtained, wherein the database recovery request is used to request data recovery of a database object set corresponding to multiple applications; an object identification set corresponding to each of the multiple applications is obtained, wherein the object identification set includes object identifications corresponding to each of the multiple database objects called by the corresponding application during runtime; a key index of each of the multiple applications is determined, and a recovery order of a subset of database objects corresponding to each of the multiple object identification sets is determined based on the order indicated by the key index, wherein the key index is used to indicate the importance of the application, and the database object subset is determined based on the database object corresponding to the object identifier in the corresponding object identification set; and data recovery is performed on the multiple database object subsets in sequence according to the recovery order, thereby achieving hierarchical recovery of the multiple database object subsets included in the database.
[0035] In the above-mentioned embodiment of the present application, when a database recovery request for a database object set corresponding to multiple applications is obtained, the object identification set corresponding to each application can be obtained first, and then the recovery order of the database object subset corresponding to each object identification set can be determined according to the key index of each application, and then the different database object subsets in the database object set can be restored according to the recovery order. In this way, after the database object subset corresponding to an application is restored, the application can be restored to run first, thereby realizing the sequential recovery of multiple applications, solving the technical problem that the existing database recovery method can only restore data of the entire database, thereby making the application restart time longer. The present application realizes the sequential recovery of multiple applications by performing hierarchical recovery of database objects, thereby solving the technical problem of low recovery efficiency of the existing database recovery method.
[0036] As an optional implementation, as shown in FIG2 , the database recovery method includes the following steps:
[0037] S202, obtaining a database recovery request, wherein the database recovery request is used to request data recovery of a database object set corresponding to multiple applications;
[0038] S204, obtaining a set of object identifiers corresponding to each of the multiple applications, wherein the set of object identifiers includes object identifiers corresponding to each of the multiple database objects called by the corresponding application during runtime;
[0039] S206: Determine a key index for each of the multiple applications, and determine a recovery order for the database object subsets corresponding to each of the multiple object identifier sets based on the order indicated by the key indexes, wherein the key index indicates the importance of the application, and the database object subset is determined based on the database objects corresponding to the object identifiers in the corresponding object identifier sets;
[0040] S208: Perform data recovery on multiple database object subsets in sequence according to the recovery order.
[0041] It should be noted that the database recovery request in step S202 can be automatically generated when a database exception occurs, or it can be proactively triggered by a user object. Specifically, the database recovery request can be used to request the recovery of relevant database objects from the time of the failure to the current time point. For example, it can be used to further load completed data operations in the server's running memory to the server's hard disk, or to undo uncommitted data operations. In this embodiment, the specific content of the database recovery request is not limited.
[0042] In addition, it should be noted that the database objects mentioned in the embodiments of the present application may include but are not limited to operation objects corresponding to database-related processing operations, such as tables, indexes, views, charts, default values, rules, triggers, users, functions and other database objects. The specific types of the above-mentioned database objects are not limited in this embodiment.
[0043] In step S202, the database object set to be restored is comprised of database objects corresponding to multiple applications. These multiple applications may include, but are not limited to, a collection of multiple business applications, or multiple application function modules within a single application. For example, these multiple applications may refer to multiple applications such as Application A, Application B, Application C, and Application D; or may refer to Function Module A, Function Module B, Function Module C, and so on within Application A. In this embodiment, the specific types of these multiple applications are not limited.
[0044] Furthermore, in step S204, object identifier sets corresponding to the multiple applications can be obtained, thereby determining the subset of database objects to be restored corresponding to each application. The object identifier set corresponding to an application can be determined based on the object identifiers of database objects called by the application during operation, and the database object subset corresponding to an application can be determined based on the database objects corresponding to the object identifiers in the object identifier set corresponding to the application.
[0045] Next, in step S206, the priority order of each application can be determined based on its respective key index, and the corresponding database object subsets of each application can be restored based on a certain order. This allows for layered recovery of different parts of the database object set, allowing applications corresponding to different database object subsets to be restored sequentially according to the recovery order.
[0046] It should be noted that the aforementioned key indexes can be used to indicate the importance of each application during operation. For example, if Application A serves as the foundation for Application B, a higher key index can be assigned to Application A, thereby prioritizing the recovery of the corresponding database object subset. Alternatively, if the set of user objects associated with Application A is larger than that of Application B, corresponding key indexes can be assigned to different applications based on the size of their user object sets. In this embodiment, the configuration method of the aforementioned key indexes is not limited.
[0047] In the above-mentioned embodiment of the present application, when a database recovery request for a database object set corresponding to multiple applications is obtained, the object identification set corresponding to each application can be obtained first, and then the recovery order of the database object subset corresponding to each object identification set can be determined according to the key index of each application, and then the different database object subsets in the database object set can be restored according to the recovery order. In this way, after the database object subset corresponding to an application is restored, the application can be restored to run first, thereby realizing the sequential recovery of multiple applications, solving the technical problem that the existing database recovery method can only restore data of the entire database, thereby making the application restart time longer. The present application realizes the sequential recovery of multiple applications by performing hierarchical recovery of database objects, thereby solving the technical problem of low recovery efficiency of the existing database recovery method.
[0048] In an optional embodiment, determining the recovery order of the database object subsets corresponding to each of the plurality of object identification sets according to the order indicated by the key indexes includes:
[0049] S1, sequentially determining the database object subsets corresponding to the respective object identifier sets according to the order indicated by the key index;
[0050] S2: Determine the order indicated by the key indexes as the recovery order of the plurality of database object subsets.
[0051] It is understandable that in this embodiment, the database object subsets corresponding to each object identification set can be determined in sequence according to the order indicated by the key index, and then the database object subsets can be restored in sequence based on the order.
[0052] In an optional embodiment, a method for determining a database object subset corresponding to an object identifier set may be: for each object identifier included in the object identifier set, determining the database object uniquely corresponding to the object identifier; and then directly determining an object set consisting of database objects corresponding to each object identifier in the object identifier set as the database object subset corresponding to the above-mentioned object identifier set.
[0053] In another optional embodiment, the above-mentioned sequentially determining the database object subsets corresponding to each of the plurality of object identification sets according to the order indicated by the key index may include:
[0054] According to the order indicated by the key indexes, one object identification set is sequentially obtained from the multiple object identification sets as the current identification set, and a database object subset determination operation is performed on the current identification set until the database object subsets corresponding to the respective object identification sets are determined:
[0055] The database object subset determination operation includes the following steps:
[0056] S1, when the current identification set does not include the object identification in the historical identification set, determining the database object corresponding to each object identification in the current identification set as the database object in the database object subset corresponding to the current identification set;
[0057] S2, when the current identification set includes the object identification in the historical identification set, determining the database objects corresponding to the object identifications in the current identification set excluding the object identifications in the historical identification set as the database objects in the database object subset corresponding to the current identification set;
[0058] The historical identification set is a set of object identifications whose order indicated by the key index is before the current identification set.
[0059] It should be noted that, in this embodiment, the method for determining each database object subset can be to determine the database objects corresponding to the object identifiers that have not been processed historically in each object identifier set in sequence according to the order indicated by the above-mentioned key index, and use these database objects to form the database object subset corresponding to the currently processed object identifier set.
[0060] The above embodiment is described below with reference to FIG3. As shown in FIG3 (a), the object identifiers corresponding to application a are Table 1, Table 2, Table 3, and Table 4; the object identifiers corresponding to application b are Table 1, Table 2, and Table 5; and the object identifiers corresponding to application c are Table 6, Table 3, and Table 4.
[0061] As shown in FIG3(b), when the priorities of the three applications are determined to be application a>application b>application c according to the order indicated by the key index, the table objects corresponding to Table 1, Table 2, Table 3, and Table 4 in the object identification set corresponding to application a can be first determined as the database object subset corresponding to the object identification set of application a, that is, the database object subset corresponding to application a includes the table objects corresponding to Table 1, Table 2, Table 3, and Table 4;
[0062] Next, determine the database object subset corresponding to the object identifier set corresponding to application b. Since the object identifier set corresponding to application b includes Table 1, Table 2, and Table 5, and Table 1 and Table 2 have already appeared in the object identifier set corresponding to application a (the historical identifier set), the table object corresponding to Table 5, which has not appeared, can be used to determine the database object subset corresponding to the object identifier set corresponding to application b. That is, the database object subset corresponding to application b includes the table object corresponding to Table 5.
[0063] Finally, determine the database object subset corresponding to the object identifier set corresponding to application C. Since the object identifier set corresponding to application C includes Table 6, Table 3, and Table 4, and Table 3 and Table 4 have already appeared in the object identifier set corresponding to application A (the historical identifier set), the table object corresponding to Table 6, which has not appeared, can be used to determine the database object subset corresponding to the object identifier set corresponding to application C. In other words, the database object subset corresponding to application C includes the table object corresponding to Table 6.
[0064] After determining the database object subsets corresponding to each of the multiple object identification sets in sequence according to the order indicated by the key indexes, the order indicated by the key indexes can be directly determined as the recovery order of the above-mentioned database object subsets, as shown in Figure 3 (b), that is, the database object subsets corresponding to application a are restored first, that is, the table objects corresponding to Table 1, Table 2, Table 3, and Table 4; then the database object subsets corresponding to application b are restored, that is, the table objects corresponding to Table 5; finally, the database object subsets corresponding to application c are restored, that is, the table objects corresponding to Table 6.
[0065] Through the above-described implementation of the present application, the database object subsets corresponding to each application can be restored in batches based on the priority relationship of each application. In addition, when determining the order in which the database object subsets are restored, the minimum database object subset required to restore the database corresponding to the current application can be further determined based on the relationship between the currently processed database object subset and the database objects included in the database object subset corresponding to the previously restored or operated application, thereby improving the efficiency of database object recovery.
[0066] In an optional embodiment, determining the key index of each of the plurality of applications includes at least one of the following:
[0067] Method 1: Obtain preset priority orders corresponding to multiple applications, and determine the key indexes of the multiple applications according to the preset priority orders;
[0068] Method 2: Obtain application dependencies of multiple applications during operation, and determine the key indexes of the multiple applications according to the application dependencies;
[0069] Method 3: Obtain the number of object identifiers included in the object identifier sets corresponding to the multiple applications, and determine the key index of each of the multiple applications according to the number of identifiers.
[0070] It is understood that in this embodiment, three optional methods for determining the above-mentioned critical index are provided. In the above-mentioned method 1, the critical index of each application can be determined based on the preset priority order corresponding to each application. For example, the preset priority order can be the importance level of each application defined by the user. Based on this, a higher critical coefficient can be assigned to applications with higher importance levels. Then, the recovery order of the database object subset corresponding to each application is determined based on the user-defined importance level;
[0071] In the second method described above, the key index of each application can be determined based on the application dependencies between them during operation. For example, if application A is a search application and application B is a data processing application that further processes data based on the search results, the operation of application B depends on the search results of application A. Furthermore, based on the relationship between application B and application A, a higher key index can be assigned to application A, thereby enabling priority recovery of the database objects corresponding to application A.
[0072] In the third approach above, the criticality index of each application can also be determined based on the size of the object identifier sets corresponding to each application. For example, if the object identifier set corresponding to application a includes 100 object identifiers, and the object identifier set corresponding to application b includes 10 object identifiers, a higher criticality index can be assigned to application b, thereby enabling priority recovery of application b.
[0073] In another optional implementation, a key index for each application can be determined based on the size of the user object collection corresponding to each application. For example, if application A has an average monthly active user base of 100,000 and application B has an average monthly active user base of 10,000, a higher key index can be assigned to application A to prioritize the recovery of its related application services.
[0074] It is understandable that the above methods for determining the key index can be arbitrarily combined with each other. When the method for determining the key index is a combination of the above methods, different index weights can be configured for each method to more accurately determine the importance of each application.
[0075] The combination of the above-mentioned methods is described in detail below.
[0076] In the first combination method, the key index of each of the above-mentioned applications can be determined by combining the above-mentioned method one and method two. Specifically, the preset priority order defined by the user and the dependency relationship between the applications obtained by analyzing the application functions can be obtained first, and the key index of each application can be determined based on the preset priority order and the dependency relationship. Optionally, when the preset priority order defined by the user is default, the key index of each application can be determined directly based on the dependency relationship between the above-mentioned applications; when the user-defined preset priority order is obtained, the first key coefficient can be allocated to each application according to the dependency relationship between the above-mentioned applications, and the second key coefficient can be allocated to each application according to the preset priority order, and the key index of each application can be determined based on the weighted sum of the first key coefficient and the second key coefficient.
[0077] For example, the user defines a priority relationship as: Application A > Application B > Application C. Applications A through C are then assigned first key coefficients of 100, 80, and 60, respectively. If, based on the dependency analysis of the application functions, it is determined that application C depends on application A for its functionality, and that application B depends on both applications A and C for its functionality, second key coefficients of 100, 30, and 80 can be assigned to applications A through C, respectively. If the weights of the first and second key coefficients are the same, the key indices of applications A through C are determined to be: 100*0.5+100*0.5=100, 80*0.5+30*0.5=55, and 60*0.5+80*0.5=70, respectively. That is, the key indices of applications A through C are 100, 55, and 70, respectively. Application A is restored first, followed by application C, and finally application B.
[0078] In the second combination method, the key index of each of the above-mentioned applications can be determined by combining the above-mentioned methods one, two and three. In this embodiment, corresponding priorities can be configured for the above-mentioned multiple methods respectively, and the key index of each application can be determined based on the priority relationship of the above-mentioned methods. For example, when the priority of method two is the highest and the priorities of methods one and three are the same, it indicates that when the preset priority order specified by the user conflicts with the priority relationship determined by the application dependency analysis, the recovery order is determined based on the priority relationship determined by the application dependency analysis.
[0079] For example, if the user specifies a priority relationship of: Application A > Application B > Application C > Application D, and the functional dependency obtained from the application function dependency analysis is: Application C's functional implementation depends on Application A, Application B's functional implementation depends on Application A and Application C, and Application D's functional implementation depends on Application A and Application C, then the recovery order can be determined based on the functional dependency relationship as: Application A > Application C > Application B = Application D. That is, the highest critical index is first configured for Application A, followed by the second highest critical index for Application C. Finally, based on the weighted sum of the critical coefficients of Application B and Application D determined by the above methods 1 to 3, the critical indexes of Application B and Application D are determined respectively, and the recovery order of Application B and Application D is then determined.
[0080] In the third combination method, the first key coefficient corresponding to each application can be determined according to method 2 (i.e., functional dependency), and the recovery order can be determined based on the ranking of the first key coefficients; when the first key coefficients of different applications are the same, the recovery order between the applications with the same first key coefficients can be determined based on the weighted sum of the key coefficients determined by the above methods 1, 3, and 4. Through the above implementation of the present application, through any combination of the four optional methods, the importance of the applications can be accurately defined, and then the operation of the application services corresponding to each application can be efficiently restored in sequence according to the importance of each application.
[0081] In an optional embodiment, the data recovery of multiple database object subsets is performed sequentially according to the recovery order, including:
[0082] S1, grouping the M database object subsets according to the recovery task amounts corresponding to the M database object subsets to obtain N to-be-recovered object subsets, where M is an integer greater than or equal to 1, and N is an integer less than or equal to M and greater than or equal to 1;
[0083] S2, obtaining reference recovery information corresponding to each of N subsets of objects to be recovered;
[0084] S3, based on the reference recovery information corresponding to each of the N subsets of objects to be recovered, determining a target sequence that matches the recovery sequence, and sequentially recovering data for the N subsets of objects to be recovered according to the target sequence.
[0085] It should be noted that, in this embodiment, after determining the aforementioned multiple database object subsets, each database object subset can be further grouped according to the data recovery workload corresponding to each database object subset to obtain multiple to-be-recovered object subsets. Data recovery is then performed in units of the to-be-recovered object subsets.
[0086] It is understandable that if data recovery is performed directly based on database object subsets, the large number of database object subsets may result in the data recovery process for each database object subset requiring significant performance overhead. In the aforementioned embodiments of the present application, the database object subsets can be further grouped based on the recovery task volume of each database object subset, thereby reducing the number of database object recovery tasks and addressing performance issues caused by excessive grouping.
[0087] In an optional embodiment, the M database object subsets are grouped according to the recovery task amounts corresponding to the M database object subsets to obtain N subsets of objects to be recovered, including:
[0088] S1, determining the recovery task volume corresponding to each of the M database object subsets based on the number of recovery logs corresponding to each of the M database object subsets, wherein the recovery log is used to record a set of database operations generated after a target time point, where the target time point is the starting time point of the data recovery operation indicated in the data recovery request;
[0089] S2: Group the M database object subsets according to the recovery task volume to obtain N to-be-recovered object subsets, wherein the difference between the number of recovery logs corresponding to any two to-be-recovered object subsets in the N to-be-recovered object subsets is less than or equal to a target threshold.
[0090] A specific process of the above embodiment will be described below with reference to FIG4 .
[0091] In one optional embodiment, database object subsets can be merged based on a user-defined number of database recovery sets. In another optional embodiment, if the user does not define the number of database recovery sets, the number of database recovery sets can be reasonably determined based on current processing performance to avoid excessive recovery sets and the resulting database recovery information explosion. The set division can be determined based on the number of redo log entries (i.e., the aforementioned recovery log) for each checkpoint of the database object over a period of time.
[0092] It's important to note that a checkpoint is the point in time when all modified data pages are written to disk during system operation. In the event of a database failure, the relevant information recorded at that point in time can be used to quickly restore the database to its most recent stable state, thus avoiding data loss or corruption.
[0093] The redo log can be used to reconstruct all changes made to the database (including undo segments). The redo log consists of a set of change vectors, each of which describes a change made to a single block in the database. For example, if a transaction value in a transaction data table is changed, a redo log containing change vectors is generated. These change vectors describe the changes to the table's data segment blocks, undo segment data blocks, and the undo segment's transaction table.
[0094] As shown in Figure 4 (a), the following divisions are performed based on the recovery set and incremental set. Considering that dividing into too many groups can lead to performance issues, database object subsets can be merged based on the size of the redo logs. Grouping needs to be performed in sequence, and recovery groups can be merged. As shown in Figure 4 (a), since the database object subset corresponding to Group 1 has 8,000 redo log entries, the database object subset corresponding to Group 2 has 2,000 redo log entries, the database object subset corresponding to Group 3 has 5,000 redo log entries, and the database object subset corresponding to Group 4 has 7,000 redo log entries, these database object subsets can be regrouped into Object Subset 1 to be recovered, Object Subset 2 to be recovered (including Groups 2 and 3), and Object Subset 3 to be recovered. These three sets are shown in Figure 4 (b). The redo logs corresponding to each group are roughly the same, thereby reducing the overhead of maintaining the object subsets to be recovered.
[0095] In an optional embodiment, the above-mentioned determining a target order that matches the recovery order based on the reference recovery information corresponding to each of the N subsets of objects to be recovered, and sequentially recovering data for the N subsets of objects to be recovered according to the target order, includes:
[0096] S1, respectively determining data buffers corresponding to N subsets of objects to be restored, wherein the data buffers do not overlap with each other;
[0097] S2, in the data buffers corresponding to the respective N subsets of objects to be restored, data of the N subsets of objects to be restored are restored sequentially according to the target order.
[0098] It should be noted that, in the above-mentioned implementation of the present application, data recovery can be performed in the data buffer corresponding to each subset of objects to be recovered.
[0099] Specifically, in order to achieve database group recovery, the recovery information needs to be stored separately:
[0100] First, according to the grouping of database objects, the database objects are mapped to the corresponding buffer pools;
[0101] Secondly, different buffer pools correspond to different subsets of objects to be recovered, and each subset of objects to be recovered contains independent recovery information files and redo log files.
[0102] After obtaining the subset of objects to be recovered, you need to establish a correspondence between the subset and the data buffers. You also need to create corresponding recovery information files and redo logs for each data buffer. Because database recovery information and data buffers are closely related, you must first determine the relationship between the subset and the data buffers, and then confirm the relationship between the data buffers and the recovery files. A single subset can correspond to multiple data buffers, but the data buffers of different subsets cannot overlap. A single subset can only correspond to one set of recovery files and redo logs.
[0103] As shown in Figure 5, the two data buffers corresponding to subset 1 of objects to be recovered are buffer 1 and buffer 2, which correspond to recovery file 1 and redo log 1. That is, during the recovery of database objects associated with subset 1 of objects to be recovered, data can be recovered in buffers 1 and 2 based on recovery file 1 and redo log 1. Furthermore, the data buffer corresponding to subset 2 of objects to be recovered is buffer 3, which corresponds to recovery file 2 and redo log 2. The data buffer corresponding to subset 3 of objects to be recovered is buffer 4, which corresponds to recovery file 3 and redo log 3.
[0104] During the recovery process, you can perform layered recovery according to the following steps.
[0105] S1, first reads the recovery information in order according to the recovery order of the database;
[0106] S2, performing database recovery based on the recovery information of each subset of objects to be recovered;
[0107] S3: Each time a database object in the subset of objects to be restored is restored, corresponding information is output, indicating that the corresponding application can be used.
[0108] Through the above-mentioned implementation of the present application, after obtaining the subset of objects to be recovered, a corresponding relationship between it and the data buffer is established, and corresponding recovery information files and redo logs are established for different data buffers, thereby ensuring that different subsets of objects to be recovered are recovered in different data buffers, avoiding errors in the recovery process, and improving the recovery efficiency of database recovery.
[0109] In an optional embodiment, the obtaining of the object identification sets corresponding to the multiple applications includes: obtaining an application from the multiple applications as the current application, performing an object identification set determination operation on the current application until the multiple applications are traversed;
[0110] The object identification set determination operation includes the following steps:
[0111] S1, filter out database operation statements from the running statements associated with the current application;
[0112] S2: Determine the database object identifier included in the database operation statement as the object identifier in the object identifier set corresponding to the current application.
[0113] The following describes in detail a method for obtaining a set of object identifiers corresponding to each application, which may include the following steps: parsing the application set by the user to obtain database-related statements; parsing the database-related statements to determine the corresponding database objects.
[0114] Generally speaking, databases can be divided into the following levels:
[0115] First, the user-specified application needs to be parsed. Based on the parsed query, a correspondence between the application and the database objects in the database is established. As shown in Figure 6, the application's database-related statements can be parsed during compilation; a parse tree for the corresponding database statement is generated based on the database statement, and the corresponding original data object is obtained based on the parse tree for the database statement.
[0116] After obtaining the original set of database objects, as shown in FIG7 , it is necessary to obtain all related database objects based on the primary and foreign key information, trigger information, restriction information, etc. of the database.
[0117] Through the above-mentioned implementation mode of the present application, database operation statements can be filtered out from the operation statements associated with the operation of the current application; the database object identifier included in the database operation statement is determined as the object identifier in the object identifier set corresponding to the current application. Thus, based on the database object identifier included in the database-related operation statement called by the application during operation, the object identifier set corresponding to the application can be determined, avoiding the user's own parsing of the corresponding database objects occupied by each application, thereby improving the parsing efficiency of the database objects.
[0118] In an optional embodiment, after performing data recovery on multiple database object subsets in sequence according to the recovery order, the method further includes: sending a recovery prompt message when data recovery of the database object subset associated with the target application among multiple applications is completed, wherein the recovery prompt message is used to indicate that the target application is currently in an operational state.
[0119] As shown in Figure 8, when restoring each subset of objects to be restored, the corresponding recovery files and redo logs are retrieved according to the defined recovery set to restore the database objects. After the corresponding database objects are restored, the user is notified that the corresponding application can be resumed. This allows the user to be promptly notified that the application is now available for use after the application-related database objects have been restored.
[0120] The following describes a complete implementation process of this application.
[0121] In this embodiment, the following steps are included:
[0122] S1, obtains the importance level of the user-defined application;
[0123] S2, sets the recovery order of applications according to the importance level of the applications involved;
[0124] S3, divides the database objects into different recovery groups according to the recovery order;
[0125] The specific implementation process of the above step S1 may further include: the user needs to define the recovery order of different applications according to the importance level of the application, and the database side needs to complete the following actions: parse according to the application specified by the user, parse out the database query statements involved; analyze the database objects involved in the checked query statements.
[0126] As shown in Figure 9, application a contains three query statements, each corresponding to a different database object. The query is parsed for the application and the information structure shown in Figure 9 is obtained.
[0127] Since the user object defines application a, the three query statements involved in application a are query 1, query 2, and query 3. As shown in Figure 9, the database objects involved in these three query statements include tables 1, 2, 3, and 4. Therefore, based on the analysis in the above steps, if application a needs to be restored, only the four tables involved need to be restored. At this point, application a can provide external services.
[0128] In the above step S2, the following steps may be further included:
[0129] The recovery order of database objects is calculated based on the analyzed correspondence between applications and database objects, and the user-specified order of importance of applications. According to the user-specified recovery order, the database objects involved in the first application are added to the starting position of the recovery sequence, indicating that these database objects should be restored first. This allows the most important applications to be restored quickly. The database objects involved in the applications are sequentially removed according to their importance, and database objects that are not in the recovery queue are added to the recovery queue. This process continues until all database objects are in the recovery queue.
[0130] The above embodiment is described below with reference to FIG3. As shown in FIG3 (a), the object identifiers corresponding to application a include Table 1, Table 2, Table 3, and Table 4; the object identifiers corresponding to application b include Table 1, Table 2, and Table 5; and the object identifiers corresponding to application c include Table 6, Table 3, and Table 4.
[0131] If the user defines the order of importance of applications as application a, application b, and application c, then application a must be restored first. Accordingly, tables 1, 2, 3, and 4 must be added to the restoration queue. Next, application b must be restored, so table 5 is added to the restoration queue. Finally, table 6, corresponding to application c, is added to the restoration queue. The resulting restoration order is shown in Figure 3 (b).
[0132] In step S3, the following further steps may be performed: Based on the order in which database objects are to be restored, the database objects may be divided into different recovery groups: first, multiple subsets of objects to be restored are established based on the initial restored subset of database objects and each incremental subset of database objects; and then, based on the number of user-defined subsets of objects to be restored, the subsets of objects to be restored are merged to avoid an explosion of database recovery information due to an excessive number of recovery sets. The subsets of objects to be restored are divided based on the number of redo log entries for each checkpoint of the database objects over a period of time.
[0133] As shown in Figure 4 (a), the following divisions are performed based on the recovery set and incremental set. Considering that dividing into too many groups can lead to performance issues, redo logs can be merged based on their size. Grouping and division need to be performed sequentially, and database object subsets can be merged. As shown in Figure 5, since the database object subset corresponding to Group 1 has 8,000 redo log entries, the database object subset corresponding to Group 2 has 2,000 redo log entries, the database object subset corresponding to Group 3 has 5,000 redo log entries, and the database object subset corresponding to Group 4 has 7,000 redo log entries, they can be further grouped into three sets: Subset 1 of Objects to be Recovered, Subset 2 of Objects to be Recovered (including Groups 2 and 3), and Subset 3 of Objects to be Recovered. The redo logs corresponding to each subset of objects to be recovered are roughly the same, thereby reducing the overhead of recovery group maintenance.
[0134] Finally, in the process of restoring each subset of objects to be restored in sequence, as shown in Figure 8, the recovery information is first read in sequence according to the recovery order of the database; the database objects are restored according to the recovery information of each subset of objects to be restored; each time the database objects of a subset of objects to be restored are restored, the corresponding information is output, indicating that the corresponding application can be used.
[0135] In the above-mentioned embodiment of the present application, when a database recovery request for a database object set corresponding to multiple applications is obtained, the object identification set corresponding to each application can be obtained first, and then the recovery order of the database object subset corresponding to each object identification set can be determined according to the key index of each application, and then the different database object subsets in the database object set can be restored according to the recovery order. In this way, after the database object subset corresponding to an application is restored, the application can be restored to run first, thereby realizing the sequential recovery of multiple applications, solving the technical problem that the existing database recovery method can only restore data of the entire database, thereby making the application restart time longer. The present application realizes the sequential recovery of multiple applications by performing hierarchical recovery of database objects, thereby solving the technical problem of low recovery efficiency of the existing database recovery method.
[0136] Through the above-mentioned implementation of the present application, database objects are automatically layered, multiple database object subsets are established, and different database recovery points are established for each database object subset; when the database is restored, the high-importance database object subsets are restored first, so as to achieve the purpose of quickly restoring critical applications.
[0137] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0138] According to another aspect of the present invention, a database recovery device for implementing the above database recovery method is provided. As shown in FIG10 , the device includes:
[0139] A first acquiring unit 1002 is configured to acquire a database recovery request, wherein the database recovery request is used to request data recovery for a database object set corresponding to multiple applications;
[0140] The second acquiring unit 1004 is configured to acquire a set of object identifiers corresponding to each of the plurality of applications, wherein the set of object identifiers includes object identifiers corresponding to each of the plurality of database objects called by the corresponding application when the application is running;
[0141] Determining unit 1006 is configured to determine a key index for each of the plurality of applications, and determine a recovery order for the database object subsets corresponding to each of the plurality of object identifier sets based on the order indicated by the key index, wherein the key index indicates the importance of the application, and the database object subset is determined based on the database objects corresponding to the object identifiers in the corresponding object identifier sets;
[0142] The recovery unit 1008 is configured to sequentially recover data on multiple database object subsets according to a recovery order.
[0143] Optionally, the determining unit 1006 includes:
[0144] A first determining module is configured to determine, in order of the order indicated by the key index, the database object subsets corresponding to the respective sets of object identifiers;
[0145] The second determining module is configured to determine the order indicated by the key indexes as the recovery order of the plurality of database object subsets.
[0146] Optionally, the first determining module is configured to:
[0147] An object identification set is sequentially obtained from the multiple object identification sets according to the order indicated by the key index as the current identification set, and a database object subset determination operation is performed on the current identification set until multiple database object subsets corresponding to each object identification set are determined:
[0148] The database object subset determination operation includes:
[0149] When the current identification set does not include object identifications in the historical identification set, the database object corresponding to each object identification in the current identification set is determined to be a database object in the database object subset corresponding to the current identification set; when the current identification set includes object identifications in the historical identification set, the database objects corresponding to object identifications in the current identification set other than the object identifications in the historical identification set are determined to be database objects in the database object subset corresponding to the current identification set; wherein the historical identification set is a set of object identifications whose order indicated by the key index is before the current identification set.
[0150] Optionally, the determining unit 1006 is further configured to perform at least one of the following:
[0151] Obtaining preset priority orders corresponding to the plurality of applications, and determining key indexes of the plurality of applications according to the preset priority orders;
[0152] Obtaining application dependencies between multiple applications during operation, and determining key indexes of the multiple applications based on the application dependencies;
[0153] The number of object identifiers included in the object identifier sets corresponding to the multiple applications is obtained, and the key index of each of the multiple applications is determined according to the number of identifiers.
[0154] Optionally, the recovery unit 1008 is configured to:
[0155] According to the recovery task amount corresponding to each of the M database object subsets, the M database object subsets are grouped to obtain N object subsets to be recovered, where M is an integer greater than or equal to 1 and N is an integer less than or equal to M and greater than or equal to 1; reference recovery information corresponding to each of the N object subsets to be recovered is obtained; based on the reference recovery information corresponding to each of the N object subsets to be recovered, a target sequence that matches the recovery sequence is determined, and data is recovered in sequence for the N object subsets to be recovered according to the target sequence.
[0156] Optionally, the recovery unit 1008 is configured to:
[0157] Data buffers corresponding to the N subsets of objects to be recovered are respectively determined, wherein the data buffers do not overlap with each other; and data of the N subsets of objects to be recovered are sequentially recovered in the data buffers corresponding to the N subsets of objects to be recovered according to the target order.
[0158] Optionally, the recovery unit 1008 is configured to: determine the recovery task volume corresponding to each of the M database object subsets based on the number of recovery logs corresponding to each of the M database object subsets, wherein the recovery log is used to record a set of database operations generated after a target time point, and the target time point is the starting time point of the data recovery operation indicated in the data recovery request; and group the M database object subsets according to the recovery task volume to obtain N subsets of objects to be recovered, wherein the difference between the number of recovery logs corresponding to any two of the N subsets of objects to be recovered is less than or equal to a target threshold.
[0159] Optionally, the second acquiring unit is configured to:
[0160] An application is obtained from the multiple applications as a current application, and an object identification set determination operation is performed on the current application until the multiple applications are traversed:
[0161] The object identification set determination operation includes:
[0162] Filter out database operation statements from the running statements associated with the current application; determine the database object identifier included in the database operation statement as the object identifier in the object identifier set corresponding to the current application.
[0163] Optionally, the above-mentioned database recovery device is further used to: send recovery prompt information when data recovery of a subset of database objects associated with a target application among multiple applications is completed, wherein the recovery prompt information is used to indicate that the target application is currently in an operational state.
[0164] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0165] According to another aspect of an embodiment of the present application, an electronic device for implementing the above-mentioned database recovery method is also provided. The electronic device may be a terminal device or a server as shown in Figure 11. This embodiment is described using the electronic device as an example of a terminal device. As shown in Figure 11, the electronic device includes a memory 1102 and a processor 1104. The memory 1102 stores a computer program, and the processor 1104 is configured to execute the steps of any of the above-mentioned method embodiments using the computer program.
[0166] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0167] Optionally, in this embodiment, the processor may be configured to execute the database recovery method through a computer program.
[0168] Alternatively, those skilled in the art will appreciate that the structure shown in FIG11 is merely illustrative, and the electronic device may also be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile internet device (MID), a PAD, or other terminal device. FIG11 does not limit the structure of the electronic device. For example, the electronic device may include more or fewer components (such as a network interface, etc.) than those shown in FIG11, or may have a configuration different from that shown in FIG11.
[0169] Memory 1102 can be used to store software programs and modules, such as program instructions / modules corresponding to the database recovery method and device in the embodiments of the present application. Processor 1104 executes the software programs and modules stored in memory 1102 to perform various functional applications and data processing, thereby implementing the above-mentioned database recovery method. Memory 1102 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, memory 1102 may further include a memory remotely located relative to processor 1104, which can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. Memory 1102 can specifically, but is not limited to, be used to store various elements in the scene image, database recovery information, and other information. As an example, as shown in FIG11 , memory 1102 may, but is not limited to, include the first acquisition unit 1002, the second acquisition unit 1004, the determination unit 1006, and the recovery unit 1008 of the above-mentioned database recovery device. In addition, it may also include but is not limited to other module units in the above-mentioned database recovery device, which will not be repeated in this example.
[0170] Optionally, the transmission device 1106 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1106 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1106 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0171] In addition, the electronic device further includes: a display 1108 for displaying a virtual scene in an interface; and a connection bus 1110 for connecting various module components in the electronic device.
[0172] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes via network communication. The nodes may form a peer-to-peer network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0173] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0174] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0175] According to one aspect of the present application, a computer-readable storage medium is provided. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned database recovery method.
[0176] Optionally, in this embodiment, the computer-readable storage medium may be configured to store data for executing the database recovery method.
[0177] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0178] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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 and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the above-mentioned methods in each embodiment of the present application.
[0179] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0181] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0183] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A database recovery method, executed by an electronic device, comprising: Obtaining a database recovery request, wherein the database recovery request is used to request data recovery for a set of database objects corresponding to a plurality of applications; Obtaining a set of object identifiers corresponding to each of the multiple applications, wherein the set of object identifiers includes object identifiers corresponding to each of multiple database objects called by the corresponding application when the application is running; Determine the key index of each of the multiple applications, and determine the recovery order of the database object subsets corresponding to each of the multiple object identifier sets according to the order indicated by the key index, wherein the key index is used to indicate the importance of the application, and the database object subset is determined according to the database object corresponding to the object identifier in the corresponding object identifier set; According to the recovery sequence, data is recovered sequentially for the plurality of database object subsets.
2. The method according to claim 1, wherein determining the recovery order of the database object subsets corresponding to each of the plurality of object identification sets according to the order indicated by the key index comprises: Determining, in sequence, the database object subsets corresponding to each of the plurality of object identification sets according to the order indicated by the key indexes; The order indicated by the key indexes is determined as the restoration order of the plurality of database object subsets.
3. The method according to claim 2, wherein the step of sequentially determining the database object subsets corresponding to each of the plurality of object identification sets according to the order indicated by the key index comprises: According to the order indicated by the key index, one object identification set is sequentially obtained from the multiple object identification sets as the current identification set, and a database object subset determination operation is performed on the current identification set until the database object subsets corresponding to the respective object identification sets are determined: The database object subset determination operation includes: In the case that the current identification set does not include the object identification in the historical identification set, determining the database object corresponding to each object identification in the current identification set as the database object in the database object subset corresponding to the current identification set; In the case where the current identification set includes the object identification in the historical identification set, determining the database objects corresponding to the object identifications in the current identification set except the object identifications in the historical identification set as the database objects in the database object subset corresponding to the current identification set; The historical identification set is a set of object identifications whose order indicated by the key index is before the current identification set.
4. The method according to any one of claims 1 to 3, wherein determining the key index of each of the plurality of applications comprises at least one of the following: Obtaining preset priority orders corresponding to the multiple applications respectively, and determining key indexes of the multiple applications respectively according to the preset priority orders; Acquire application dependencies of the multiple applications during operation, and determine key indexes of the multiple applications according to the application dependencies; Obtain the number of object identifiers included in the object identifier sets corresponding to the multiple applications, according to The number of identifications determines a critical index of each of the plurality of applications.
5. The method according to any one of claims 1 to 4, wherein the step of sequentially restoring data on a plurality of the database object subsets according to the recovery order comprises: According to the recovery task amounts corresponding to the M database object subsets, the M database object subsets are grouped to obtain N to-be-recovered object subsets, wherein M is an integer greater than or equal to 1, and N is an integer less than or equal to M and greater than or equal to 1; Obtaining reference restoration information corresponding to each of the N subsets of objects to be restored; Based on the reference recovery information corresponding to each of the N subsets of objects to be recovered, a target sequence matching the recovery sequence is determined, and data of the N subsets of objects to be recovered are sequentially recovered according to the target sequence.
6. The method according to claim 5, characterized in that The determining, based on the reference recovery information corresponding to each of the N subsets of objects to be recovered, a target sequence matching the recovery sequence, and sequentially recovering data for the N subsets of objects to be recovered according to the target sequence, comprises: Respectively determine data buffers corresponding to the N subsets of objects to be restored, wherein the data buffers do not overlap with each other; In the data buffers corresponding to the respective N subsets of objects to be restored, data of the N subsets of objects to be restored are restored in sequence according to the target order.
7. The method according to claim 5 or 6, wherein the M database object subsets are grouped according to the recovery task amounts corresponding to the M database object subsets to obtain N to-be-recovered object subsets, comprising: Determining the recovery task amount corresponding to each of the M database object subsets according to the number of recovery logs corresponding to each of the M database object subsets, wherein the recovery log is used to record a set of database operations generated after a target time point, and the target time point is a starting time point of the data recovery operation indicated in the data recovery request; The M database object subsets are grouped according to the recovery task amount to obtain the N to-be-recovered object subsets, wherein a difference between the quantities of the recovery logs corresponding to any two of the N to-be-recovered object subsets is less than or equal to a target threshold.
8. According to the method according to any one of claims 1 to 7, the step of obtaining the object identification sets corresponding to the plurality of applications comprises: Obtain an application from the multiple applications as the current application, and perform an object identification set determination operation on the current application until the multiple applications are traversed: The object identification set determination operation includes: Filtering out database operation statements from the running statements associated with the current application; The database object identifier included in the database operation statement is determined as an object identifier in the object identifier set corresponding to the current application.
9. The method according to any one of claims 1 to 8, after sequentially restoring data on the plurality of database object subsets according to the recovery order, further comprising: When the database object subset associated with the target application among the multiple applications completes data recovery, recovery prompt information is sent, wherein the recovery prompt information is used to indicate that the target application is currently in an executable state.
10. A database recovery device, comprising: A first acquisition unit, configured to acquire a database recovery request, wherein the database recovery request is used to request data recovery for a database object set corresponding to a plurality of applications; A second acquisition unit is used to acquire a set of object identifiers corresponding to each of the multiple applications, wherein the set of object identifiers includes object identifiers corresponding to each of the multiple database objects called by the corresponding application when it is running; a determination unit, configured to determine a key index of each of the plurality of applications, and determine a recovery order of the database object subsets corresponding to each of the plurality of object identifier sets according to an order indicated by the key index, wherein the key index is used to indicate the importance of the application, and the database object subset is determined according to the database object corresponding to the object identifier in the corresponding object identifier set; The recovery unit is used to sequentially recover data of the plurality of database object subsets according to the recovery sequence.
11. A computer-readable storage medium, the computer-readable storage medium comprising a stored program, wherein: When the program is executed, the method described in any one of claims 1 to 9 is executed.
12. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.
13. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the method according to any one of claims 1 to 9 through the computer program.
Citation Information
Patent Citations
Backing up and restoring security information for selected database objects
CN102187316A
Program recovery method and device
CN106528283A
Data recovery method and device, electronic equipment and computer readable storage medium
CN116149902A
Database recovery method and device, storage medium and electronic equipment
CN116909816A
Backup and restore of databases
US9535932B1