Processing method, device, electronic device and storage medium for archival data recovery
By obtaining the block height range of archived data and migrating it to an online database, the problem of low accuracy of archived data recovery in the existing technology is solved, and efficient and accurate archived data recovery and blockchain data query are achieved.
Patent Information
- Application Number
- CN202011252867.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-11
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-11-11
AI Technical Summary
The processing accuracy of archived data recovery in the existing technology is low, mainly because backup files are easily tampered with or lost, resulting in inaccurate data recovery.
By obtaining the block height range of archived data to be restored, if the block number is within this range, the block will be migrated to the online database of the archive recovery node. If the block number is out of bounds, the transaction log data will be migrated to the online database. , ensuring the accuracy of data recovery.
It achieves efficient and accurate archived data recovery, avoids the problem of incorrect block location or unsuccessful recovery of part of the data, and reduces the pressure of blockchain data storage query.
Smart Images

Figure CN112328433B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a processing method, device, electronic device and storage medium for archived data recovery. Background Art
[0002] With the continuous expansion of blockchain business, the complexity of business is constantly increasing, which also causes the continuous increase of data stored on the chain. For blockchain, older blocks are less likely to be read. Therefore, it is necessary to archive data and transfer archived data to a lower-cost infrastructure. However, after the data is transferred, a method for externally recovering and querying archived data is still required. In related technologies, data file recovery under archived data usually relies on a backup file to restore operations after the backup; for example, the archive mode relies on archive log files, which are put into the databuffer cache using arc and then written to restore; however, backup files such as archive logs are easily tampered with or lost, resulting in low accuracy in the processing of archived data recovery.
[0003] Currently, no effective solution has been proposed for the problem of low processing accuracy of archived data recovery in related technologies. Summary of the invention
[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for processing archived data recovery, so as to at least solve the problem of low processing accuracy of archived data recovery in the related art.
[0005] In a first aspect, an embodiment of the present application provides a method for processing archived data recovery, the method comprising:
[0006] Get the block height range of the archived data to be restored;
[0007] If the block number of the archived data is within the block height range, restore the migration data of the block corresponding to the block number to the online database of the archive recovery node;
[0008] If the block number is outside the block height range, the transaction log data of the block corresponding to the block number is migrated to the online database.
[0009] In some embodiments, before obtaining the block height range of the archived data to be restored, the method further includes:
[0010] receiving archive recovery requests;
[0011] If the first genesis block number of the archive recovery node in the archive recovery request is 0, the state data of the blockchain is replaced with the snapshot database of the block height specified in the archive recovery request.
[0012] In some embodiments, after receiving the archive recovery request, the method further includes:
[0013] If the first genesis block number is not 0, comparing the first genesis block number with the highest block number of the archived data;
[0014] According to the comparison result, it is determined whether to reject the archive recovery request.
[0015] In some embodiments, restoring the migration data of the block corresponding to the block number to the online database of the archive recovery node includes:
[0016] The migration data is restored, and key-value pair data is written to the online database; wherein the key-value pair data includes a preset character string and the restored block number.
[0017] In some embodiments, after migrating the transaction log data of the block corresponding to the block number to the online database, the method further includes:
[0018] In the case of entering the abnormal recovery process, if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node, delete the data corresponding to the migration information;
[0019] When the block number corresponding to the preset string is within the block height range, traverse the preset string within the genesis height of the archive recovery node;
[0020] If the block number corresponding to the traversed preset string is greater than the end block number of the archive recovery node, the transaction information, block index and the preset string are deleted.
[0021] In some embodiments, when entering the abnormal recovery process, if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node, before deleting the data corresponding to the migration information, the method further includes:
[0022] receiving archive recovery requests;
[0023] When the first genesis block number is equal to the second genesis block number on the current chain, the preset character string is compared with the boundary value of the block height range; and according to the comparison result, it is determined whether to enter the abnormal recovery process; or,
[0024] When the first genesis block number is greater than the second genesis block number, the abnormal recovery process is entered.
[0025] In some embodiments, if the block number is within the block height range, the method further includes:
[0026] Migrating illegal transactions stored in the archive data to the archive recovery node.
[0027] In some embodiments, after migrating the transaction log data of the block corresponding to the block number to the online database, the method further includes:
[0028] Update the record metadata of the archive recovery node.
[0029] In some of the embodiments, the archive recovery node is also used to provide a data query interface.
[0030] In a second aspect, an embodiment of the present application provides a processing device for archived data recovery, the device comprising: an acquisition module, a first recovery module and a second recovery module;
[0031] The acquisition module is used to acquire the block height range of the archived data to be restored;
[0032] The first recovery module is used to restore the migration data of the block corresponding to the block number to the online database of the archive recovery node if the block number of the archive data is within the block height range;
[0033] The second recovery module is used to migrate the transaction log data of the block corresponding to the block number to the online database if the block number is outside the block height range.
[0034] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the processing method for archived data recovery as described in the first aspect above is implemented.
[0035] In a fourth aspect, an embodiment of the present application provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the processing method for archived data recovery as described in the first aspect above is implemented.
[0036] Compared with the related art, the processing method, device, electronic device and storage medium for archived data recovery provided in the embodiments of the present application obtain the block height range of the archived data to be recovered; if the block number of the archived data is within the block height range, the migration data of the block corresponding to the block number is restored to the online database of the archive recovery node; if the block number is outside the block height range, the transaction log data of the block corresponding to the block number is migrated to the online database, thereby solving the problem of processing accuracy of archived data recovery and realizing efficient and accurate archived data recovery. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] 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:
[0038] Figure 1 A schematic diagram of an application scenario of archived data recovery processing according to an embodiment of the present application;
[0039] Figure 2 A flowchart of an archived data recovery processing method according to an embodiment of the present application;
[0040] Figure 3 is a flowchart of another archived data recovery processing method according to an embodiment of the present application;
[0041] Figure 4 is a flowchart of another archived data recovery processing method according to an embodiment of the present application;
[0042] Figure 5 It is a flowchart of an abnormal recovery processing method according to a preferred embodiment of the present application;
[0043] Figure 6 It is a flowchart of an archived data recovery processing method according to a preferred embodiment of the present application;
[0044] Figure 7 is a structural block diagram of an archived data recovery processing device according to an embodiment of the present application;
[0045] Figure 8 is a structural block diagram of another archived data recovery processing device according to an embodiment of the present application;
[0046] Fig. 9 The present invention is a structural diagram of the interior of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for ordinary technicians in the field related to the contents disclosed in the present application, some changes such as design, manufacturing or production based on the technical contents disclosed in the present application are only conventional technical means, and should not be understood as insufficient contents disclosed in the present application.
[0048] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0049] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application means greater than or equal to two. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The terms "first", "second", "third" and the like involved in the present application are merely used to distinguish similar objects and do not represent a specific ordering of the objects.
[0050] In this embodiment, an application scenario of archived data recovery processing is provided. Figure 1Schematic diagram of an application scenario of archived data recovery processing according to an embodiment of the present application, such as Figure 1 As shown, the blockchain network 102 and the server 104 communicate through a network, which may include a local area network (LAN), a wide area network (WAN), the Internet, or a combination thereof, and is connected to a website, a user device (such as a computing device), and a back-end system. The server 104 obtains the archived data and compares the block number of the archived data with the block height range of the archived data to be restored, and then restores the archived data to the archive recovery node. Optionally, the server 104 can be a node of a cloud computing system (not shown in the figure), or each server 104 can be a separate cloud computing system, including multiple computers interconnected by a network and working as a distributed processing system. The server 104 can run any appropriate computing system that enables it to serve as a node in the blockchain network 102.
[0051] In this embodiment, a processing method for restoring archived data is provided. Figure 2 is a flowchart of an archived data recovery processing method according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0052] Step S202, obtaining the block height range of the archived data to be restored, wherein the starting block number in the archived data is obtained according to the snapshot of the archived data, and the block height range from the starting block number to the block height specified by the user is the block height range of the archived data to be restored this time.
[0053] Step S204, if the block number of the archived data is within the block height range, restore the migration data of the block corresponding to the block number to the online database of the archive recovery node. The block height range of this archive recovery and all transactions in each archived block are traversed, and each block is used as an atomic unit to restore the migration data corresponding to the block number of the traversal number to the online database of the archive recovery node. The migration data includes transaction index, transaction receipt index, block index, transaction operation log information, etc.
[0054] It should be noted that the archive recovery node can be a node on the blockchain or an archive query. After the archive data recovery process is completed, the archive recovery node can also provide various blockchain data query interfaces, such as transaction, transaction receipt, blockchain status data query interfaces, so that users can easily query the restored archive data from the chain.
[0055] Step S206, if the block number is outside the block height range, migrate the transaction log data of the block data corresponding to the block number to the online database. Wherein, repeat the above step S204 until the restored block number exceeds the block height range of the above archive recovery, then migrate the blocks and transaction log data in the Filelog database, and migrate to the online database of the archive recovery node. It should be noted that if the restored block number is within the block height range, migrate the illegal transactions of the archive data stored in the snapshot database, and restore the illegal transactions to the archive recovery node; wherein, the illegal transactions refer to abnormal transactions in the archive data.
[0056] After the above step S206 is executed, the record metadata in the archive recovery node is updated; wherein the record metadata includes Genesis information, online and offline transaction statistics, and receipt statistics information, thereby completing the archive data recovery process.
[0057] In the related art, backup files are usually required in the archive data recovery process, resulting in low accuracy of the archive data recovery process; however, the embodiment of the present application obtains the block height range of the archive data to be restored through the above steps S202 to S206, and compares the block number of the archive data with the block height range, and then migrates the blocks, transaction logs, transaction receipts and other data within the block height range of this archive recovery to the online database of the archive recovery node, so that the archive recovery node can archive and restore each part of the blockchain data within the specified range in turn, effectively avoiding the occurrence of errors in the archive data recovery block position or the failure to successfully restore some data, thereby solving the problem of archive data recovery processing accuracy and achieving efficient and accurate archive data recovery; at the same time, through the archive recovery node, it can be ensured that when the online data has been archived, the relevant blockchain historical data query can still be performed, effectively reducing the storage query pressure of blockchain data.
[0058] In some embodiments, a method for restoring archived data is provided. Figure 3 FIG. 1 is a flowchart of another archived data recovery processing method according to an embodiment of the present application. Figure 3 As shown, the process includes the following steps:
[0059] Step S302, receiving an archive recovery request; wherein the archive recovery request may be input by a user, and the archive recovery status also includes a specified block height set by the user, and a state database snapshot where the user-specified block height is less than or equal to the current block height, and the snapshot is the latest state data after the archive recovery.
[0060] Step S304, if the first genesis block number of the archive recovery node in the archive recovery request is 0, the state data of the blockchain is replaced with the snapshot database of the specified block height in the archive recovery request. It should be noted that the state data of the blockchain refers to the data in the blockchain itself other than the block data, including data such as smart contracts. Among them, the specified block height is compared with the current block, that is, the first genesis block number of the archive recovery node. It should be noted that during the archive data recovery process, the first genesis block number may change; for example, after the block data with block numbers 0 to 50 are recovered, the first genesis block number will change from 0 to 50 in sequence; therefore, if the current first genesis block number is 0, it means that the archive data has not been restored to the archive recovery node, and the snapshot database of the specified block height queried needs to be directly replaced with the online blockchain state data.
[0061] In some embodiments, after receiving the archive recovery request, the archive data recovery processing method further includes the following steps: if the first genesis block number is not 0, compare the first genesis block number with the highest block number of the archive data; and determine whether to reject the archive recovery request based on the comparison result. Among them, when the block height of the archive recovery node, that is, the first genesis block number is not equal to 0, it is necessary to compare whether the currently specified archive recovery is equal to the genesis block number of the archive recovery. If they are not equal, the request is rejected. If they are equal, the execution process of replacing the blockchain state data in the above step S304 is skipped.
[0062] Through the above steps S302 to S304, the specified block height in the archive recovery request is compared with the current first block genesis number. If the first genesis block number is 0, the snapshot database is directly replaced with the blockchain state number, thereby restoring the block data in the archive data; and the first genesis block number is first judged, so that the archive data recovery status can be detected in advance, avoiding repeated recovery of the archive data, which is beneficial to effectively improve the efficiency of archive data recovery while ensuring the accuracy of archive data recovery.
[0063] In some embodiments, restoring the migration data of the block corresponding to the block number to the archive recovery node also includes the following steps: restoring the migration data and writing key-value pair data on the online database; wherein the key-value pair data includes a preset string and the restored block number. It should be noted that in the archive data recovery process, each time the migration data in a block is restored, a key-value pair consisting of a preset string and the current block number is written to the online database of the archive recovery node, and while traversing the block to read the data, the number of restored transactions and the number of receipts are counted. It can be understood that the preset string can be a pre-set string used to represent the restored data, for example, the preset string is set to "RestoreNumber".
[0064] Through the above embodiment, after each block's migration data is restored, the key-value pair data recording the current block number is written into the online database, thereby recording the currently restored block number in real time, facilitating block query and recovery status detection in subsequent recovery processes, and further improving the accuracy of archived data recovery processing.
[0065] In some embodiments, a method for processing archived data recovery is provided. Figure 4 FIG. 1 is a flowchart of another archived data recovery processing method according to an embodiment of the present application. Figure 4 As shown, the process includes the following steps:
[0066] Step S402, when entering the abnormal recovery process, if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node, delete the data corresponding to the migration information.
[0067] If the archive recovery process exits abnormally, it will enter the abnormal recovery process when it is restarted. It should be noted that the migration information includes information such as transaction logs and blocks in the archive data; for example, if the starting block number of the transaction log is equal to the first genesis block number, the transaction log data within the block height range is deleted; or, if the starting block number is equal to the first genesis block number, the block data within the block height range is deleted.
[0068] Step S404, when the block number corresponding to the preset string is within the block height range, the preset string is traversed within the genesis height of the archive recovery node, wherein the block number corresponding to the preset string is compared with the boundary value of the block number range of this archive recovery.
[0069] Step S406: If the block number corresponding to the preset string traversed is greater than the end block number of the archive recovery node, delete the transaction information, block index and the preset string. When the traversed block number is greater than the end block number, all transaction indexes, transaction receipt indexes and block indexes within the range from the preset string to the end block number of this archive recovery service are deleted from the online database of the archive recovery node; after the deletion is completed, delete the key-value pair of "RestoreNumber" in the online database.
[0070] Through the above steps S402 to S406, when entering the abnormal recovery process, the starting block number of the migration information is compared with the first genesis block number, and the block number corresponding to the preset string is compared with the block height range, and the corresponding deletion operation is performed according to the results of each comparison, thereby avoiding the phenomenon of data recovery confusion caused by abnormal exit and inability to process during the archive data recovery process, and effectively improving the accuracy and efficiency of the archive data recovery process.
[0071] In some of these embodiments, before entering the abnormal recovery mode, the process further includes the following steps: receiving an archive recovery request;
[0072] When the first genesis block number is equal to the second genesis block number on the current chain, the preset character string is compared with the boundary value of the block height range; based on the comparison result, it is determined whether to enter the abnormal recovery process.
[0073] Among them, for the case where the genesis block number in the block database of the archive recovery node is equal to the second genesis block number on the current chain, the block number corresponding to the preset string is compared with the boundary value of the block number range of this archive recovery: It should be noted that the above-mentioned online database includes the state database and the block database. If the preset string does not exist, there is no need to enter the abnormal recovery process; if the block number corresponding to the preset string is equal to the starting point of the range of this archive recovery, it means that the last archive recovery service did not occur and no abnormal recovery is required; if the preset string is equal to the last block number of this archive service, it means that the archive recovery service is completed and there is no need to enter the abnormal recovery process again; if the preset string is between the block number range of this archive recovery service, it means that the archive recovery service is not completed, so enter the abnormal recovery process.
[0074] Alternatively, when the first genesis block number is greater than the second genesis block number, the abnormal recovery process is entered. Wherein, if the first genesis block number in the block data in the archive recovery node is greater than the second genesis block number on the chain in the current archive recovery node, the abnormal recovery process is entered, and then the abnormal recovery data is deleted and processed; for example, the genesis block number in the transaction log data is compared with the genesis height on the archive recovery node, and the block database, transaction receipt database, and transaction operation database are restored to the end block number of this archive recovery. If the above data is successfully restored, the preset string is read, and various index data within the range from the starting point of this archive recovery range to the preset string is deleted; finally, the preset string key-value pair is directly deleted from the online database of the archive recovery node.
[0075] Through the above embodiments, different processing operations are performed for different comparison results of the first genesis block number and the second genesis block number on the current chain, so that the archive recovery node compares the genesis block number in the block database with the genesis block number on the current chain to analyze whether the archive process before this startup is in an abnormal state, so as to judge in advance whether it is necessary to enter the abnormal recovery process, thereby avoiding untimely detection of abnormal recovery situations and further improving the accuracy and efficiency of archive data recovery processing.
[0076] The abnormal recovery processing method in the embodiment of the present application is described and illustrated below through a preferred embodiment. Figure 5 The following is a flowchart of an abnormality recovery processing method according to a preferred embodiment of the present application. The abnormality recovery processing method includes the following steps:
[0077] Step S502, start the abnormal recovery process, determine whether the starting block number of the transaction log is equal to the first genesis block number, if so, delete the transaction log data within the block height range; otherwise, end the abnormal recovery process.
[0078] Step S504, determine whether the starting block number of the block is equal to the first genesis block number, if so, delete the block data within the block height range; otherwise, end the abnormal recovery process.
[0079] Step S506, determine whether the value of a preset string, such as RestoreNumber, is within the range of this archive recovery; if so, traverse RestoreNumber to the archive recovery node creation height; otherwise, end the abnormal recovery process.
[0080] Step S508, determine whether the traversed block number is greater than the end block number of the archive recovery range. If so, delete the transaction receipt, transaction index and block index within the block height range; otherwise, re-determine the traversed block number.
[0081] Step S510, delete the RestoreNumber key-value pair and end the abnormal recovery process; wherein the RestoreNumber key-value pair is a key-value pair data consisting of the RestoreNumber string and the current block number; after the abnormal recovery process is completed, continue to repeat the archive data recovery processing process to complete the blockchain archive recovery.
[0082] The following describes the embodiments of the present application in detail in combination with actual application scenarios. Figure 6 FIG. 1 is a flowchart of an archived data recovery method according to a preferred embodiment of the present application. The specific implementation steps of the archived data recovery method are as follows: Figure 6 shown.
[0083] Step S602, start this processing flow; determine whether the first genesis block number of the archive recovery node is 0, if so, replace the state database of the archive recovery node with the snapshot database.
[0084] Step S604, if the result of step S602 is no, further determine whether the first genesis block number is equal to the highest block number of the offline archive database. If so, continue the subsequent processing flow; if not, end the current processing flow.
[0085] Step S606, determine whether the recovery block number is within the block height range.
[0086] Step S608: If the result of step S606 is yes, the transaction index, transaction receipt and block index are migrated, and a key-value pair consisting of a preset string RestoreNumber and the current block number is written; step S606 is repeated until the restored blockchain exceeds the block height range of the above-mentioned archive recovery.
[0087] Step S610: If the result of step S606 is no, the blocks and transaction log numbers in Filelog are migrated, and the archive metadata file is updated, and then the processing flow ends.
[0088] It should be noted that in the embodiment of the present application, after restoring the state database, it is necessary to restore the archived off-chain block data, transaction receipt data, illegal transaction data and related index data, and migrate them from the offline archive database to the online database of the archive reading node. This process involves data migration of multiple underlying databases, so it is necessary to ensure atomic security across data and abnormal recovery solutions, support recovery queries to restore any previously archived data in the archive reading node, and provide archive data query functions.
[0089] It should be understood that although Figures 2 to 6The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figures 2 to 6 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0090] In this embodiment, a processing device for archived data recovery is provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "module", "unit", "subunit", etc. can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0091] Figure 7 FIG. 1 is a structural block diagram of an archived data recovery processing device according to an embodiment of the present application, such as Figure 7 As shown, the device includes: an acquisition module 72, a recovery module 74 and a migration module 76.
[0092] The acquisition module 72 is used to obtain the block height range of the archived data to be restored; the first recovery module 74 is used to restore the migration data of the block corresponding to the block number to the online database of the archive recovery node if the block number of the archived data is within the block height range; the second recovery module 76 is used to migrate the transaction log data of the block corresponding to the block number to the online database if the block number is outside the block height range.
[0093] Through the above embodiment, the block height range of the archived data to be restored is obtained through the acquisition module 72, and the block number of the archived data is compared with the block height range through the first recovery module 74 and the second recovery module 76, and then the blocks, transaction logs, transaction receipts and other data within the block height range of this archive recovery are migrated to the online database of the archive recovery node, so that the archive recovery node can archive and restore each part of the blockchain data within the specified range in turn, effectively avoiding the occurrence of errors in the position of the archived data recovery block, or the phenomenon that some data are not successfully restored, thereby solving the problem of processing accuracy of archived data recovery and realizing efficient and accurate archived data recovery; at the same time, through the archive recovery node, it can be ensured that when the online data has been archived, the relevant blockchain historical data query can still be performed, which effectively reduces the storage query pressure of blockchain data.
[0094] Figure 8 FIG. 1 is a structural block diagram of another archived data recovery processing device according to an embodiment of the present application. Figure 8 As shown, the device comprises Figure 7 All modules shown also include: a request module 82 and a replacement module 84; the request module 82 is used to receive an archive recovery request; the replacement module 84 is used to replace the status data of the blockchain with a snapshot database of the block height specified in the archive recovery request if the first genesis block number of the archive recovery node in the archive recovery request is 0.
[0095] In some embodiments, the processing device also includes a comparison module; the comparison module is used to compare the first genesis block number with the highest block number of the archived data if the first genesis block number is not 0; the comparison module determines whether to reject the archive recovery request based on the comparison result.
[0096] In some embodiments, the first recovery module 74 is further used to recover the migration data and write key-value pair data on the online database; wherein the key-value pair data includes a preset string and the recovered block number.
[0097] In some embodiments, the processing device also includes an exception recovery module; the exception recovery module is used to, when entering an exception recovery process, delete the data corresponding to the migration information if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node; the exception recovery module traverses the preset string within the genesis height of the archive recovery node when the block number corresponding to the preset string is within the block height range; if the block number corresponding to the traversed preset string is greater than the end block number of the archive recovery node, the exception recovery module deletes the transaction information, block index and the preset string.
[0098] In some of the embodiments, the exception recovery module is also used to receive an archive recovery request; the exception recovery module compares the preset string with the boundary value of the block height range when the first genesis block number is equal to the second genesis block number on the current chain; the exception recovery module determines whether to enter the exception recovery process based on the comparison result; or, the exception recovery module enters the exception recovery process when the first genesis block number is greater than the second genesis block number.
[0099] In some of the embodiments, the processing device further includes a migration module; the migration module is used to migrate the illegal transactions stored in the archived data to the archive recovery node.
[0100] In some of the embodiments, the processing device further includes an update module; the update module is used to update the record metadata of the archive recovery node.
[0101] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0102] In this embodiment, a computer device is provided, which may be a server. Fig. 9 is a structural diagram of the inside of a computer device according to an embodiment of the present application, such as Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store archived data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above-mentioned processing method for recovering archived data is implemented.
[0103] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0104] This embodiment further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0105] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0106] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0107] S1, obtain the block height range of the archived data to be restored.
[0108] S2: If the block number of the archived data is within the block height range, restore the migration data of the block corresponding to the block number to the online database of the archive recovery node.
[0109] S3: If the block number is outside the block height range, migrate the transaction log data of the block corresponding to the block number to the online database.
[0110] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0111] In addition, in combination with the processing method for archived data recovery in the above embodiments, the present application embodiment can provide a storage medium for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, any one of the processing methods for archived data recovery in the above embodiments is implemented.
[0112] Those skilled in the art should understand that the technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0113] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A processing method for archived data recovery, characterized in that: The method comprises: Get the block height range of the archived data to be restored; If the block number of the archived data is within the block height range, restoring the migration data of the block corresponding to the block number to the online database of the archive recovery node includes: Restoring the migration data, and writing key-value pair data on the online database; wherein the key-value pair data includes a preset string and the restored block number; If the block number is outside the block height range, migrate the transaction log data of the block corresponding to the block number to the online database; In the case of entering the abnormal recovery process, if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node, delete the data corresponding to the migration information; When the block number corresponding to the preset string is within the block height range, traverse the preset string within the genesis height of the archive recovery node; If the block number corresponding to the traversed preset string is greater than the end block number of the archive recovery node, the transaction information, block index and the preset string are deleted.
2. The processing method according to claim 1, characterized in that: Before obtaining the block height range of the archived data to be restored, the method further includes: receiving archive recovery requests; If the first genesis block number of the archive recovery node in the archive recovery request is 0, the state data of the blockchain is replaced with the snapshot database of the block height specified in the archive recovery request.
3. The processing method according to claim 2, characterized in that: After receiving the archive recovery request, the method further includes: If the first genesis block number is not 0, comparing the first genesis block number with the highest block number of the archived data; According to the comparison result, it is determined whether to reject the archive recovery request.
4. The processing method according to claim 1, characterized in that: In the case of entering the abnormal recovery process, if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node, before deleting the data corresponding to the migration information, the method further includes: receiving archive recovery requests; When the first genesis block number is equal to the second genesis block number on the current chain, the preset character string is compared with the boundary value of the block height range; and according to the comparison result, it is determined whether to enter the abnormal recovery process; or, When the first genesis block number is greater than the second genesis block number, the abnormal recovery process is entered.
5. The processing method according to claim 1, characterized in that: If the block number is within the block height range, the method further includes: Migrating illegal transactions stored in the archive data to the archive recovery node.
6. The processing method according to claim 1, characterized in that: After migrating the transaction log data of the block corresponding to the block number to the online database, the method further includes: Update the record metadata of the archive recovery node.
7. The processing method according to any one of claims 1 to 6, characterized in that: The archive recovery node is also used to provide a data query interface.
8. A processing device for archived data recovery, characterized in that: The device comprises: an acquisition module, a first recovery module, a second recovery module and an abnormal recovery module; The acquisition module is used to acquire the block height range of the archived data to be restored; The first recovery module is used to restore the migration data of the block corresponding to the block number to the online database of the archive recovery node if the block number of the archive data is within the block height range; the first recovery module is also used to restore the migration data and write key-value pair data on the online database; wherein the key-value pair data includes a preset string and the restored block number; The second recovery module is used to migrate the transaction log data of the block corresponding to the block number to the online database if the block number is outside the block height range; The abnormal recovery module is used to delete the data corresponding to the migration information if the starting block number of the migration information in the archived data is equal to the first genesis block number of the archive recovery node when entering the abnormal recovery process; The abnormal recovery module is further used to traverse the preset string within the genesis height of the archive recovery node when the block number corresponding to the preset string is within the block height range; The abnormal recovery module is also used to delete the transaction information, block index and the preset string if the block number corresponding to the traversed preset string is greater than the end block number of the archive recovery node.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the processing method for restoring archived data according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the processing method for archived data recovery according to any one of claims 1 to 7 when running.
Citation Information
Patent Citations
Snapshot-based block chain direct archiving method
CN110543446A
Block chain state data storage and rollback method and device and storage medium
CN111274318A
Block chain network bifurcation automatic recovery method, device and system
CN111679936A
Block chain state data synchronization method, apparatus, and electronic device
US20200167367A1
