Database-based read-write concurrency control method, medium, equipment and program product
By allocating the latest version of hierarchical data in the database system and allowing write transactions to be submitted out of order, the problem of low read and write efficiency in the database system is solved, and efficient concurrent writing and stable data processing are achieved.
Patent Information
- Application Number
- CN202410869818.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-18
AI Technical Summary
In large-scale hierarchical data processing, the existing database system has complex processing logic and severe read and write amplification, resulting in low processing efficiency and inability to support high concurrency and write performance improvement.
By allocating the latest version of hierarchical data in the database system when responding to the target write transaction, executing the write transaction and recording the transaction status, allowing write transactions to be submitted out of order, thereby achieving concurrent writing, and determining the stable version of the data when reading the request to avoid reading Write conflict.
It improves the writing performance of the database system, improves the processing capacity of hierarchical data, achieves no conflict between reading and writing, and reduces writing and writing conflicts, greatly improving the ability of hierarchical data.
Smart Images

Figure CN118796852A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a database-based read-write concurrency control method, medium, device, and program product. Background Art
[0002] In related database systems, the way to store large-scale hierarchical data is essentially to map the hierarchical data to the relational model of the relational database. However, in business scenarios with large-scale hierarchical data, not only is it necessary to perform both deep and broad traversal of the hierarchical data at the same time, but there are also complex operations such as moving data across hierarchical data. In this regard, the related database systems have complex processing logic when handling these complex operations, and there is serious read-write amplification during data storage and access, resulting in the inability to increase the processing scale of hierarchical data and low access efficiency. For example, a hierarchical data can only be written serially and cannot support high concurrency, which greatly limits the write performance. Summary of the invention
[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a database-based read-write concurrency control method, comprising:
[0005] In response to receiving a target write transaction, determining first hierarchical structure data targeted by the target write transaction;
[0006] Allocating first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data;
[0007] The target write transaction is executed for the first version data corresponding to the first hierarchical structure data, and the transaction execution status of the target write transaction is recorded for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data is determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
[0008] In a second aspect, the present disclosure provides a read-write concurrency control device based on a database, comprising:
[0009] a determination module, configured to, in response to receiving a target write transaction, determine first hierarchical structure data targeted by the target write transaction;
[0010] an allocating module, configured to allocate first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data;
[0011] An execution module is configured to execute the target write transaction for the first version data corresponding to the first hierarchical structure data, and record the transaction execution status of the target write transaction for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data can be determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
[0012] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.
[0013] In a fourth aspect, the present disclosure provides an electronic device, including:
[0014] a storage device having a computer program stored thereon;
[0015] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.
[0016] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0017] Based on the above technical solution, by responding to receiving a target write transaction, determining the first hierarchical structure data targeted by the target write transaction, allocating the first version data corresponding to the first hierarchical structure data to the target write transaction, executing the target write transaction for the first version data corresponding to the first hierarchical structure data, and recording the transaction execution status of the target write transaction for the first hierarchical structure data, the write transactions in the database system can be submitted out of order by allocating the first version data corresponding to each first hierarchical structure data targeted by the target write transaction, thereby achieving the goal of concurrent writing for hierarchical structure data and improving the write performance of the database system. Based on this, it is possible to achieve read-write non-conflict in hierarchical structure data, and minimize write-write conflicts, so that the capacity of hierarchical structure data is greatly improved.
[0018] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:
[0020] Figure 1 It is a flowchart of a database-based read-write concurrency control method according to some embodiments.
[0021] Figure 2 is a schematic diagram showing the association relationship between a transaction identifier and version data according to some embodiments.
[0022] Figure 3 is a schematic diagram showing determination of stable version data according to some embodiments.
[0023] Figure 4 is a schematic diagram showing hierarchical data according to some embodiments.
[0024] Figure 5 It is a flowchart of a database-based read-write concurrency control method according to some further embodiments.
[0025] Figure 6 It is a flowchart of a database-based read-write concurrency control method according to other embodiments.
[0026] Figure 7 is a flow chart illustrating adjusting a consistency view according to some embodiments.
[0027] Figure 8 It is a flowchart of a database-based read-write concurrency control method according to some embodiments.
[0028] Fig. 9 It is a structural diagram of a database-based read-write concurrency control device according to some embodiments.
[0029] Fig.10 is a schematic diagram of the structure of an electronic device according to some embodiments. DETAILED DESCRIPTION
[0030] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0031] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0032] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0033] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0034] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0035] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0036] Figure 1 FIG. 1 is a flowchart of a method for controlling read and write concurrency based on a database according to some embodiments. Figure 1 As shown, the embodiment of the present disclosure provides a method for concurrent control of read and write based on a database, which can be executed by an electronic device, specifically, by a device for concurrent control of read and write based on a database, which can be implemented by software and / or hardware and configured in an electronic device. Figure 1 As shown, the method may include the following steps.
[0037] In step 110 , in response to receiving a target write transaction, first hierarchical structure data targeted by the target write transaction is determined.
[0038] Here, hierarchical data is a way of organizing data. Hierarchical data organizes data according to hierarchical relationships to form a tree structure. In hierarchical data, data is divided into multiple levels, each level contains one or more nodes, and each node can have zero or more child nodes. For example, hierarchical data can be a directory node. For another example, hierarchical data can be large-scale data in a company's organizational structure.
[0039] A write transaction refers to a series of operations performed in a database system that permanently saves data changes to the database system. Transactions are the basic unit of operation in a database system to ensure data integrity and consistency. When all operations in a write transaction are completed successfully, the write transaction can be committed and all changes will be permanently saved.
[0040] In Multiversion Concurrency Control (MVCC), the target write transaction can be understood as a distributed transaction. A distributed transaction refers to a transaction that can be performed across multiple database instances or services, which may be located in different geographical locations or different system architectures.
[0041] When receiving a target write transaction, all first hierarchical structure data operated by the target write transaction are determined. The target write transaction may operate on one or more first hierarchical structure data. For example, a target write transaction may be for hierarchical structure data A. For another example, a target write transaction may be for hierarchical structure data A, hierarchical structure data B, and hierarchical structure data C.
[0042] In step 120, first version data corresponding to the first hierarchical structure data is allocated to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data.
[0043] Here, for each first hierarchical data targeted by the target write transaction, the first version data corresponding to each first hierarchical data is allocated to the target write transaction. For example, assuming that the target write transaction is a write transaction for hierarchical data A, hierarchical data B, and hierarchical data C, the first version data of hierarchical data A, the first version data of hierarchical data B, and the first version data of hierarchical data C are allocated to the target write transaction.
[0044] Among them, each first version data is the latest version data of the corresponding first hierarchical structure data. It should be understood that the latest version data of the first hierarchical structure data can be understood as that when a target write transaction is initiated, the first hierarchical structure data allocates the next version data to the target write transaction based on the version data of the largest version that has been allocated. For example, the version data that has been allocated to the first hierarchical structure data include "1, 2, 3, 4, 5, 6, 7, 8". When a target write transaction for the first hierarchical structure data is initiated, the first version data allocated to the target write transaction is the version data corresponding to the first hierarchical structure data, which is "9".
[0045] It is worth noting that versioned data refers to multiple versions of each piece of data saved in the database system. It should be noted that when executing a write transaction, the existing data is not directly overwritten, but a new version of the data is created.
[0046] It should be noted that each write transaction may have its corresponding transaction identifier (txn_id). A write transaction may include an update operation for one hierarchical data or multiple hierarchical data. Therefore, there is a 1:n relationship between the write transaction and the hierarchical data, where n is greater than or equal to 1.
[0047] Figure 2 FIG. 1 is a schematic diagram showing the association relationship between a transaction identifier and version data according to some embodiments. Figure 2 As shown, the transaction identifier allocator assigns a corresponding transaction identifier (such as txn_1, txn_2, txn_m) to each write transaction to uniquely identify each write transaction. Among them, txn_1, txn_2, txn_m represent the transaction identifiers corresponding to different write transactions, and each write transaction corresponds to a transaction identifier. The data identifier allocator assigns a data identifier (such as tree_1, tree_2, tree_n) to each hierarchical data to uniquely identify the hierarchical data. In other words, the transaction identifier and the write transaction are in a 1:1 relationship, indicating that one write transaction corresponds to a unique transaction identifier. The data identifier and the hierarchical data are in a 1:1 relationship, indicating that one hierarchical data corresponds to a unique data identifier.
[0048] There is a 1:n relationship between a write transaction and hierarchical data, which means that a write transaction can perform data operations on one or more hierarchical data.
[0049] The version allocator allocates the first version data (txn_version) corresponding to the hierarchical data targeted by the write transaction. For each hierarchical data, the write transaction holds a first version data corresponding to the hierarchical data targeted. Therefore, there is a 1:1 relationship between the write transaction and the first version data of each hierarchical data. It should be noted that the stable version data (tree_version) of a hierarchical data is equal to the version data corresponding to the largest consecutive resolved transaction.
[0050] like Figure 2 As shown, each write transaction has a consistent view (such as readview_1, readview_2, readview_m) during execution, which is used to control the visibility of the write transaction update. Under the same consistent view, the data updates of the same write transaction are either all visible or all invisible.
[0051] In step 130, a target write transaction is executed for the first version data corresponding to the first hierarchical structure data, and the transaction execution status of the target write transaction is recorded for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data can be determined based on the transaction execution status of each target write transaction related to the first hierarchical structure data.
[0052] Here, based on all the first version data held by the target write transaction, the target write transaction is executed to write or record specific data to the database. After the target write transaction is executed, the corresponding first version data will be submitted to determine the corresponding stable version data of the first hierarchical structure data according to the submitted first version data.
[0053] It should be noted that in the process of executing the target write transaction, the transaction execution status of the target write transaction can be recorded, and the stable version data corresponding to the first hierarchical structure data can be determined according to the transaction execution status, so that the target write transaction can be committed out of order and concurrent writing can be achieved. Among them, the transaction execution status refers to the different stages of a write transaction in the execution process in the database system. The transaction execution status can include the committed status (committed), the aborted status (aborted), and the pending status (pending). The committed status indicates that all operations of the write transaction have been successfully executed, and the results (corresponding to the first version data) have been permanently saved to the database. The aborted status indicates that the write transaction is aborted due to an error or violation of constraints, the entire transaction is revoked, and the database state is restored to the state before the start of the write transaction. The pending state indicates that the write transaction has not been completed and is currently waiting for further operations.
[0054] It should be understood that a write transaction in a committed state or an aborted state can be understood as a resolved write transaction, and a write transaction in a pending state can be understood as a pending write transaction. The stable version data (tree_version) corresponding to the first hierarchical structure data can be determined through the transaction execution status of the write transaction.
[0055] When supporting a read request, the stable version data corresponding to the first hierarchical structure data is determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data. Supporting a read request can be understood as the database responding to the read request and returning the stable version data of the data indicated by the read request.
[0056] Exemplarily, the stable version data is the first version data submitted by the largest write transaction among the consecutive resolved write transactions corresponding to the first hierarchical data. It should be noted that the stable version data can actually be understood as the version data visible to the visitor of the first hierarchical data. Generally speaking, the stable version data is the first version data submitted by the largest consecutive resolved write transaction of the hierarchical data.
[0057] Figure 3 FIG. 4 is a schematic diagram showing how to determine stable version data according to some embodiments. Figure 3 As shown, Figure 3 Each box in the diagram represents a data operation of a write transaction on the hierarchical data tree_A. Each box records the first version data (such as 1, 2, 3, 4, 5, 6, 7, 8) assigned to the write transaction represented by the box. The latest version data assigned to tree_A is the first version data 8. Since the transaction execution status of the write transactions 1-4 is committed or aborted, the first version data 4 is the stable version data of tree_A. There is no clear requirement for the transaction execution order of the write transactions between (4, 8]. The write transactions can be submitted out of order. In other words, the larger version of the first version of the write transaction can be submitted first, thereby realizing concurrent updates for the same hierarchical data and improving write performance.
[0058] It is worth noting that in the disclosed embodiment, since each write transaction holds the first version data corresponding to the first-level structure data, each write transaction can be submitted out of order, thereby realizing concurrent writing. Since the target write transaction holds the first version data corresponding to each first-level structure data, when the target write transaction is submitted out of order, for each first-level structure data, the first version data submitted by the largest continuous and resolved write transaction is the stable version data corresponding to the first-level structure data.
[0059] For example, Figure 3As shown, write transactions 1-8 can be submitted out of order, but since write transaction 5 is a pending transaction, its corresponding first version data is not a stable version data. Even if write transaction 8 is resolved, since write transaction 5 is pending, the first version data submitted by write transaction 8 cannot be used as the stable version data of tree_A. The stable version data of tree_A that is finally determined is the first version data submitted by write transaction 4.
[0060] That is to say, by allocating the first version data corresponding to all the first hierarchical data targeted by the target write transaction, the write transactions in the database system can be committed out of order, and the hierarchical data can no longer be written serially, thereby achieving the goal of concurrent writing of the hierarchical data and improving the write performance of the database system.
[0061] Thus, by responding to receiving a target write transaction, determining the first hierarchical data targeted by the target write transaction, assigning the first version data corresponding to the first hierarchical data to the target write transaction, executing the target write transaction for the first version data corresponding to the first hierarchical data, and recording the transaction execution status of the target write transaction for the first hierarchical data, the write transaction in the database system can be submitted out of order by assigning the first version data corresponding to each first hierarchical data targeted by the target write transaction, thereby achieving the goal of concurrent writing for hierarchical data and improving the write performance of the database system. Based on this, it is possible to achieve read-write conflicts in hierarchical data, and write-write conflicts as small as possible, so that the capacity of hierarchical data is greatly improved. For example, through the method provided in the embodiment of the present disclosure, the amount of data moved across hierarchical data can be increased from 1,500 to more than 20,000, the number of nodes in a single layer can be increased from 1,500 to more than 100,000, and the capacity upper limit of a single hierarchical data can be increased from 400,000 to more than 5 million.
[0062] In some achievable implementations, the target write transaction may be a write transaction that adds new data to the first hierarchical data. For example, taking the hierarchical data as a tree, the target write transaction may be to add a node B to the node A of the tree. In actual application scenarios, it can be understood as adding a new employee or subordinate department to a department in the company structure.
[0063] Accordingly, the target write transaction actually adds a new node B to the A node of a tree by executing the steps of "changing the parent node of the B node to the A node and adding the information of the B node to the child node list of the A node".
[0064] In some practicable implementations, the target write transaction is used to indicate that data in the first hierarchical structure data with the second target data as a root is moved to below the third target data in the target hierarchical structure data.
[0065] For example, in an actual application scenario, moving the data in the first hierarchical data with the second target data as the root to the third target data in the target hierarchical data can be understood as moving all employees of a department in the company structure to other departments.
[0066] It is worth noting that the target hierarchical data may be the first hierarchical data where the second target data is located. That is, the data in the first hierarchical data with the second target data as the root is moved to below the third target data in the first hierarchical data. Of course, the target hierarchical data may also be other hierarchical data other than the first hierarchical data where the second target data is located. That is to say, data on one hierarchical data may be moved across hierarchical data.
[0067] For example, taking deleting data with the second target data as the root in a hierarchical structure data as an example, the data with the second target data as the root needs to be moved to the hierarchical structure data for physical deletion, and the hierarchical structure data for physical deletion is the target hierarchical structure data.
[0068] It should be noted that deleting data with the second target data as the root in a hierarchical data structure is referred to as soft deletion. Hierarchical data for physical deletion may be built into the database. Deleting data with the second target data as the root in a hierarchical data structure is to move the data with the second target data as the root to the hierarchical data for physical deletion. For data on the hierarchical data for physical deletion, asynchronous deletion can be performed through the background garbage collection (GC) task, so as to achieve non-blocking reading and writing.
[0069] Figure 4 FIG. 1 is a schematic diagram of hierarchical data according to some embodiments. Figure 4 As shown, taking the hierarchical data as a tree as an example, each node in the tree represents a target data in the hierarchical data. Assuming that the second target data is node 4 in the tree, the target hierarchical data is also Figure 4 In the tree, the third target data is node 6 in the tree. Accordingly, the target write transaction may be to move the entire subtree rooted at node 4 to below node 6.
[0070] Accordingly, in step 130, the second target data can be locked, and it can be checked whether the third target data and the ancestor node corresponding to the third target data are locked. If the third target data and the ancestor node corresponding to the third target data are not locked, the target write transaction is executed for each first version data held by the target write transaction to move the data with the second target data as the root to the third target data. Through asynchronous update, the ancestor path information of all descendant nodes corresponding to the second target data is modified to the ancestor path information with the third target data as the parent node path, and the second target data is unlocked.
[0071] Here, in the hierarchical structure, ancestor nodes are all nodes that can be traced back through consecutive parent node links. Figure 4 As shown, the ancestor nodes of node 6 are node 3 and node 1.
[0072] By checking whether the third target data and the ancestor node corresponding to the third target data have a lock, it can be prevented that the third target data and the ancestor node corresponding to the third target data are moving and thus form a loop.
[0073] When the third target data and the ancestor node corresponding to the third target data have locks, it means that there are currently two operations to move data, which may form a loop. Therefore, failure can be directly returned and the target write transaction can be stopped. It should be noted that the third target data and the ancestor node corresponding to the third target data have locks can be any one of the third target data and the ancestor node corresponding to the third target data.
[0074] When the third target data and the ancestor node corresponding to the third target data do not have locks, the target write transaction is executed based on all the first version data held by the target write transaction, thereby moving the data rooted in the second target data to below the third target data. It should be understood that the target write transaction is a distributed transaction, which can move the data rooted in the second target data to below the third target data through multiple execution units.
[0075] Then, by means of asynchronous update, the ancestor path information of all descendant nodes corresponding to the second target data is modified to the ancestor path information with the third target data as the parent node path. Among them, all descendant nodes of a node can be called descendant nodes of the node, such as the child nodes of a node, the child nodes (grandchild nodes) of the child nodes, and the descendant nodes at a deeper level. Ancestor path information refers to the path information from a node in a tree structure to its ancestor node. In a tree data structure, each node (except the root node) has a parent node, and the parent node itself may also have a parent node, and so on until the root node. The ancestor path information can be used to trace the direct relationship chain from any node to the root node.
[0076] Before the move, the descendant nodes of the second target data are the ancestor path information with the second target data as the parent node path. After the move, the parent node of the second target data is the third target data. Accordingly, the ancestor path information of all descendant nodes corresponding to the second target data needs to be modified to the ancestor path information with the third target data as the parent node path, so that the descendant nodes of the second target data can be indexed normally.
[0077] It is worth noting that asynchronous updates are updates that are performed independently of the main program flow, and other tasks can be continued without waiting for the update to complete. By using asynchronous updates, the main flow of executing the target write transaction will not be blocked.
[0078] It should be noted that the ancestor path information in the hierarchical data will be verified when used. Therefore, the ancestor path information of all descendant nodes corresponding to the second target data can be modified to the ancestor path information with the third target data as the parent node path through asynchronous updating.
[0079] like Figure 4 As shown, assuming that the target write transaction is to move the entire subtree rooted at node 4 to below node 6, node 4 can be locked, and node 6 and its ancestor nodes (node 1 and node 3) can be checked to see if they are locked. If not, the target write transaction is executed. Executing the target write transaction includes: pointing the parent node of node 4 to node 6, deleting node 6 from the child node list of node 2, and adding node 4 to the child node list of node 6. In addition, the ancestor path information of nodes 7 and 8 is modified from "1-2-4" to "1-3-6-4" by asynchronous update. Then, node 4 is unlocked.
[0080] It is worth noting that, whether it is data movement for data in the same hierarchical structure or data movement across hierarchical structures, data movement can be performed through the above implementation method.
[0081] Therefore, through the above implementation, when data in the hierarchical data is moved, it is possible to achieve no read-write conflict and minimize write-write conflict, thereby improving the write performance of the database system.
[0082] In some feasible implementations, the electronic device may also receive a target read request, determine the stable version data of the first target data according to the transaction execution status of each historical write transaction related to the second hierarchical structure data, and respond to the target read request to return the stable version data of the first target data.
[0083] Here, the target read request is used to read the first target data in the second hierarchical structure data. The second hierarchical structure data may be one or more hierarchical structure data in the database system, and the hierarchical structure data may be the first hierarchical structure data. In other words, the target read request may indicate reading at least one first target data in one second hierarchical structure data. The target read request may also indicate reading at least one first target data in a plurality of second hierarchical structure data respectively.
[0084] The historical write transaction related to the second-level structure data refers to the write transaction for the second-level structure data before the target read request is initiated.
[0085] The stable version data of the first target data is the first version data which is closest to the request time point of the target read request and involves a committed write transaction of the first target data.
[0086] That is, the stable version data of the first target data may be first version data that is before the request time point of the target read request, is closest to the request time point, and involves a committed historical write transaction of the first target data.
[0087] After determining the stable version data corresponding to the first target data, the user end that initiates the target read request can return the stable version data of the first target data, so that the user end can accurately read the required data in a concurrent read and write scenario.
[0088] Therefore, through the above implementation, data changes of a hierarchical structure data and consistency guarantee across multiple hierarchical structure data can be achieved, and consistent reading at the session level can be achieved.
[0089] Figure 5 is a flow chart of a method for controlling read and write concurrency based on a database according to some other embodiments. Figure 5 As shown, the stable version data of the first target data can be determined through the following steps.
[0090] In step 510, an initial consistency view is constructed based on the first version data corresponding to the historical write transactions related to the second hierarchical structure data.
[0091] Here, the consistent view refers to a snapshot of the database at a specific point in time. This snapshot provides a consistent state of the database, so that transactions can operate on this view without worrying about the impact of other concurrent transactions. The consistent view represents the state of the database at a specific point in time. Therefore, when a target read request is received, the initial consistent view is constructed based on the first version of the second hierarchy data that has been assigned to the write transaction at the request time of the target read request.
[0092] That is to say, the constructed initial consistency view is a consistency view constructed based on the first version data that has been allocated to the second-level structure data at the request time point of the target read request. For example, the first version data that has been allocated to the second-level structure data include 1, 2, 3, 4, 5, 6, 7, and 8 respectively. If the target read request is received after the second-level structure data allocates the first version data 4 but before the first version data 5 is allocated, then when the target read request is received, the first version data that has been allocated to the write transaction by the second-level structure data include the first version data 1, 2, 3, and 4.
[0093] Among them, the initial consistency view includes a first list (TreeGenVersions) and a second list (PendingTxnIDs). The first list is used to record the second version data, and the second version data is the first version data allocated for the write transaction most recently from the request time point. The second list is used to record the transaction identifier of the write transaction for the first target data and in a pending state.
[0094] For example, when a target read request is received, the first version data of the second hierarchical structure data that has been allocated to the write transaction includes first version data 1, 2, 3, and 4, and the second version data is the first version data 4, that is, when the target read is generated, the second hierarchical structure data has been allocated the latest first version data.
[0095] It is worth noting that, for the first list in the initial consistency view, if the target read request indicates to read the first target data in a second hierarchical structure data, the first list records the second version data corresponding to the second hierarchical structure data. For example, if the target read request indicates to read the first target data in tree_1, the first list can be expressed as {tree_1:4}, that is, the second version data corresponding to the second hierarchical structure data tree_1 is 4. If the target read request indicates to read the first target data in multiple second hierarchical structure data, the first list records the second version data corresponding to multiple second hierarchical structure data respectively. For example, if the target read request indicates to read the first target data in tree_1, tree_2 and tree_3 respectively, the first list can be expressed as {tree_1:4, tree_2:8, tree_3:4}, that is, the second version data corresponding to the second hierarchical structure data tree_1 is 4, the second version data corresponding to the second hierarchical structure data tree_2 is 8, and the second version data corresponding to the second hierarchical structure data tree_3 is 6.
[0096] For the first list in the initial consistency view, any first version data in the second hierarchical structure data that is greater than the second version data in the first list can be understood as the first version data assigned to the write transaction after the target read request is generated. Even if the write transaction corresponding to the first version data has been resolved, the first version data submitted by the write transaction is not visible in the first list of the initial consistency view. In other words, the first version data submitted by the write transaction does not belong to the valid version data indicated by the target read request.
[0097] It should be noted that the second list may be initially empty, and in the process of reading the stable version data of the first target data based on the initial consistency view, the transaction identifiers corresponding to all write transactions encountered whose transaction execution status is in a pending state may be recorded in the second list.
[0098] Since write transactions can be committed out of order, when traversing a data A, its corresponding write transaction B may be pending. When traversing to data C, its corresponding write transaction B may be resolved. The second list can record whether the transaction execution status of the write transaction is resolved globally.
[0099] In step 520, stable version data of the first target data is determined based on the first version data allocated by the historical write transaction related to the second hierarchical structure data and the initial consistency view.
[0100] Here, the first version data allocated to the historical write transaction related to the second hierarchical structure data may refer to all the first version data of the first target data that have been allocated to the write transaction. It should be noted that all the first version data corresponding to the first target data may not be determined by the request time point of the target read request, that is, all the first version data corresponding to the first target data may include the first version data allocated after the request time point of the target read request.
[0101] Stable version data refers to a specific version of the first target data in the database system, which is determined when a transaction starts and remains unchanged during the execution of the entire transaction.
[0102] The stable version data of the first target data is the latest first version data among all first version data that is allocated before the target read request is initiated and does not have a write transaction with a pending transaction execution status.
[0103] It should be understood that the first version data allocated before the target read request is initiated refers to the first version data of the second hierarchical structure data allocated to the write transaction before the time point of initiating the target read request.
[0104] The stable version data of the first target data is the latest first version data determined through the initial consistency view among all the first version data of the first target data, which is allocated before the target read request is initiated and has no pending write transaction.
[0105] For example, assuming that the first list of the initial consistency view is {tree_1:4}, all first version data of the first target data include version data 1, 2, 3, 4, 5, 6, 7, 8. Since the version numbers of version data 5, 6, 7, 8 are greater than {tree_1:4} in the first list of the initial consistency view, version data 5, 6, 7, 8 are allocated after the target read request is initiated, and version data 5, 6, 7, 8 do not belong to stable version data. Version data 1, 2, 3, 4 are allocated before the target read request is initiated, and version data 1, 2, 3, 4 may be stable version data of the first target data. Since version data 4 is the latest version data among version data 1, 2, 3, 4, if it is determined through the second list of the initial consistency view that there is no pending write transaction for version data 4 among version data 1, 2, 3, 4, then version data 4 is the stable version data of the first target data.
[0106] Therefore, through step 510 to step 520, data changes of a hierarchical data and consistency guarantee across multiple hierarchical data can be achieved, and consistent reading at the session level can be achieved through the initial consistent view including the first list and the second list.
[0107] In some possible implementations, the first target data includes first sub-data located in a second hierarchical structure data.
[0108] That is, the target read request is used to instruct to read one or more first sub-data in the second hierarchical structure data.
[0109] Accordingly, in step 520, if there is a pending write transaction for the first sub-data, the transaction identifier corresponding to the pending write transaction can be recorded in the second list of the consistency view, and the historical first version data corresponding to the first sub-data can be sorted in descending order of version numbers, and the first historical first version data that meets the first filtering condition is selected as the stable version data in the order of sorting, wherein the first filtering condition indicates that the version number of the selected historical first version data is not greater than the version number of the second version data recorded in the first list, and the transaction identifier of the related write transaction is not in the second list.
[0110] Here, for each first sub-data that needs to be read, the transaction execution status corresponding to the write transaction associated with the first sub-data is used to detect whether there is a pending write transaction for the first sub-data. If there is a pending write transaction for the first sub-data, the transaction identifier corresponding to the pending write transaction is recorded in the second list in the initial consistency view.
[0111] It should be noted that the existence of a pending write transaction in the first sub-data indicates that the historical first version data corresponding to the pending write transaction in the first sub-data is unavailable version data.
[0112] Then, all the historical first version data corresponding to the first sub-data are sorted in descending order of the version number to obtain the sorted historical first version data. In the embodiment of the present disclosure, the larger the version number of the version data, the newer the version data, and the smaller the version number of the version data, the older the version data. Sorting in descending order of the version number is actually sorting all the historical first version data from new to old.
[0113] After obtaining the sorted historical first version data, the first historical first version data that is ranked high and meets the first screening condition is selected from the sorted historical first version data.
[0114] It is worth noting that the first version data ranked higher in the sorted first version data is the newer first version data. The stable version data is actually the first version data selected from the sorted first version data that ranks higher in the sorted first version data and can meet the first screening condition.
[0115] The first screening condition indicates that the version number of the selected historical first version data is not greater than the version number of the second version data recorded in the first list, and the transaction identifier of the related write transaction is not in the second list.
[0116] That is, the historical first version data selected from the sorted historical first version data is the latest historical first version data that was allocated before the target read request was initiated and for which there is no write transaction with a pending transaction execution status.
[0117] Correspondingly, the stable version data corresponding to the first sub-data is the first historical first version data that satisfies the first screening condition and is selected in the order of sorting.
[0118] It is worth noting that, in the implementation manner, for a single second-level structure data, the stable version data of the first sub-data in the second-level structure data is read through the corresponding initial consistency view.
[0119] Therefore, through the above implementation, when the target read request indicates to read the first sub-data in the second hierarchical structure data, the latest stable version data can be accurately read, thereby realizing concurrent read and write control of the database.
[0120] Figure 6 FIG. 1 is a flowchart of a method for controlling read and write concurrency based on a database according to other embodiments. Figure 6 As shown, the following steps may be included.
[0121] In step 601, for each first sub-data, if there is a pending write transaction in the first sub-data, a transaction identifier corresponding to the pending write transaction is recorded in a second list in the initial consistency view.
[0122] Here, for the detailed description of step 601, reference can be made to the relevant description of the above implementation manner, which will not be repeated here.
[0123] In step 602, all historical first version data corresponding to the first sub-data are sorted in descending order of version numbers to obtain sorted historical first version data.
[0124] Here, the detailed description of step 602 can refer to the relevant description of the above implementation mode, which will not be repeated here.
[0125] In step 603, a historical first version data with a higher ranking is selected from the sorted historical first version data in turn.
[0126] Here, selecting a historical first version data with a higher ranking from the sorted historical first version data can be understood as selecting the latest historical first version data from the historical first version data that has not been selected each time the historical first version data is selected.
[0127] For example, in the first selection process, the first historical first version data with the highest ranking among the sorted historical first version data is selected. In the second selection process, the second historical first version data with the highest ranking among the sorted historical first version data is selected.
[0128] In step 604, it is determined whether the version number of the selected historical first version data is greater than the version number of the second version data included in the first list in the initial consistency view.
[0129] Here, if the version number of the selected historical first version data is greater than the version number of the second version data included in the first list in the initial consistency view, it means that the selected historical first version data is allocated after the initial consistency view is generated, and the selected historical first version data is not visible to the visitor.
[0130] If the version number of the selected historical first version data is less than or equal to the version number of the second version data included in the first list in the initial consistent view, it means that the selected historical first version data was allocated before the initial consistent view was generated.
[0131] If the version number of the selected historical first version data is greater than the version number of the second version data, the process returns to step 603. If the version number of the selected historical first version data is greater than the version number of the second version data, the process proceeds to step 605.
[0132] In step 605, it is determined whether there is a transaction identifier corresponding to the selected historical first version data in the second list of the initial consistent view.
[0133] Here, if the transaction identifier corresponding to the selected historical first version data exists in the second list of the initial consistency view, it means that when the initial consistency view is generated, the write transaction corresponding to the selected historical first version data is pending, and accordingly, the selected historical first version data is not visible to the initial consistency view, and the historical first version data needs to be reselected. If the transaction identifier corresponding to the selected historical first version data does not exist in the second list of the initial consistency view, it means that when the initial consistency view is generated, the write transaction corresponding to the selected historical first version data is resolved, and accordingly, the selected historical first version data is visible to the initial consistency view.
[0134] If the transaction identifier corresponding to the selected historical first version data does not exist in the second list, execute step 606. If the transaction identifier corresponding to the selected historical first version data exists in the second list, return to execute step 603 to reselect the historical first version data until the stable version data is determined.
[0135] In step 606, the selected historical first version data is determined as the stable version data of the first sub-data.
[0136] Here, if the version number of the selected historical first version data is less than or equal to the version number of the second version data included in the first list in the initial consistency view, and the transaction identifier corresponding to the selected historical first version data does not exist in the second list of the initial consistency view, then the selected historical first version data is the stable version data of the first sub-data.
[0137] Therefore, through the above steps 601 to 606, for a single second hierarchical structure data, the stable version data corresponding to the first sub-data can be accurately read, thereby realizing concurrent read and write control of the database, so that read and write conflicts can be avoided in the hierarchical structure data, and write conflicts can be minimized, thereby greatly improving the capacity of the hierarchical structure data.
[0138] In some feasible implementations, the first target data includes a plurality of second sub-data located in different second hierarchical structure data, and accordingly, the first list records the second version data corresponding to each second hierarchical structure data.
[0139] The target read request may be used to instruct reading of one or more second sub-data located in a plurality of different second hierarchical data. For example, the target read request may instruct reading of at least one second sub-data in the second hierarchical data tree_1, reading of at least one second sub-data in the second hierarchical data tree_2, and reading of at least one second sub-data in the second hierarchical data tree_3.
[0140] In this scenario, the first list of the initial consistent view will include the second version data corresponding to each second-level organizational data. For example, the first list of the initial consistent view can be represented as {tree_1:4, tree_2:8, tree_3:4}.
[0141] Accordingly, in step 520, the target consistency view can be obtained according to the historical first version data allocated by the historical write transaction related to the second sub-data and the initial consistency view, and the stable version data of each second sub-data can be determined according to the target consistency view.
[0142] Here, the historical first version data allocated to the historical write transaction related to the second sub-data may refer to all the first version data of the second sub-data held by the write transaction for the second sub-data. All the historical first version data included in the second sub-data may refer to all the first version data of the second sub-data that have been allocated to the write transaction. It should be noted that all the historical first version data included in the second sub-data may not be determined by the request time point of the target read request. In other words, all the historical first version data included in the second sub-data may include the first version data allocated after the request time point of the target read request.
[0143] The target consistent view is obtained by adjusting the initial consistent view through the historical first version data allocated by the historical write transaction related to the second sub-data.
[0144] In the target consistency view, each second version data in the first list of the target consistency view is the committed and latest historical first version data in the historical first version data of the corresponding historical write transaction, and the second list of the target consistency view records the transaction identifiers of the write transactions in the pending state in the historical write transactions.
[0145] Exemplarily, the initial consistency view may be adjusted for multiple rounds according to all the historical first version data corresponding to all the second sub-data to obtain a target consistency view.
[0146] That is to say, all historical first version data corresponding to all second sub-data are used to continuously adjust the initial consistency view, so that in a certain round of adjustment, the consistency view obtained in this round of adjustment does not change compared with the consistency view obtained in the previous round of adjustment. In this case, the consistency view obtained in this round of adjustment is the target consistency view.
[0147] In some embodiments, the initial consistency view is adjusted for multiple rounds based on the historical first version data allocated by the historical write transactions related to the second sub-data, until the consistency view obtained by the current round of adjustment does not change relative to the consistency view obtained by the previous round of adjustment, and the consistency view obtained by the current round of adjustment is determined as the target consistency view.
[0148] Among them, in each round of adjustment, the transaction identifier of the pending write transaction associated with each second sub-data is recorded in the second list of the consistency view corresponding to this round, and the second version data in the first list of the consistency view corresponding to this round is adjusted through the first target version data corresponding to each second sub-data, the first target version data is the historical first version data in the historical first version data corresponding to the second sub-data, and the version number is greater than the version number of the second target version data, the second target version data is the historical first version data in the historical first version data corresponding to the second sub-data that meets the second filtering condition, and the second filtering condition indicates that the second target version data is the historical first version data whose version number is not greater than the version number of the corresponding second version data in the first list of the consistency view corresponding to this round, and the transaction identifier of the related write transaction is not in the second list of the consistency view corresponding to this round.
[0149] It should be noted that in the first round of adjustment, the consistency view obtained in this round of adjustment is a consistency view obtained by adjusting the initial consistency view according to all the first version data corresponding to all the second sub-data. In the second round of adjustment, the consistency view obtained in the first round of adjustment is adjusted according to all the historical first version data corresponding to all the second sub-data, and the consistency view corresponding to the second round of adjustment is obtained. In the third round of adjustment, the consistency view obtained in the second round of adjustment is adjusted according to all the historical first version data corresponding to all the second sub-data, and the consistency view corresponding to the third round of adjustment is obtained.
[0150] The consistency view obtained in this round of adjustment has not changed compared with the consistency view obtained in the previous round of adjustment, which may mean that the first list and the second list of the consistency view obtained in this round of adjustment have not changed compared with the first list and the second list of the consistency view obtained in the previous round of adjustment.
[0151] For example, if the second version data in the first list of the consistency view obtained in this round of adjustment has not changed compared with the second version data in the first list of the consistency view obtained in the previous round of adjustment, and if no new transaction identifier is added to the second list of the consistency view obtained in this round of adjustment compared with the second list of the consistency view obtained in the previous round of adjustment, then it can be determined that the consistency view obtained in this round of adjustment has not changed compared with the consistency view obtained in the previous round of adjustment.
[0152] It is worth noting that the consistency view obtained in this round of adjustment has not changed compared with the consistency view obtained in the previous round of adjustment. It can be understood that the consistency view obtained in this round of adjustment remains globally stable from the perspective of all second sub-data.
[0153] In each round of adjustment, the second version data recorded in the first list of the consistent view obtained in the previous round of adjustment and the second list of the consistent view obtained in the previous round of adjustment are adjusted according to all historical first version data corresponding to all second sub-data.
[0154] It should be understood that if the consistency view obtained in this round of adjustment does not change compared to the consistency view obtained in the previous round of adjustment, it means that the consistency view obtained in this round of adjustment remains stable from a global perspective. Accordingly, the stable version data corresponding to each second sub-data can be determined through the consistency view obtained in this round of adjustment.
[0155] Exemplarily, the stable version data corresponding to each second sub-data can be determined based on the second version data recorded in the first list of the consistency view (target consistency view) obtained by the current round of adjustment without changes. The second version data read from the consistency view (target consistency view) obtained by the current round of adjustment without changes can be used as the latest stable version data corresponding to the corresponding second sub-data.
[0156] For example, assuming that after multiple rounds of adjustments to the initial consistency view {tree_1:4, tree_2:8, tree_3:4}, the initial consistency view converges to the target initial consistency view {tree_1:4, tree_2:6, tree_3:3} and no longer changes, then the stable version of the second sub-data of tree_1 is tree_1:4, the stable version of the second sub-data of tree_2 is tree_2:6, and the stable version of the second sub-data of tree_3 is tree_3:3.
[0157] Therefore, through the above implementation, snapshot-level consistency across multiple hierarchical data can be achieved, and consistent reading at the session level can be achieved.
[0158] Figure 7 FIG. 4 is a flowchart of adjusting a consistency view according to some embodiments. Figure 7 As shown, the following steps may be included.
[0159] In step 701, one second sub-data is selected from all second sub-data.
[0160] Here, a second sub-data may be randomly selected from all the second sub-data, or may be selected in sequence.
[0161] In step 702, when there is a pending write transaction in the selected second sub-data, a transaction identifier corresponding to the pending write transaction is recorded in the second list of the consistency view corresponding to the current round.
[0162] Here, for each selected second sub-data, the transaction execution status corresponding to the historical write transaction associated with the second sub-data is used to detect whether there is a pending write transaction for the second sub-data. If there is a pending write transaction for the second sub-data, the transaction identifier corresponding to the pending write transaction is recorded in the second list of the consistency view corresponding to this round.
[0163] It should be noted that the existence of a pending write transaction in the second sub-data indicates that the historical first version data corresponding to the pending write transaction in the second sub-data is unavailable version data.
[0164] It is worth noting that the consistency view corresponding to this round refers to the consistency view used in this round of adjustment. For example, in the first round of adjustment, the consistency view corresponding to this round is the initial consistency view, and in the second round and all subsequent rounds of adjustment, the consistency view corresponding to this round is the consistency view obtained in the previous round of adjustment.
[0165] In step 703, all historical first version data of the selected second sub-data are sorted in descending order of version numbers to obtain sorted historical first version data.
[0166] Here, for each second sub-data, it may have one or more historical first version data. Sorting by version number in descending order is actually sorting all the historical first version data of the selected second sub-data from the newest to the oldest version.
[0167] In step 704, the first historical first version data that is ranked high and meets the second screening condition is selected from the sorted historical first version data, and the selected historical first version data is determined as the second target version data.
[0168] Here, the historical first version data ranked higher in the sorted historical first version data is the newer historical first version data. The second target version data is actually the first historical first version data selected from the sorted historical first version data that ranks higher in the sorted historical first version data and can meet the second screening condition.
[0169] Among them, the second filtering condition indicates that the second target version data is the historical first version data whose version number is not greater than the version number of the corresponding second version data in the first list of the consistency view corresponding to this round, and the transaction identifier of the related write transaction is not in the second list of the consistency view corresponding to this round.
[0170] For example, the first list of the consistency view corresponding to this round is {tree_1:4, tree_2:8, tree_3:4}. Assuming that the selected first sub-data is the data on tree_1, after sorting all the historical first version data included in the first sub-data, the sorted historical first version data are 8, 7, 6, 5, 4, 3, 2, 1. If there is no pending write transaction for the historical first version data 4, the historical first version data 4 is the determined second target version data.
[0171] It should be noted that the first list of the consistency view corresponding to this round includes the historical second version data corresponding to each second hierarchical structure data. Accordingly, the second version data matching the second sub-data in the first list of the consistency view corresponding to this round means that the second sub-data and the second version data belong to the same second hierarchical structure data.
[0172] It is worth noting that if a second target version data cannot be selected from the sorted historical first version data, it means that all historical first version data of the second sub-data are not stable version data, and failure can be returned.
[0173] In step 705, first target version data is determined from all historical first version data of the second sub-data according to the second target version data.
[0174] Here, after determining the second target version data, the first target version data is determined from all the historical first version data of the second sub-data, wherein the first target version data is the historical first version data of the second sub-data whose version number is greater than the version number of the second target version data.
[0175] It is worth noting that the version number of all historical first version data of the second sub-data is greater than the version number of the second target version data, indicating that the determined first target version data is historical first version data that is newer than the second target version data.
[0176] In step 706, the second version data associated with the first target version data in the first list of the consistency view corresponding to the current round is adjusted according to the first target version data to obtain an adjusted consistency view.
[0177] Here, after the first target version data is determined, the first target version data is used to adjust the second version data associated with the first target version data in the first list of the consistency view corresponding to the current round to obtain an adjusted consistency view.
[0178] In some embodiments, the allocation of each second-level structure data associated with a write transaction corresponding to the first target version data to the third version data of the write transaction can be determined based on the first target version data; for each second-level structure data, the smallest third version data in the third version data corresponding to the second-level structure data is reduced by one version to obtain valid version data; for each second version data in the first list of the consistency view corresponding to this round, the second version data in the first list is replaced with the minimum value of the second version data and the valid version data corresponding to the second version data.
[0179] Among them, the historical first version data of each write transaction is the first version data assigned to the write transaction, and the write transaction corresponding to the first target version data can be determined through the first target version data. Since a write transaction can target one or more hierarchical structure data, the various hierarchical structure data associated with the write transaction corresponding to the first target version data can be determined through the historical first version data corresponding to the various hierarchical structure data held by the write transaction corresponding to the first target version data, thereby further determining the third version data assigned to the write transaction by the various hierarchical structure data associated with the write transaction corresponding to the first target version data. It should be understood that the third version data can actually be understood as the first version data assigned to the write transaction by the various second hierarchical structure data targeted by the write transaction corresponding to the first target version data.
[0180] For each second-level structure data, the smallest third version data among all the third version data corresponding to the second-level structure data is reduced by one version to obtain valid version data.
[0181] It is worth noting that, since the write transaction corresponding to the first target version data is pending, the historical first version data corresponding to all the second-level structure data held by the write transaction is not visible under the consistency view. Therefore, it is necessary to reduce the smallest third version data among all the third version data corresponding to the second-level structure data by one version. Among them, the valid version data obtained by reducing the smallest third version data by one version can be understood as the stable version data from the perspective of the second-level structure data.
[0182] Then, for each second version data in the first list of the consistency view corresponding to this round, the second version data in the first list is replaced with the minimum value of the second version data and the valid version data corresponding to the second version data to obtain an adjusted consistency view.
[0183] That is, the value in the first list of the consistency view corresponding to this round is replaced by the minimum value of the corresponding second version data and the valid version data corresponding to the second version data.
[0184] For example, the first list of the consistency view corresponding to this round is {tree_1:4, tree_2:8, tree_3:4}. Assuming that the selected first sub-data is the data on tree_1, after sorting all the historical first version data included in the first sub-data, the sorted historical first version data are 8, 7, 6, 5, 4, 3, 2, 1. If there is no pending write transaction for the historical first version data 4, the first version data 4 is the determined second target version data.
[0185] Furthermore, the first target version data determined is the historical first version data 8, 7, 6, 5. If the pending write transaction corresponding to the historical first version data 5 is for tree_1 and tree_2, and the historical first version data held by the write transaction is tree_1:5 and tree_2:7, since tree_2:7 is smaller than tree_2:8 in the first list {tree_1:4, tree_2:8, tree_3:4} of the consistency view corresponding to this round, the valid version data of tree_2 is tree_2:7-1=tree_2:6. Therefore, the first list of the adjusted consistency view is {tree_1:4, tree_2:6, tree_3:4}.
[0186] In step 707, the process returns to step 701 until all second sub-data are selected, and the last adjusted consistent view is determined as the consistent view obtained in this round of adjustment.
[0187] Here, return to step 701 and perform the next round of adjustments on the consistency view obtained in this round of adjustments, until a round of adjustments is completed on the consistency view corresponding to this round using all the second sub-data, and the last adjusted consistency view is determined as the consistency view obtained in this round of adjustments.
[0188] During the next round of adjustment, the consistency view obtained in this round of adjustment is used as the consistency view corresponding to the next round of adjustment. By repeatedly executing steps 701 to 707, until in a certain round of adjustment, the consistency view obtained in this round of adjustment does not change relative to the consistency view obtained in the previous round of adjustment, multiple rounds of adjustment of the initial consistency view are completed.
[0189] It is worth noting that the consistency view corresponding to this round is always being maintained, and it is necessary to use all the second sub-data to adjust the consistency view corresponding to this round to obtain the adjusted consistency view.
[0190] It should be noted that the consistency view obtained in this round of adjustment has not changed compared with the consistency view obtained in the previous round of adjustment, so the first target version data corresponding to the consistency view obtained in this round of adjustment is the stable version data corresponding to the second sub-data.
[0191] Therefore, through the above steps 701 to 707, snapshot-level consistency across multiple hierarchical data can be achieved, and consistent reading at the session level can be achieved.
[0192] Figure 8 FIG. 1 is a flowchart of a method for controlling read and write concurrency based on a database according to some embodiments. Figure 8As shown, generate an initial consistency view, obtain all second sub-data, select a second sub-data from all second sub-data, determine the consistency view corresponding to this round, determine whether the second sub-data is selected, and if the second sub-data is selected, detect whether there is a pending write transaction for the selected second sub-data. If there is a pending write transaction, add the transaction identifier of the pending write transaction to the second list of the consistency view corresponding to this round. If there is no pending write transaction, sort all the first version data of the selected second sub-data in descending order of version number, and select the first first version data from the sorted first version data. Then, determine whether the selected first version data is the second target version data. If it is the second target version data, adjust the consistency view corresponding to this round through the first target version data, and return to select the next second sub-data, and adjust the consistency view corresponding to this round through the next second sub-data selected. If it is not the second target version data, select the next first version data from the sorted first version data.
[0193] If the second sub-data is not selected, it means that all the second sub-data have been selected and a round of adjustment is completed. Then, it is determined whether the consistency view obtained by this round of adjustment has changed compared with the consistency view obtained by the previous round of adjustment. If there is no change, the stable version data of each second sub-data is determined according to the second version data recorded in the first list of the consistency view obtained by this round of adjustment and the transaction identifier recorded in the second list. If there is a change, continue to select a second sub-data from all the second sub-data to perform the next round of adjustment.
[0194] It should be noted that in the first round of adjustment, the consistency view corresponding to this round is the initial consistency view, and in subsequent adjustment rounds, the consistency view corresponding to this round is the consistency view obtained in the previous round of adjustment.
[0195] The above implementation is described in detail below by taking an example.
[0196] Assume that node A (equivalent to a second child data) exists in tree1 (equivalent to a hierarchical structure data), node B exists in tree2, and node C exists in tree3. When there are write transactions on nodes A, B, and C, the information corresponding to their associated write transactions is shown in Table 1.
[0197] Table 1:
[0198]
[0199] In Table 1, there are write transactions txnA, txnB, and txnC. When reading nodes A, B, and C, the generated initial consistency view contains the second version data of tree1, tree2, and tree3. Since the timing (non-atomicity) of obtaining the initial consistency view is inconsistent, the obtained initial consistency view is uncertain. Assume that the value of the first list of the initial consistency view is {tree1:4, tree2:8, tree3:4}.
[0200] For node A, its corresponding second target version data is tree1:4, and its first target version data is tree1:5. Since in the first list {tree1:4, tree2:8, tree3:4}, the second version data of tree1 is 4, the update operation (tree1:5) of the write transaction txnA is invisible, so the stable version data of node A is tree1:4. Since the write transaction txnA also targets tree2, the corresponding third version data is tree2:7, and the write transaction txnA is pending, tree2:7 is not visible. Therefore, tree2:7 is downgraded by one version and changed to tree2:6. In other words, the first list is adjusted from {tree1:4, tree2:8, tree3:4} to {tree1:4, tree2:6, tree3:4}.
[0201] Then, the first list {tree1:4, tree2:6, tree3:4} is adjusted through node B, and the update operations of write transaction txnB and write transaction txnC are also invisible, so tree3:4 in write transaction txnB is invisible, and tree3:4 is downgraded by one version and changed to tree3:3. In other words, the first list is adjusted from {tree1:4, tree2:6, tree3:4} to {tree1:4, tree2:6, tree3:3}. The first list {tree1:4, tree2:6, tree3:3} is the first list corresponding to the final target consistency view. Correspondingly, the stable version data of node A is tree1:4, the stable version data of node B is tree2:6, and the stable version data of node C is tree3:3.
[0202] In some embodiments, step 520 may include the following steps:
[0203] Determine all second sub-data that are read as indicated by the target read request;
[0204] According to all the second sub-data, the initial consistent view is adjusted in multiple rounds in sequence to obtain a consistent view obtained by this round of adjustment, wherein each round of adjustment includes:
[0205] Selecting one second sub-data from all the second sub-data;
[0206] If there is a pending write transaction in the selected second sub-data, record the transaction identifier corresponding to the pending write transaction in the second list of the consistency view corresponding to the current round;
[0207] Sorting all the historical first version data of the selected second sub-data in descending order of version numbers to obtain sorted historical first version data;
[0208] Selecting the first historical first version data that is ranked high and meets the second screening condition from the sorted historical first version data, and determining the selected historical first version data as the second target version data;
[0209] According to the second target version data, determining the first target version data in all the historical first version data of the second sub-data;
[0210] According to the first target version data, adjusting the second version data corresponding to the first list in the consistency view corresponding to the current round to obtain an adjusted consistency view;
[0211] Return to the step of selecting one second sub-data from all the second sub-data until all the second sub-data are selected, and determine the last adjusted consistent view as the consistent view obtained in this round of adjustment;
[0212] If the consistency view obtained by the current round of adjustment is changed relative to the consistency view obtained by the previous round of adjustment, the consistency view obtained by the current round of adjustment is used as the consistency view corresponding to the next round, and the step of performing multiple rounds of adjustments on the initial consistency view in sequence according to all the second sub-data to obtain the consistency view obtained by the current round of adjustment is returned to, until the consistency view obtained by the current round of adjustment is unchanged relative to the consistency view obtained by the previous round of adjustment;
[0213] When the consistency view obtained in this round of adjustment has not changed compared with the consistency view obtained in the previous round of adjustment, the consistency view obtained in this round of adjustment is determined as the target consistency view, and the corresponding second target version data is determined as the stable version data corresponding to each second sub-data.
[0214] Fig. 9 is a schematic diagram of a structure of a read-write concurrency control device based on a database according to some embodiments. Fig. 9 As shown, the embodiment of the present disclosure provides a database-based read-write concurrency control device 900, and the database-based read-write concurrency control device 900 may include:
[0215] A determination module 901 is configured to, in response to receiving a target write transaction, determine the first hierarchical structure data targeted by the target write transaction;
[0216] An allocating module 902 is configured to allocate first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data;
[0217] The execution module 903 is configured to execute the target write transaction for the first version data corresponding to the first hierarchical structure data, and record the transaction execution status of the target write transaction for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data can be determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
[0218] Optionally, the database-based read-write concurrency control device 900 further includes:
[0219] A receiving module, configured to receive a target read request, wherein the target read request is used to read first target data in the second hierarchical structure data;
[0220] a data determination module configured to determine stable version data of the first target data according to the transaction execution status of each historical write transaction related to the second hierarchical structure data, wherein the stable version data is the first version data that is closest to the request time point of the target read request and involves a committed write transaction of the first target data;
[0221] The return module is configured to return the stable version data of the first target data in response to the target read request.
[0222] Optionally, the data determination module is specifically configured to:
[0223] According to the first version data corresponding to the historical write transaction related to the second hierarchical structure data, an initial consistency view is constructed, wherein the initial consistency view includes a first list and a second list, wherein the first list is used to record the second version data, the second version data is the first version data allocated to the write transaction most recently from the request time point, and the second list is used to record the transaction identifier of the write transaction in a pending state for the first target data;
[0224] The stable version data of the first target data is determined according to the first version data allocated by the historical write transaction related to the second hierarchical structure data and the initial consistency view.
[0225] Optionally, the first target data includes first sub-data located in a second hierarchical structure data;
[0226] The data determination module is specifically configured as follows:
[0227] If there is a pending write transaction for the first sub-data, record a transaction identifier corresponding to the pending write transaction in the second list of the consistency view;
[0228] The historical first version data corresponding to the first sub-data are sorted in descending order of version number, and the first historical first version data that meets the first filtering condition is selected as the stable version data according to the sorting order, wherein the first filtering condition indicates that the version number of the selected historical first version data is not greater than the version number of the second version data recorded in the first list, and the transaction identifier of the related write transaction is not in the second list.
[0229] Optionally, the first target data includes a plurality of second sub-data located in different second hierarchical structure data, and the first list records the second version data corresponding to each second hierarchical structure data;
[0230] The data determination module is specifically configured as follows:
[0231] A target consistency view is obtained according to the historical first version data allocated by the historical write transaction related to the second sub-data and the initial consistency view, wherein each second version data in the first list of the target consistency view is the latest and submitted historical first version data in the corresponding historical write transaction, and the transaction identifier of the pending write transaction in the historical write transaction is recorded in the second list of the target consistency view;
[0232] According to the target consistency view, stable version data of each of the second sub-data is determined.
[0233] Optionally, the data determination module is specifically configured to:
[0234] According to the historical first version data allocated by the historical write transaction related to the second sub-data, the initial consistency view is adjusted for multiple rounds until the consistency view obtained by the current round of adjustment does not change with respect to the consistency view obtained by the previous round of adjustment, and the consistency view obtained by the current round of adjustment is determined as the target consistency view;
[0235] Among them, in each round of adjustment, the transaction identifier of the pending write transaction associated with each second sub-data is recorded in the second list of the consistency view corresponding to this round, and the second version data in the first list of the consistency view corresponding to this round is adjusted through the first target version data corresponding to each second sub-data, the first target version data being the historical first version data corresponding to the second sub-data and having a version number greater than the version number of the second target version data, the second target version data being the historical first version data corresponding to the second sub-data and meeting the second filtering condition, the second filtering condition indicating that the second target version data is the historical first version data having a version number not greater than the version number of the corresponding second version data in the first list of the consistency view corresponding to this round, and the transaction identifier of the related write transaction is not in the second list of the consistency view corresponding to this round.
[0236] Optionally, the data determination module is specifically configured to:
[0237] According to the first target version data, determining that each second hierarchical structure data associated with the write transaction corresponding to the first target version data is allocated to the third version data of the write transaction;
[0238] For each of the second hierarchical structure data, the smallest third version data in the third version data corresponding to the second hierarchical structure data is reduced by one version to obtain valid version data;
[0239] For each second version data in the first list of the consistency view corresponding to the current round, the second version data in the first list is replaced with the minimum value between the second version data and the valid version data corresponding to the second version data.
[0240] Optionally, the target write transaction is used to indicate that the data in the first hierarchical structure data with the second target data as the root is moved to below the third target data in the target hierarchical structure data;
[0241] The execution module 903 is specifically configured as follows:
[0242] Lock the second target data, and check whether the third target data and the ancestor node corresponding to the third target data have a lock;
[0243] In a case where the third target data and the ancestor node corresponding to the third target data do not have a lock, executing the target write transaction for each of the first version data held by the target write transaction to move the data rooted at the second target data to below the third target data;
[0244] By asynchronous updating, the ancestor path information of all descendant nodes corresponding to the second target data is modified to the ancestor path information with the third target data as the parent node path;
[0245] The second target data is unlocked.
[0246] The logic of the method executed by each functional module in the above-mentioned database-based read-write concurrency control device 900 can refer to the part of the method related to the above-mentioned embodiment, and will not be repeated here.
[0247] Reference below Fig.10 , which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 1000 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.10 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0248] like Fig.10 As shown, the electronic device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0249] Typically, the following devices may be connected to the I / O interface 1005: an input device 1006 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device 1000 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10 The electronic device 1000 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0250] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 1009, or installed from a storage device 1008, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0251] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0252] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0253] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0254] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: in response to receiving a target write transaction, determines the first hierarchical structure data targeted by the target write transaction; allocates the first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data; executes the target write transaction for the first version data corresponding to the first hierarchical structure data, and records the transaction execution status of the target write transaction for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data is determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
[0255] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0256] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0257] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.
[0258] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0259] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0260] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0261] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0262] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A read-write concurrency control method based on a database, characterized in that: include: In response to receiving a target write transaction, determining first hierarchical structure data targeted by the target write transaction; Allocating first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data; The target write transaction is executed for the first version data corresponding to the first hierarchical structure data, and the transaction execution status of the target write transaction is recorded for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data is determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
2. The method according to claim 1, characterized in that: The method further comprises: receiving a target read request, wherein the target read request is used to read first target data in the second hierarchical structure data; Determine stable version data of the first target data according to the transaction execution status of each historical write transaction related to the second hierarchical structure data, wherein the stable version data is the first version data that is closest to the request time point of the target read request and involves a committed write transaction of the first target data; In response to the target read request, stable version data of the first target data is returned.
3. The method according to claim 2, characterized in that The determining the stable version data of the first target data according to the transaction execution status of each historical write transaction related to the second hierarchical structure data includes: According to the first version data corresponding to the historical write transaction related to the second hierarchical structure data, an initial consistency view is constructed, wherein the initial consistency view includes a first list and a second list, wherein the first list is used to record the second version data, the second version data is the first version data allocated to the write transaction most recently from the request time point, and the second list is used to record the transaction identifier of the write transaction in a pending state for the first target data; The stable version data of the first target data is determined according to the first version data allocated by the historical write transaction related to the second hierarchical structure data and the initial consistency view.
4. The method according to claim 3, characterized in that The first target data includes first sub-data located in a second hierarchical structure data; The determining the stable version data of the first target data according to the first version data allocated by the historical write transaction related to the second hierarchical structure data and the initial consistency view includes: If there is a pending write transaction for the first sub-data, record a transaction identifier corresponding to the pending write transaction in the second list of the consistency view; The historical first version data corresponding to the first sub-data are sorted in descending order of version number, and the first historical first version data that meets the first filtering condition is selected as the stable version data according to the sorting order, wherein the first filtering condition indicates that the version number of the selected historical first version data is not greater than the version number of the second version data recorded in the first list, and the transaction identifier of the related write transaction is not in the second list.
5. The method according to claim 3, characterized in that: The first target data includes a plurality of second sub-data located in different second hierarchical structure data, and the first list records the second version data corresponding to each second hierarchical structure data; The determining the stable version data of the first target data according to the first version data allocated by the historical write transaction related to the second hierarchical structure data and the initial consistency view includes: A target consistency view is obtained according to the historical first version data allocated by the historical write transaction related to the second sub-data and the initial consistency view, wherein each second version data in the first list of the target consistency view is the latest and submitted historical first version data in the corresponding historical write transaction, and the transaction identifier of the pending write transaction in the historical write transaction is recorded in the second list of the target consistency view; According to the target consistency view, stable version data of each of the second sub-data is determined.
6. The method according to claim 5, characterized in that The obtaining of the target consistency view according to the historical first version data allocated according to the historical write transaction related to the second sub-data and the initial consistency view comprises: According to the historical first version data allocated by the historical write transaction related to the second sub-data, the initial consistency view is adjusted for multiple rounds until the consistency view obtained by the current round of adjustment does not change with respect to the consistency view obtained by the previous round of adjustment, and the consistency view obtained by the current round of adjustment is determined as the target consistency view; Among them, in each round of adjustment, the transaction identifier of the pending write transaction associated with each second sub-data is recorded in the second list of the consistency view corresponding to this round, and the second version data in the first list of the consistency view corresponding to this round is adjusted through the first target version data corresponding to each second sub-data, the first target version data being the historical first version data corresponding to the second sub-data and having a version number greater than the version number of the second target version data, the second target version data being the historical first version data corresponding to the second sub-data and meeting the second filtering condition, the second filtering condition indicating that the second target version data is the historical first version data having a version number not greater than the version number of the corresponding second version data in the first list of the consistency view corresponding to this round, and the transaction identifier of the related write transaction is not in the second list of the consistency view corresponding to this round.
7. The method according to claim 6, characterized in that The adjusting the second version data in the first list of the consistency view corresponding to the current round by using the first target version data corresponding to each of the second sub-data includes: According to the first target version data, determining that each second hierarchical structure data associated with the write transaction corresponding to the first target version data is allocated to the third version data of the write transaction; For each of the second hierarchical structure data, the smallest third version data in the third version data corresponding to the second hierarchical structure data is reduced by one version to obtain valid version data; For each second version data in the first list of the consistency view corresponding to the current round, the second version data in the first list is replaced with the minimum value between the second version data and the valid version data corresponding to the second version data.
8. The method according to claim 1, characterized in that The target write transaction is used to indicate that the data in the first hierarchical structure data with the second target data as the root is moved to below the third target data in the target hierarchical structure data; The executing the target write transaction on the first version data corresponding to the first hierarchical structure data includes: Lock the second target data, and check whether the third target data and the ancestor node corresponding to the third target data have a lock; In a case where the third target data and the ancestor node corresponding to the third target data do not have a lock, executing the target write transaction for each of the first version data held by the target write transaction to move the data rooted at the second target data to below the third target data; By asynchronous updating, the ancestor path information of all descendant nodes corresponding to the second target data is modified to the ancestor path information with the third target data as the parent node path; The second target data is unlocked.
9. A read-write concurrency control device based on a database, characterized in that: include: a determination module, configured to, in response to receiving a target write transaction, determine first hierarchical structure data targeted by the target write transaction; an allocating module, configured to allocate first version data corresponding to the first hierarchical structure data to the target write transaction, wherein the first version data is the latest version data of the first hierarchical structure data; An execution module is configured to execute the target write transaction for the first version data corresponding to the first hierarchical structure data, and record the transaction execution status of the target write transaction for the first hierarchical structure data, so that when supporting a read request, the stable version data corresponding to the first hierarchical structure data can be determined according to the transaction execution status of each target write transaction related to the first hierarchical structure data.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 8 are implemented.
11. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
