Log processing method, device, equipment and storage medium
By determining the target fault page block number and page serial number set in a distributed database, efficient recovery processing of the fault log is achieved, solving the problems of low recovery efficiency and poor accuracy in the prior art, and improving the database service time.
Patent Information
- Application Number
- CN202111529708.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-12-14
AI Technical Summary
When a node fails in a distributed database, the failure log recovery processing efficiency is low and the time is long, resulting in a reduced service time and poor accuracy.
By reading the fault page block number on each fault node in the node cluster, the target fault page block number corresponding to the current surviving node is determined, and the target page sequence number set in the surviving node is read, and the target fault log is restored according to the set.
Improves the processing efficiency of fault logs, shortens recovery time, and enhances the service duration and recovery accuracy of distributed databases.
Smart Images

Figure CN114253755B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a log processing method, device, equipment and storage medium. Background Art
[0002] When a node in a distributed database fails, the failure log on the failed node needs to be recovered.
[0003] In the related art, the fault logs on the faulty nodes are read in sequence and replayed. However, in the above method, the efficiency of restoring the fault logs is low, and the recovery process takes a long time, thereby reducing the time for the distributed database to provide services, and the accuracy is poor. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a log processing method, apparatus, device and storage medium.
[0005] In a first aspect, the present disclosure provides a log processing method, the method comprising:
[0006] Read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node;
[0007] Reading a target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster;
[0008] The target fault log corresponding to the target fault page block number is recovered according to the target page sequence number set.
[0009] In an optional implementation manner, determining the target faulty page block number to be processed corresponding to the current surviving node includes:
[0010] Calculate the block number hash value of each of the faulty page block numbers;
[0011] Calculate the node identifier corresponding to the faulty page block number according to the block number hash value of the faulty page block number;
[0012] The page block number whose node identifier is consistent with the current node identifier of the current surviving node is determined as the target fault page block number.
[0013] In an optional implementation manner, the recovering the target fault log corresponding to the target fault page block number according to the target page sequence number set includes:
[0014] Determine whether there is a latest serial number in the target page serial number set;
[0015] If the latest sequence number exists in the target page sequence number set, all target fault logs corresponding to the target fault page block number are not restored.
[0016] In an optional implementation, the method further includes:
[0017] If the latest sequence number does not exist in the target page sequence number set, obtaining the initial target fault log corresponding to the earliest sequence number in the target fault log;
[0018] Determine whether there is a historical sequence number in the target page sequence number set that is after the sequence number of the initial target fault log and before the latest sequence number;
[0019] If the historical sequence number exists in the target page sequence number set, the fault logs whose sequence numbers are after the historical sequence number in the target fault log are restored in order of sequence numbers from earliest to latest according to the historical pages of the historical sequence number;
[0020] If the historical sequence number does not exist in the target page sequence number set, the target fault logs are restored in sequence from earliest to latest according to the sequence numbers based on the initial page corresponding to the initial target fault log.
[0021] In an optional implementation, if there are multiple sequence numbers in the target page sequence number set that are after the sequence number of the initial target fault log and before the latest sequence number, the sequence number closest to the latest sequence number is determined as the historical sequence number.
[0022] In an optional implementation manner, obtaining the initial target fault log corresponding to the earliest sequence number in the target fault log includes:
[0023] Sorting the target fault logs in a first-to-last order;
[0024] The fault log that ranks first after the sorting process is determined as the initial target fault log.
[0025] In a second aspect, the present disclosure further provides a log processing device, the device comprising:
[0026] A determination module is used to read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node;
[0027] A reading module, used for reading a set of target page sequence numbers corresponding to the target fault page block number in all surviving nodes of the node cluster;
[0028] A processing module is used to recover the target fault log corresponding to the target fault page block number according to the target page sequence number set.
[0029] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the above method.
[0030] In a fourth aspect, the present disclosure provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement the above method.
[0031] In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor.
[0032] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0033] The log processing method provided by the embodiment of the present disclosure reads the fault page block number corresponding to each fault log on each fault node in the node cluster, determines the target fault page block number to be processed corresponding to the current surviving node; reads the target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster; and recovers the target fault log corresponding to the target fault page block number according to the target page sequence number set.
[0034] It can be seen that in the embodiment of the present disclosure, the surviving nodes can process the fault logs on the faulty nodes in parallel, thereby improving the processing efficiency of the fault logs, reducing the time spent on fault log recovery, and thus increasing the length of time that the distributed database can provide services. At the same time, the target fault log is recovered according to the target page sequence number set, further improving the efficiency of processing the target fault log, and because the target page sequence number set is confirmed based on all surviving nodes, the accuracy of recovering the target fault log is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 A flow chart of a log processing method provided by an embodiment of the present disclosure;
[0038] Figure 2 A flowchart of another log processing method provided by an embodiment of the present disclosure;
[0039] Figure 3 A schematic diagram of the structure of a log processing device provided by an embodiment of the present disclosure;
[0040] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0042] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0043] Figure 1 A flow chart of a log processing method provided by an embodiment of the present disclosure is provided. The method can be executed by a log processing device, wherein the device can be implemented by software and / or hardware and can generally be integrated in an electronic device.
[0044] like Figure 1 As shown, the log processing method may include:
[0045] Step 101, read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node.
[0046] A distributed database includes multiple nodes, which form a node cluster. When data in the distributed database is modified, the corresponding modification operation will be performed in the memory and a log will be generated. In the embodiment of the present disclosure, data is recorded on a data page, and the data page is marked by a page block number. The page block number of the page to which the data belongs is recorded in the generated log. When a distributed database crashes due to a database instance failure or other reasons, in order to ensure data consistency, it is necessary to process the fault log on the faulty node where the fault occurs. In the embodiment of the present disclosure, the following steps may be specifically included:
[0047] In this embodiment, the surviving nodes that have not failed in the node cluster can read each fault log on each faulty node, and parse each fault log to obtain the fault page block number involved in the fault log, thereby determining the fault page block number in the current node cluster, and determining the target fault page block number to be processed by the current surviving node from the fault page block number. Among them, the current surviving node can be any surviving node in the node cluster, so that the fault page block number to be processed by each surviving node in the node cluster can be determined, which realizes parallel processing of fault logs and improves the processing efficiency of fault logs.
[0048] In the above embodiment, there are multiple methods for determining the target fault page block number to be processed by the current surviving node from the fault page block number, which can be set according to the application scenario, etc. This embodiment is not limited, and the examples are as follows:
[0049] In an optional implementation, a first corresponding processing relationship between nodes and page block numbers can be established in advance. When a faulty node appears in the node cluster, the page block number corresponding to the faulty node in the first corresponding processing relationship is allocated to the surviving node in the node cluster, thereby obtaining a second management relationship between the surviving node and the page block number. The second management relationship is queried based on the current surviving node and the faulty page block number, thereby determining the target faulty page block number that the current surviving node manages.
[0050] In another optional implementation, the target faulty page block number to be processed by the current surviving node may be determined by calculating a hash value for the faulty page block number, which specifically includes the following steps:
[0051] Step a, calculate the block number hash value of each faulty page block number.
[0052] In this embodiment, a hash function may be used to perform hash calculation on the faulty page block number, thereby obtaining a block number hash value corresponding to each faulty page block number.
[0053] Step b: Calculate the node identifier corresponding to the faulty page block number according to the block number hash value of the faulty page block number.
[0054] After determining the block number hash value corresponding to each faulty page block number, the node identifier corresponding to each faulty page block number can be calculated based on the block number hash value, wherein the node identifier can be used to identify the surviving node that manages the faulty page. In an optional implementation, the node identifier can be the remainder of dividing the block number hash value by the number of surviving nodes.
[0055] Step c: determine the page block number whose node identifier is consistent with the current node identifier of the current surviving node as the target fault page block number.
[0056] Furthermore, the faulty page block numbers in the node cluster can be screened according to the current node identifier corresponding to the current surviving node, and the target faulty page block numbers whose node identifiers match the current node identifiers can be screened out. The number of target faulty page block numbers can be one or more, which is not limited in this embodiment.
[0057] For example, assume that there are four faulty page block numbers, namely, faulty page block number A, faulty page block number B, faulty page block number C, and faulty page block number D, and there are two surviving nodes, where the current node identifier corresponding to the current surviving node is 1. Hash calculation is performed on each faulty page block number, and the calculated hash values are divided by 2 respectively, and the remainders obtained by the division are used as the node identifier corresponding to the faulty page block number. If the node identifier of the faulty page block number A is 0, the node identifier of the faulty page block number B is 1, the node identifier of the faulty page block number C is 1, and the node identifier of the faulty page block number D is 0, then the target faulty page block numbers managed by the current surviving node are the faulty page block number B and the faulty page block number C.
[0058] Step 102: read a target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster.
[0059] In the present embodiment, the log also includes a serial number for recording the time when the log was generated. The serial number can be a logical timestamp, and the order of log generation can be determined through the serial number. In the present embodiment, there is also a corresponding page serial number for the data page. It should be noted that after the log is executed on the data page, the page serial number in the data page can be updated according to the serial number in the log. For example, assuming that the serial number of the log to be executed is 300, if the log to be executed is not executed, the page serial number of the first page is 200, and the log to be executed generates a second page, and the page serial number of the second page is updated to the serial number 300 of the log to be executed. It should be noted that in the above example, the page block numbers of the first page and the second page are the same.
[0060] When a failure occurs in a node cluster, one or more target pages with the target fault page block number may exist in the surviving nodes of the node cluster. The target page sequence numbers on the one or more target pages may be different. A target page sequence number set is established based on the target page sequence number, and then the target page sequence number set is read.
[0061] Step 103: recover the target fault log corresponding to the target fault page block number according to the target page sequence number set.
[0062] After reading the target page sequence number set, the target fault log corresponding to the target fault page block number can be restored according to the target page sequence number in the target page sequence number set. There are many methods for restoring the target fault log, which are not limited in this embodiment. Examples are as follows:
[0063] In an optional implementation, the latest serial number in the target page serial number set can be used as the base serial number, and the page corresponding to the base serial number can be used as the base page. Based on the base page, the fault logs with serial numbers after the base serial number in the target fault log are executed in order from first to last. For example, if the serial number is generated incrementally, the target page serial number set includes 250, 200, and 100, and the target fault log includes fault logs with serial numbers of 100, 300, 360, and 400, then the serial number 250 is determined as the base serial number, and based on the page corresponding to the serial number 250, the target fault logs with serial numbers of 300, 360, and 400 are executed in order.
[0064] After the current surviving node completes the recovery processing of the target fault log, it can send a processing completion notification to other surviving nodes in the node cluster. If all surviving nodes that process the fault log in the node cluster have sent a processing completion notification, it means that the recovery processing of the fault log has been completed in the node cluster.
[0065] The log processing method provided by the embodiment of the present disclosure reads the fault page block number corresponding to each fault log on each faulty node in the node cluster, determines the target fault page block number to be processed corresponding to the current surviving node; reads the target page sequence number set corresponding to the target fault page block number in all surviving nodes in the node cluster; and recovers the target fault log corresponding to the target fault page block number according to the target page sequence number set. It can be seen that in the embodiment of the present disclosure, the surviving nodes can process the fault logs on the faulty nodes in parallel, thereby improving the processing efficiency of the fault logs, reducing the time spent on fault log recovery, and thus increasing the length of time that the distributed database can provide services. At the same time, the target fault log is recovered according to the target page sequence number set, which further improves the efficiency of processing the target fault log, and because the target page sequence number set is confirmed based on all surviving nodes, the accuracy of recovering the target fault log is improved.
[0066] Based on the above embodiments, Figure 2 A flow chart of another log processing method provided by the embodiment of the present disclosure is as follows: Figure 2 As shown, the recovery process of the target fault log corresponding to the target fault page block number according to the target page sequence number set includes:
[0067] Step 201, determine whether there is a latest sequence number in the target page sequence number set.
[0068] In this embodiment, the latest sequence number is the latest sequence number generated in the node cluster, and the target page sequence number set can be searched according to the latest sequence number to determine whether the target page sequence number set contains the latest sequence number.
[0069] Step 202: If the latest sequence number exists in the target page sequence number set, all target fault logs corresponding to the target fault page block number are not restored.
[0070] If the latest sequence number exists in the target page sequence number set, it means that there is a data page in the surviving node that is considered valid by the node cluster and has the target fault page block number. Therefore, all target fault logs corresponding to the target fault page block number are not recovered.
[0071] For example, if the latest sequence number in the node cluster is 360, and the target page sequence number set includes 360, then all target fault logs corresponding to the target fault page block number will not be recovered.
[0072] Step 203: If the latest sequence number does not exist in the target page sequence number set, obtain the initial target fault log corresponding to the earliest sequence number in the target fault log.
[0073] If the latest sequence number does not exist in the target page sequence number set, the initial target fault log corresponding to the earliest sequence number in the target fault log can be obtained. The initial target fault log is the earliest fault log generated in the target fault log. There are many ways to determine the initial target fault log, which is not limited in this embodiment. Examples are as follows:
[0074] In an optional implementation manner, the initial target fault log may be determined by sorting the target fault logs, which specifically includes the following steps:
[0075] Step a: sort the target fault logs in order from first to last.
[0076] In this embodiment, the target fault logs may be sorted from first to last according to the generation order of the sequence numbers. For example, if the sequence numbers are generated in ascending order, the target fault logs may be sorted in the ascending order of the sequence numbers.
[0077] In an optional implementation, the target fault logs may be stored in a linked list, and the target fault logs in the linked list may be sorted in the order in which the serial numbers are generated from the earliest to the latest.
[0078] Step b: determining the fault log that ranks first after sorting as the initial target fault log.
[0079] It can be understood that after the target fault logs are sorted, the first one is the earliest generated one among the target fault logs, and thus the first fault log can be determined as the initial target fault log.
[0080] Step 204 , determining whether there is a historical sequence number in the target page sequence number set that is after the sequence number of the initial target fault log and before the latest sequence number.
[0081] In this embodiment, the historical serial number is a serial number determined from the target page serial number set, and the historical serial number is a serial number located after the serial number of the initial target fault log and before the latest serial number, and it is determined whether there is a historical serial number that meets the above conditions in the target page serial number set.
[0082] For example, if the sequence number is generated incrementally and the latest sequence number is 360, the sequence number of the initial target fault log is 150, and the sequence numbers in the target page sequence number set are 200 and 100, of which 200 is less than 360 and greater than 150, so 200 can be determined as the historical sequence number. In the above example, if the sequence numbers in the target page sequence number set are 50 and 100, since both 50 and 100 are less than 150, there is no historical sequence number in the target page sequence number set.
[0083] In some application scenarios, if there are multiple sequence numbers in the target page sequence number set that are after the sequence number of the initial target fault log and before the latest sequence number, the sequence number closest to the latest sequence number is determined as the historical sequence number.
[0084] Taking the generation of serial numbers in increments as an example, if there are multiple serial numbers after the serial number of the initial target fault log and before the latest serial number, the serial number with the smallest difference from the latest serial number in the target page serial number set can be used as the historical serial number. For example, if the latest serial number is 360, the serial number of the initial target fault log is 150, and the serial numbers in the target page serial number set are 250 and 200, where 250 and 200 are both smaller than the latest serial number 360 and larger than the serial number 150 of the initial target fault log, then 250 with the smallest difference from 360 is used as the historical serial number.
[0085] Step 205 , if there is a historical sequence number in the target page sequence number set, the fault logs whose sequence numbers are after the historical sequence number in the target fault log are restored in order of sequence numbers from first to last according to the historical pages of the historical sequence number.
[0086] If there is a historical sequence number in the target page sequence number set, the historical page with the historical sequence number can be read, and based on the historical page, the fault logs in the target fault log that are located after the historical sequence number can be restored in order from first to last.
[0087] For example, if the serial number is generated incrementally and the historical serial number is 200, the serial numbers in the target fault log include: 100, 150, 250, 360, then the target fault log with serial number 250 and the target fault log with serial number 360 are executed in sequence according to the historical page with historical serial number 200.
[0088] Step 206 , if there is no historical sequence number in the target page sequence number set, the target fault logs are restored in sequence from earliest to latest sequence number according to the initial page corresponding to the initial target fault log.
[0089] If there is no historical sequence number in the target page sequence number set, the initial page corresponding to the initial target fault log can be read, and the target fault log can be restored in order from the first to the last based on the initial page.
[0090] For example, if the serial number is generated incrementally and there is no historical serial number in the target page serial number set, the serial numbers in the target fault log include: 100, 150, 250, 360, where the serial number corresponding to the initial fault log is 100, the initial page corresponding to 100 is read, and according to the initial page, the target fault log with serial number 100, the target fault log with serial number 150, the target fault log with serial number 250 and the target fault log with serial number 360 are executed in sequence.
[0091] The log processing method provided by the embodiment of the present disclosure can appropriately reduce the number of target fault logs to be recovered, thereby improving the recovery efficiency of faulty nodes, shortening the recovery time of faulty nodes, and increasing the time that a distributed database can provide services.
[0092] Figure 3 This is a schematic diagram of the structure of a log processing device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 3 As shown, the log processing device 300 may include:
[0093] Determination module 301, used to read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node;
[0094] A reading module 302 is used to read a target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster;
[0095] The processing module 303 is used to perform recovery processing on the target fault log corresponding to the target fault page block number according to the target page sequence number set.
[0096] Optionally, the determining module 301 is used to:
[0097] Calculate the block number hash value of each of the faulty page block numbers;
[0098] Calculate the node identifier corresponding to the faulty page block number according to the block number hash value of the faulty page block number;
[0099] The page block number whose node identifier is consistent with the current node identifier of the current surviving node is determined as the target fault page block number.
[0100] Optionally, the processing module 303 includes:
[0101] A first judgment unit, used to judge whether there is a latest sequence number in the target page sequence number set;
[0102] The first processing unit is configured to not perform recovery processing on all target fault logs corresponding to the target fault page block number if the latest sequence number exists in the target page sequence number set.
[0103] Optionally, the processing module 303 further includes:
[0104] an acquiring unit, configured to acquire an initial target fault log corresponding to an earliest sequence number in the target fault log if the latest sequence number does not exist in the target page sequence number set;
[0105] A second judgment unit is used to judge whether there is a historical sequence number located after the sequence number of the initial target fault log and before the latest sequence number in the target page sequence number set;
[0106] A second processing unit is configured to, if the target page sequence number set contains the historical sequence number, restore the fault logs whose sequence numbers are after the historical sequence number in the target fault log in order of sequence numbers from earliest to latest according to the historical pages of the historical sequence number;
[0107] The third processing unit is used to restore the target fault log in sequence from the earliest to the latest sequence number according to the initial page corresponding to the initial target fault log if the historical sequence number does not exist in the target page sequence number set.
[0108] Optionally, if there are multiple sequence numbers in the target page sequence number set that are located after the sequence number of the initial target fault log and before the latest sequence number, the sequence number closest to the latest sequence number is determined as the historical sequence number.
[0109] Optionally, the acquiring unit is used to:
[0110] Sorting the target fault logs in a first-to-last order;
[0111] The fault log that ranks first after the sorting process is determined as the initial target fault log.
[0112] The log processing device provided in the embodiments of the present disclosure can execute the log processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0113] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the log processing method described in the embodiments of the present disclosure.
[0114] The embodiments of the present disclosure also provide a computer program product, including a computer program / instruction, which implements the log processing method provided by any embodiment of the present disclosure when the computer program / instruction is executed by a processor.
[0115] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0116] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure.
[0117] The following specific reference Figure 4 , which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present disclosure. The electronic device 400 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0118] like Figure 4 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0119] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0120] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains 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 through a communication device 409, or installed from a storage device 408, or installed from a ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the log processing method of the embodiment of the present disclosure are executed.
[0121] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0122] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0123] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0124] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: reads the fault page block number corresponding to each fault log on each fault node in the node cluster, and determines the target fault page block number to be processed corresponding to the current surviving node; reads the target page sequence number set corresponding to the target fault page block number in all surviving nodes in the node cluster; and recovers the target fault log corresponding to the target fault page block number according to the target page sequence number set. It can be seen that in the embodiment of the present disclosure, the surviving nodes can process the fault logs on the faulty nodes in parallel, thereby improving the processing efficiency of the fault logs, reducing the time spent on fault log recovery, and thus improving the length of time that the distributed database can provide services. At the same time, the target fault log is recovered according to the target page sequence number set, which further improves the efficiency of processing the target fault log, and because the target page sequence number set is confirmed based on all surviving nodes, the accuracy of recovering the target fault log is improved.
[0125] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0126] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0127] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0128] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0129] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0130] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0131] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0132] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0133] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0134] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A log processing method, characterized in that: The following steps are involved: Read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node; wherein the fault page block number is used to mark the data page involved in the fault log; Reading a target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster; wherein the target page sequence number set is established according to the target page sequence number on the target page, and the target page sequence number is updated according to the sequence number of the log executed on the target page; The target fault log corresponding to the target fault page block number is restored according to the target page sequence number set; wherein the restoration process is a playback process.
2. The method according to claim 1, characterized in that The step of determining the target fault page block number to be processed corresponding to the current surviving node includes: Calculate the block number hash value of each of the faulty page block numbers; Calculate the node identifier corresponding to the faulty page block number according to the block number hash value of the faulty page block number; The page block number whose node identifier is consistent with the current node identifier of the current surviving node is determined as the target fault page block number.
3. The method according to claim 1, characterized in that The recovering process of the target fault log corresponding to the target fault page block number according to the target page sequence number set includes: Determine whether there is a latest serial number in the target page serial number set; If the latest sequence number exists in the target page sequence number set, all target fault logs corresponding to the target fault page block number are not restored.
4. The method according to claim 3, characterized in that Also includes: If the latest sequence number does not exist in the target page sequence number set, obtaining the initial target fault log corresponding to the earliest sequence number in the target fault log; Determine whether there is a historical sequence number in the target page sequence number set that is after the sequence number of the initial target fault log and before the latest sequence number; If the historical sequence number exists in the target page sequence number set, the fault logs whose sequence numbers are after the historical sequence number in the target fault log are restored in order of sequence numbers from earliest to latest according to the historical pages of the historical sequence number; If the historical sequence number does not exist in the target page sequence number set, the target fault logs are restored in sequence from earliest to latest according to the sequence numbers based on the initial page corresponding to the initial target fault log.
5. The method according to claim 4, characterized in that: If there are multiple sequence numbers in the target page sequence number set that are located after the sequence number of the initial target fault log and before the latest sequence number, the sequence number closest to the latest sequence number is determined as the historical sequence number.
6. The method according to claim 4, characterized in that The obtaining the initial target fault log corresponding to the earliest sequence number in the target fault log includes: Sorting the target fault logs in a first-to-last order; The fault log that ranks first after the sorting process is determined as the initial target fault log.
7. A log processing device, characterized in that: The device comprises: A determination module is used to read the fault page block number corresponding to each fault log on each faulty node in the node cluster, and determine the target fault page block number to be processed corresponding to the current surviving node; wherein the fault page block number is used to mark the data page involved in the fault log; A reading module, used for reading a target page sequence number set corresponding to the target fault page block number in all surviving nodes of the node cluster; wherein the target page sequence number set is established according to the target page sequence number on the target page, and the target page sequence number is updated according to the sequence number of the log executed on the target page; A processing module is used to perform recovery processing on the target fault log corresponding to the target fault page block number according to the target page sequence number set; wherein the recovery processing is a playback processing.
8. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the log processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the log processing method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the log processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Multi-copy data recovery method and device
CN108228678A
Database cluster network partition selection method and device
CN112181305A