Data migration method and related device
Through the migration system contract configuration task instructions of the blockchain network, multiple nodes are used to perform data migration sub-tasks in parallel, solving the complex and time-consuming problem of data migration operations in the existing technology, and achieving efficient data migration.
Patent Information
- Application Number
- CN202410098553.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-23
- Publication Date
- 2025-07-25
AI Technical Summary
In the prior art, data migration to blockchain requires manual writing and deployment of smart contracts, which are cumbersome and complex, time-consuming and inefficient.
Through the migration system contract configuration task instructions provided by the blockchain network, multiple nodes are allocated to perform data migration subtasks in parallel, generate parallel formatting results and put them on the chain to record.
Simplify the operation process, improve data migration efficiency, and shorten the migration time.
Smart Images

Figure CN120371807A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular, to a data migration method and related devices. Background Art
[0002] A blockchain is a block-chain storage, immutable, secure, and trustworthy decentralized distributed ledger, which combines technologies such as distributed storage, peer-to-peer transmission, consensus mechanism, and cryptography. By continuously growing blocks to record data, it ensures the security and transparency of data.
[0003] Given the above storage advantages of the blockchain, many services choose to migrate the data stored in their databases to the blockchain for storage. When specifically implementing data migration, relevant personnel need to deploy a smart contract for executing the data migration task on the blockchain node. Then, the data to be migrated is sent to the blockchain node one by one. The blockchain node processes the received data according to the smart contract deployed on it, and constructs a new block based on the processed data for on-chain storage.
[0004] However, the above method requires manual writing and deployment of a smart contract for executing the data migration task, which is cumbersome and complex, and requires relevant personnel to invest a lot of time and effort to execute the data migration task. In addition, the above method migrates data one by one, that is, the blockchain node needs to perform a series of operations such as verifying, packing, and block generating on each piece of received data, resulting in a long migration time and low efficiency. Summary of the Invention
[0005] Embodiments of this application provide a data migration method and related devices, which can simplify the operations that relevant personnel need to perform, shorten the data migration time, and improve the data migration efficiency.
[0006] In view of this, a first aspect of this application provides a data migration method, and the method includes:
[0007] Obtain a migration task transaction; the migration task transaction includes task indication information corresponding to the data migration task to be executed, and the task indication information is configured by a migration system contract provided by the blockchain network;
[0008] In response to the migration task transaction, allocate corresponding data migration subtasks to multiple nodes in the blockchain network; the multiple nodes are used to execute the corresponding data migration subtasks in parallel, so as to obtain the data to be migrated indicated by the data migration subtask from the source database indicated by the task indication information, and perform formatting processing on the data to be migrated to obtain a target formatting result;
[0009] Receive the target formatting results respectively sent by the multiple nodes;
[0010] Generate a target block according to each of the received target formatting results; perform an on-chain recording process on the target block.
[0011] The second aspect of the present application provides a data migration device, which includes:
[0012] A transaction acquisition module, configured to acquire a migration task transaction; the migration task transaction includes task indication information corresponding to a data migration task to be executed, and the task indication information is configured by a migration system contract provided by a blockchain network;
[0013] A task allocation module, configured to respond to the migration task transaction and allocate corresponding data migration subtasks to multiple nodes in the blockchain network respectively; the multiple nodes are used to execute the corresponding data migration subtasks in parallel to obtain the data to be migrated indicated by the data migration subtasks from the source database indicated by the task indication information, and perform formatting processing on the data to be migrated to obtain a target formatting result;
[0014] A result receiving module, configured to receive the target formatting results respectively sent by the multiple nodes;
[0015] A block on-chain module, configured to generate a target block according to each of the received target formatting results; perform an on-chain recording process on the target block.
[0016] The third aspect of the present application provides a computer device, which includes a processor and a memory:
[0017] The memory is used to store a computer program;
[0018] The processor is configured to execute the steps of the data migration method described in the first aspect above according to the computer program.
[0019] The fourth aspect of the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the steps of the data migration method described in the first aspect above.
[0020] The fifth aspect of the present application provides a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of the data migration method described in the first aspect above.
[0021] From the above technical solutions, it can be seen that the embodiments of the present application have the following advantages:
[0022] An embodiment of the present application provides a data migration method. In this method, first, a migration task transaction is obtained. The migration task transaction includes task indication information corresponding to a data migration task to be executed, and the task indication information is configured by a migration system contract provided by a blockchain network. The migration system contract is a system smart contract innovatively proposed in an embodiment of the present application for executing data migration tasks. Relevant personnel can configure the task indication information corresponding to the data migration task to be executed through the migration system contract to use the task indication information to guide the execution of the data migration task. Compared with the related art where smart contract codes for executing data migration tasks are manually written and deployed, the embodiment of the present application supports relevant personnel to directly fill in the task indication information in the migration system contract provided by the blockchain network, without manually writing and deploying smart contract codes, the operation is simpler, and it does not require much time and effort. Further, in response to the obtained migration task transaction, corresponding data migration subtasks are respectively assigned to multiple nodes in the blockchain network, so that the multiple nodes execute the corresponding data migration subtasks in parallel, obtain the data to be migrated indicated by the data migration subtasks from the source database indicated by the task indication information, and perform formatting processing on the obtained data to be migrated to obtain a target formatting result. Furthermore, receive the target formatting results respectively sent by the above-mentioned multiple nodes, generate a target block according to the received target formatting results, and perform an on-chain recording process on the target block. In this way, the data to be migrated in the source database is migrated to be stored on the blockchain through the above method. In the above data migration process, multiple nodes in the blockchain network execute the corresponding data migration subtasks in parallel to perform parallel migration on different data to be migrated in the source database. Compared with the method of migrating data one by one in the related art, in the embodiment of the present application, multiple nodes perform data migration in parallel, which can greatly improve the migration efficiency and shorten the migration duration. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic structural diagram of a distributed system applied to a blockchain system provided by an embodiment of the present application;
[0024] Figure 2 It is a schematic diagram of a block structure provided by an embodiment of the present application;
[0025] Figure 3 It is a schematic diagram of an application scenario of the data migration method provided by an embodiment of the present application;
[0026] Figure 4 It is a schematic flowchart of the data migration method provided by an embodiment of the present application;
[0027] Figure 5 It is a schematic diagram of a migration system contract provided by an embodiment of the present application;
[0028] Figure 6 Schematic diagram of the principle for allocating data to be migrated provided by the embodiments of the present application;
[0029] Figure 7 Schematic diagram of the process for allocating data migration subtasks to nodes provided by the embodiments of the present application;
[0030] Figure 8 Schematic flowchart of the method for generating migration task transactions provided by the embodiments of the present application;
[0031] Figure 9 Schematic diagram of the system architecture for executing the data migration method provided by the embodiments of the present application;
[0032] Figure 10 Schematic diagram of the process for initiating a migration task provided by the embodiments of the present application;
[0033] Figure 11 Schematic diagram of the process for executing a migration task provided by the embodiments of the present application;
[0034] Figure 12 Schematic diagram of the structure of the data migration device provided by the embodiments of the present application;
[0035] Figure 13 Schematic diagram of the structure of the terminal device provided by the embodiments of the present application;
[0036] Figure 14 Schematic diagram of the structure of the server provided by the embodiments of the present application. Detailed implementation manners
[0037] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0038] In the description, claims and the above-mentioned drawings of the present application, terms such as "first", "second", "third", "fourth", etc. (if any) are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0039] The system involved in the embodiments of the present application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device in the access network, such as a server, a user terminal) through network communication.
[0040] Taking the distributed system as a blockchain system as an example, see Figure 1 , Figure 1 FIG. is an optional schematic structural diagram of the distributed system 100 provided by the embodiments of the present application applied to a blockchain system, formed by multiple nodes 200 (any form of computing device in the access network, such as a server, a user terminal) and a client. A peer-to-peer network is formed between the nodes. The peer-to-peer protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In a distributed system, any machine such as a server or a terminal can join and become a node. A node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.
[0041] See Figure 1 The functions of each node in the blockchain system shown involve the following functions:
[0042] 1) Routing, a basic function of a node, used to support communication between nodes.
[0043] In addition to the routing function, a node may also have the following functions:
[0044] 2) Application, used to be deployed in the blockchain, implement specific services according to actual business requirements, record the data related to the implemented functions to form record data, carry a digital signature in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes verify the source and integrity of the record data successfully, the record data is added to a temporary block.
[0045] For example, the services implemented by the application include:
[0046] 2.1) Wallet, which is used to provide the function of conducting electronic currency transactions, including initiating a transaction (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After successful verification by other nodes, as a response to acknowledging the validity of the transaction, the record data of the transaction is deposited into the temporary block of the blockchain. Of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;
[0047] 2.2) Shared ledger, which is used to provide functions such as storage, query, and modification of account data. The record data of the operations on the account data is sent to other nodes in the blockchain system. After other nodes verify its validity, as a response to acknowledging the validity of the account data, the record data is deposited into the temporary block, and it can also send a confirmation to the node that initiated the operation.
[0048] 2.3) Smart contract, a computerized protocol that can execute the terms of a certain contract, implemented through code deployed on the shared ledger and executed when certain conditions are met. According to actual business requirements, the code is used to complete automated transactions, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.
[0049] 3) Blockchain, which includes a series of blocks (Block) connected in sequence according to the chronological order of generation. Once a new block is added to the blockchain, it will not be removed again. The block records the record data submitted by nodes in the blockchain system.
[0050] See Figure 2 , Figure 2 is an optional schematic diagram of the block structure provided by the embodiments of the present application. Each block includes the hash value of the transaction record stored in this block (the hash value of this block), as well as the hash value of the previous block. Each block is connected to form a blockchain through the hash value. In addition, the block may also include information such as the timestamp when the block is generated. Blockchain, essentially a decentralized database, is a string of data blocks generated by using cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.
[0051] The data migration method provided by the embodiments of this application can be executed by a computer device, which can be a device acting as a primary node in a blockchain network, specifically a terminal device or a server. Among them, the terminal device includes, but is not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server.
[0052] In addition, the information, data, and signals involved in the embodiments of this application are all authorized by relevant objects or fully authorized by all parties, and the collection, use, and processing of relevant data all comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0053] To facilitate the understanding of the data migration method provided by the embodiments of this application, the following takes the execution entity of the data migration method as a server as an example to make an exemplary introduction to the application scenario of the data migration method.
[0054] See Figure 3 , Figure 3 is a schematic diagram of the application scenario of the data migration method provided by the embodiments of this application. As Figure 3 shown, this application scenario includes a terminal device 310 and a blockchain network 320. The blockchain network 320 includes servers 321, 322, 323, 324,..., 32n; the terminal device 310 can communicate with any one of the servers in the blockchain network 320 through a network, and the servers in the blockchain network 320 can communicate with each other through a network.
[0055] The terminal device 310 faces a target object that triggers the implementation of a data migration task. This data migration task is used to migrate the data to be migrated in the source database to be stored on the blockchain; the target object can specifically trigger the configuration of the data migration task through a specific application program running on the terminal device 310, or can trigger the configuration of the data migration task by accessing a specific web page on the terminal device 310. Each server included in the blockchain network 320 can be regarded as each node in the blockchain network. In this embodiment, the server 321 is used as the primary node in the blockchain network to execute the data migration method provided by the embodiments of this application and control other nodes (i.e., other servers) in the blockchain network to cooperate in executing the data migration task configured by the above target object.
[0056] In practical applications, the target object can configure the data migration task to be executed through the terminal device 310. Specifically, the target object can select, through the terminal device 310, a migration system contract provided by the blockchain network 320 for executing the data migration task, and configure task indication information corresponding to the data migration task to be executed through the migration system contract. The task indication information is used to guide the execution of the data migration task. Exemplarily, the task indication information can indicate the source database and the data to be migrated in the source database. It should be understood that the operation of configuring the task indication information through the migration system contract is essentially filling in the task indication information in the migration system contract. Compared with the related art where the smart contract code for executing the data migration task is manually written and deployed, the above operation of configuring the task indication information through the migration system contract is simpler and does not require a large amount of time and effort.
[0057] After the target object completes the configuration of the task indication information through the migration system contract, the terminal device 310 can send the task indication information configured through the migration system contract to any node in the blockchain network 320. Correspondingly, based on the task indication information configured through the migration system contract, the node generates a migration task transaction, and through the way of reaching consensus on the block including the migration task transaction with other nodes in the blockchain network system 320 and uploading the block to the chain, the migration task transaction is put into the transaction pool of other nodes in the blockchain network 320.
[0058] Furthermore, the master node in the blockchain network 320, that is, the server 321, can obtain the migration task transaction from its transaction pool. In response to the obtained migration task transaction, the server 321 can allocate corresponding data migration subtasks to multiple nodes in the blockchain network 320. For example, corresponding data migration subtasks are allocated to the servers 321, 322, 323, 324,..., 32n in the blockchain network 320. The multiple nodes that receive the data migration subtasks can execute their corresponding data migration subtasks in parallel to obtain the data to be migrated indicated by the data migration subtask from the source database 330 indicated by the task indication information, perform formatting processing on the obtained data to be migrated to obtain a target formatting result, and then send the obtained target formatting result to the server 321.
[0059] After receiving the target formatting results sent by the above-mentioned multiple nodes, the server 321 may generate a target block according to the received target formatting results, and perform an on-chain recording process on the target block, so as to realize migrating and storing the data to be migrated obtained from the source database to the blockchain network 320. During the above data migration process, multiple nodes in the blockchain network 320 execute corresponding data migration subtasks in parallel to perform parallel migration on different data to be migrated in the source database. Compared with the method of migrating data one by one in the related art, in the embodiments of the present application, multiple nodes perform data migration in parallel, which can greatly improve the migration efficiency and shorten the migration duration.
[0060] It should be understood that Figure 3 the application scenarios shown are only examples. In actual applications, the data migration method provided in the embodiments of the present application can also be applied to other scenarios, and no limitations are imposed on the application scenarios of the data migration method provided in the embodiments of the present application.
[0061] The data migration method provided by the present application will be introduced in detail below through method embodiments.
[0062] See Figure 4 , Figure 4 which is a schematic flowchart of the data migration method provided in the embodiments of the present application. As Figure 4 shown, the data migration method includes the following steps:
[0063] Step 401: Obtain a migration task transaction; the migration task transaction includes task indication information corresponding to the data migration task to be executed, and the task indication information is configured through a migration system contract provided by the blockchain network.
[0064] In the embodiments of the present application, the main node in the blockchain network may obtain an unexecuted migration task transaction from the transaction pool. The transaction pool (Transaction Pool), also known as the memory pool (mempool), is used to store unprocessed transactions that have not been packaged into blocks; when a user submits a new transaction to the blockchain network, the transaction will be put into the transaction pool, and when the blockchain node is ready to generate a new block, it will obtain a certain number of transactions from the transaction pool for packaging; the transaction pool helps to improve the processing capacity of the blockchain network.
[0065] A migration task transaction is a transaction used to trigger a blockchain network to execute a data migration task. After obtaining the migration task transaction, the master nodes in the blockchain network can accordingly execute the data migration task based on the information carried in the migration task transaction. The migration task transaction includes task indication information corresponding to the data migration task to be executed. This task indication information is important information required for executing the data migration task. For example, this task indication information can indicate the source database of the data migration task (i.e., the database storing the data to be migrated), and can also indicate the data to be migrated in the data migration task (i.e., the data in the source database that needs to be migrated to be stored on the blockchain network). The above task indication information is configured through a migration system contract provided by the blockchain network. This migration system contract is a system smart contract provided by the blockchain network for relevant users to execute data migration tasks; when a user needs to migrate the data stored in a certain database to be stored on the blockchain network, they can choose to call this migration system contract and configure the task indication information corresponding to the data migration task to be executed through this migration system contract.
[0066] Exemplarily, Figure 5 FIG. is a schematic diagram of a migration system contract provided by an embodiment of the present application. As Figure 5 shown, this migration system contract includes two items: the database connection method and the migration specification. In the database connection method, it includes the Internet Protocol Address (IP) of the database, the port of the database, the database name, the username, the user password, etc. Users who need to initiate a data migration task can configure the above items in the database connection method to indicate the source database corresponding to this data migration task and enable the blockchain network to successfully establish a connection with the source database. In the migration specification, it includes the data tables to be migrated, the start row, the end row, the key information, and the value information, etc. Users can configure the above items in the migration specification to indicate the data to be migrated corresponding to this data migration task, that is, to indicate to migrate the key information and value information within the start row to the end row in the data table to be migrated, and reconstruct the data that conforms to the storage specification of the blockchain network based on the key information and value information. It should be understood that Figure 5 the migration system contract shown is only an example. In practical applications, the migration system contract can include other information items that need to be configured by users and are used to indicate data migration tasks, and are not limited to Figure 5 the information items in the migration system contract shown. The embodiments of the present application do not make any limitations on the specific form of the migration system contract here.
[0067] As introduced above, the user configures the task indication information corresponding to the data migration task through the migration system contract. Essentially, it is to assign specific content related to a specific data migration task to each information item in the migration system contract. Compared with the related technology where the user manually writes and deploys smart contract code for executing the data migration task, the operation of configuring the task indication information through the migration system contract is simpler and does not require a large amount of time and effort.
[0068] In practical applications, the user can use a terminal device to perform the operation of configuring the task indication information corresponding to the data migration task through the migration system contract. For example, the user can use a specific application program running on the terminal device to perform the operation of configuring the task indication information corresponding to the data migration task through the migration system contract, or can access a specific web page through the terminal device and perform the operation of configuring the task indication information corresponding to the data migration task based on the specific web page. After the terminal device determines that the user has completed the operation of configuring the task indication information, it can generate a data migration request based on the task indication information configured through the migration system contract and send the data migration request to a node in the blockchain network. Then, the node in the blockchain network performs a series of processes based on the data migration request, generates the above-mentioned migration task transaction, and adds the migration task transaction to the transaction pool so that the main node in the blockchain network can obtain the migration task transaction and execute the corresponding data migration task accordingly. The specific implementation process of the above series of operations of generating the migration task transaction based on the data migration request and putting the migration task transaction into the transaction pool will be introduced in detail in the embodiments shown below and will not be elaborated here for the time being. Figure 8 as shown in the embodiments below and will not be elaborated here for the time being.
[0069] Step 402: In response to the migration task transaction, allocate corresponding data migration subtasks to multiple nodes in the blockchain network; the multiple nodes are used to execute the corresponding data migration subtasks in parallel to obtain the data to be migrated indicated by the data migration subtask from the source database indicated by the task indication information and perform formatting processing on the data to be migrated to obtain a target formatting result.
[0070] After the main node in the blockchain network obtains the migration task transaction, it can allocate corresponding data migration subtasks to multiple nodes in the blockchain network so that the multiple nodes execute the corresponding data migration subtasks in parallel. It should be understood that the above data migration subtasks are tasks used to migrate some of the data to be migrated in the data migration task, that is, multiple data migration subtasks are split from the data migration task, and the multiple data migration subtasks are respectively used to migrate different data to be migrated.
[0071] When the master node specifically assigns data migration subtasks to other nodes, it needs to inform the node of the connection method of the source database and the data to be migrated that the node is specifically responsible for. More specifically, based on the task indication information configured through the migration system contract, the master node can set the task indication information corresponding to the data migration subtask. For example, it can modify the start row and end row in the task indication information and change them to the start row and end row of the data to be migrated corresponding to the data migration subtask. Furthermore, it sends the modified task indication information to the nodes in the blockchain network to allocate the data migration subtask for the node.
[0072] It should be understood that the multiple nodes used to execute the data migration subtasks can be all the nodes in the blockchain network or some nodes in the blockchain network (such as some nodes with idle processing resources in the blockchain network). In addition, the above multiple nodes can include the master node in the blockchain network or not include the master node in the blockchain network, that is, the master node can choose whether to assign data migration subtasks to itself. The embodiments of the present application do not make any limitations on the multiple nodes used to execute the data migration subtasks here.
[0073] After receiving the data migration subtask assigned by the master node, the node can obtain the data to be migrated indicated by the data migration subtask from the source database indicated by the task indication information. As introduced above, when the master node assigns a data migration subtask to the node, it can send the task indication information corresponding to the data migration subtask to it. The task indication information can indicate the connection method of the source database and the data to be migrated that the node needs to be responsible for. Correspondingly, the node can establish a connection with the source database according to the task indication information it receives and obtain the data to be migrated that it is responsible for from the source database. After the node obtains the data to be migrated, it can perform formatting processing on the data to be migrated. The so-called formatting processing is to convert the obtained data to be migrated into a data format supported by the blockchain network, such as converting it into a key-value pair data format, so as to obtain the target formatting result.
[0074] In a possible implementation manner, "responding to the migration task transaction and respectively allocating corresponding data migration subtasks to multiple nodes in the blockchain network" in step 402 above can specifically include:
[0075] Step 4021: Determine the total data to be migrated in the current stage of the data migration task according to a preset block size threshold and execution time threshold.
[0076] Considering that the amount of data to be migrated corresponding to a data migration task is usually large, if all the data to be migrated corresponding to the data migration task is migrated at once and blocks are generated based on all the data to be migrated, the generated blocks will exceed the block size supported by the blockchain network, and the task execution time required will be too long. Therefore, the master node in the blockchain network can execute the data migration task in stages according to a preset block size threshold and execution time threshold. In each stage, a part of the data to be migrated in the data migration task is migrated, and corresponding blocks are generated based on the migrated data to be migrated in each stage. In this way, it is ensured that the generated blocks conform to the block size supported by the blockchain network, avoiding the generation of overly large blocks, and it is possible to avoid spending too much time executing the data migration task at once.
[0077] It should be noted that the above block size threshold is set according to the block structure supported by the blockchain network, and this block size threshold is used to indicate the maximum block structure supported by this blockchain network. The above execution time threshold is set according to the performance of each node in the blockchain network, and this execution time threshold is used to indicate the longest task processing time allowed for the nodes in this blockchain network under the condition of relatively good performance. Here, relatively good performance means that the performance indicators of the nodes meet the preset indicator requirements. It should be understood that this block size threshold can change following the change of the block structure supported by the blockchain network, and this execution time threshold can change following the change of the node performance in the blockchain network.
[0078] In practical applications, corresponding data amounts can be set for the above block size threshold and execution time threshold; the data amount corresponding to the block size threshold represents the data amount when reaching the maximum block structure supported by the blockchain network, and the data amount corresponding to the execution time threshold represents the data amount when reaching the longest task processing time allowed. It should be understood that the data amount corresponding to the above block size threshold can change following the change of the block size threshold, and the data amount corresponding to the above execution time threshold can change following the change of the execution time threshold.
[0079] When the master node determines the total data to be migrated in the current stage of the data migration task, it can select the smaller data amount from the data amount corresponding to the current block size threshold and the data amount corresponding to the current execution time threshold. Furthermore, among all the data to be migrated corresponding to the data migration task, the data to be migrated that meets this smaller data amount is determined as the total data to be migrated in the current stage of this data migration task.
[0080] Step 4022: Obtain the respective target performance indicators of the multiple nodes.
[0081] In addition, the master node can also periodically obtain the target performance metrics of other nodes in the blockchain network. Here, the target performance metrics are the performance metrics related to the execution of the data migration task, such as the available Central Processing Unit (CPU) resources, available memory, running status, etc. of the nodes. In the embodiments of the present application, the master node can directly obtain the target performance metrics of other nodes collected most recently.
[0082] Step 4023: Determine the data to be migrated corresponding to each of the multiple nodes in the total data to be migrated according to the target performance metrics of each of the multiple nodes.
[0083] After the master node obtains the target performance metrics of each of the multiple nodes, it can allocate the data to be migrated that needs to be responsible for by each node in the total data to be migrated in the current stage, that is, allocate the data to be migrated responsible for by the data migration subtask corresponding to each node. Specifically, when allocating, the master node can allocate more data to be migrated to the nodes with better target performance metrics, and allocate less data to be migrated to the nodes with worse target performance metrics.
[0084] As an example, when the target performance metrics of the nodes include the available processing resources and available memory of the nodes, the master node can determine the data to be migrated corresponding to each of the multiple nodes in the following manner:
[0085] For each node, calculate the target proportion of the available resources of the high node in the total available resources according to the available processing resources and available memory of the node, as well as the available processing resources and available memory of each of the multiple nodes; furthermore, determine the data to be migrated corresponding to the node according to the target proportion and the total data to be migrated in the current stage.
[0086] Specifically, Figure 6 is a schematic diagram of the principle of allocating the data to be migrated provided by the embodiments of the present application. As Figure 6 shown, the available processing resources of the node can be the available number of CPU cores of the node, and the available content of the node is the remaining memory space of the node currently; it is assumed that the nodes that can participate in the data migration task in the blockchain network include node 1 (the master node), node 2, node 3, and node 4, and the available number of CPU cores and available memory of node 1, node 2, node 3, and node 4 are as Figure 6 shown, and it is further assumed that the total data to be migrated in the current stage of the data migration task is 60,000 rows of data; corresponding weight values of 5 and 4 are assigned to the available number of CPU cores and available memory respectively.
[0087] When calculating the data to be migrated corresponding to node 1, it can be calculated by the following formula:
[0088]
[0089] That is, the master node can calculate the target proportion of the available resources of Node 1 in the total available resources based on the available CPU cores (2) corresponding to Node 1 and the weight value (5) corresponding to the available CPU cores, the available memory (1GB) corresponding to Node 1 and the weight value 4, as well as the available CPU cores (2, 4, 2, 1) corresponding to Node 1, Node 2, Node 3, and Node 4 respectively and the weight values (5) corresponding to the available CPU cores, and the available memory (1GB, 1GB, 4GB, 2GB) corresponding to Node 1, Node 2, Node 3, and Node 4 respectively and the weight values (4) corresponding to the available memory, that is, calculate (2 * 5 + 1 * 4) / [(2 * 5 + 1 * 4) + (4 * 5 + 1 * 4) + (2 * 5 + 4 * 4) + (1 * 5 + 2 * 4)] = 0.182. Furthermore, using this target proportion and the total data to be migrated in the current stage, determine the data to be migrated corresponding to Node 1, that is, 10,909 pieces of data.
[0090] Correspondingly, for other nodes, the master node can also use the above method to calculate the data to be migrated corresponding to each of them.
[0091] In this way, through the above method, according to the available processing resources and available memory of each node, allocate the corresponding data to be migrated for each node, realize the dynamic allocation of the data migration subtasks, and ensure the rationality of the allocation of the data migration subtasks, that is, ensure that the data migration subtasks allocated to each node conform to the current running state of the node, and at the same time ensure the load balance of the entire blockchain network.
[0092] Step 4024: For each of the nodes, generate a data migration subtask corresponding to the node according to the data to be migrated corresponding to the node, and allocate the corresponding data migration subtask to the node.
[0093] After the master node determines the data to be migrated corresponding to each node, it can generate a data migration subtask corresponding to the node according to the data to be migrated corresponding to the node, that is, generate task indication information for indicating this part of the data to be migrated as the task indication information corresponding to the data migration subtask. Furthermore, send the task indication information corresponding to the data migration subtask to the node to realize the allocation of the data migration subtask for the node. The above process of allocating the data migration subtask can be regarded as the Map process, that is, allocate the data migration subtask to the nodes in the blockchain network through the Map process.
[0094] Figure 7 It is a schematic diagram of the process of allocating data migration subtasks for nodes provided by the embodiments of the present application. As Figure 7As shown in the figure, assume that the data migration task is used to migrate the data from the first row to the 3999th row in the data table B in the current stage. Node 1 (i.e., the master node) can, through the Map process, assign the data migration subtask of migrating the data from the 1st row to the 999th row in the data table B to itself, assign the data migration subtask of migrating the data from the 1000th row to the 1999th row in the data table B to Node 2, assign the data migration subtask of migrating the data from the 2000th row to the 2999th row in the data table B to Node 3, and assign the data migration subtask of migrating the data from the 3000th row to the 3999th row in the data table B to Node 4.
[0095] In this way, through the above method, the master node divides the data migration task into multiple stages according to the preset block size threshold and execution time threshold, which can ensure that the data migrated in each stage does not exceed the data corresponding to the largest block structure in the blockchain network, and the time consumed for migrating the data does not exceed the execution time threshold allowed by the blockchain network, that is, to ensure the rationality of the execution of the data migration task to avoid generating too much data migration pressure on the blockchain network at one time. In addition, the master node dynamically assigns corresponding data migration subtasks to multiple nodes according to their target performance indicators, which can ensure the reasonable utilization of node resources in the blockchain network, that is, to ensure the load balance of each node in the blockchain network.
[0096] In a possible implementation manner, after receiving the data migration subtask assigned to it, the node can execute the corresponding data migration subtask in the following manner:
[0097] Through multiple data migration processes, parallelly obtain the data to be migrated indicated by the data migration subtask from the source database; through multiple data migration processes, parallelly perform formatting processing on each obtained data to be migrated to obtain the initial formatting result corresponding to each data to be migrated; perform reduction processing on the initial formatting result corresponding to each data to be migrated to obtain the target formatting result.
[0098] Specifically, after the node receives the data migration subtask assigned by the master node and learns the source database and the data to be migrated that it is responsible for in the source database, the node can start multiple data migration processes, and the multiple data migration processes can pull the data to be migrated that it is responsible for from the source database in parallel. It should be understood that after the data migration process pulls the data to be migrated, the pulled data to be migrated can be temporarily stored in a specific storage space. After the node completes the pulling operation of the data to be migrated that it is responsible for through multiple data migration processes, the node can further format the obtained data to be migrated through these multiple data migration processes. That is, the multiple data migration processes can obtain the pulled data to be migrated from the storage space and format the data to be migrated, converting it into a data structure supported on the blockchain network. For example, it is converted into a key-value pair structure to obtain the initial formatting result corresponding to the data to be migrated. Considering that there may be duplicate or invalid data in the obtained initial formatting results, the node can further perform a reduction process on the initial formatting results through multiple data migration processes, that is, perform a Reduce process, to deduplicate the duplicate data in the initial formatting results and remove the invalid data in the initial formatting results, so as to obtain a target formatting result with higher quality.
[0099] In this way, through the above method, each node executing the data migration subtask can use multiple data migration processes to obtain the data to be migrated that it is responsible for from the source database and format the data to be migrated, which can further improve the execution efficiency of the data migration task. Moreover, each node will perform a reduction process on each initial formatting result obtained from the formatting process, which can further improve the quality of the obtained target formatting result and reduce the duplicate data and invalid data therein.
[0100] In a possible implementation manner, before executing the above step 402, the method provided by the embodiment of the present application may further include:
[0101] Based on the connection method of the source database indicated by the task indication information, perform a connection detection on the source database; if it is determined that the connection to the source database is successful through this connection detection, then execute the above step 402; if it is determined that the connection to the source database fails through this connection detection, then abandon the execution of the above step 402.
[0102] Specifically, before the master node assigns data migration subtasks to other nodes, it can first detect whether it can successfully establish a connection with the source database based on the task indication information in the migration task transaction. For example, when the connection method of the source database indicated in the task indication information includes the IP of the source database, the source database connection port, the source database name, the user name, and the user password, the master node can first initiate an access to the source database based on the IP of the source database, the source database connection port, and the source database name. Furthermore, based on the user name and the user password, it can detect whether it can successfully log in to the source database and whether it has the permission to migrate the data in the source database. If it is determined that it can successfully log in to the source database and has the permission to migrate the data in the source database, it can be considered that the connection with the source database is successful. Conversely, if it cannot successfully access the source database, or cannot successfully log in to the source database, or does not have the permission to migrate the data in the source database, it can be considered that the connection with the source database fails.
[0103] If the master node successfully connects to the source database, it indicates that the connection method of the source database indicated in the task indication information is valid, and the nodes in the blockchain network can successfully obtain the data to be migrated from the source database. Therefore, the above step 402 can be further executed. Conversely, if the master node fails to connect to the source database, it indicates that the connection method of the source database indicated in the task indication information is invalid, and the nodes in the blockchain network cannot successfully obtain the data to be migrated from the source database. At this time, it is not necessary to continue executing this data migration task, and an error indication information indicating an abnormal connection to the source database can be correspondingly feedback.
[0104] In this way, by the above method, it is possible to pre-detect whether a successful connection can be established with the source database. In the case of a successful connection with the source database, data migration subtasks are assigned to other nodes in the blockchain network. In the case of a failure to connect successfully to the source database, the operation of assigning data migration subtasks is not performed, which can effectively avoid wasting the resources consumed by assigning data migration subtasks and help to timely find the reason for the failure of the connection to the source database.
[0105] Step 403: Receive the target formatting results respectively sent by the multiple nodes.
[0106] After the node that receives the data migration subtask completes its corresponding data migration subtask, it can send the generated target formatting result to the master node in the blockchain network, enabling the master node to obtain the target formatting results respectively generated by the multiple nodes.
[0107] Step 404: Generate a target block according to the received target formatting results; perform an on-chain recording process on the target block.
[0108] After the master node receives the target formatting results sent by multiple nodes respectively, it can generate a target block according to the received target formatting results, that is, use the block to record the data migrated from the source database and conforming to the data storage specification of the blockchain network, and generate the target block to be uploaded to the chain. Furthermore, perform an on-chain recording process on the target block to realize the migration of the data to be migrated obtained from the source database to the blockchain network for storage.
[0109] In a possible implementation manner, the "generating a target block according to the received target formatting results" in step 404 above may specifically include:
[0110] Step 4041: Perform a reduction process on the received target formatting results to obtain a comprehensive formatting result.
[0111] That is, after the master node receives the target formatting results sent by multiple nodes respectively, it can perform a reduction process on the target formatting results again, that is, perform a secondary reduction process on the target formatting results obtained by the reduction process of each node, that is, a secondary Reduce process, to remove duplicate data in each target formatting result and remove invalid data in each target formatting result, so as to obtain a comprehensive formatting result with higher quality.
[0112] Step 4042: Generate the target block according to the comprehensive formatting result.
[0113] Furthermore, the master node can generate a target block to be uploaded to the chain according to the obtained comprehensive formatting result.
[0114] In this way, through the above method, perform a secondary reduction process on the target formatting results sent by each node to obtain a comprehensive formatting result, which can ensure that the obtained comprehensive formatting result has higher quality, that is, ensure that the data recorded in the target block has higher quality.
[0115] As introduced above, based on the block size threshold and execution time threshold of the blockchain network, the data migration task can be divided into multiple stages for execution, and the generation of a target block by the master node can be regarded as completing a stage of the data migration task. When not all the data to be migrated corresponding to the data migration task has been migrated to the blockchain network, the master node still needs to continue to execute the next stage of the data migration task. To ensure the smooth execution of the next stage of the data migration task, the "generating the target block according to the comprehensive formatting result" in step 4042 above may specifically include:
[0116] Step 40421: Detect whether the currently migrated data of the data migration task has reached the total data to be migrated of the data migration task.
[0117] When the master node generates a target block, it can first detect whether the currently migrated data of the data migration task has reached all the data to be migrated corresponding to the data migration task. The currently migrated data of the data migration task here includes the data in the successfully chained target block, that is, the data successfully migrated to the blockchain network through the completed stage of the data migration task; it also includes the data to be migrated corresponding to the comprehensive formatting result generated by the master node. This part of the data is the data to be migrated in the current stage of the data migration task. Although this part of the data has not been recorded in the target block and successfully chained, it has been obtained by the blockchain network.
[0118] Step 40422: If not, generate a new migration task transaction according to the currently migrated data and the task indication information; write the new migration task transaction and the comprehensive formatting result into the processing result of the current migration task transaction to obtain the target block.
[0119] If the currently migrated data of the data migration task has not reached all the data to be migrated corresponding to the data migration task, it means that the data migration task is not fully completed and the data migration task needs to be continued, that is, the next stage of the data migration task is started. To start the next stage of the data migration task, the master node needs to generate a new migration task transaction according to the currently migrated data and the task indication information.
[0120] When specifically generating a new migration task transaction, the master node can determine the data to be migrated that has not been migrated in the data migration task according to the currently migrated data and the task indication information, and then modify the task indication information so that the task indication information indicates this part of the data to be migrated that has not been migrated; exemplarily, the master node can modify the data start row in the task indication information, that is, modify the data start row to the smallest data row corresponding to the unmigrated data in the data table to be migrated. Furthermore, the master node can generate a new migration task transaction according to the modified task indication information, so that the new migration task transaction carries the modified task indication information.
[0121] Furthermore, the master node can write the above new migration task transaction and the comprehensive formatting result into the processing result of the current migration task transaction to obtain the target block, that is, the target block carries both the data migrated from the source database (i.e., the comprehensive formatting result) and the new migration task transaction indicating the next stage of the data migration task. After the target block is chained on each node in the blockchain network, the new migration task transaction carried in the target block will be put into the transaction pool, so that the master node can re-obtain the new migration task transaction from the transaction pool and re-execute the above steps 401 to 404 to execute the next stage of the data migration task.
[0122] Step 40423: If it has been reached, write the comprehensive formatting result into the processing result of the migration task transaction for this time to obtain the target block.
[0123] If the currently migrated data of the data migration task has reached all the data to be migrated corresponding to this data migration task, it means that this data migration task has been completely completed. At this time, the master node can directly write the obtained comprehensive formatting result into the processing result of the migration task transaction for this time to obtain the target block, which is used to carry the data migrated in the last stage of the data migration task.
[0124] In this way, through the above method, according to the current execution progress of the data migration task, the corresponding target block is generated, so as to ensure that the next stage of the data migration task can be carried out smoothly when the data migration task has not been completely executed, and at the same time write the data migrated in this stage into the block, that is, ensure the reliable execution of the data migration task.
[0125] In a possible implementation manner, the "processing of recording the target block on the chain" in the above step 404 may specifically include:
[0126] Step 4043: Send the target block to other nodes in the blockchain network for consensus.
[0127] After the master node generates the target block, it can send the target block to other nodes in the blockchain network for consensus. The specific consensus mechanism is the same as the mechanism adopted when blockchain nodes conduct consensus in related technologies, which will not be elaborated here.
[0128] Step 4044: If the target block meets the consensus passing condition, notify other nodes in the blockchain network to append the target block to the ledger, update the status data corresponding to the target block in the status database, and, if the new migration task transaction is carried in the target block, add the new migration task transaction to the transaction pool.
[0129] If it is determined that the target block meets the consensus passing condition, that is, the target block passes the consensus, it can notify each node in the blockchain network to append the target block to its ledger, that is, add the target block to the end of the existing blockchain. At the same time, each node in the blockchain network will update the status data corresponding to the target block in the status database.
[0130] In addition, when the target block carries a new migration task transaction, the node will also put the new migration task transaction into the transaction pool so that the master node can obtain the new migration task transaction from the transaction pool to start the next stage of the data migration task. It should be understood that in practical applications, the master node in the blockchain network may change. Therefore, each node in the blockchain network puts the new migration task transaction into the transaction pool, which can ensure that the master node can obtain the new migration task transaction even when the master node changes.
[0131] In this way, through the above method, the target block is recorded on the blockchain, completing the migration of the data in the current stage of the data migration task. And when the target block carried a new migration task transaction, each node in the blockchain network put the new migration task transaction into its own transaction pool, which can reliably ensure that the master node can obtain the new migration task transaction, that is, ensure that the next stage of the data migration task can be carried out smoothly.
[0132] In the data migration method provided by the embodiments of the present application, first obtain a migration task transaction, where the migration task transaction includes task indication information corresponding to the data migration task to be executed, and the task indication information is configured by a migration system contract provided by a blockchain network. The migration system contract is a system smart contract innovatively proposed by the embodiments of the present application for executing data migration tasks. Relevant personnel can configure the task indication information corresponding to the data migration task to be executed through the migration system contract to use the task indication information to guide the execution of the data migration task. Compared with the related art where smart contract code for executing data migration tasks is manually written and deployed, the embodiments of the present application support relevant personnel to directly fill in the task indication information in the migration system contract provided by the blockchain network, without manually writing and deploying smart contract code, the operation is simpler, and it does not require much time and effort. Further, in response to the obtained migration task transaction, allocate corresponding data migration subtasks to multiple nodes in the blockchain network, so that the multiple nodes execute the corresponding data migration subtasks in parallel, obtain the data to be migrated indicated by the data migration subtask from the source database indicated by the task indication information, and perform formatting processing on the obtained data to be migrated to obtain a target formatting result. Furthermore, receive the target formatting results respectively sent by the above multiple nodes, generate a target block according to the received target formatting results, and perform an on-chain recording process on the target block. In this way, the data to be migrated in the source database is migrated to be stored on the blockchain through the above method. In the above data migration process, multiple nodes in the blockchain network execute the corresponding data migration subtasks in parallel to perform parallel migration on different data to be migrated in the source database. Compared with the method of migrating data one by one in the related art, in the embodiments of the present application, multiple nodes perform data migration in parallel, which can greatly improve the migration efficiency and shorten the migration duration.
[0133] The following introduces the generation method of the migration task transaction in the above text through method embodiments.
[0134] See Figure 8 , Figure 8 is a schematic flowchart of the migration task transaction generation method provided by the embodiments of the present application. As Figure 8 shown, the migration task transaction generation method includes the following steps:
[0135] Step 801: Receive a data migration request; the data migration request is generated based on the migration system contract, and includes the task indication information corresponding to the data migration task configured through the migration system contract.
[0136] In an embodiment of the present application, a target node in a blockchain network can receive a data migration request from a terminal device. The data migration request is a request initiated by a user of the terminal device to trigger the blockchain network to execute a data migration task. Here, the target node can be any node in the blockchain network, which can be the primary node in the blockchain network or other nodes in the blockchain network.
[0137] Exemplarily, a user can send a data migration request to the blockchain network in the following manner: The user can use a specific application installed on the terminal device or access a specific website using the terminal device (the application or website can provide a data migration service for migrating data from a source database to the blockchain network); then, through an interface provided by the specific application or the specific website for initiating a data migration task, select to invoke a migration system contract dedicated to implementing the data migration task provided by the blockchain network, and configure the task indication information in the migration system contract. For example, fill in the indication information related to the current data migration task in the provided migration system contract template, such as the connection method of the source database (IP of the source database, connection port, database name, username, user password, etc.), and migration specification parameters (such as data tables to be migrated, start row, end row, key information, value information, etc.); furthermore, after completing the configuration of the above task indication information, the user can trigger a confirmation operation on the configured task indication information. The terminal device responds to the confirmation operation and correspondingly packages the task indication information configured through the migration system contract, and generates a data migration request based on the packaged task indication information, and sends the data migration request to a node in the blockchain network.
[0138] In addition, the terminal device can also use its own certificate to sign the above-packaged task indication information to obtain a corresponding signature. Furthermore, add both the signature and the packaged task indication information to the data migration request, and send the data migration request to a node in the blockchain network.
[0139] Step 802: Perform a first verification process on the data migration request.
[0140] After receiving the data migration request, a node in the blockchain network can perform a first verification process on the data migration request to determine the legality of the data migration request. That is, the first verification process is a process for verifying the legality of the data migration request.
[0141] In a possible implementation, when the data migration request includes a signature generated based on the task instruction information (i.e., the signature obtained by signing the packaged task instruction information using the certificate of the terminal device in the above text), the above step 802 of "performing a first verification process on the data migration request" may specifically include:
[0142] Step 8021: Perform certificate verification, signature verification, and authority verification on the data migration request.
[0143] Specifically, the nodes in the blockchain network can perform certificate verification on the data migration request, that is, verify whether the certificate of the terminal device that generates the data migration request is legal; for example, the node can send the identification information of the terminal device to the relevant certificate verification agency, so that the certificate verification agency can verify the legitimacy of the certificate of the terminal device based on this. If the certificate verification agency determines that the certificate of the terminal device is legal, it can be determined that the data migration request has passed the certificate verification, and the certificate verification agency can also provide the certificate of the terminal device to the nodes in the blockchain network.
[0144] In addition, the nodes in the blockchain network can also perform signature verification on the data migration request, that is, verify whether the signature in the data migration request is legal; for example, the node can use the certificate of the terminal device provided by the certificate verification agency to sign the task instruction information packaged in the data migration request, obtain the corresponding signature, and then compare the signature with the signature originally carried in the data migration request. If the two are consistent, it means that the signature verification in the data migration request has passed.
[0145] In addition, the nodes in the blockchain network can also perform authority verification on the data migration request, that is, verify whether the user who initiated the data migration request has the authority to trigger the blockchain network to perform the data migration task; for example, the node can obtain the identification information of the user who initiated the data migration request, and then search for the identification information in a pre-built whitelist (which records the identification information of each object that has the authority to trigger the blockchain network to perform the data migration task). If the identification information is found, it means that the data migration request has passed the authority verification.
[0146] Step 8022: If the data migration request passes the certificate verification, the signature verification, and the authority verification, it is determined that the data migration request has passed the first verification process; if the data migration request fails to pass at least one of the certificate verification, the signature verification, and the authority verification, it is determined that the data migration request has not passed the first verification process.
[0147] If it is determined through step 8021 above that the data migration request has passed the certificate verification, signature verification, and permission verification, it can be considered that the data migration request has passed the first verification process. Furthermore, subsequent step 803 can be continued for this data migration request. If it is determined through step 8021 above that the data migration request has not passed at least one of the certificate verification, signature verification, and permission verification, it can be considered that there is a problem with the data migration request. Therefore, subsequent step 803 for this data migration request can be temporarily not executed, and the result of the failure of the first verification process can be returned accordingly.
[0148] In this way, through the above method, the data migration request is subjected to certificate verification, signature verification, and permission verification to complete the first verification process for the data migration request. The pre-verification of the data migration request can be carried out from dimensions such as the legality of the certificate of the terminal device, whether the data in the data migration request has been tampered with during transmission, and whether the initiating object of the data migration request has the permission to initiate the data migration task, so as to ensure that the subsequent steps can be executed based on a reliable data migration request, that is, to ensure the reliability of the entire data migration process.
[0149] Of course, in practical applications, the nodes in the blockchain network can also only perform any one or more of the above certificate verification, signature verification, and permission verification. Or, the nodes in the blockchain network can also perform other verification processes. The embodiments of the present application do not make any limitations on the verification links included in the first verification process.
[0150] Step 803: If the data migration request passes the first verification process, generate a migration request transaction according to the data migration request, and add the migration request transaction to the transaction pool.
[0151] If the nodes in the blockchain network determine through step 802 that the received data migration request has passed the first verification process, a migration request transaction can be generated according to the data migration request. For example, the packaged task indication information can be taken out from the data migration request, and the packaged task indication information can be unpacked to restore the original task indication information, and a migration request transaction can be generated using the task indication information. Furthermore, the node can add the migration request transaction to the transaction pool so as to obtain the migration request transaction from the transaction pool subsequently and perform the block generation process on it.
[0152] Step 804: Obtain the migration request transaction from the transaction pool and perform a second verification process on the migration request transaction.
[0153] Nodes in the blockchain network can periodically obtain transactions in the transaction pool. When a node obtains a migration request transaction in the transaction pool, it can perform a second verification process on the migration request transaction to determine the reliability of the task indication information in the migration request transaction. That is, the second verification process is used to verify the reliability of the task indication information configured by the user through the migration system contract.
[0154] In a possible implementation, when the task indication information configured by the user through the migration system contract includes the connection method of the source database and the migration specification parameters, and the migration specification parameters are used to indicate the data to be migrated in the data migration task, the above step 804 "perform a second verification process on the migration request transaction" can specifically include:
[0155] Step 8041: Based on the connection method in the task indication information, perform a connection detection on the source database.
[0156] Nodes in the blockchain network can use the connection method of the source database in the task indication information to attempt to establish a connection with the source database, that is, to implement the connection detection of the source database. If the node successfully connects to the source database based on this connection method, it can be considered that the migration request transaction has passed the connection detection; if the node fails to connect to the source database based on this connection method, it can be considered that the migration request transaction has not passed the connection detection.
[0157] Step 8042: If it is determined that the connection to the source database is successful through the connection detection, detect whether there is the data to be migrated indicated by the migration specification parameters in the source database; if it is determined that there is the data to be migrated in the source database, determine that the migration request transaction has passed the second verification process.
[0158] If it is determined that the connection to the source database is successful through the connection detection in the above step 8041, the node can continue to detect whether there is the data to be migrated indicated by the migration specification parameters in the source database; for example, when the migration specification parameters include the data table to be migrated, the start row, the end row, the key information, and the value information, the node can query in the source database whether there is the data table indicated by the migration specification parameters, query whether there are the start row and the end row indicated by the migration specification parameters in the data table, and query whether there are the key information and the value information indicated by the migration specification parameters in the data table.
[0159] If it is detected that there is the data to be migrated indicated by the migration specification parameters in the source database, it can be determined that the migration request transaction has passed the data detection; if it is detected that there is no the data to be migrated indicated by the migration specification parameters in the source database, it can be considered that the migration request transaction has not passed the data detection.
[0160] In the case where it is determined that the above migration request transaction has passed both the connection detection and the data detection, that is, when it is determined based on the task indication information in the above migration request transaction that a connection can be successfully established with the source database, and there is the data to be migrated indicated by the task indication information in the source database, it can be considered that the migration request transaction has passed the second verification process. Furthermore, the subsequent step 805 can be continued based on this migration request transaction.
[0161] Step 8043: If it is determined that the connection to the source database fails through the connection detection, or if it is determined that the data to be migrated does not exist in the source database, it is determined that the migration request transaction has not passed the second verification process.
[0162] Conversely, in the case where it is determined that the above migration request transaction fails the connection detection and / or the data detection, that is, when it is determined based on the task indication information in the above migration request transaction that the connection to the source database fails and / or it is determined that the data to be migrated indicated by the task indication information does not exist in the source database, it can be considered that the migration request transaction has not passed the second verification process. At this time, the subsequent step 805 may not be executed based on this migration request transaction, and an error prompt message indicating that the source database cannot be successfully connected and / or an error prompt message indicating that the migration specification parameter check fails can be fed back accordingly.
[0163] In this way, through the above method, the task indication information configured by the user through the migration system contract is verified to verify whether the connection method of the source database indicated by the task indication information is correct, and to verify whether the data to be migrated indicated by the task indication information exists, thereby realizing the second verification process for the migration request transaction. Through this second verification process, the reliability of the task indication information on which the subsequent data migration task is executed can be ensured, that is, it is ensured that a connection can be reliably established with the source database, and the data required for migration can be obtained from the source database, so as to ensure the smooth progress of the data migration task.
[0164] Step 805: If the migration request transaction passes the second verification process, a migration task transaction is generated according to the task indication information in the migration request transaction.
[0165] If a node in the blockchain network determines through step 804 that the migration request transaction passes the second verification process, a new transaction can be further generated according to the task indication information in this migration request transaction as the migration task transaction. Exemplarily, the node can generate a migration task transaction for executing the data migration task and determining the execution status of the data migration task. Furthermore, the source database connection method and the migration specification parameters in the migration request transaction are written into this migration task transaction, thus generating this migration task transaction.
[0166] To ensure that the master nodes in the blockchain network can obtain the above migration task transactions and control the execution of the corresponding data migration tasks accordingly, the nodes that execute the above steps 801 to 805 also need to further execute the following steps 806 to 808 to put the migration task transactions into the transaction pools of each node in the blockchain network, so as to facilitate the master nodes to obtain the migration task transactions.
[0167] Step 806: Write the migration task transaction into the processing result of the migration request transaction to obtain a reference block.
[0168] After a node in the blockchain network generates a migration task transaction, it can use the migration task transaction as the processing result of the above migration request transaction, that is, write the migration task transaction into the processing result of the migration request transaction, so as to obtain a new reference block to be chained.
[0169] Step 807: Perform blockchain recording processing on the reference block.
[0170] Furthermore, the nodes in the blockchain network can perform blockchain recording processing on the generated reference block. Specifically, the node can send the reference block to other nodes in the blockchain network for consensus. The specific consensus mechanism is the same as that used when blockchain nodes perform consensus in related technologies and will not be elaborated here. If it is determined that the reference block meets the consensus passing condition, that is, the reference block passes the consensus, it can notify each node in the blockchain network to append the reference block to its ledger, that is, add the reference block to the end of the existing blockchain. At the same time, each node in the blockchain network will update the status data corresponding to the reference block in the status database, thus completing the blockchain recording processing for the reference block.
[0171] Step 808: After the reference block is successfully chained, add the migration task transaction carried in the reference block to the transaction pool so that the nodes in the blockchain network can obtain the migration task transaction from the transaction pool.
[0172] After the reference block is successfully chained, the reference block will be recorded on the blockchains maintained by each node in the blockchain network. At this time, each node in the blockchain network can add the migration task transaction carried in the reference block to its own transaction pool. Correspondingly, the master node in the blockchain network can obtain the migration task transaction from its own transaction pool, that is, execute the above step 401.
[0173] In the method for generating a migration task transaction provided in the embodiments of the present application, first, a data migration request is received, and a first verification process is performed on the data migration request to verify the legality of the data migration request. After determining that the data migration request passes the first verification process, a migration request transaction is further generated according to the data migration request, and the migration request transaction is added to the transaction pool; correspondingly, after obtaining the migration request transaction from the transaction pool, a second verification process can be performed on the migration request transaction to verify the reliability of the task indication information in the migration request transaction. After determining that the migration request transaction passes the second verification process, a migration task transaction is further generated according to the task indication information in the migration request transaction. In this way, the generation process of the migration task transaction is completed, and during this process, through multiple verification processes in different dimensions, the reliability of the generated migration task transaction is ensured, that is, it is ensured that the corresponding data migration task can be smoothly carried out based on the migration task transaction. Furthermore, the migration task transaction is recorded on the blockchain, so that the master node in the blockchain network can obtain the migration task transaction and accordingly carry out the subsequent actual data migration task, that is, it is ensured that the data migration task can be smoothly started.
[0174] To facilitate further understanding of the data migration method provided in the embodiments of the present application, first, an exemplary system architecture provided in the embodiments of the present application for executing the data migration method will be introduced below. Furthermore, the specific implementation manner of the data migration method adopted in the embodiments of the present application will be introduced in combination with this system architecture.
[0175] See Figure 9 , Figure 9 is a schematic diagram of an exemplary system architecture provided in the embodiments of the present application for executing the data migration method; it should be understood that this system architecture can be deployed on each node in the blockchain network. As Figure 9 shown, this system architecture may include the following modules:
[0176] 1) Network module: Responsible for communication between nodes in the blockchain network, including but not limited to broadcasting of transactions and blocks, information interaction during the block consensus process, etc.
[0177] 2) Verification module: Responsible for performing certificate verification, signature verification, and permission verification on the received data migration request. Certificate verification is used to ensure the legal identity of the initiator of the data migration task, signature verification is used to ensure that the task indication information in the data migration request has not been tampered with, and permission verification is used to ensure that the initiator has the relevant permissions to initiate the data migration task.
[0178] 3) Transaction pool module: Responsible for storing transactions to be processed and providing transactions to be packaged for the block generator.
[0179] 4) Monitoring Module: Responsible for collecting and managing the status information of nodes in the blockchain network, including but not limited to the load of nodes, available processing resources, available memory, etc.
[0180] 5) Scheduling and Execution Module: Responsible for obtaining transactions from the transaction pool module and starting the contract process to process the obtained transactions and generate new blocks. The scheduling and execution module mainly includes the following sub-modules:
[0181] a. Block Transaction Packager: Responsible for obtaining transactions from the transaction pool module and packing the transactions according to certain rules.
[0182] b. Virtual Machine Engine: Responsible for executing the smart contract code in the transaction, such as executing the code of the migration system contract.
[0183] c. Block Generator: Responsible for packing the processed transactions into new blocks.
[0184] d. Contract Repository: Responsible for storing ordinary user contracts and system contracts. The migration system contract, as a sub-module in this system contract, is responsible for executing data migration tasks.
[0185] e. MapReduce Task Scheduler: Responsible for dynamically allocating corresponding data migration subtasks to nodes according to the status information of nodes collected by the monitoring module.
[0186] f. Contract Process Pool: Responsible for managing contract processes that execute in parallel, such as parallel migration contract processes (also known as data migration processes).
[0187] 6) Consensus Module: Responsible for reaching a consensus among blockchain nodes and maintaining the consistency of the blockchain maintained with other blockchain nodes.
[0188] 7) Storage Module: Responsible for storing blockchain data, including block ledgers and status data.
[0189] a. Block Ledger: Stores all block data that has passed consensus.
[0190] b. Status Data: Stores the current status of the blockchain, including block status, smart contract status, etc.
[0191] See Figure 10 , Figure 10 which is the schematic diagram of the migration task initiation process provided by the embodiments of this application. As Figure 10 shown, the migration task initiation process includes the following steps:
[0192] 1. Start.
[0193] 2. The user uses the terminal device to specify the invocation of the migration system contract, and uses the terminal device to configure the task indication information of the data migration task through the migration system contract, including the source database connection method and migration specification parameters.
[0194] 3. The terminal device packs the above task indication information.
[0195] 4. The terminal device signs the packed task indication information above.
[0196] 5. The terminal device sends the data migration request carrying the packed task indication information and signature to the nodes in the blockchain network.
[0197] 6. The nodes in the blockchain network receive the data migration request.
[0198] 7. The verification module on the node performs certificate verification and signature verification on the received data migration request. If the verification passes, step 9 is executed; if the verification fails, step 8 is executed.
[0199] 8. Return the result that the certificate verification and / or signature verification fails. Jump to execute step 27.
[0200] 9. The verification module on the node performs permission verification on the received data migration request. If the verification passes, step 11 is executed; if the verification fails, step 10 is executed.
[0201] 10. Return the result that the permission verification fails. Jump to execute step 27.
[0202] 11. Take the data migration request as a migration request transaction and put the migration request transaction into the transaction pool.
[0203] 12. The scheduling execution module on the node regularly fetches transactions from the transaction pool to prepare for block production and fetches the above migration request transaction.
[0204] 13. The scheduling execution module on the node starts an instance of the migration system contract and prepares to execute the migration operation.
[0205] 14. The migration system contract in the scheduling execution module performs connection detection on the source database based on the source database connection method in the migration request transaction.
[0206] 15. Whether the source database is successfully connected. If it is successfully connected, step 17 is executed; if the connection fails, step 16 is executed.
[0207] 16. Return the error prompt message that the source database cannot be connected. Jump to execute step 22.
[0208] 17. The migration system contract in the scheduling execution module queries the source database to check whether there are the data tables, start rows, end rows, key information, and value information indicated by the migration specification parameters in the migration request transaction. If all exist, step 19 is executed; if not, step 18 is executed.
[0209] 18. Return an error prompt message indicating that the migration specification parameter check has failed. Jump to execute step 22.
[0210] 19. The migration system contract in the scheduling execution module generates a new migration task transaction for executing the data migration task and monitoring the execution status of the data migration task.
[0211] 20. The migration system contract in the scheduling execution module writes the source database connection method and migration specification parameters in the migration request transaction into the migration task transaction.
[0212] 21. The migration system contract in the scheduling execution module writes the migration task transaction as the processing result of the migration request transaction into the processing result of this migration request transaction to obtain a reference block.
[0213] 22. The node sends the above reference block to other nodes in the blockchain network for consensus.
[0214] 23. Detect whether the reference block passes the consensus. If it passes, step 24 is executed; if not, step 27 is executed.
[0215] 24. All nodes in the blockchain network append this reference block to the block ledger.
[0216] 25. All nodes in the blockchain network update the status data of this reference block in the status data.
[0217] 26. All nodes in the blockchain network put the migration task transaction in the reference block into the transaction pool.
[0218] 27. End.
[0219] See Figure 11 , Figure 11 which is the schematic diagram of the migration task execution process provided by the embodiment of this application. As Figure 11 shown, the migration task execution process includes the following steps:
[0220] 1. Start.
[0221] 2. The scheduling execution module on the primary node in the blockchain network regularly obtains transactions from the transaction pool to prepare for block generation and obtains the above migration task transaction.
[0222] 3. The primary node starts the migration contract process to execute the corresponding data migration task.
[0223] 4. The migration contract process performs a connection check on the source database based on the source database connection method in the migration task transaction.
[0224] 5. If the source database is successfully connected, step 7 is executed; if the connection fails, step 6 is executed.
[0225] 6. The migration contract process returns an error message indicating an abnormal connection to the source database. Then it jumps to and executes step 26.
[0226] 7. The migration contract process obtains the block size threshold and the execution time threshold.
[0227] 8. The migration contract process determines the data tables to be migrated and their row counts required for the data migration task in the current stage based on the block size threshold and the execution time threshold.
[0228] 9. The migration contract process obtains the target performance metrics of each node in the blockchain network from the monitoring module.
[0229] 10. The migration contract process calculates the start row and end row of the data to be migrated for each node.
[0230] 11. Based on the above calculation results, the migration contract process assigns corresponding data migration subtasks to each node, that is, sends the start row and end row of the data to be migrated for which it is responsible to the node, and also sends the source database connection method to the node, thus realizing the task assignment in the Map process.
[0231] 12. Each node in the blockchain network starts multiple migration contract processes to obtain the data to be migrated for which it is responsible from the source database in parallel.
[0232] 13. Each node in the blockchain network uses multiple migration contract processes to format the obtained data to be migrated in parallel.
[0233] 14. Each node in the blockchain network uses multiple migration contract processes to reduce the formatted processing results to a unified node calculation formatted result, that is, the target formatted result.
[0234] 15. Each node in the blockchain network sends the target formatted result to the master node.
[0235] 16. The master node collects the target formatted results sent by each node and performs a secondary reduction (Reduce) process to obtain the comprehensive formatted result of the data migration task in the current stage.
[0236] 17. The migration contract process checks whether the data migration task is all completed. If it is all completed, step 20 is executed; if not all completed, step 18 is executed.
[0237] 18. The migration contract process generates a new migration task transaction according to the current execution progress of the data migration task, and updates the start row of the data table indicated by the migration specification parameter.
[0238] 19. The migration contract process writes the generated new migration task transaction into the processing result of this migration task transaction.
[0239] 20. The migration contract process writes the comprehensive formatting results of the current stage into the processing results of this migration task transaction to obtain the target block.
[0240] 21. The master node sends the above target block to other nodes in the blockchain network for consensus.
[0241] 22. Check whether the target block has passed the consensus. If it has passed, execute step 23. If it has not passed, execute step 26.
[0242] 23. All nodes in the blockchain network append the target block to the block ledger.
[0243] 24. All nodes in the blockchain network update the status data of the target block in the status data.
[0244] 25. In the case where the target block includes a new migration task transaction, all nodes in the blockchain network put the new migration task transaction in the target block into the transaction pool.
[0245] 26. The end.
[0246] It should be noted that the data migration method provided in the embodiment of the present application can be used, for example, to migrate business data in the following scenarios: business data in supply chain finance scenarios, business data in cross-border payment scenarios, business data in Internet of Things scenarios, business data in electronic medical scenarios, business data in asset digitization scenarios, etc. No limitation is imposed herein on the types of data to which the data migration method is applicable.
[0247] With respect to the data migration method described above, the present application also provides a corresponding data migration device, so that the above data migration method can be applied and implemented in practice.
[0248] See also Figure 12 , Figure 12 It is the same as above Figure 4 The data migration method shown in FIG. Figure 12 As shown, the data migration device 1200 includes:
[0249] A transaction acquisition module 1201, configured to acquire a migration task transaction; the migration task transaction includes task indication information corresponding to a data migration task to be executed, and the task indication information is configured by a migration system contract provided by a blockchain network;
[0250] A task allocation module 1202, configured to, in response to the migration task transaction, allocate corresponding data migration subtasks to multiple nodes in the blockchain network; the multiple nodes are configured to execute the corresponding data migration subtasks in parallel, so as to obtain the data to be migrated indicated by the data migration subtasks from a source database indicated by the task indication information, and perform formatting processing on the data to be migrated to obtain a target formatting result;
[0251] A result receiving module 1203, configured to receive the target formatting results respectively sent by the multiple nodes;
[0252] A block chain - linking module 1204, configured to generate a target block according to each of the received target formatting results; and perform block - chain recording processing on the target block.
[0253] Optionally, the task allocation module 1202 is specifically configured to:
[0254] Determine the total data to be migrated in the current stage of the data migration task according to a preset block size threshold and execution time threshold;
[0255] Obtain the target performance metrics of each of the multiple nodes;
[0256] Determine the data to be migrated corresponding to each of the multiple nodes in the total data to be migrated according to the target performance metrics of each of the multiple nodes;
[0257] For each of the nodes, generate a data migration subtask corresponding to the node according to the data to be migrated corresponding to the node, and allocate the data migration subtask corresponding to the node to the node.
[0258] Optionally, the target performance metrics include available processing resources and available memory; the task allocation module 1202 is specifically configured to:
[0259] For each of the nodes, calculate a target proportion of the available resources of the node in the total available resources according to the available processing resources and available memory of the node and the available processing resources and available memory of each of the multiple nodes; and determine the data to be migrated corresponding to the node according to the target proportion and the total data to be migrated.
[0260] Optionally, the apparatus further includes: a task execution module; the task execution module is configured to:
[0261] Fetch the data to be migrated indicated by the data migration subtask from the source database in parallel through multiple data migration processes;
[0262] Format the fetched data to be migrated in parallel through the multiple data migration processes to obtain the initial formatting results corresponding to the respective data to be migrated;
[0263] Perform a reduction process on the initial formatting results corresponding to the respective data to be migrated to obtain the target formatting result.
[0264] Optionally, the block chain - uploading module 1204 is specifically configured to:
[0265] Perform a reduction process on the received target formatting results to obtain a comprehensive formatting result;
[0266] Generate the target block according to the comprehensive formatting result.
[0267] Optionally, the block chain - uploading module 1204 is specifically configured to:
[0268] Detect whether the currently migrated data of the data migration task has reached the total data to be migrated of the data migration task;
[0269] If not, generate a new migration task transaction according to the currently migrated data and the task indication information; write the new migration task transaction and the comprehensive formatting result into the processing result of the current migration task transaction to obtain the target block;
[0270] If so, write the comprehensive formatting result into the processing result of the current migration task transaction to obtain the target block.
[0271] Optionally, the block chain - uploading module 1204 is specifically configured to:
[0272] Send the target block to other nodes in the blockchain network for consensus;
[0273] If the target block meets the consensus - passing condition, notify other nodes in the blockchain network to append the target block to the ledger, update the status data corresponding to the target block in the status database, and, when the new migration task transaction is carried in the target block, add the new migration task transaction to the transaction pool.
[0274] Optionally, the task indication information is used to indicate the connection method of the source database; the device further includes: a connection detection module; the connection detection module is used to:
[0275] Perform connection detection on the source database based on the connection method indicated by the task indication information;
[0276] If it is determined through the connection detection that the connection to the source database is successful, then execute the transaction responding to the migration task, and allocate corresponding data migration subtasks to multiple nodes in the blockchain network respectively; if it is determined through the connection detection that the connection to the source database fails, then abandon the execution of the transaction responding to the migration task, and allocate corresponding data migration subtasks to multiple nodes in the blockchain network respectively.
[0277] Optionally, the device further includes:
[0278] A request receiving module, configured to receive a data migration request; the data migration request is generated based on the migration system contract, and includes the task indication information corresponding to the data migration task configured through the migration system contract;
[0279] A first verification module, configured to perform first verification processing on the data migration request;
[0280] A transaction adding module, configured to, if the data migration request passes the first verification processing, generate a migration request transaction according to the data migration request, and add the migration request transaction to the transaction pool;
[0281] A second verification module, configured to obtain the migration request transaction from the transaction pool and perform second verification processing on the migration request transaction;
[0282] A transaction generating module, configured to, if the migration request transaction passes the second verification processing, generate the migration task transaction according to the task indication information in the migration request transaction.
[0283] Optionally, the data migration request further includes a signature generated based on the task indication information; the first verification module is specifically configured to:
[0284] Perform certificate verification, signature verification, and permission verification on the data migration request;
[0285] If the data migration request passes the certificate verification, the signature verification, and the permission verification, it is determined that the data migration request passes the first verification processing; if the data migration request fails at least one of the certificate verification, the signature verification, and the permission verification, it is determined that the data migration request fails the first verification processing.
[0286] Optionally, the task indication information includes the connection method of the source database and migration specification parameters for indicating the data to be migrated in the data migration task; the second verification module is specifically configured to:
[0287] Perform a connection detection on the source database based on the connection method in the task indication information;
[0288] If it is determined that the connection to the source database is successful through the connection detection, then detect whether there is the data to be migrated indicated by the migration specification parameters in the source database; if it is determined that there is the data to be migrated in the source database, then determine that the migration request transaction passes the second verification process;
[0289] If it is determined that the connection to the source database fails through the connection detection, or if it is determined that there is no data to be migrated in the source database, then determine that the migration request transaction does not pass the second verification process.
[0290] Optionally, the device further includes:
[0291] A block generation module, configured to write the migration task transaction into the processing result of the migration request transaction to obtain a reference block;
[0292] The block chain-insertion module 1204 is further configured to perform a chain-insertion record process on the reference block;
[0293] The transaction addition module is further configured to, after the reference block is successfully chained, add the migration task transaction carried in the reference block to the transaction pool, so that nodes in the blockchain network can obtain the migration task transaction from the transaction pool.
[0294] In the data migration device provided in the embodiments of the present application, the transaction acquisition module first acquires a migration task transaction, which includes task indication information corresponding to the data migration task to be executed, and the task indication information is configured by a migration system contract provided by the blockchain network. The migration system contract is a system smart contract innovatively proposed in the embodiments of the present application for executing data migration tasks. Relevant personnel can configure the task indication information corresponding to the data migration task to be executed through the migration system contract to use the task indication information to guide the execution of the data migration task. Compared with the related art where smart contract codes for executing data migration tasks are manually written and deployed, the embodiments of the present application support relevant personnel to directly fill in the task indication information in the migration system contract provided by the blockchain network, without manually writing and deploying smart contract codes, the operation is simpler, and it does not require much time and effort. Further, the task allocation module responds to the acquired migration task transaction and allocates corresponding data migration subtasks to multiple nodes in the blockchain network respectively, so that the multiple nodes execute the corresponding data migration subtasks in parallel, obtain the data to be migrated indicated by the data migration subtasks from the source database indicated by the task indication information, and perform formatting processing on the obtained data to be migrated to obtain a target formatting result. Further, the result receiving module receives the target formatting results respectively sent by the above multiple nodes, and the block chain-on module generates a target block according to the received target formatting results and performs blockchain recording processing on the target block. In this way, the data to be migrated in the source database is migrated to be stored on the blockchain through the above method. During the above data migration process, multiple nodes in the blockchain network execute the corresponding data migration subtasks in parallel to perform parallel migration on different data to be migrated in the source database. Compared with the method of migrating data one by one in the related art, in the embodiments of the present application, multiple nodes perform data migration in parallel, which can greatly improve the migration efficiency and shorten the migration duration.
[0295] The embodiments of the present application also provide a computer device for implementing data migration. The computer device may specifically be a terminal device or a server. Hereinafter, the terminal device and the server provided in the embodiments of the present application will be introduced from the perspective of hardware implementation.
[0296] See Figure 13 , Figure 13 is a schematic structural diagram of the terminal device provided in the embodiments of the present application. As Figure 13As shown, for ease of explanation, only parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), an in-vehicle computer, etc. Taking the terminal as a computer as an example:
[0297] Figure 13 The figure shows a block diagram of a part of the structure of a computer related to the terminal provided by the embodiments of the present application. Referring to Figure 13 , the computer includes: a radio frequency (RF) circuit 1310, a memory 1320, an input unit 1330 (including a touch panel 1331 and other input devices 1332), a display unit 1340 (including a display panel 1341), a sensor 1350, an audio circuit 1360 (which can be connected to a speaker 1361 and a microphone 1362), a wireless fidelity (WiFi) module 1370, a processor 1380, and a power supply 1390 and other components. Those skilled in the art can understand that Figure 13 the computer structure shown in does not constitute a limitation on the computer, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0298] The memory 1320 can be used to store software programs and modules. The processor 1380 executes various functional applications and data processing of the computer by running the software programs and modules stored in the memory 1320. The memory 1320 may mainly include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the computer (such as audio data, a phone book, etc.). In addition, the memory 1320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0299] The processor 1380 is the control center of the computer, connecting various parts of the entire computer through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 1320, and by calling data stored in the memory 1320, it performs various functions of the computer and processes data. Optionally, the processor 1380 may include one or more processing units; preferably, the processor 1380 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 1380 either.
[0300] In the embodiment of the present application, the processor 1380 included in the terminal is further configured to execute the steps of any implementation manner of the data migration method provided in the embodiment of the present application.
[0301] See Figure 14 , Figure 14 is a schematic structural diagram of a server 1400 provided in an embodiment of the present application. The server 1400 may vary greatly due to configuration or performance differences, and may include one or more central processing units (CPUs) 1422 (for example, one or more processors) and a memory 1432, and one or more storage media 1430 (for example, one or more mass storage devices) for storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage media 1430 may be transient storage or persistent storage. The programs stored in the storage media 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processor 1422 may be configured to communicate with the storage media 1430 and execute a series of instruction operations in the storage media 1430 on the server 1400.
[0302] The server 1400 may further include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input / output interfaces 1458, and / or one or more operating systems, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM and so on.
[0303] The steps performed by the server in the above embodiments may be based on the Figure 14 shown server structure.
[0304] Among them, the CPU 1422 can also be used to execute the steps of any implementation manner of the data migration method provided in the embodiments of the present application.
[0305] The embodiments of the present application also provide a computer-readable storage medium for storing a computer program, and the computer program is used to execute any implementation manner of the data migration methods described in the foregoing various embodiments.
[0306] The embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any implementation manner of the data migration methods described in the foregoing various embodiments.
[0307] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.
[0308] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be in electrical, mechanical, or other forms.
[0309] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0310] In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0311] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store computer programs, such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0312] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist simultaneously. Among them, A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (one) of the following" or its similar expression refers to any combination of these items, including any combination of single item (one) or plural items (ones). For example, at least one (one) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0313] As described above, the above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of various embodiments of this application.
Claims
1. A data migration method, characterized in that, The method includes: Obtaining a migration task transaction; the migration task transaction includes task indication information corresponding to a data migration task to be executed, and the task indication information is configured by a migration system contract provided by a blockchain network; In response to the migration task transaction, respectively allocating corresponding data migration subtasks to multiple nodes in the blockchain network; the multiple nodes are used to execute the corresponding data migration subtasks in parallel to obtain the data to be migrated indicated by the data migration subtasks from the source database indicated by the task indication information, and perform formatting processing on the data to be migrated to obtain a target formatting result; Receiving the target formatting results respectively sent by the multiple nodes; Generating a target block according to each of the received target formatting results; performing an on-chain recording process on the target block.
2. The method according to claim 1, characterized in that, The step of, in response to the migration task transaction, respectively allocating corresponding data migration subtasks to multiple nodes in the blockchain network includes: Determining the total data to be migrated in the current stage of the data migration task according to a preset block size threshold and execution time threshold; Obtaining the respective target performance metrics of the multiple nodes; Determining the data to be migrated corresponding to each of the multiple nodes in the total data to be migrated according to the respective target performance metrics of the multiple nodes; For each node, generating a data migration subtask corresponding to the node according to the data to be migrated corresponding to the node, and allocating the corresponding data migration subtask to the node.
3. The method according to claim 2, wherein The target performance metrics include available processing resources and available memory; the step of determining the data to be migrated corresponding to each of the multiple nodes in the total data to be migrated according to the respective target performance metrics of the multiple nodes includes: For each node, calculating a target proportion of the available resources of the node in the total available resources according to the available processing resources and available memory of the node, and the available processing resources and available memory of each of the multiple nodes; determining the data to be migrated corresponding to the node according to the target proportion and the total data to be migrated.
4. The method according to claim 1, wherein The node executes the corresponding data migration subtask in the following manner: Parallelly obtaining the data to be migrated indicated by the data migration subtask from the source database through multiple data migration processes; Parallelly performing formatting processing on each of the obtained data to be migrated through the multiple data migration processes to obtain an initial formatting result corresponding to each of the data to be migrated; Performing a reduction process on the initial formatting results corresponding to each of the data to be migrated to obtain the target formatting result.
5. The method according to claim 1 or 4, characterized in that, The step of generating a target block according to each of the received target formatting results includes: Performing a reduction process on each of the received target formatting results to obtain a comprehensive formatting result; Generating the target block according to the comprehensive formatting result.
6. The method according to claim 5, characterized in that, The step of generating the target block according to the comprehensive formatting result includes: Detecting whether the currently migrated data of the data migration task has reached the total data to be migrated of the data migration task; If not, a new migration task transaction is generated based on the currently migrated data and the task indication information; the new migration task transaction and the comprehensive formatting result are written into the processing result of the current migration task transaction to obtain the target block. If it has been reached, the comprehensive formatting result is written into the processing result of the current migration task transaction to obtain the target block.
7. The method according to claim 6, wherein The processing of recording the target block on the blockchain includes: Sending the target block to other nodes in the blockchain network for consensus; If the target block meets the consensus passing condition, other nodes in the blockchain network are notified to append the target block to the ledger, update the status data corresponding to the target block in the status database, and, if the new migration task transaction is carried in the target block, add the new migration task transaction to the transaction pool.
8. The method according to claim 1, characterized in that, The task indication information is used to indicate the connection method of the source database; before responding to the migration task transaction and separately allocating corresponding data migration subtasks to multiple nodes in the blockchain network, the method further includes: Performing a connection detection on the source database based on the connection method indicated by the task indication information; If it is determined that the connection to the source database is successful through the connection detection, then respond to the migration task transaction and separately allocate corresponding data migration subtasks to multiple nodes in the blockchain network; if it is determined that the connection to the source database fails through the connection detection, then give up executing the response to the migration task transaction and separately allocate corresponding data migration subtasks to multiple nodes in the blockchain network.
9. The method according to claim 1, characterized in that, The migration task transaction is generated in the following manner: Receiving a data migration request; the data migration request is generated based on the migration system contract and includes the task indication information corresponding to the data migration task configured through the migration system contract; Performing a first verification process on the data migration request; If the data migration request passes the first verification process, a migration request transaction is generated based on the data migration request and the migration request transaction is added to the transaction pool; Obtaining the migration request transaction from the transaction pool and performing a second verification process on the migration request transaction; If the migration request transaction passes the second verification process, the migration task transaction is generated based on the task indication information in the migration request transaction.
10. The method according to claim 9, wherein The data migration request further includes a signature generated based on the task indication information; the performing a first verification process on the data migration request includes: Performing certificate verification, signature verification, and permission verification on the data migration request; If the data migration request passes the certificate verification, the signature verification, and the permission verification, it is determined that the data migration request passes the first verification process; if the data migration request fails at least one of the certificate verification, the signature verification, and the permission verification, it is determined that the data migration request fails the first verification process.
11. The method according to claim 9, wherein The task indication information includes the connection method of the source database and migration specification parameters, where the migration specification parameters are used to indicate the data to be migrated in the data migration task; the performing a second verification process on the migration request transaction includes: Based on the connection method in the task indication information, performing a connection detection on the source database; If it is determined that the connection to the source database is successful through the connection detection, detecting whether there is the data to be migrated indicated by the migration specification parameters in the source database; if it is determined that there is the data to be migrated in the source database, determining that the migration request transaction passes the second verification process; If it is determined that the connection to the source database fails through the connection detection, or if it is determined that there is no data to be migrated in the source database, determining that the migration request transaction fails to pass the second verification process.
12. The method according to claim 9, wherein The method further includes: Writing the migration task transaction into the processing result of the migration request transaction to obtain a reference block; Performing an on-chain recording process on the reference block; After the reference block is successfully on-chain, adding the migration task transaction carried in the reference block to the transaction pool, so that nodes in the blockchain network can obtain the migration task transaction from the transaction pool.
13. A data migration device, characterized in that, The apparatus includes: A transaction acquisition module, configured to acquire a migration task transaction; the migration task transaction includes task indication information corresponding to a data migration task to be executed, and the task indication information is configured through a migration system contract provided by a blockchain network; A task allocation module, configured to, in response to the migration task transaction, allocate corresponding data migration subtasks to multiple nodes in the blockchain network; the multiple nodes are used to execute the corresponding data migration subtasks in parallel to obtain the data to be migrated indicated by the data migration subtasks from the source database indicated by the task indication information, and perform a formatting process on the data to be migrated to obtain a target formatting result; A result receiving module, configured to receive the target formatting results respectively sent by the multiple nodes; A block on-chain module, configured to generate a target block according to the received target formatting results; performing an on-chain recording process on the target block.
14. A computer device, characterized in that, The device includes a processor and a memory; The memory is used to store a computer program; The processor is configured to execute the data migration method according to any one of claims 1 to 12 based on the computer program.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the data migration method according to any one of claims 1 to 12.
16. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or the instruction is executed by the processor, the data migration method according to any one of claims 1 to 12 is implemented.