Data processing method, database system, computer device and storage medium

By maintaining multiple versions of the Merkle B+ tree on multiple devices, the performance degradation problem of database systems when the data volume increases is solved, and a distributed database solution with improved throughput and resource savings is achieved.

CN116431632BActive Publication Date: 2026-01-16HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310334927.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2026-01-16
Estimated Expiration
2043-03-24

AI Technical Summary

Technical Problem

With the continuous growth of data volume, the performance of database systems based on Merkle B+ trees is affected by the size of single-machine memory and disk performance, resulting in a continuous decline in throughput.

Method used

By maintaining multiple versions of the Merkle B+ tree on multiple devices, the scheduling module distributes data modification instructions to the target devices. The target devices update the node data in the node path and store it to disk pages, reducing the data storage and multi-version maintenance pressure on a single device.

Benefits of technology

It improved the throughput of the database system, enhanced performance, reduced single-machine disk resource overhead, and enabled horizontal scaling and multi-version control of the distributed database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116431632B_ABST
    Figure CN116431632B_ABST
Patent Text Reader

Abstract

The application discloses a data processing method, system, device and storage medium, and belongs to the technical field of databases. The method is applied to a database system, the database system comprises a scheduling module and a plurality of devices, and different devices store data of root nodes in different versions of Merkle B+ trees. The scheduling module sends a data modification instruction carrying data of a target root node and a data modification set to a target device; the target device instructs at least one device to obtain data of nodes in a node path from the target root node to a target data node and update the nodes according to the data of the target root node and the data modification set; and the target device stores data of root nodes in the updated node path to a disk page of the target device, and the at least one device stores data of nodes other than the root nodes in the updated node path to disk pages. According to the application, multi-version data is dispersed to a plurality of devices, so that the pressure of data storage and multi-version maintenance can be reduced, and the performance of the database system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, and in particular to a data processing method, a database system, a computer device and a storage medium. BACKGROUND

[0002] The Merkle B+ tree is a tree structure improved based on the B+ tree, which contains two types of nodes: index nodes and data nodes at the last layer. In the related art, the index nodes store the minimum keys and hash values of their subordinate nodes, and the data nodes store key-value pairs. The data stored in each node of the Merkle B+ tree can be stored in the form of a page in the disk.

[0003] At present, a database can be implemented based on the Merkle B+ tree, that is, the underlying storage engine of the database can be a Merkle B+ tree structure. However, in the case of continuous growth of data, the performance of the database will continue to decline in throughput performance after the data volume accumulates to a certain extent, which is affected by the size of the single machine memory and the performance of the disk. SUMMARY

[0004] The present application provides a data processing method, a database system, a computer device and a storage medium, which can improve the performance of the database system. The technical solution is as follows:

[0005] In a first aspect, a data processing method is provided, which is applied to a database system, the database system includes a scheduling module and a plurality of devices, different devices in the plurality of devices are used to store data of root nodes in different versions of Merkle B+ trees, and the method includes:

[0006] The scheduling module sends a data modification instruction to a target device, the data modification instruction carries data of a target root node and a data modification set, the target root node is a root node in the latest version of the Merkle B+ tree, the target device is a device in the plurality of devices which is arranged after a device storing data of the target root node, and the data modification set includes key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted;

[0007] After the target device receives the data modification instruction, at least one device in the plurality of devices is instructed by the data of the target root node and the data modification set to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path;

[0008] The target device stores data of a root node in the updated node path to a disk page of the target device, and the at least one device stores data of other nodes except the root node in the updated node path to a disk page.

[0009] In the present application, a device can correspond to one version of the Merkel B+ tree, multiple devices can maintain multiple versions of the Merkel B+ tree, by dispersing multiple versions of data to multiple devices, the pressure of data storage and multiple version maintenance of a single device can be reduced, thereby improving the throughput of the database system, and further improving the performance of the database system.

[0010] Optionally, the target device instructs at least one device in the multiple devices to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and the data modification set, including:

[0011] The target device obtains data of nodes in a node path from the target root node to the target data node according to the data of the target root node and the key value in the data modification set;

[0012] The target device updates the nodes in the node path according to the data modification set.

[0013] Optionally, the target device stores data of a root node in the updated node path to a disk page of the target device, and the at least one device stores data of other nodes in the updated node path except the root node to a disk page, including:

[0014] If the tree height of the node path is less than or equal to a preset height, the target device stores data of each node in the updated node path to a disk page of the target device;

[0015] If the tree height of the node path is greater than the preset height, the target device divides the node path into m segment paths, the first segment path in the m segment paths includes the root node, and the m is an integer greater than or equal to 2; the target device stores data of nodes in the first segment path in the updated node path to a disk page of the target device, and stores data of nodes in m-1 segment paths in the m segment paths except the first segment path to disk pages of other devices in the multiple devices except the target device.

[0016] Optionally, any one of the m-1 segment paths corresponds to one device in the multiple devices except the target device.

[0017] The target device stores data of nodes in m-1 segment paths in the m segment paths except the first segment path to disk pages of other devices in the multiple devices except the target device, including:

[0018] The target device stores the updated data of the nodes in any one of the m-1 segments of the path to the disk page of the device corresponding to the one segment of the path;

[0019] The method further comprises:

[0020] If a network exception occurs between the target device and the device corresponding to the one segment of the path, the target device stores the updated data of the nodes in the one segment of the path to the disk page of the device located after the device corresponding to the one segment of the path.

[0021] Optionally, the target device instructs at least one of the plurality of devices to acquire the data of the nodes in the node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and the data modification set, comprising:

[0022] The target device determines a first node according to the data of the target root node and the key value in the data modification set, the first node being a node to which the key value pair and / or key in the data modification set is distributed among the nodes subordinate to the target root node;

[0023] If the target device does not store the data of the first node, the target device acquires a first data amount and a second data amount corresponding to the first node, the first data amount corresponding to the first node being a total data amount of the key value pair and / or key in the data modification set to be distributed to the first node, and the second data amount corresponding to the first node being a total data amount of the first node and the nodes located in a lower layer of the first node in the node path;

[0024] The target device instructs the at least one device to acquire the data of the first node and the nodes located in the lower layer of the first node in the node path and update the nodes in the node path according to the first data amount and the second data amount corresponding to the first node.

[0025] Optionally, the target device instructs the at least one device to acquire the data of the first node and the nodes located in the lower layer of the first node in the node path and update the nodes in the node path according to the first data amount and the second data amount corresponding to the first node, comprising:

[0026] If the first data amount corresponding to the first node is less than the second data amount, the target device sends a first update request to a first device of the plurality of devices storing the data of the first node to instruct the first device to acquire the data of the first node and the nodes located in the lower layer of the first node in the node path and update the nodes.

[0027] The target device receives a first update result returned by the first device for the first update request, and updates a root node in the node path according to the first update result.

[0028] Optionally, after the target device sends the first update request to the first device storing the data of the first node in the plurality of devices, the method further comprises:

[0029] After the first device receives the first update request, the first device acquires the data of the first node stored in a corresponding disk page in the first device according to the page identifier of the first node.

[0030] If the first node is an index node, the first device determines a second node according to the data of the first node and the key value in the key value pair and / or the key carried in the first update request, the second node being a node to which the key value pair and / or the key carried in the first update request is distributed among nodes subordinate to the first node.

[0031] If the first device does not store the data of the second node, the first device acquires a first data amount and a second data amount corresponding to the second node, the first data amount corresponding to the second node being a total data amount of the key value pair and / or the key carried in the first update request and needing to be distributed to the second node, and the second data amount corresponding to the second node being a total data amount of the second node and nodes located in a lower layer of the second node in the node path.

[0032] If the first data amount corresponding to the second node is less than the second data amount, the first device sends a second update request to a second device storing the data of the second node in the plurality of devices, to instruct the second device to acquire the data of the second node and nodes located in a lower layer of the second node in the node path and update nodes.

[0033] The first device receives a second update result returned by the second device for the second update request, and updates the first node according to the second update result, and carries a minimum key, a hash value and a page identifier of a node in an uppermost layer in the updated node in the first update result and returns the first update result to the target device.

[0034] Optionally, the data modification instruction carries a block identifier, and the block identifier in the data modification instruction is used to identify a block corresponding to the data modification set; the method further comprises:

[0035] The scheduling module receives a rollback request, and the rollback request carries a target block identifier.

[0036] The scheduling module sends a rollback instruction to each of the plurality of devices if the execution progress of the current block is already logged, and the rollback instruction carries the target block identifier;

[0037] After each of the plurality of devices receives the rollback instruction, the target block identified by the target block identifier and the version information corresponding to all blocks after the target block are deleted, a rollback completion message is sent to the scheduling module, and the version information corresponding to the block is information recorded in the process of processing the data modification set corresponding to the block;

[0038] If the scheduling module receives the rollback completion message sent by each of the plurality of devices, the data of the root node corresponding to the target block and all blocks after the target block are deleted, and the block identifiers of the target block and all blocks after the target block are deleted.

[0039] Optionally, the method further comprises:

[0040] The scheduling module sends a first device addition instruction to each of the plurality of devices, and sends a second device addition instruction to the specified device, the first device addition instruction carries device information of the specified device, and the second device addition instruction carries the number of devices of the plurality of devices;

[0041] For any one of the plurality of devices, after the one device receives the first device addition instruction, the device information is recorded, and a communication connection is established with the specified device corresponding to the device information, and an addition success message is returned to the scheduling module after successfully establishing a communication connection with the specified device;

[0042] After the specified device receives the second device addition instruction, a communication connection is established with other devices, and when the number of devices successfully establishing a communication connection with itself is determined to be the number of devices carried by the second device addition instruction, an addition success message is returned to the scheduling module;

[0043] If the scheduling module receives the addition success message returned by each of the plurality of devices and receives the addition success message returned by the specified device, it is determined that the specified device is added successfully.

[0044] In a second aspect, a database system is provided, which comprises a scheduling module and a plurality of devices, and different devices in the plurality of devices are used to store data of root nodes in different versions of Merkle B+ trees.

[0045] The scheduling module is configured to send a data modification instruction to a target device, the data modification instruction carrying data of a target root node and a data modification set, the target root node being a root node in a latest version of the Merkle B+ tree, and the target device being a device in the plurality of devices that is arranged after a device storing data of the target root node.

[0046] The target device is configured to, after receiving the data modification instruction, instruct at least one device in the plurality of devices to acquire data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and the data modification set.

[0047] The target device is further configured to store data of a root node in the updated node path to a disk page of the target device.

[0048] The at least one device is configured to store data of nodes other than the root node in the updated node path to a disk page.

[0049] In a third aspect, a data processing method is provided, and the method is applied to a target device in a database system, the database system including a scheduling module and a plurality of devices, different devices in the plurality of devices being configured to store data of root nodes in different versions of a Merkle B+ tree, the target device being a device in the plurality of devices that is arranged after a device storing data of a target root node, the target root node being a root node in a latest version of the Merkle B+ tree, and the method including:

[0050] receiving a data modification instruction sent by the scheduling module, the data modification instruction carrying data of the target root node and a data modification set, the data modification set including key-value pairs to be added, key-value pairs to be updated, and / or key-value pairs to be deleted;

[0051] instructing at least one device in the plurality of devices to acquire data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and the data modification set;

[0052] storing data of a root node in the updated node path to a disk page of the target device, and storing data of nodes other than the root node in the updated node path to a disk page by the at least one device.

[0053] In a fourth aspect, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the computer program is executed by the processor, the operations performed by the scheduling module or any one of the plurality of devices in the data processing method of the first aspect are implemented.

[0054] In a fifth aspect, a computer readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the operations performed by the scheduling module or any one of the plurality of devices in the data processing method of the first aspect are implemented.

[0055] In a sixth aspect, a computer program product containing instructions, which when executed on a computer, causes the computer to perform the operations performed by the scheduling module or any one of the plurality of devices in the data processing method of the first aspect.

[0056] It can be understood that the beneficial effects of the second aspect, the third aspect, the fourth aspect, the fifth aspect, and the sixth aspect can be referred to the related description in the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0058] Figure 1 is a schematic diagram of a Merkle B+ tree provided by an embodiment of the present application;

[0059] Figure 2 is a schematic diagram of a database system provided by an embodiment of the present application;

[0060] Figure 3 is a flowchart of a data processing method provided by an embodiment of the present application;

[0061] Figure 4 is a schematic diagram of a node path provided by an embodiment of the present application;

[0062] Figure 5 is a schematic diagram of another node path provided by an embodiment of the present application;

[0063] Figure 6 is a structural schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0064] In order to make the objects, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0065] It should be understood that the "multiple" mentioned in the present application refers to two or more. In the description of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" herein only represents the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent three cases of A alone, A and B together, and B alone. In addition, in order to clearly describe the technical solutions of the present application, the same items or similar items with basically the same functions and roles are distinguished by using "first", "second", etc. The skilled in the art can understand that "first", "second", etc. do not limit the quantity and execution order, and "first", "second", etc. also do not necessarily mean different.

[0066] The phrase "one embodiment" or "some embodiments" appearing in the present application means that the specific features, structures or characteristics described in the embodiment are included in one or more embodiments of the present application. Therefore, the phrases "in one embodiment", "in some embodiments", "in other some embodiments", "in other some embodiments" appearing in the present application do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. In addition, the terms "include", "contain", "have" and their variants mean "include but not limited to", unless otherwise specifically emphasized.

[0067] Before the embodiments of the present application are explained in detail, the application scenarios of the embodiments of the present application are described.

[0068] The embodiments of the present application are applied to the scene of data processing based on Merkle B+ tree. For example, after the execution module in the blockchain system executes all transactions in a block, a series of ledger modification sets are generated. In this case, the data processing method provided by the embodiments of the present application can be used to process these ledger modification sets based on Merkle B+ tree.

[0069] Next, the structure of Merkle B+ tree is introduced.

[0070] Merkle B+ tree is a tree data structure, and Merkle B+ tree includes two types of nodes: index node and data node at the lowest layer. The index node and the data node are both logical nodes.

[0071] The data node stores a plurality of key-value pairs, each of which includes a key value and a value. The data node has a minimum key and a hash value. The minimum key of the data node is the minimum key value among the key values of all the key-value pairs stored in the data node. Alternatively, the hash value of the data node is the hash value of the data obtained by concatenating all the key-value pairs stored in the data node.

[0072] The index node stores the minimum key and the hash value of each of all the nodes under it. The index node has a minimum key and a hash value, the minimum key of the index node being the minimum key value among the minimum keys of all the nodes stored in the index node, and the hash value of the index node being the hash value of the data obtained by concatenating the hash values of all the nodes stored in the index node.

[0073] For example, Figure 1 is a schematic diagram of a Merkle B+ tree provided by an embodiment of the present application. Referring to Figure 1 , the Merkle B+ tree includes a plurality of data nodes (for example, Figure 1 , nodes n4, n5, and n6) and a plurality of index nodes (for example, Figure 1 , nodes n1, n2, and n3). The nodes under node n1 include nodes n2 and n3, the nodes under node n2 include nodes n4 and n5, and the nodes under node n3 include node n6. In the present embodiment, the index node at the uppermost layer can be referred to as a root node, for example, Figure 1 , node n1 in

[0074] Figure 1 The data node n4 in stores a key-value pair key:a-value:1 and a key-value pair key:b-value:2. The data node n5 stores a key-value pair key:c-value:3 and a key-value pair key:d-value:4. The data node n6 stores a key-value pair key:e-value:5 and a key-value pair key:f-value:6. In this case, the minimum key of the data node n4 is the smaller key:a among key:a and key:b, and the hash value of the data node n4 is the hash value hash:H(n4) of the data obtained by concatenating key:a-value:1 and key:b-value:2. The minimum key of the data node n5 is the smaller key:c among key:c and key:d, and the hash value of the data node n5 is the hash value hash:H(n5) of the data obtained by concatenating key:c-value:3 and key:d-value:4. The minimum key of the data node n6 is the smaller key:e among key:e and key:f, and the hash value of the data node n6 is the hash value hash:H(n6) of the data obtained by concatenating key:e-value:5 and key:f-value:6.

[0075] Figure 1 Index node n2 stores the minimum key (key:a) and hash value (hash:H(n4)) of its subordinate data node n4, and the minimum key (key:c) and hash value (hash:H(n5)) of its subordinate data node n5. Index node n3 stores the minimum key (key:e) and hash value (hash:H(n6)) of its subordinate data node n6. Furthermore, the minimum key of index node n2 is the smaller of key:a and key:c (key:a), and the hash value of index node n2 is the hash value (hash:H(n2)) obtained by concatenating hash:H(n4) and hash:H(n5). The minimum key of index node n3 is key:e, and the hash value of index node n3 is the hash value (hash:H(n3)) of hash:H(n6).

[0076] Figure 1 The index node n1 (i.e., the root node n1) stores the minimum key key: a and hash value hash: H(n2) of its subordinate index node n2 and the minimum key key: e and hash value hash: H(n3) of its subordinate index node n3.

[0077] In a Merkle B+ tree, all nodes except the root node have a key range. Specifically, for any node at any level in a Merkle B+ tree, if this node is the first node at that level (generally the leftmost node), then the key range of this node is less than the minimum key of the next node in that level. If this node is the last node at that level (generally the rightmost node), then the key range of this node is greater than or equal to the minimum key of this node. If this node is any node at that level other than the first or last node, then the key range of this node is greater than or equal to the minimum key of this node and less than the minimum key of the next node in that level.

[0078] For example, such as Figure 1 As shown, the second level of the Merkle B+ tree includes index nodes n2 and n3. Index node n2 is the first node in the second level, and the range of keys for index node n2 is the range of keys less than the smallest key (key:e) of index node n3. Index node n3 is the last node in the second level, and the range of keys for index node n3 is the range of keys greater than or equal to the smallest key (key:e) of index node n3.

[0079] The data stored in each node (including index nodes and data nodes) in the Merkel B+ tree can be stored in a disk, and specifically can be stored in a disk page of the disk. In some embodiments, in order to adapt to the read-write strategy of the disk, the size of each disk page is usually specified as 4K (kilobyte). In this case, in addition to containing the minimum key and hash value of each node under the index node, the data in any index node can also contain the page identity (ID) of the index node and the page identity of each node under the index node. The page identity of a certain node is used to identify the disk page storing the data of the node. That is, the page identity of the index node is used to identify the disk page storing the data of the index node, and the page identity of a certain node under the index node is used to identify the disk page storing the data of the node under the index node.

[0080] At present, a database can be implemented based on a Merkel B+ tree, that is, the underlying storage engine of the database can be a Merkel B+ tree structure. However, in the case of continuous growth of data, the performance of the database will continue to decline in throughput performance after the data accumulates to a certain extent, which is affected by the size of the single machine memory and the performance of the disk.

[0081] Therefore, an embodiment of the present application proposes a new database system based on the existing database basic process, which is a new distributed horizontal expansion scheme, and can solve the single machine performance bottleneck of the database while ensuring the correctness of the functions and protocols of the database, such as ensuring the correctness of various protocols such as data reading, writing, multi-version control, and fast rollback.

[0082] The related concepts involved in the database system provided by the embodiment of the present application are described below.

[0083] After storing the data of each node in the Merkel B+ tree to the disk page, the logical tree of the Merkel B+ tree is saved in the disk. In this case, the page identity of the root node of the Merkel B+ tree can be recorded, and all node data in the Merkel B+ tree can be obtained from the disk according to the page identity of the root node of the Merkel B+ tree, so the page identity of the root node of the Merkel B+ tree can correspond to the logical tree of the Merkel B+ tree saved in the disk. When the Merkel B+ tree is updated subsequently, a new version of the logical tree of the Merkel B+ tree is saved in the disk each time the Merkel B+ tree is updated, and the page identity of the root node corresponding to this version of the logical tree (i.e., the page identity of the root node in the updated Merkel B+ tree) is recorded. In this case, not only the latest version of the logical tree is saved in the disk, but also at least one historical version of the logical tree. The page identity of the root node corresponding to the latest version of the logical tree can be recorded, and the page identity of the root node corresponding to each historical version of the at least one historical version of the logical tree can also be recorded.

[0084] It should be noted that, in terms of multi-version control and data rollback, since the Merkle B+ tree is equivalent to saving multiple logical trees in the disk, when the Merkle B+ tree needs to be rolled back to a version, only the current root node needs to be pointed to the root node of the logical tree of this version.

[0085] The database system provided by the embodiments of the present application will be described below.

[0086] The database system provided by the embodiments of the present application retains the functions supported by the existing single-machine database based on the Merkle B+ tree (which can be referred to as vidb (Verified Independent Database)) to ensure that the database system can be applied to the existing system that needs to apply the Merkle B+ tree for data processing. For example, the database system can be applied to a blockchain system, and the blockchain system can perform data reading and writing on the database system, such as querying data from the database system, adding data to the database system, updating or deleting data in the database system, and the like.

[0087] The embodiments of the present application take "the database needs to retain limited multi-version data to meet the needs of data rollback" and "the mode of multi-version control is cow (copy on write)" as the starting point, and propose a strategy that each device (also referred to as a physical machine) corresponds to a version of a logical tree, which overall implements a distributed database scheme distributed on N devices. Wherein, N is an integer greater than or equal to 2. Optionally, N is greater than or equal to a preset version number. The preset version number is the number of rollback versions supported by the Merkle B+ tree. For example, the preset version number is related to the rollback limit of the blockchain system, that is, the preset version number can be the maximum range allowed by the blockchain system.

[0088] Figure 2 is a schematic diagram of a database system provided by an embodiment of the present application. Referring to Figure 2 The database system can include a scheduling module 201 and a plurality of devices 202.

[0089] The scheduling module 201 can communicate with each device 202 in the plurality of devices 202, such as the scheduling module 201 and any one device 202 can communicate through wired connection or wireless connection. Any two devices 202 in the plurality of devices 202 can also communicate, such as any two devices 202 can communicate through wired connection or wireless connection.

[0090] The scheduling module 201 can be a standalone physical machine, or can be part of other systems, for example, the scheduling module 201 can be arranged in a blockchain system. Optionally, in one aspect, the scheduling module 201 is responsible for interfacing and managing the progress of block execution in the blockchain system, and the scheduling module 201 exposes an API (Application Program Interface) layer providing basic read-write interfaces to the blockchain system. In another aspect, the scheduling module 201 needs to maintain the connection with the plurality of devices 202, and is responsible for sensing the execution progress, survival status, etc. of the plurality of devices 202.

[0091] The underlying storage engine of the database system uses the plurality of devices 202. Each device 202 can correspond to a version of the Merkle B+ tree. Different devices 202 correspond to different versions of the Merkle B+ tree. Different devices 202 are used to store the data of the root nodes in different versions of the Merkle B+ tree. In this way, according to the data of the root nodes stored in any one device 202, all node data in the corresponding version of the Merkle B+ tree can be obtained, thereby realizing the correspondence between one device 202 and one version of the Merkle B+ tree.

[0092] For any one device 202, the device 202 independently maintains the functions of index data management, index file storage, data data management, and data file storage, wherein the index data is the data of the index node, and the data data is the data of the data node. The device 202 not only stores the data of the root nodes in its corresponding version of the Merkle B+ tree, but also can store the data of one or more nodes other than the root nodes in its corresponding version of the Merkle B+ tree, and further can store the data of one or more nodes other than the root nodes in other versions of the Merkle B+ tree.

[0093] For any one device 202, the index data and the data data are managed in the memory of the device 202 in logical nodes, and are organized in units of disk pages on the disk of the device 202, which can also be referred to as pages, and is usually an array of 4K bytes. Each disk page has a globally unique page identifier (page ID). In the distributed architecture provided in the embodiments of the present application, the page identifier needs to be able to represent device information and disk page information, that is, the page identifier is used to identify a disk page in a device 202. For example, the page identifier can include a device identifier used to identify the device 202 and an offset position used to indicate the file offset position of the disk page in the device 202 identified by the device identifier. For example, the page identifier can be of uint64 type, in which case the first 8 bits or 16 bits can be used to represent the device identifier, and the remaining bits can be used to represent the offset position. In this way, the page identifier can be quickly indexed to a certain device 202, and the offset position of the disk page in the file of the device 202 can be obtained, so that the page identifier can uniquely identify a disk page in a device 202.

[0094] In the embodiments of the present application, the multi-version control mechanism becomes a single machine that only needs to maintain one active version due to the distributed architecture. On the one hand, the multi-version data is dispersed to multiple devices 202, reducing the data storage amount of a single device 202; on the other hand, the disk read I / O (Input / Output) caused by reading data during block execution and the disk write I / O caused by writing the account book modification set to the disk are dispersed from the single machine to multiple devices 202. Thus, compared with the manner of simultaneously maintaining multiple active versions on a single machine in the related art, the distributed architecture provided in the embodiments of the present application greatly reduces the overhead of the disk resources of the single machine and saves the processing resources of the single machine.

[0095] In some embodiments, the execution module in the blockchain system generates a key to be queried in the process of executing a transaction in a block, and the execution module can call the read-write interface provided by the API layer to send a data query request carrying the key to be queried to the scheduling module 201. After receiving the data query request, the scheduling module 201 can query the value corresponding to the key carried by the data query request from the multiple devices 202 according to the page identifier of the target root node and return the value to the execution module, and the target root node is the root node in the latest version of the Merkle B+ tree.

[0096] In some embodiments, the execution module generates a series of ledger modification sets after completing all transactions in a certain block, which can include key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted, and in this case, the execution module can call the read-write interface provided by the API layer to send a data modification request carrying the key-value pairs to be added, the key-value pairs to be updated, and / or the keys to be deleted to the scheduling module 201. After receiving the data modification request, the scheduling module 201 can determine that the execution progress of the block is being executed, and update the Merkle B+ tree stored in the plurality of devices 202 according to the page identifier of the target root node and the key-value pairs and / or keys carried by the data modification request. In this case, if the plurality of devices 202 implement the persistence of the updated Merkle B+ tree, i.e., all node data in the updated Merkle B+ tree is stored in the disk page, the scheduling module 201 can determine that the execution progress of the block is already on disk.

[0097] In some embodiments, the scheduling module 201 is responsible for receiving computing requests (including the above-mentioned data modification requests) and persistence requests in the blockchain system, and organizing them into network requests to be delivered to a determined device 202 in the lower layer for execution. With the coordination mechanism of the scheduling module 201, the devices 202 that actually process the requests in the lower layer can execute the core process asynchronously to the maximum extent (such as completing the batch update operation and directly submitting it to the background for asynchronous disk flushing), and the scheduling module 201 is responsible for coordinating the execution gap between the upper-layer blockchain system and the lower-layer devices 202.

[0098] Each device 202 in the lower layer holds a root node of a Merkle B+ tree. According to the characteristics of the tree-shaped data structure, each device 202 can communicate with other devices 202 through the data of the root node held by itself to obtain the node data of the complete Merkle B+ tree in the current version. In this way, a device 202 can start from the root node and, through coordination with other devices 202, be responsible for controlling the completion of the update of the Merkle B+ tree, which also completes the execution process of a block. After completing the update of the Merkle B+ tree, a device 202 can also complete the persistence of the updated Merkle B+ tree through coordination with other devices 202, which also completes the disk landing process of a block.

[0099] It should be noted that each device 202 in the plurality of devices 202 can cyclically process the computing request corresponding to a block to implement the execution of the block. That is, after the computing request corresponding to a certain block is processed by a certain device 202, the computing request corresponding to the next block of this block can be processed by the next device 202 of this device 202. In this way, each device 202 in the plurality of devices 202 can maintain the corresponding version of the Merkle B+ tree obtained after executing the computing request corresponding to a block.

[0100] In the database system provided in the embodiments of the present application, the plurality of devices 202 store multi-version information, thereby not only reducing resource consumption caused by storing multiple versions on a single machine, but also naturally implementing a multi-version control protocol, thus reducing the pressure of single-machine data storage and multi-version maintenance. In addition, the number of the plurality of devices 202 at the bottom layer can be dynamically added or deleted as the system continuously runs, that is, a user can customize the number of the plurality of devices 202 at the bottom layer, thus realizing dynamic horizontal expansion.

[0101] The process of constructing an initial Merkle B+ tree based on the database system will be described below, which can include the following steps (1)-(4):

[0102] (1) The scheduling module obtains a plurality of key-value pairs to be stored.

[0103] The plurality of key-value pairs are key-value pairs that need to be stored based on the Merkle B+ tree. The plurality of key-value pairs are key-value pairs used to construct an initial Merkle B+ tree.

[0104] The plurality of key-value pairs can be sent to the scheduling module by other systems. For example, after executing all transactions in a block, the execution module in the blockchain system will generate a series of ledger modification sets, which can include the plurality of key-value pairs to be stored. In this case, the execution module in the blockchain system can send the plurality of key-value pairs to the scheduling module in a data storage request to instruct the scheduling module to store the plurality of key-value pairs based on the Merkle B+ tree, at which time the scheduling module can construct an initial Merkle B+ tree according to the plurality of key-value pairs.

[0105] There is a natural global clock, such as a block number, in the blockchain system, and the block number is continuously increasing. In some embodiments, the data storage request can carry a block number, which is used to indicate that the data storage request is generated after executing transactions in which block. The scheduling module can determine the block number carried in the data storage request as the block number of the current block.

[0106] (2) The scheduling module sends a data storage instruction carrying the plurality of key-value pairs to one of the plurality of devices, and the data storage instruction is used to instruct to construct an initial Merkle B+ tree according to the plurality of key-value pairs to be stored.

[0107] Optionally, the scheduling module can randomly select a device from the plurality of devices and send the data storage instruction to the device.

[0108] Alternatively, the scheduling module can select a device with the smallest device identifier from the plurality of devices according to the device identifier of each device in the plurality of devices, and send the data storage instruction to the device. For example, the number of the plurality of devices is 10, and the device identifiers of the 10 devices are 0 to 9 respectively. The scheduling module can send the data storage instruction to the device with the device identifier 0.

[0109] Alternatively, the scheduling module can select a device from the plurality of devices according to the block identifier of the current block, and send the data storage instruction to the device. Alternatively, the block identifier of the current block and the device identifier of the device capable of executing the current block (herein, the device capable of processing the data storage instruction corresponding to the current block) can have an association relationship, which can be set by the technician in advance. For example, the number of the plurality of devices is 10, and the device identifiers of the 10 devices are 0 to 9 respectively. The block identifier of the current block is 0. In this case, the device identifier of the device capable of executing the current block can be obtained by taking the block identifier of the current block modulo the number of the plurality of devices, i.e., 0 modulo 10 is 0. The device with the device identifier 0 is determined as the device capable of executing the current block.

[0110] (3) The device constructs a Merkle B+ tree according to the plurality of key-value pairs.

[0111] Constructing a Merkle B+ tree according to the plurality of key-value pairs means storing the plurality of key-value pairs into data nodes in the Merkle B+ tree.

[0112] The data nodes in the Merkle B+ tree contain key-value pairs. The data nodes have minimum keys and hash values. The minimum key of a data node is the minimum key value among all key values of key-value pairs contained in the data node. Alternatively, the hash value of the data node is the hash value of the data obtained by concatenating all key-value pairs contained in the data node. The index nodes in the Merkle B+ tree contain the minimum keys and hash values of all nodes under them. The index nodes have minimum keys and hash values. The minimum key of an index node is the minimum key value among all minimum keys of nodes contained in the index node. The hash value of the index node is the hash value of the data obtained by concatenating all hash values of nodes contained in the index node.

[0113] The operation of the device for constructing a Merkle B+ tree according to the plurality of key-value pairs is similar to the operation of a device for constructing a Merkle B+ tree according to a plurality of key-value pairs in related technologies, and the embodiments of the present application do not elaborate on this.

[0114] It should be noted that, in the process of constructing the Merkle B+ tree, the device can assign a page identifier to each newly generated node in the Merkle B+ tree, and the page identifier of any node is used to identify the device and the disk page used to subsequently store data of the node. In this case, for any index node, the device can also add the page identifier of the index node and the page identifier of each node under the index node in the data of the index node. It can be understood that, the assignment of a page identifier to a node in the Merkle B+ tree by a device indicates that the data of the node will be subsequently stored in the disk page of the device, that is, the device identifier in the page identifier assigned to the node by the device is the device identifier of the device, and the page identifier assigned by the device is used to identify the device and the disk page in the device.

[0115] It should be noted that, the data amount of each node in the Merkle B+ tree is less than or equal to a preset data amount. The preset data amount can be set in advance, for example, the preset data amount can be the same as the storage space size (such as 4K) of the disk page.

[0116] (4) The device stores the data of each node in the Merkle B+ tree to the disk page of the device.

[0117] When the device stores the data of each node in the Merkle B+ tree to the disk page of the device, the data of each node can be stored in the corresponding disk page according to the page identifier of each node in the Merkle B+ tree, so as to realize the persistence of the Merkle B+ tree.

[0118] It should be noted that, after the device stores the data of each node in the Merkle B+ tree to the disk page of the device, the logical tree of the Merkle B+ tree of this version is saved in the disk. In this case, the device can also record the page identifier of the root node in the Merkle B+ tree, and according to the page identifier of the root node in the Merkle B+ tree, all node data in the Merkle B+ tree can be obtained layer by layer through the root node, that is, all node data in the Merkle B+ tree can be obtained from the disk, so the page identifier of the root node in the Merkle B+ tree can correspond to the logical tree of the Merkle B+ tree of this version saved in the disk.

[0119] Optionally, after the device builds the Merkle B+ tree according to the plurality of key-value pairs in step (3) above, the device can further send data of a root node in the Merkle B+ tree to the scheduling module, so that the scheduling module can determine that the execution progress of the current block is completed. Then, the scheduling module can obtain a hash value (merkle-root) of the root node according to the data of the root node, and return the hash value of the root node to the upper-layer blockchain system. In addition, the scheduling module can also record a mapping relationship between a page identifier of the root node and a block identifier of the current block, so as to determine which version of the Merkle B+ tree the page identifier of the root node corresponds to. It should be noted that, after receiving the hash value of the root node sent by the scheduling module, the blockchain system can determine that the current block is executed completely, and at this time, the blockchain system can start to execute the next block.

[0120] In some embodiments, after the device builds the Merkle B+ tree in step (3) above, the device can directly execute step (4) above to store data of each node in the built Merkle B+ tree to a disk page of the device, and send a persistence completion message to the scheduling module after the storage is completed. After receiving the persistence completion message, the scheduling module determines that the execution progress of the current block is completed. Then, the scheduling module sends the persistence completion message to the blockchain system to indicate that the current block is completed.

[0121] In some other embodiments, after the blockchain system receives the hash value of the root node sent by the scheduling module, the blockchain system can send a persistence request to the scheduling module. After receiving the persistence request, the scheduling module can send a commit request to the device responsible for executing the current block. After receiving the commit request, the device executes step (4) above to store data of each node in the built Merkle B+ tree to a disk page of the device, and sends a persistence completion message to the scheduling module after the storage is completed. After receiving the persistence completion message, the scheduling module determines that the execution progress of the current block is completed. Then, the scheduling module sends the persistence completion message to the blockchain system to indicate that the current block is completed.

[0122] After the initial Merkle B+ tree is built through steps (1) to (4) above and all node data in the Merkle B+ tree is saved in the disk of the device, subsequent data processing can be performed based on the Merkle B+ tree. The data processing method provided by the embodiments of the present application is explained and described in detail below.

[0123] Figure 3 is a flowchart of a data processing method provided by the embodiments of the present application. The method can be applied to a database system as shown in Figure 2 . Referring to Figure 3 , the method comprises the following steps:

[0124] Step 301: The scheduling module sends a data modification instruction to the target device, the data modification instruction carrying data of the target root node and a data modification set.

[0125] The target root node is a root node in the latest version of the Merkle B+ tree. The scheduling module records data of the root node in the latest version of the Merkle B+ tree, and also records data of the root node in the Merkle B+ tree in one or more historical versions.

[0126] The data modification instruction is used to instruct updating the Merkle B+ tree based on the data modification set carried by the data modification instruction. The data modification set can include key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted. The data modification set can be sent to the scheduling module by other systems. For example, an execution module in a blockchain system can generate a series of ledger modification sets after executing all transactions in a block, and the ledger modification sets can include key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted. In this case, the execution module can send a data modification request carrying the key-value pairs to be added, the key-value pairs to be updated, and / or the keys to be deleted to the scheduling module. After receiving the data modification request, the scheduling module can carry the key-value pairs to be added, the key-value pairs to be updated, and / or the keys to be deleted as the data modification set in the data modification instruction and send the data modification instruction to the target device. Optionally, the data modification request can also carry a block identifier, which is used to indicate that the data modification request is generated after executing transactions in which block. The scheduling module can determine the block identifier carried in the data modification request as the block identifier of the current block, and can also carry the block identifier in the data modification instruction. The block identifier in the data modification instruction is used to identify the block corresponding to the data modification set in the data modification instruction.

[0127] Optionally, the Merkle B+ tree in the embodiments of the present application can support batch modification. In this case, the number of key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted included in the data modification set can be multiple, and accordingly concurrent updating of nodes in the Merkle B+ tree can be implemented.

[0128] The target device is a device that is arranged after a device storing data of the target root node among a plurality of devices. The plurality of devices can execute blocks in a loop. In this case, the device storing data of the target root node is a device that executes a previous block, and thus a device arranged after the device can be used as a target device that executes a current block.

[0129] It is noted that if the number of blocks completed by the plurality of devices is greater than or equal to the number of the plurality of devices, each of the plurality of devices stores data of a root node of a version of the Merkle B+ tree, in which case, the device storing the data of the target root node corresponds to the latest version of the Merkle B+ tree, and the device following the device in the order (i.e., the target device) corresponds to the oldest version of the Merkle B+ tree. Since the number of the plurality of devices is greater than or equal to the preset number of versions, the node data of the oldest version of the Merkle B+ tree corresponding to the target device has been finally confirmed, and the node data of the oldest version of the Merkle B+ tree is in a state that can be released, in which case, the node data covered by the subsequent version can be deleted from the disk page. In this way, the node data of the new version of the Merkle B+ tree generated by the subsequent target device after executing the current block can cover the node data of the old version of the Merkle B+ tree.

[0130] In some embodiments, the order of the plurality of devices can be set in advance and recorded in the scheduling module. The scheduling module can determine the device storing the data of the target root node according to the recorded page identifier of the target root node, and then determine the device following the device in the order as the target device.

[0131] In some embodiments, the order of the plurality of devices can be set in advance and recorded in the scheduling module. The scheduling module can determine the device storing the data of the target root node according to the recorded page identifier of the target root node, and then determine the device following the device in the order as the target device.

[0132] Step 302: After receiving the data modification instruction, the target device acquires the data of the nodes in the node path from the target root node to the target data node and updates the nodes in the node path according to the data of the target root node and the data modification set.

[0133] The target data node is the data node indicated to be updated in the data modification set, i.e., the data node to which the key-value pair and / or key in the data modification set is distributed. Specifically, for the key-value pair to be added in the data modification set, the target data node is the data node in which the key-value pair is to be inserted. For the key-value pair to be updated in the data modification set, the target data node is the data node storing the key value of the key-value pair. For the key (i.e., key value) to be deleted in the data modification set, the target data node is the data node storing the key value.

[0134] Optionally, the step 302 can be implemented by the following first way or second way:

[0135] The first way: after receiving the data modification instruction, the target device acquires the data of the nodes in the node path from the target root node to the target data node according to the data of the target root node and the key values in the data modification set, and updates the nodes in the node path according to the data modification set.

[0136] In this case, the at least one device in the step 302 is the target device. That is, the target device can directly acquire the data of the nodes in the node path from the target root node to the target data node and update the nodes in the node path.

[0137] The data of the target root node includes the page identifier of the target root node, the minimum key and hash value of each node under the target root node, and the page identifier of each node under the target root node.

[0138] In this case, for the key value of any key-value pair to be added in the data modification set, or for the key value of any key-value pair to be updated in the data modification set, or for any key (i.e., key value) to be deleted in the data modification set, the target device can compare the key value with the key range of each node under the target root node to determine which node under the target root node the key value belongs to. Then, the target device acquires the data of the node from the corresponding disk page in the device according to the page identifier of the node included in the data of the target root node.

[0139] After the target device acquires the data of a node under the target root node by the above way, if the node is a data node, the target device can determine that the data node is the target data node, and at this time, the data of the target data node is acquired, and thus the data of the nodes in the node path from the target root node to the target data node is acquired.

[0140] If the node is an index node, the target device can continue to compare the key value with the key range of each node under the index node according to the data of the index node to determine which node under the index node the key value belongs to. Then, the data of the node is acquired from the corresponding disk page in the device according to the page identifier of the node included in the data of the index node. In this case, if the node is an index node, the above process is continued to be repeated until the key value is determined to belong to a data node and the data of the data node is acquired, and the data node is the target data node, and thus the data of the nodes in the node path from the target root node to the target data node is acquired.

[0141] It should be noted that the process of obtaining the data of the target data node according to the key value can be referred to as a process of distributing the key value from the target root node to the target data node in the Merkle B+ tree, that is, a process of distributing the key value pair to be added, the key value pair to be updated or the key to be deleted in the Merkle B+ tree from the target root node to the target data node. The key value is in the key range of the target data node.

[0142] In some embodiments, when the target device obtains the node data stored in the disk page in the corresponding device according to the page identifier, the node data stored in the disk page in the corresponding device is read into the memory of the target device according to the page identifier, and then the target device can update the node data in the memory of the target device.

[0143] It should be noted that any one of the key value pairs to be added in the data modification set can correspond to a target data node, which is the data node to which the key value pair needs to be inserted. Any one of the key value pairs to be updated in the data modification set can correspond to a target data node, which is the data node storing the key value of the key value pair. Any one of the keys (i.e. key values) to be deleted in the data modification set can correspond to a target data node, which is the data node storing the key value. In this way, the data modification set can correspond to at least one target data node, and each target data node corresponds to one or more key value pairs to be added, one or more key value pairs to be updated, and / or one or more keys to be deleted.

[0144] In this case, after the target device obtains the data of the nodes in the node path from the target root node to the target data node, the target device can update the nodes in the node path according to the data modification set in the following way 1 or way 2, which will be described below:

[0145] The operation of way 1 is as follows:

[0146] For any one of the target data nodes corresponding to the data modification set, if the target data node has a corresponding key value pair to be added, the target device adds the key value pair in the data of the target data node; if the target data node has a corresponding key value pair to be updated, the target device updates the specified key value pair in the data of the target data node to the key value pair, the key value of the specified key value pair being the same as the key value of the key value pair; if the target data node has a corresponding key to be deleted, the target device deletes the key value pair to which the key belongs in the data of the target data node. In this way, the update of the target data node can be completed.

[0147] If the updated target data node is empty, i.e., the updated target data node does not contain data, the target device deletes the index item pointing to the target data node in the data of the index node to which the target data node belongs, and deletes the page identifier of the index node contained in the data of the index node, to update the index node. If the updated index node is empty, the target device continues to update the parent index node upwards until the root node is updated. If the updated index node is not empty, the target device allocates a page identifier for the updated index node, and then continues to update the parent index node upwards according to the minimum key, hash value and page identifier of the updated index node, until the root node is updated. In this way, the update of the nodes in the node path is completed.

[0148] If the updated target data node is not empty and the data amount of the updated target data node is less than or equal to the preset data amount, the data node splitting operation is not needed to be performed. If the data amount of the updated target data node is greater than the preset data amount, the data node splitting operation needs to be performed. After the index node in the Merkle B+ tree is updated according to the updated target data node, if the data amount of the updated index node is less than or equal to the preset data amount, the index node splitting operation is not needed to be performed. If the data amount of the updated index node is greater than the preset data amount, the index node splitting operation needs to be performed. This is described in detail as follows:

[0149] In some embodiments, if the updated target data node is not empty and the data amount of the updated target data node is less than or equal to the preset data amount, the target device allocates a page identifier for the updated target data node, and determines the minimum key value of the updated target data node as the minimum key of the updated target data node, and determines the hash value of the data obtained by splicing all key value pairs contained in the updated target data node as the hash value of the updated target data node. The target device updates the index node in the Merkle B+ tree according to the minimum key, hash value and page identifier of the updated target data node. Specifically, the target device updates the index item pointing to the target data node in the data of the index node to which the target data node belongs according to the minimum key, hash value and page identifier of the updated target data node, and deletes the page identifier of the index node contained in the data of the index node, to update the index node. Then, the target device allocates a page identifier for the updated index node, and then continues to update the parent index node upwards according to the minimum key, hash value and page identifier of the updated index node, until the root node is updated. In this way, the update of the nodes in the node path is completed.

[0150] In some embodiments, if the updated target data node is not empty and the data amount of the updated target data node is greater than the preset data amount, the target device splits the updated target data node into at least two data nodes, each of which has a data amount less than or equal to the preset data amount and contains at least one key-value pair. For any one of the at least two data nodes, the target device assigns a page identifier to the data node, determines the minimum key of the data node as the minimum key of the data node from all the key values contained in the data node, and determines the hash value of the data obtained by splicing all the key-value pairs contained in the data node as the hash value of the data node. Then, the target device updates the index nodes in the Merkle B+ tree according to the minimum key, the hash value and the page identifier of each of the at least two data nodes. Specifically, the target device updates the index item of the target data node in the data of the index node to which the target data node belongs to the index item of each of the at least two data nodes (including the minimum key, the hash value and the page identifier of the data node), and deletes the page identifier of the index node contained in the data of the index node to update the index node. If the data amount of the updated index node is less than or equal to the preset data amount, the target device assigns a page identifier to the updated index node, and then continues to update the parent index node upwards according to the minimum key, the hash value and the page identifier of the updated index node until the root node is updated. If the data amount of the updated index node is greater than the preset data amount, the target device splits the updated index node into at least two index nodes, each of which has a data amount less than or equal to the preset data amount and contains the index item of at least one data node, and assigns a page identifier to each of the at least two index nodes. Then, the target device continues to update the parent index node upwards according to the minimum key, the hash value and the page identifier of each of the at least two index nodes until the root node is updated. In this way, the update of the nodes in the node path is completed.

[0151] The operation of Mode 2 is as follows:

[0152] As an example, if the tree height (i.e. the number of layers) of the node path is less than or equal to the preset height, the target device updates the nodes in the node path according to the data modification set in Mode 1.

[0153] The preset height can be set in advance, and the preset height can be set to be small, for example, the preset height can be 3.

[0154] According to the characteristics of the tree data structure, when the tree height is low, the data amount of the whole tree is small, and thus even if the complete modified node path is transmitted between devices, the transmission cost is relatively small. Therefore, when the tree height of the node path is low, the target device can directly update the nodes in the node path, and in the updating process, page identifiers are allocated to each node in the updated node path, so that the data of each node in the updated node path can be stored in the disk page of the target device in the subsequent process. In this case, even if the node data stored in the target device needs to be transmitted to other devices when the Merkle B+ tree is updated subsequently, the transmission cost can be guaranteed to be small.

[0155] For example, the preset height is 3, as shown in the node path, the tree height of the node path is 3, which is equal to the preset height, and thus the target device can directly update the nodes in the node path, and in the updating process, page identifiers are allocated to each node in the updated node path. In this way, the target device can store the data of each node in the updated node path in the disk page of the target device according to the page identifier of each node in the updated node path. Figure 4

[0156] As another example, if the tree height of the node path is greater than the preset height, the target device divides the node path into m segment paths, the m segment paths are sequentially divided from the upper layer to the lower layer, the first segment path in the m segment paths includes the root node, the mth segment path in the m segment paths includes the target data node, and the tree height of each segment path in the m segment paths is less than or equal to the preset height, and m is an integer greater than or equal to 2. Among them, each segment path in the m-1 segment paths in the m segment paths except the first segment path corresponds to other devices in the plurality of devices except the target device. Optionally, the m-1 segment paths can correspond to m-1 devices in the plurality of devices except the target device one by one, or a plurality of segment paths in the m-1 segment paths can correspond to the same device in the plurality of devices except the target device.

[0157] For the mth segment path, the target device updates the nodes in the mth segment path according to the data modification set, and in the updating process, does not allocate page identifiers to the nodes in the updated mth segment path.

[0158] ​Specifically, for the target data node in the mth segment path, if the target data node has a corresponding key-value pair to be added, the target device adds the key-value pair in the data of the target data node; if the target data node has a corresponding key-value pair to be updated, the target device updates a specified key-value pair in the data of the target data node to the key-value pair, the key value of the specified key-value pair being the same as that of the key-value pair; if the target data node has a corresponding key to be deleted, the target device deletes the key-value pair to which the key belongs in the data of the target data node. In this way, the update of the target data node can be completed.

[0159] If the mth segment path only includes the target data node and does not include the index node to which the target data node belongs, the target device completes the update of the target data node, and thus completes the update of the nodes in the mth segment path.

[0160] If the mth segment path includes not only the target data node but also the index node to which the target data node belongs, the target device deletes the index item (including the minimum key, the hash value and the page identifier of the target data node) in the data of the index node to which the target data node belongs, and deletes the page identifier of the index node included in the data of the index node, to update the index node, in the case that the updated target data node is empty, i.e., the updated target data node does not contain data. If the updated index node is empty, the target device continues to update the index node to which the target data node belongs upwards until the top node in the mth segment path is updated. If the updated index node is not empty, the target device continues to update the index node to which the target data node belongs upwards according to the minimum key and the hash value of the updated index node until the top node in the mth segment path is updated. In this way, the update of the nodes in the mth segment path is completed.

[0161] If the mth segment path includes not only the target data node but also the index node to which the target data node belongs, the target device does not need to perform a data node splitting operation in the case that the updated target data node is not empty and the data amount of the updated target data node is less than or equal to a preset data amount. If the data amount of the updated target data node is greater than the preset data amount, the data node splitting operation needs to be performed. After the index node in the mth segment path is updated according to the updated target data node, if the data amount of the updated index node is less than or equal to the preset data amount, the index node splitting operation does not need to be performed. If the data amount of the updated index node is greater than the preset data amount, the index node splitting operation needs to be performed. Details are as follows:

[0162] In some embodiments, if the updated target data node is not empty and the data amount of the updated target data node is less than or equal to the preset data amount, the target device determines the minimum key value among all key values contained in the updated target data node as the minimum key of the updated target data node, and determines the hash value of the data obtained by splicing all key value pairs contained in the updated target data node as the hash value of the updated target data node. The target device updates the index node in the mth segment path according to the minimum key and the hash value of the updated target data node. Specifically, the target device updates the minimum key and the hash value in the index item pointing to the target data node in the data of the index node to which the target data node belongs according to the minimum key and the hash value of the updated target data node, and deletes the page identifier in the index item, and then deletes the page identifier of the index node contained in the data of the index node, so as to update the index node. Then, the target device continues to backtrack to update the index node to which the index node belongs according to the minimum key and the hash value of the updated index node, until the update reaches the uppermost node in the mth segment path. In this way, the update of the nodes in the mth segment path is completed.

[0163] In some embodiments, if the updated target data node is not empty and the data amount of the updated target data node is greater than the preset data amount, the target device splits the updated target data node into at least two data nodes, each of which has a data amount less than or equal to the preset data amount and contains at least one key-value pair. For any one of the at least two data nodes, the target device determines the minimum key value among all key values contained in the data node as the minimum key of the data node, and determines the hash value of the data obtained by concatenating all key-value pairs contained in the data node as the hash value of the data node. Then, the target device updates the index nodes in the mth segment of the path according to the minimum key and the hash value of each of the at least two data nodes. Specifically, the target device updates the index item of the target data node in the data of the index node to which the target data node belongs to the index items of each of the at least two data nodes (including the minimum key and the hash value of the data node), and deletes the page identifier of the index node contained in the data of the index node, so as to update the index node. If the data amount of the updated index node is less than or equal to the preset data amount, the target device continues to update the parent index node upwards according to the minimum key and the hash value of the updated index node, until the most upper node in the mth segment of the path is updated. If the data amount of the updated index node is greater than the preset data amount, the target device splits the updated index node into at least two index nodes, each of which has a data amount less than or equal to the preset data amount and contains at least one index item of a data node, and continues to update the parent index node upwards according to the minimum key and the hash value of each of the at least two index nodes, until the most upper node in the mth segment of the path is updated. In this way, the update of the nodes in the mth segment of the path is completed.

[0164] After completing the update of the nodes in the mth segment of the path, the target device can send the data of the updated nodes in the mth segment of the path to the device corresponding to the mth segment of the path. The device can assign a page identifier to each of the updated nodes in the mth segment of the path, and add the page identifier of each index node and the page identifiers of the nodes subordinate to the index node in the data of each index node in the mth segment of the path, specifically, the page identifier of a node can be added in the index item of the node. In this way, the device can subsequently store the data of each of the updated nodes in the mth segment of the path to the disk page of the device according to the page identifier of each of the updated nodes in the mth segment of the path. Moreover, the device can return the page identifier of the most upper node in the mth segment of the path to the target device.

[0165] Then, for the m-1th path, if the m-1th path is the 1st path, the target device updates the nodes in the 1st path according to the minimum key, hash value and page identifier of the uppermost node in the updated mth path, and assigns a page identifier to the nodes in the updated 1st path during the updating process. In this way, the updating of the nodes in the path is completed.

[0166] If the m-1th path is not the 1st path, the target device updates the nodes in the m-1th path according to the minimum key, hash value and page identifier of the uppermost node in the updated mth path, and similar to the mth path, the target device does not assign a page identifier to the nodes in the updated m-1th path during the updating process. After the updating of the nodes in the m-1th path is completed, similar to the mth path, the target device can send the data of the nodes in the updated m-1th path to the device corresponding to the m-1th path. The device can assign a page identifier to each node in the updated m-1th path, and add the page identifier of each index node and the page identifier of the subordinate nodes of the index node in the data of each index node in the m-1th path, so that the device can subsequently store the data of each node in the updated m-1th path to the disk page of the device according to the page identifier of each node in the updated m-1th path. In addition, the device can return the page identifier of the uppermost node in the updated m-1th path to the target device.

[0167] Then, similar, if the m-2th path is the 1st path, the target device updates the nodes in the 1st path according to the minimum key, hash value and page identifier of the uppermost node in the updated m-1th path, and assigns a page identifier to the nodes in the updated 1st path during the updating process. If the m-2th path is not the 1st path, the target device updates the nodes in the m-2th path according to the minimum key, hash value and page identifier of the uppermost node in the updated m-1th path, and does not assign a page identifier to the nodes in the updated m-2th path during the updating process, but sends the data of the nodes in the updated m-2th path to the device corresponding to the m-2th path, which assigns a page identifier to each node in the updated m-2th path, and adds the page identifier of each index node and the page identifier of the subordinate nodes of the index node in the data of each index node in the updated m-2th path, and then sends the page identifier of the uppermost node in the updated m-2th path to the target device. In this way, the updating of the nodes in the path is completed.

[0168] It should be noted that as the tree height increases, the amount of data of a complete node path also increases, in which case the node path can be divided into several segments and transmitted to different devices, and the corresponding devices can assign page identifiers to the nodes in a segment to facilitate subsequent storage of the data of the nodes in the segment to the disk page of the device. In this way, it can be ensured that from a node in the node path, the subsequent continuous nodes are stored locally in the same device, so that the device can have a greater possibility of obtaining the data of the continuous nodes locally when updating the Merkle B+ tree, thereby reducing the processing delay.

[0169] Optionally, the at least one device corresponding to the m-1 segments of the path other than the first segment of the path can be at least one device arranged after the target device. Since the device after the target device is the device performing the next block, storing the updated m-1 segments of the path in at least one device arranged after the target device can enable the device performing the next block to have a greater possibility of obtaining the required node data locally when updating the Merkle B+ tree, thereby reducing the processing delay.

[0170] Optionally, the target device can divide the node path into m segments of paths according to a preset strategy, and determine the device corresponding to each segment of the m-1 segments of the path other than the first segment of the path. The preset strategy can be set in advance. For example, the preset strategy can be: when the tree height is less than or equal to 4, the node path is divided into two segments of paths from top to bottom in order, the first segment of the path includes the root node, and the second segment of the path includes nodes other than the root node, the updated second segment of the path is transmitted to a random one of the three devices arranged after the target device for storage, and the updated first segment of the path is stored locally in the target device to ensure load balancing of the devices. When the tree height is greater than 4, the node path is divided into four segments of paths from top to bottom in order, the first segment of the path includes the root node, and the second segment of the path, the third segment of the path, and the fourth segment of the path include nodes other than the root node, the updated fourth segment of the path, the updated third segment of the path, and the updated second segment of the path are transmitted to the three devices arranged after the target device in turn for storage, and the updated first segment of the path is stored locally in the target device to ensure load balancing of the devices.

[0171] For example, the preset height is 3, and the node path is divided into three segments of paths from top to bottom in order, the first segment of the path includes the root node, and the second segment of the path and the third segment of the path include nodes other than the root node. Figure 5As shown, the tree height of the node path is 5, which is greater than the preset height, and thus the target device can divide the node path into two segments. Then, the target device can update the nodes in the second segment, and in the updating process, does not assign a page identifier to each node in the updated second segment. Then, the target device sends the data of the nodes in the updated second segment to the device that is located next to the target device in the order, which can assign a page identifier to each node in the updated second segment, and add the page identifier of each index node and the page identifier of the data node under the index node in the data of each index node in the updated second segment, so that the device can store the data of each node in the updated second segment to the disk page of the device according to the page identifier of each node in the updated second segment. The device sends the page identifier of the uppermost node in the updated second segment to the target device. Then, the target device can update the first segment according to the minimum key, the hash value and the page identifier of the uppermost node in the second segment, and in the updating process, assigns a page identifier to each node in the updated first segment, so that the target device can store the data of each node in the updated first segment to the disk page of the target device according to the page identifier of each node in the updated first segment.

[0172] The second way: after the target device receives the data modification instruction, the target device performs the following steps one to four:

[0173] Step one: the target device determines the first node according to the data of the target root node and the key value in the data modification set.

[0174] The target device can distribute the key value pair and / or the key in the data modification set to the nodes under the target root node according to the data of the target root node and the key value in the data modification set. The first node is the node that distributes the key value pair and / or the key in the data modification set to in the nodes under the target root node.

[0175] The data of the target root node includes the page identifier of the target root node, the minimum key and the hash value of each node under the target root node, and the page identifier of each node under the target root node.

[0176] In this case, for the key value of any one key value pair to be added in the data modification set, or for the key value of any one key value pair to be updated in the data modification set, or for any one key to be deleted in the data modification set (i.e. the key value), the target device can compare the key value with the key range of each node under the target root node to determine which node under the target root node the key value belongs to. Then, the target device obtains the page identifier of the node (i.e. the first node) in the data of the target root node.

[0177] The target device can determine whether the data of the first node is stored in the target device according to the page identifier of the first node.

[0178] If the target device does not store the data of the first node, the following steps two and three are performed.

[0179] If the target device stores the data of the first node, the target device acquires the data of the first node stored in the disk page of the target device. If the first node is a data node, the target device can determine that the first node is a target data node, and at this time, the data of the target data node is acquired, so that the distribution process is completed, and the data of the nodes in the node path from the target root node to the target data node is acquired. If the first node is an index node, the target device needs to continue to distribute the key-value pairs and / or keys in the data modification set to the nodes subordinate to the first node. Specifically, the target device determines a second node according to the data of the first node and the key in the data modification set, and the second node is a node in the nodes subordinate to the first node to which the key-value pairs and / or keys in the data modification set are distributed. The operation of determining the second node according to the data of the first node and the key in the data modification set by the target device is similar to the operation of determining the first node according to the data of the target root node and the key in the data modification set by the target device in step one, and the embodiments of the present application will not be repeated. Then, the target device can determine whether the data of the second node is stored in the target device according to the page identifier of the second node. Similarly, if the target device does not store the data of the second node, the target device can take similar measures as steps two and three. If the target device stores the data of the second node, the target device acquires the data of the second node stored in the disk page of the target device; if the second node is a data node, the target device can determine that the second node is a target data node, and at this time, the data of the target data node is acquired, so that the distribution process is completed, and the data of the nodes in the node path from the target root node to the target data node is acquired; if the second node is an index node, the target device needs to continue to distribute the key-value pairs and / or keys in the data modification set to the nodes subordinate to the second node. In this way, the key-value pairs and / or keys in the data modification set are distributed to the target data node.

[0180] Step two: If the target device does not store the data of the first node, the first data amount and the second data amount corresponding to the first node are acquired.

[0181] The first data amount corresponding to the first node is the total data amount of the key-value pairs and / or keys in the data modification set that needs to be distributed to the first node. That is, the first data amount corresponding to the first node is the data amount of the modification set data bound to the first node, that is, the total data amount of the key-value pairs and / or keys expected to be distributed to the nodes on the subsequent path to which the first node belongs. The first data amount corresponding to the first node is the data amount that the target device needs to transmit to other devices to achieve distribution of the data modification set.

[0182] The second data amount corresponding to the first node is the total data amount of the first node and the nodes located at the lower level of the first node in the node path. That is, the second data amount corresponding to the first node is the total data amount of the key-value pairs and / or keys in the data modification set that is predicted to be distributed to the nodes on the subsequent path to which the first node belongs. The second data amount is the data amount that the target device needs to obtain from other devices to achieve distribution of the data modification set.

[0183] Optionally, the second data amount corresponding to the first node can be obtained by multiplying the node number by the estimated node data amount, and the node number can be obtained by subtracting the number of nodes located at the upper level of the first node in the node path from the current tree height of the Merkle B+ tree.

[0184] The estimated node data amount can be set in advance, and the estimated node data amount is the data amount of one node. Optionally, the estimated node data amount can be set in advance by a technician according to actual conditions, for example, the estimated node data amount can be determined according to the node splitting strategy and the business data condition.

[0185] As an example, the inodes and data nodes inside the system are expected to have a probability of overflow (referring to the number of disk pages that a node actually corresponds to, i.e., indicating that the data of a node is stored in several consecutive disk pages). The probability can be estimated, and optionally, the probability depends on whether the node splitting strategy of the system is more inclined to generate nodes with overflow or more inclined to generate nodes corresponding to 1 disk page. If the node splitting strategy of the system is more inclined to generate nodes with overflow, it also needs to consider whether the expected value of overflow due to the business data situation is more inclined to small overflow or large overflow. For example, in the case of the business scenario is to continuously insert new key-value pairs, and 90% of the key-value pairs have a data size of 4K to 6K, if the size of a single disk page is 4K, then the overflow of the data node is more inclined to be 2. However, considering that the node splitting strategy of the system is to make the data of the data node or the inode as compact as possible, taking the splitting process of the data node as an example, on the data node that needs to be split beyond the threshold, it is likely that a disk page that should be split into overflow of 2 and an independent disk page without overflow are combined into a disk page with overflow of 3. In this case, the data amount of a node can be estimated as: 10%*4K+90%*50%*8K+90%*50%*12K=9.4K, where 10% represents the probability that the data of a node is stored in an independent disk page without overflow (size 4K), 90%*50% represents the probability that the data of a node is stored in a disk page with overflow of 2 (size 8K), and 90%*50% represents the probability that the data of a node is stored in a disk page with overflow of 3 (size 12K).

[0186] The target device can instruct the at least one device to obtain data of the first node and nodes located at a lower level of the first node in the node path and update the nodes in the node path according to the first data amount and the second data amount corresponding to the first node.

[0187] Specifically, if the first data amount corresponding to the first node is greater than or equal to the second data amount, it indicates that the target device needs to transmit more data to other devices to implement the distribution of the data modification set than the target device needs to obtain from other devices. In this case, to minimize the network transmission amount in the system, the target device can directly obtain the data of the first node from the disk page corresponding to the first node in the other device. If the first node is a data node, the target device can determine that the first node is a target data node, and at this time, the data of the target data node is obtained, so that the distribution process is completed, and the data of the nodes in the node path from the target root node to the target data node is obtained. If the first node is an index node, the target device needs to continue to distribute the key-value pairs and / or keys in the data modification set to the nodes subordinate to the first node.

[0188] Step three: if the first data amount corresponding to the first node is less than the second data amount, the target device sends an update request (which can be referred to as a first update request) to a first device in the plurality of devices that stores the data of the first node, to instruct the first device to obtain the data of the first node and the nodes located in the lower layer of the first node in the node path and update the nodes.

[0189] If the first data amount corresponding to the first node is less than the second data amount, it indicates that the target device needs to transmit less data to other devices to implement the distribution of the data modification set than the target device needs to obtain from other devices. In this case, to minimize the network transmission amount in the system, the target device can directly send an update request to the first device that stores the data of the first node.

[0190] The update request carries the page identifier of the first node and the key-value pairs and / or keys in the data modification set distributed to the first node. After receiving the update request, the first device can obtain the data of the first node stored in the corresponding disk page in the first device according to the page identifier of the first node.

[0191] In some embodiments, if the first node is a data node, the first device can determine that the first node is a target data node, and at this time, the data of the target data node is obtained. Since the target device has obtained the data of the target root node, the target device and the first device as a whole obtain the data of the nodes in the node path from the target root node to the target data node, and the distribution process is completed.

[0192] In this case, the first device can update the target data node according to the key-value pair and / or the key carried in the update request. If the data amount of the updated target data node is less than or equal to the preset data amount, the first device directly allocates a page identifier to the updated target data node, so that the first device can subsequently store the data of the updated target data node to a disk page of the first device, and the first device returns the minimum key, the hash value and the page identifier of the updated target data node to the target device as an update result (which can be referred to as a first update result). If the data amount of the updated target data node is greater than the preset data amount, the first device splits the updated target data node into at least two data nodes, allocates a page identifier to each of the at least two data nodes, so that the first device can subsequently store the data of each of the at least two data nodes to a disk page of the first device, and the first device returns the minimum key, the hash value and the page identifier of each of the at least two data nodes to the target device as an update result.

[0193] After the target device receives the update result, the target device can update the root node in the node path according to the update result, and allocates a page identifier to the updated root node in the node path during the updating process, so that the target device can subsequently store the data of the updated root node in the node path to a disk page of the target device. In this way, the update of the node in the node path is completed.

[0194] In some other embodiments, if the first node is an index node, the first device can determine the second node according to the data of the first node and the key value in the key of the key-value pair and / or the key carried in the update request.

[0195] The first device can distribute the key-value pair and / or the key carried in the update request to the nodes subordinate to the first node according to the data of the first node and the key value in the key of the key-value pair and / or the key carried in the update request. The second node is the node to which the key-value pair and / or the key carried in the update request is distributed among the nodes subordinate to the first node.

[0196] The page identifier of the second node is contained in the data of the first node. The first device can determine whether the data of the second node is stored in the first device according to the page identifier of the second node.

[0197] In one case, if the first device stores the data of the second node, the first device acquires the data of the second node stored in the disk page of the first device. If the second node is a data node, the first device can determine that the second node is a target data node, and at this time, the data of the target data node is acquired. In this case, the first device can update the target data node and the first node belonging to the target data node according to the key-value pair and / or the key carried in the update request, and assign a page identifier to the updated node in the updating process, so that the first device can subsequently store the data of the updated node to the disk page of the first device. Then, the first device returns the minimum key, the hash value and the page identifier of the node at the uppermost layer in the updated node to the target device as an update result, and the target device can update the root node in the node path according to the update result, and assign a page identifier to the updated root node in the node path in the updating process, so that the target device can subsequently store the data of the updated root node in the node path to the disk page of the target device. In this way, the update of the nodes in the node path is completed. If the second node is an index node, the first device needs to continue to distribute the key-value pair and / or the key carried in the update request to the nodes belonging to the second node, similar to the above.

[0198] In another case, if the first device does not store the data of the first node, similar methods to steps two and three described above can be taken.

[0199] Specifically, the first device can acquire the first data amount and the second data amount corresponding to the second node.

[0200] If the first data amount corresponding to the second node is greater than or equal to the second data amount, the first device can directly obtain the data of the second node from the disk page of the corresponding other device according to the page identifier of the second node. If the second node is a data node, the first device can determine that the second node is a target data node, and at this time, the data of the target data node is obtained. In this case, the first device can update the target data node and the first node belonging to the target data node according to the key-value pair and / or key carried in the update request, and allocate a page identifier to the updated node in the updating process, so that the first device can subsequently store the data of the updated node to the disk page of the first device. Then, the first device returns the minimum key, hash value and page identifier of the node at the uppermost layer in the updated node to the target device as an update result, and the target device can update the root node in the node path according to the update result, and allocate a page identifier to the updated root node in the node path in the updating process, so that the target device can subsequently store the data of the updated root node in the node path to the disk page of the target device. In this way, the update of the nodes in the node path is completed. If the second node is an index node, the first device needs to continue to distribute the key-value pair and / or key carried in the update request to the nodes belonging to the second node, similar to the above.

[0201] If the first data amount corresponding to the second node is less than the second data amount, the first device can send an update request (which can be referred to as a second update request) to a second device storing the data of the second node in the plurality of devices to instruct the second device to obtain the data of the second node and the nodes located at the lower layer of the second node in the node path and update the nodes. The update request carries the page identifier of the second node and the key-value pair and / or key distributed to the second node in the data modification set. Then, similar to the processing process of the first device after receiving the update request sent by the target device, the second device can process the update request sent by the first device and then return an update result (which can be referred to as a second update result) to the first device. After receiving the update result sent by the second device, the first device can update the first node, and allocate a page identifier to the updated node in the updating process, so that the first device can subsequently store the data of the updated node to the disk page of the first device. Then, the first device returns the minimum key, hash value and page identifier of the node at the uppermost layer in the updated node to the target device as an update result, and the target device can update the root node in the node path according to the update result, and allocate a page identifier to the updated root node in the node path in the updating process, so that the target device can subsequently store the data of the updated root node in the node path to the disk page of the target device. In this way, the update of the nodes in the node path is completed.

[0202] It should be noted that in the embodiments of the present application, after a device (such as the target device, the first device or the second device) distributes the key-value pairs and / or keys in the data modification set to a node, the device can acquire the first data amount and the second data amount corresponding to the node, so as to determine whether to send an update request to other devices storing data of the node or to acquire the data of the node from other devices to directly update, so that the network transmission amount can be minimized in the update process of the node path.

[0203] For example, the node path includes a root node 1, an index node 2, an index node 3, an index node 4, an index node 5, and a data node 6. The target device stores data of the root node 1, and distributes the key-value pair and / or key in the data modification set to the index node 2 according to the data of the root node 1. If the target device stores data of the index node 2, the target device continues to distribute the key-value pair and / or key in the data modification set to the index node 3 according to the data of the index node 2. If the target device does not store data of the index node 3, and the target device determines that the first data amount corresponding to the index node 3 is less than the second data amount, the target device can send an update request to a first device storing data of the index node 3, where the update request carries a page identifier of the index node 3 and the key-value pair and / or key distributed to the index node 3. After the first device receives the update request sent by the target device, the first device distributes the key-value pair and / or key in the update request to the index node 4 according to the data of the index node 3. If the first device does not store data of the index node 4, and the first device determines that the first data amount corresponding to the index node 4 is less than the second data amount, the first device can send an update request to a second device storing data of the index node 4, where the update request carries a page identifier of the index node 4 and the key-value pair and / or key distributed to the index node 4. After the second device receives the update request sent by the first device, the second device distributes the key-value pair and / or key in the update request to the index node 5 according to the data of the index node 4. If the second device does not store data of the index node 5, and the second device determines that the first data amount of the index node 5 is greater than or equal to the second data amount, the second device can obtain the data of the index node 5 from the disk page of another device according to the page identifier of the index node 5, and then distribute the key-value pair and / or key in the update request to the data node 6 according to the data of the index node 5. If the second device does not store data of the data node 6, and the second device determines that the first data amount corresponding to the data node 6 is less than the second data amount, the second device can send an update request to a third device storing data of the data node 6, where the update request carries a page identifier of the data node 6 and the key-value pair and / or key distributed to the data node 6. After the third device receives the update request sent by the second device, the third device updates the data node 6 according to the key-value pair and / or key carried in the update request, and allocates a page identifier for the updated data node in the updating process, so that the third device can subsequently store the updated data node to the disk page of the third device. Then, the third device returns the minimum key, hash value, and page identifier of the updated data node to the second device as an update result. After the second device receives the update result returned by the third device, the second device updates the index node 4 and the index node 5 according to the update result, and allocates a page identifier for the updated index node in the updating process, so that the second device can subsequently store the updated index node to the disk page of the second device. Then, the second device returns the minimum key, hash value, and page identifier of the index node at the uppermost layer in the updated index node to the first device as an update result.After the first device receives the update result returned by the second device, the first device updates the index node 3 according to the update result, and allocates a page identifier for the updated index node in the update process, so that the first device can store the updated index node to the disk page of the first device in the future. Then, the first device returns the minimum key, the hash value and the page identifier of the index node at the top layer in the updated index node to the target device as the update result. After the target device receives the update result returned by the first device, the target device updates the root node 1 and the index node 2 according to the update result, and allocates a page identifier for the updated index node and the root node in the update process. In this way, the update of the nodes in the node path is completed, and the minimization of network transmission amount is realized in the update process.

[0204] Step four: the target device receives the update result returned by the first device for the update request, and updates the root node in the node path according to the update result.

[0205] It should be noted that the nodes in the node path are updated in the above step 302, that is, the update of the Merkle B+ tree is realized. In this case, the target device obtains the data of the root node in the updated Merkle B+ tree, that is, the data of the root node corresponding to the current block is obtained. In this case, the target device can send the data of the root node to the scheduling module, so that the scheduling module can determine that the execution progress of the current block is completed. Then, the scheduling module can obtain the hash value of the root node according to the data of the root node, and return the hash value of the root node to the upper blockchain system. In addition, the scheduling module can also record the mapping relationship between the page identifier of the root node and the block identifier of the current block, so as to determine which version of the Merkle B+ tree the page identifier of the root node corresponds to. After receiving the hash value of the root node sent by the scheduling module, the blockchain system can determine that the current block has been executed, and at this time the blockchain system can start to execute the next block.

[0206] In some embodiments, after step 302, the target device can directly persist the updated Merkle B+ tree, that is, the following step 303 can be directly executed. After the target device completes the persistence, the target device can send a persistence completion message to the scheduling module. After receiving the persistence completion message, the scheduling module determines that the execution progress of the current block is completed. Then, the scheduling module sends a persistence completion message to the blockchain system to indicate that the current block is completed.

[0207] In some embodiments, after the blockchain system receives the hash value of the root node sent by the scheduling module, the scheduling module can send a persistence request to the blockchain system. After the scheduling module receives the persistence request, the scheduling module can send a commit request to the target device responsible for executing the current block. After the target device receives the commit request, the target device can persist the updated Merkle B+ tree, i.e., the target device can perform the following step 303. After the target device completes the persistence, the target device can send a persistence completion message to the scheduling module. After the scheduling module receives the persistence completion message, the scheduling module determines that the execution progress of the current block is persisted. Then, the scheduling module sends a persistence completion message to the blockchain system to indicate that the current block is persisted.

[0208] Step 303: The target device stores the data of the root node in the updated node path to a disk page of the target device, and the at least one device stores the data of the nodes other than the root node in the updated node path to a disk page.

[0209] If step 302 is implemented by the first method described above, the at least one device in step 303 is the target device.

[0210] In this case, if step 302 is implemented by way 1 in the first method described above, the target device stores the data of each node in the updated node path to a disk page of the target device. Specifically, the target device can store the data of each node in the updated node path to a corresponding disk page in the target device according to the page identifier of each node in the updated node path.

[0211] If step 302 is implemented by way 2 in the first method described above, if the tree height of the node path is less than or equal to the preset height, the target device stores the data of each node in the updated node path to a disk page of the target device. Specifically, the target device can store the data of each node in the updated node path to a corresponding disk page in the target device according to the page identifier of each node in the updated node path. If the tree height of the node path is greater than the preset height, the target device divides the node path into m segment paths; the target device stores the data of the nodes in the updated first segment path to a disk page of the target device, and stores the data of the nodes in the updated m-1 segment paths other than the first segment path to disk pages of the other devices other than the target device. Specifically, the target device stores the data of each node in the updated first segment path to a corresponding disk page in the target device according to the page identifier of each node in the updated first segment path; for any one of the m-1 segment paths, the device corresponding to the segment path stores the data of each node in the updated segment path to a corresponding disk page in the device according to the page identifier of each node in the updated segment path.

[0212] If step 302 is implemented in the second way, the at least one device in step 303 can include the target device and / or one or more devices other than the target device.

[0213] In this case, if the target device does not send an update request to other devices, the target device independently completes the update of all nodes in the node path, and the target device can directly store the data of each node in the updated node path to a disk page of the target device.

[0214] If the target device sends an update request to other devices, the target device can update the related nodes (at least including the root node) according to the update result returned for the update request, and then the target device can store the data of the updated nodes in a disk page of the target device. If any one device (referred to as device A) receives an update request sent by other devices (referred to as device B), the device A can process the update request. In the processing process, if the device A does not need to send an update request to other devices, the device A updates the related nodes and returns an update result to the device B, and then the device A can store the data of the updated nodes in a disk page of the device A. In the processing process, if the device A needs to send an update request to other devices, the device A sends an update request to other devices and, after receiving the returned update result, updates the related nodes according to the update result and returns the update result to the device B, and then the device A can store the data of the updated nodes in a disk page of the device A.

[0215] In an embodiment of the present application, the database system includes a scheduling module and a plurality of devices, different devices in the plurality of devices are used to store the data of the root nodes in different versions of the Merkle B+ tree. The scheduling module sends a data modification instruction to a target device, the data modification instruction carries the data of a target root node and a data modification set. After receiving the data modification instruction, the target device instructs at least one device in the plurality of devices to obtain the data of the nodes in the node path from the target root node to the target data node and update the nodes in the node path according to the data of the target root node and the data modification set. Moreover, the target device stores the data of the root nodes in the updated node path to a disk page of the target device, and the at least one device stores the data of the other nodes in the updated node path except the root nodes to a disk page. In this way, one device can correspond to one version of the Merkle B+ tree, a plurality of versions of the Merkle B+ tree are maintained by a plurality of devices, by dispersing the multi-version data to a plurality of devices, the pressure of data storage and multi-version maintenance of a single device can be reduced, thereby the throughput of the database system can be improved, and the performance of the database system can be improved.

[0216] It should be noted that the modification of the node data of the Merkle B+ tree stored by the plurality of devices can be achieved through the above steps 301 to 303.

[0217] In some embodiments, the Merkle B+ tree stored by the plurality of devices can also be version-rolled back, which is described as follows:

[0218] The blockchain system can ensure that the rollback and block generation are not executed concurrently, that is, the rollback process needs to be performed after the execution of one block and before the execution of another block.

[0219] If the blockchain system needs to roll back all the blocks after the target block, that is, the blockchain system needs to roll back to the previous block of the target block, the blockchain system can send a rollback request to the scheduling module, and the rollback request carries a target block identifier, which is used to indicate that all the blocks after the target block are rolled back, that is, the corresponding version of the Merkle B+ tree of all the blocks after the target block is rolled back, in other words, the node data of the Merkle B+ tree is rolled back to the node data of the corresponding version of the Merkle B+ tree of the previous block of the target block.

[0220] After the scheduling module receives the rollback request, it needs to determine the execution progress of the current block. If the execution progress of the current block is not on disk, the scheduling module needs to wait until the execution progress of the current block is on disk, and then send a rollback instruction to each device in the plurality of devices, and the rollback instruction can carry a target block identifier. For any one of the plurality of devices, after receiving the rollback instruction, the device can delete the version information corresponding to the target block and all the blocks after the target block identified by the target block identifier. The version information corresponding to a block is information recorded in the process of processing the data modification set corresponding to the block, for example, the version information corresponding to a block can include the data of the root node corresponding to the block, the modification content of the freelist component, the block execution progress control information, etc., wherein the freelist component is used to configure the free page identifier list, the to-be-freed page identifier list and the maximum page identifier, and the freelist component is used to allocate page identifiers for the updated nodes. In this way, after deleting the version information corresponding to the target block and all the blocks after the target block, the latest version information recorded in the device corresponds to the block before the target block, so that the corresponding version of the Merkle B+ tree of the previous block of the target block is rolled back. Then, the device can send a rollback completion message to the scheduling module.

[0221] After the scheduling module receives the rollback completion message sent by each of the plurality of devices, the scheduling module can delete the data of the root node corresponding to the target block and all blocks after the target block, and delete the identifier of the target block and all blocks after the target block. In this way, the latest block recorded in the scheduling module is the previous block of the target block, and the latest version of the Merkle B+ tree recorded is the Merkle B+ tree to which the data of the root node corresponding to the previous block of the target block belongs, so as to roll back to the corresponding version of the Merkle B+ tree of the previous block of the target block.

[0222] In some embodiments, network exceptions in the database system can also be processed, which will be described as follows:

[0223] In the database system, network exceptions can occur between the scheduling module and any of the plurality of devices. For example, network exceptions can occur during execution of control instructions such as data modification instructions and rollback instructions. Alternatively, network exceptions can also occur between the plurality of devices, such as during node data query, node data update or storage between the plurality of devices.

[0224] Alternatively, network exceptions can occur between the scheduling module and any of the plurality of devices. For example, if the scheduling module sends a control instruction to a device and the device does not reply for a long time, the scheduling module can determine that a network exception occurs between itself and the device. Since the block identifier is strongly bound to the device in the embodiments of the present application, such a network exception can cause the progress of the entire database system to be blocked, so the scheduling module needs to resend the control instruction to the device in this case.

[0225] Alternatively, if a network exception occurs between any of the plurality of devices and other devices, the following two solutions can be used to solve the problem:

[0226] The first solution: a device (referred to as device A) needs to obtain node data from another device (referred to as device B) or send an update request to another device (referred to as device B) in the process of distributing key-value pairs or keys to data nodes. Device A finds that device B is unreachable, that is, it is determined that a network anomaly occurs between device A and device B. In this case, if there is no redundant backup strategy, device A can only block and wait. If a mature consensus algorithm (such as raft) is used for multiple redundant backups on random devices in the node update phase, that is, in the node update phase, not only can one device allocate a page identifier for the updated node, but also the data of the updated node can be sent to at least one other device (referred to as a backup device), and each backup device allocates a page identifier (referred to as a backup page identifier) for the updated node. In this way, the data of the updated node not only contains the page identifier of the node, but also contains at least one backup page identifier. In the case of a network anomaly between device A and device B, device A can try to access different backup devices, that is, device A can try to obtain node data from a backup device or send an update request to a backup device.

[0227] The second solution: a device (referred to as device A) needs to send the data of the updated node to another device (device B) for storage in the process of updating the node. Device A finds that device B is unreachable, that is, it is determined that a network anomaly occurs between device A and device B. In this case, device A can change the device according to the order of the device identifier until the device network is reachable, and then send the data of the updated node to the device for storage. For example, the device identifier of the device currently processing the current block is 2, and the device identifiers expected to store the node data are 3, 4, and 5. However, device 2 finds that device 5 is unreachable, so it can consider sending the node data to device 6 for storage.

[0228] For example, in the second way of the first way of the above step 302, m-1 paths in the m-path correspond to one device in the plurality of devices except the target device in addition to the first path, and the subsequent target device stores the data of the node in any one of the updated m-1 paths to the disk page of the device corresponding to the path. In this case, if a network anomaly occurs between the target device and the device corresponding to the path, the target device can store the data of the node in the updated path to the disk page of the device located after the device corresponding to the path.

[0229] Further, the embodiments of the present application can also realize dynamic addition and deletion of multiple devices, which will be described as follows:

[0230] Since the number of devices in the embodiments of the present application is naturally bound to the block identifier, the scheduling module can expose an interface to allow technicians to add devices as needed. The logic of adding devices is not executed in parallel with the block chain system block logic, that is, the device addition process needs to be performed after the execution of a block and before the execution of another block. The specific operation can include the following steps a to d:

[0231] Step a: The scheduling module can receive a device addition request. The device addition request carries device information, which can include a device identifier and further include a URL (Uniform Resource Locator, Uniform Resource Locator). The device addition request is used to request to add a device corresponding to the device information (referred to as a specified device). The device addition request can be sent by the block chain system, or by other systems, or by technicians directly triggering on the scheduling module.

[0232] Step b: The scheduling module determines the block identifier of the next block of the latest executed block. The scheduling module carries the device information and the block identifier (referred to as a specified block identifier) in the first device addition instruction to send to each device in the plurality of devices, to indicate the addition of the specified device corresponding to the device information and to indicate that the added specified device is enabled from the block identified by the block identifier. The scheduling module carries the device information, the block identifier, and the number of devices (i.e., the target number of enabled devices) in the second device addition instruction to send to the specified device corresponding to the device information. Then the scheduling module can synchronously wait for the reply of all devices including the added specified device.

[0233] Step c: For any one of the plurality of devices, the device receives the first device addition instruction, records the device information carried in the first device addition instruction, attempts to establish a communication connection with the specified device corresponding to the device information, and can also inform the specified device of its URL for inter-device communication during the establishment of the communication connection. After successfully establishing a communication connection with the specified device, the device returns an addition success message to the scheduling module. For the specified device, the specified device receives the second device addition instruction, establishes a communication connection with other devices, and returns an addition success message to the scheduling module after determining that the number of devices successfully establishing a communication connection with itself is the number of devices carried in the second device addition instruction. Optionally, any two devices can only maintain one physical connection to communicate with each other in a bidirectional flow.

[0234] Step d: If the scheduling module determines that the adding success message sent by each of the plurality of devices is received and the adding success message sent by the specified device is received, it can be determined that the specified device is added successfully. In this case, the scheduling module can also send a device confirmation message to the plurality of devices and the specified device to notify all devices that the specified device is enabled. Each device sets the specified device to an enabled state in response to the device confirmation message.

[0235] It should be noted that in the above step c, if a network exception occurs between the scheduling module and any device, there may be a device that cannot receive the device adding instruction (the first device adding instruction or the second device adding instruction), or a device that receives the device adding instruction but cannot return the adding success message to the scheduling module. In this case, the specified device cannot be enabled, i.e., the specified device will fail to be added. In this case, the device adding process needs to be performed as usual, i.e., the scheduling module and the device can be based on the original plurality of devices when performing the next block.

[0236] In addition, in the above step d, if a network exception occurs between the scheduling module and any device, there may be a device that cannot receive the device confirmation message, or a device that cannot reply to the device confirmation message. In this case, subsequent processing can be performed as usual according to the device adding success, i.e., the scheduling module and the device can be based on all devices after adding the specified device when performing the block with the block identifier greater than or equal to the specified block identifier.

[0237] Figure 6 A structure schematic diagram of a computer device provided by an embodiment of the present application is shown in FIG. 6. As shown in FIG. 6, the computer device 6 includes a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60. The processor 60 implements the operations performed by the scheduling module or any one of the plurality of devices in the data processing method of the above embodiment when executing the computer program 62. Figure 6

[0238] The computer device 6 can be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device 6 can be a desktop computer, a laptop computer, a network server, a palmtop computer, a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. The type of the computer device 6 is not limited in the present application. Those skilled in the art can understand that the computer device 6 shown in FIG. 6 is only an example of the computer device 6, and does not constitute a limitation on the computer device 6, which can include more or fewer components than those shown in the figure, or combine certain components, or different components, such as an input / output device, a network access device, and the like. Figure 6

[0239] ​​The processor 60 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0240] The memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6 in some embodiments. The memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 6 in other embodiments. Further, the memory 61 can include both the internal storage unit and the external storage device of the computer device 6. The memory 61 is used to store an operating system, application programs, a boot loader, data, and other programs, etc. The memory 61 can also be used to temporarily store data that has been output or will be output.

[0241] The embodiments of the present application also provide a computer device, which comprises at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above method embodiments when executing the computer program.

[0242] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is executable by a processor to implement the steps in any of the above method embodiments.

[0243] The embodiments of the present application provide a computer program product, which, when running on a computer, causes the computer to perform the steps in any of the above method embodiments.

[0244] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above method embodiments can be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. The computer program can implement the steps of each method embodiment when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the photographing device / terminal equipment, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage equipment, etc. The computer readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, a non-transitory storage medium.

[0245] It should be understood that all or part of the steps of the above-mentioned embodiments can be realized by software, hardware, firmware or any combination thereof. When realized by software, it can be realized in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.

[0246] In the above embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.

[0247] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0248] In the embodiments of the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other manners. For example, the embodiments of the apparatus / computer device described above are merely schematic; for example, the division of the modules or units can not be strict, and some modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the modules or units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or in other forms.

[0249] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0250] The above-described embodiments are merely used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: the technical solutions recorded in the foregoing embodiments can still be modified, or some technical features can be replaced by equivalent replacements; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A data processing method, characterized by, The method is applied to a database system comprising a scheduling module and a plurality of devices, different devices in the plurality of devices being configured to store data of root nodes in different versions of a Merkel B+ tree, and the method comprises: The scheduling module sends a data modification instruction to a target device, the data modification instruction carrying data of a target root node and a data modification set, the target root node being a root node in the latest version of the Merkel B+ tree, and the target device being a device in the plurality of devices arranged after a device storing data of the target root node; the data modification set comprising key-value pairs to be added, key-value pairs to be updated, and / or key-value pairs to be deleted; After receiving the data modification instruction, the target device instructs at least one device in the plurality of devices to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and key values in the data modification set; The target device stores data of root nodes in the updated node path to a disk page of the target device, and the at least one device stores data of other nodes in the updated node path except the root nodes to disk pages.

2. The method of claim 1, wherein, The target device instructs at least one device in the plurality of devices to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and key values in the data modification set, comprising: The target device obtains data of nodes in a node path from the target root node to the target data node according to the data of the target root node and the key values in the data modification set; The target device updates the nodes in the node path according to the data modification set.

3. The method of claim 2, wherein, The target device stores data of root nodes in the updated node path to a disk page of the target device, and the at least one device stores data of other nodes in the updated node path except the root nodes to disk pages, comprising: If a tree height of the node path is less than or equal to a preset height, the target device stores data of each node in the updated node path to a disk page of the target device; If the tree height of the node path is greater than the preset height, the target device divides the node path into m segment paths, the first segment path of the m segment paths comprising the root node, and the m being an integer greater than or equal to 2; the target device stores data of nodes in the first segment path in the updated node path to a disk page of the target device, and stores data of nodes in m-1 segment paths in the updated m segment paths except the first segment path to disk pages of devices in the plurality of devices except the target device.

4. The method of claim 3, wherein, Any one of the m-1 segment paths corresponds to one device in the plurality of devices except the target device. The target device stores data of nodes in m-1 paths of the m paths except the first path in the updated m paths in disk pages of devices other than the target device in the plurality of devices, including: The target device stores data of nodes in any one path of the m-1 paths in the updated m-1 paths in a disk page of a device corresponding to the one path; The method further includes: If a network exception occurs between the target device and the device corresponding to the one path, the target device stores data of nodes in the one path in an updated disk page of a device located after the device corresponding to the one path.

5. The method of claim 1, wherein, The target device acquires data of nodes in a node path from the target root node to a target data node and updates the nodes in the node path according to data of the target root node and key values in the data modification set, including: The target device determines a first node according to data of the target root node and key values in the data modification set, the first node being a node to which key values and / or keys in the data modification set are distributed among nodes subordinate to the target root node; If the target device does not store data of the first node, the target device acquires a first data amount and a second data amount corresponding to the first node, the first data amount corresponding to the first node being a total data amount of key values and / or keys in the data modification set to be distributed to the first node, and the second data amount corresponding to the first node being a total data amount of the first node and nodes located below the first node in the node path predicted; The target device instructs the at least one device to acquire data of the first node and nodes located below the first node in the node path and update the nodes in the node path according to the first data amount and the second data amount corresponding to the first node.

6. The method of claim 5, wherein, The target device instructs the at least one device to acquire data of the first node and nodes located below the first node in the node path and update the nodes in the node path according to the first data amount and the second data amount corresponding to the first node, including: If the first data amount corresponding to the first node is less than the second data amount, the target device sends a first update request to a first device storing data of the first node among the plurality of devices to instruct the first device to acquire data of the first node and nodes located below the first node in the node path and update the nodes; The target device receives a first update result returned by the first device in response to the first update request and updates a root node in the node path according to the first update result.

7. The method of claim 6, wherein, After the target device sends the first update request to the first device storing data of the first node among the plurality of devices, the method further includes: After the first device receives the first update request, the first device acquires data of the first node stored in a corresponding disk page in the first device according to a page identifier of the first node; If the first node is an index node, the first device determines a second node according to data of the first node and key values in the key-value pair and / or key carried in the first update request, the second node being a node in nodes subordinate to the first node to which the key-value pair and / or key carried in the first update request is distributed; If the first device does not store data of the second node, the first device acquires a first data amount and a second data amount corresponding to the second node, the first data amount corresponding to the second node being a total data amount of the key-value pair and / or key in the key-value pair and / or key carried in the first update request that needs to be distributed to the second node, and the second data amount corresponding to the second node being a total data amount of the second node and nodes located at a lower layer of the second node in the node path predicted; If the first data amount corresponding to the second node is less than the second data amount, the first device sends a second update request to a second device of the plurality of devices storing data of the second node, to instruct the second device to acquire data of the second node and nodes located at a lower layer of the second node in the node path and update nodes; The first device receives a second update result returned by the second device for the second update request, updates the first node according to the second update result, and carries a minimum key, a hash value and a page identifier of a node at an uppermost layer in the updated node in the first update result to return to the target device.

8. The method according to any one of claims 1 to 7, characterized in that, The data modification instruction carries a block identifier, and the block identifier in the data modification instruction is used to identify a block corresponding to the data modification set; the method further comprises: The scheduling module receives a rollback request, and the rollback request carries a target block identifier; In a case where the execution progress of the current block is that the data has been written to a disk, the scheduling module sends a rollback instruction to each device in the plurality of devices, and the rollback instruction carries the target block identifier; After each device in the plurality of devices receives the rollback instruction, the device deletes version information corresponding to a target block identified by the target block identifier and all blocks after the target block, sends a rollback completion message to the scheduling module, and the version information corresponding to the block is information recorded in a process of processing a data modification set corresponding to the block; If the scheduling module receives the rollback completion message sent by each device in the plurality of devices, the scheduling module deletes data of a root node corresponding to the target block and all blocks after the target block, and deletes block identifiers of the target block and all blocks after the target block.

9. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: The scheduling module sends a first device addition instruction to each device in the plurality of devices and a second device addition instruction to a specified device, the first device addition instruction carrying device information of the specified device, and the second device addition instruction carrying a device quantity of the plurality of devices. For any one of the plurality of devices, the one device records the device information after receiving the first device addition instruction, and establishes a communication connection with the specified device corresponding to the device information, and returns an addition success message to the scheduling module after successfully establishing the communication connection with the specified device; The specified device establishes a communication connection with other devices after receiving the second device addition instruction, and returns an addition success message to the scheduling module when determining that the number of devices with which the specified device successfully establishes a communication connection is the number of devices carried by the second device addition instruction; The scheduling module determines that the specified device is successfully added if it receives the addition success message returned by each device in the plurality of devices and receives the addition success message returned by the specified device.

10. A database system, characterized by The database system includes a scheduling module and a plurality of devices, different devices in the plurality of devices are used to store the data of the root nodes in different versions of the Merkel B+ tree; The scheduling module is configured to send a data modification instruction to a target device, the data modification instruction carrying data of a target root node and a data modification set, the target root node being a root node in the latest version of the Merkel B+ tree, and the target device being a device in the plurality of devices arranged after a device storing data of the target root node; the data modification set including key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted; The target device is configured to, after receiving the data modification instruction, instruct at least one device in the plurality of devices to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path according to the data of the target root node and key values in the data modification set; The target device is further configured to store data of the root node in the updated node path to a disk page of the target device; The at least one device is configured to store data of nodes other than the root node in the updated node path to a disk page.

11. A data processing method, characterized by, The method is applied to a target device in a database system, the database system including a scheduling module and a plurality of devices, different devices in the plurality of devices being used to store data of root nodes in different versions of the Merkel B+ tree, the target device being a device in the plurality of devices arranged after a device storing data of a target root node, the target root node being a root node in the latest version of the Merkel B+ tree, and the method including: Receiving a data modification instruction sent by the scheduling module, the data modification instruction carrying data of the target root node and a data modification set, the data modification set including key-value pairs to be added, key-value pairs to be updated, and / or keys to be deleted; According to the data of the target root node and the key values in the data modification set, instructing at least one device in the plurality of devices to obtain data of nodes in a node path from the target root node to a target data node and update the nodes in the node path; The data of the root node in the updated node path is stored to a disk page of the target device, and the data of other nodes in the updated node path except the root node is stored to a disk page by the at least one device.

12. A computer device, comprising: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program, when executed by the processor, implements the method in claim 11.

13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the method in claim 11.

Citation Information

Patent Citations

  • Multi-version data storage method and device, computer equipment and storage medium

    CN112579602A

  • Method and system for optimization of blockchain data storage

    US20210194673A1