Transaction processing method, system, device, equipment, and program
The transaction processing method optimizes transaction allocation and execution in distributed database systems by selecting cooperating node devices based on allocation indicators, addressing efficiency and reliability issues in shared-disk architectures.
Patent Information
- Application Number
- JP2023517375
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-11-27
- Filing Date
- 2021-10-26
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-10-26
AI Technical Summary
Distributed database systems based on shared-disk architecture face limitations in transaction processing efficiency and reliability due to transactions being assigned to fixed node devices, which hinders effective processing and consistency.
A transaction processing method that involves determining a transaction allocation indicator for each node device, selecting a cooperating node device based on this indicator, and enabling cooperative processing across multiple node devices without considering data item distribution, using a transaction allocation index to optimize transaction allocation and execution.
Improves transaction processing efficiency and reliability by allowing decentralized processing of transactions, enhancing system performance and ensuring data consistency across distributed transactions.
Smart Images

Figure 0007549137000006 
Figure 0007549137000007 
Figure 0007549137000002
Abstract
Description
[Technical field]
[0001] The embodiments of the present application relate to the technical field of databases, and in particular to a transaction processing method, system, device, equipment, storage medium and program product.
[0002] This application claims priority to a Chinese patent application filed on November 27, 2020, bearing application number 202011362629.2 and entitled "Transaction Processing Method, Apparatus, and Computer-Readable Storage Medium," the entire contents of which are incorporated herein by reference. [Background technology]
[0003] With the development of database technology, distributed database systems are gradually becoming popular to accommodate business scenarios such as big data, cloud computing, etc. Among the various types of distributed database systems, distributed database systems based on shared-disk architecture have become the mainstream system.
[0004] Currently, in a distributed database system based on a shared-disk architecture, transactions are assigned according to the distribution of data items, and transactions related to a certain data item are assigned to fixed node devices that service the data items and processed independently, which greatly limits the transaction processing efficiency and makes the reliability of transaction processing relatively poor. Summary of the Invention [Problem to be solved by the invention]
[0005] The embodiments of the present application provide a transaction processing method, system, device, apparatus, storage medium and program product, which can be used to improve transaction processing efficiency. [Means for solving the problem]
[0006] In one aspect, an embodiment of the present application provides a transaction processing method, the method being applied to a transaction allocation device, the transaction allocation device being in a distributed database system, the distributed database system further including at least two node devices sharing a same storage system, the method comprising: determining a transaction allocation index corresponding to each of the at least two node devices in response to an allocation request for the target transaction, the transaction allocation index corresponding to one node device being used to indicate a matching degree for allocating a new transaction to the one node device; The method includes a step of determining a cooperative node device of the target transaction among the at least two node devices based on a transaction allocation indicator corresponding to each of the at least two node devices, and cooperatively processing the target transaction by the cooperative node devices.
[0007] A transaction processing method is further provided, the method being applied to a cooperative node device, the cooperative node device being a node device used to cooperatively process a target transaction among at least two node devices sharing the same storage system, the cooperative node device being determined based on a transaction allocation index corresponding to each of the at least two node devices, the method comprising: obtaining transaction information of the target transaction; sending a data read request to a data node device based on transaction information of the target transaction, the data node device being one of the at least two node devices that is used to participate in processing the target transaction; In response to the data read result returned from the data node device satisfying a transaction authentication condition, transmitting a transaction authentication request and a local write set to the data node device; The method includes a step of determining a processing instruction for the target transaction based on the authentication result of the target transaction returned from the data node device, and sending the processing instruction to the data node device, wherein the processing instruction is a commit command or an abort command, and the data node device is used to execute the processing instruction.
[0008] A transaction processing method is further provided, the method being applied to a data node device, the data node device being one of at least two node devices sharing a same storage system that is used to participate in processing a target transaction, the method comprising: According to a data read request sent from a cooperative node device, a data read result is obtained, and the data read result is returned to the cooperative node device, where the cooperative node device is determined based on a transaction allocation index corresponding to each of the at least two node devices; obtaining an authentication result of the target transaction based on a transaction authentication request and a local write set transmitted from the cooperative node device, and returning the authentication result of the target transaction to the cooperative node device; and in response to receiving a processing instruction for the target transaction transmitted from the cooperative node device, executing the processing instruction, the processing instruction being a commit instruction or an abort instruction.
[0009] In another aspect, a transaction processing system is provided, the transaction processing system including a cooperative node device and a data node device, the cooperative node device being one of at least two node devices sharing the same storage system that is used to cooperatively process a target transaction, the cooperative node device being determined based on a transaction allocation index corresponding to each of the at least two node devices, and the data node device being one of the at least two node devices that is used to participate in processing the target transaction; the cooperative node device is used for acquiring transaction information of the target transaction and transmitting a data read request to the data node device based on the transaction information of the target transaction; the data node device is used to obtain a data read result based on the data read request transmitted from the cooperative node device, and to return the data read result to the cooperative node device; The cooperative node device is further used to send a transaction authentication request and a local write set to the data node device in response to the data read result returned from the data node device satisfying a transaction authentication condition; The data node device is further used for obtaining an authentication result of the target transaction based on the transaction authentication request and the local write set sent from the cooperative node device, and returning the authentication result of the target transaction to the cooperative node device; The cooperative node device is further used for determining a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device, and sending the processing command to the data node device, the processing command being a commit command or an abort command; The data node device is further adapted to execute, in response to receiving a processing instruction for the target transaction transmitted from the cooperative node device, the processing instruction.
[0010] In another aspect, a transaction processing device is provided, the device comprising: a first determination unit, which is used to determine a transaction allocation index corresponding to each of at least two node devices sharing the same storage system in response to an allocation request of the target transaction, wherein the transaction allocation index corresponding to one node device is used to indicate a matching degree of allocating a new transaction to the one node device; and a second determination unit for determining a cooperative node device of the target transaction among the at least two node devices based on a transaction allocation indicator corresponding to each of the at least two node devices, and for cooperatively processing the target transaction by the cooperative node devices.
[0011] There is further provided a transaction processing device, said device comprising: an acquiring unit, used for acquiring transaction information of a target transaction; a first sending unit used to send a data read request to a data node device based on transaction information of the target transaction, the data node device being one of at least two node devices sharing the same storage system that is used to participate in processing the target transaction; and a second sending unit, which is used to send a transaction authentication request and a local write set to the data node device in response to the data read result returned from the data node device satisfying a transaction authentication condition; a determination unit used for determining a processing instruction of the target transaction according to the authentication result of the target transaction returned from the data node device; A third transmitting unit used to transmit the processing command to the data node device, the processing command being a commit command or an abort command, and the data node device being used to execute the processing command.
[0012] There is further provided a transaction processing device, said device comprising: a first acquisition unit used to acquire a data read result based on a data read request sent from a cooperative node device, the cooperative node device being a node device used to cooperatively process a target transaction among at least two node devices sharing the same storage system, the cooperative node device being determined based on transaction allocation indicators corresponding to each of the at least two node devices; a reply unit for replying the data read result to the cooperative node device; A second acquisition unit is used for acquiring an authentication result of the target transaction according to the transaction authentication request sent by the cooperative node device and a local write set; an execution unit used for executing a processing command for the target transaction in response to receiving the processing command for the target transaction transmitted from the cooperative node device, the processing command being a commit command or an abort command; The reply unit is further used for replying the authentication result of the target transaction to the cooperative node device.
[0013] In another aspect, a computer device is provided, the computer device including a processor and a memory, at least one computer program stored in the memory, the at least one computer program being loaded and executed by the processor to cause the computer device to implement the transaction processing method described in any one of the preceding claims.
[0014] In another aspect, there is further provided a non-transitory computer readable storage medium, wherein at least one computer program is stored in the non-transitory computer readable storage medium, and the at least one computer program is loaded and executed by a processor to cause the computer to realize the transaction processing method described in any one of the preceding claims.
[0015] In another aspect, there is further provided a computer program product or computer program comprising computer instructions, the computer instructions being stored in a computer readable storage medium, a processor of a computing device reading the computer instructions from the computer readable storage medium, and the processor executing the computer instructions, thereby causing the computing device to perform the transaction processing method of any one of the preceding claims.
[0016] In the embodiment of the present application, the cooperative node devices used to cooperatively process the target transaction are determined based on the transaction allocation index corresponding to each node device, and the transaction allocation process does not need to take into account the data items related to the transaction, nor the distribution of the data items. Based on this method, each node device can cooperatively process the transaction as a distributed device, thereby enabling the transaction to be processed between nodes, which is favorable for improving the transaction processing efficiency, making the transaction processing more reliable, and improving the system performance of the database system. [Brief description of the drawings]
[0017] [Figure 1] FIG. 1 is a schematic diagram of an implementation environment of a transaction processing method provided by an embodiment of the present application. [Diagram 2] 2 is a flowchart of a transaction processing method provided by an embodiment of the present application; [Diagram 3] FIG. 2 is a schematic diagram of a format of a transaction log provided by an embodiment of the present application. [Figure 4] FIG. 2 is a schematic diagram of a format of a transaction log provided by an embodiment of the present application. [Diagram 5] 1 is a schematic diagram of a transaction processing device provided by an embodiment of the present application. [Figure 6] 1 is a schematic diagram of a transaction processing device provided by an embodiment of the present application. [Figure 7] 1 is a schematic diagram of a transaction processing device provided by an embodiment of the present application. [Figure 8] FIG. 2 is a structural schematic diagram of a computer device provided by an embodiment of the present application; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0018] In order to make the objectives, technical solutions and advantages of the present application clearer, the following describes the embodiments of the present application in more detail in combination with the drawings.
[0019] As should be explained, the terms "first," "second," and the like in the specification and claims of this application are used to distinguish between similar objects, and are not used to describe a particular order or sequence. As should be understood, the data used in this manner can be interchanged where appropriate to allow the embodiments of the application described herein to be performed in orders other than those illustrated or described herein. The embodiments described in the following illustrative examples are not representative of all embodiments consistent with this application. On the contrary, they are merely examples of apparatus and methods consistent with certain aspects of the application as recited in the appended claims.
[0020] In some embodiments, the distributed database system according to the embodiments of the present application is a distributed database system based on a shared-disk architecture, and the distributed database system based on the shared-disk architecture includes at least two node devices, and the at least two node devices have their own local internal memory areas and directly access the same storage system through a network communication mechanism, that is, the at least two node devices share the same storage system, for example, sharing the same HDFS (Hadoop Distributed File System). A plurality of data tables can be stored in the storage system shared by the at least two node devices, and each data table can be used to store one or more data items.
[0021] From a logical point of view, the node devices in the distributed database system can be divided into two kinds of roles: collaboration node devices and data node devices, where the collaboration node devices are mainly responsible for producing, distributing processing plans and coordinating distributed transactions, and the data node devices are mainly responsible for receiving processing plans sent from the collaboration node devices, executing corresponding transactions, and returning relevant data about the transactions to the collaboration node devices.
[0022] In a distributed database system, the smallest operation execution unit is a transaction. Depending on whether a transaction needs to operate data items on multiple data node devices, the transaction can be divided into two types: distributed transaction and local transaction. Different execution processes can be adopted for these two different types of transactions to reduce network communication overhead as much as possible and improve transaction processing efficiency. Here, a distributed transaction refers to a transaction that needs to perform read and write operations among multiple data node devices, that is, a transaction needs to operate data items on multiple data node devices. For example, if transaction T needs to operate data items on data node devices RM1, RM2, and RM3, the transaction T is a distributed transaction. A local transaction refers to a transaction that only needs to operate data items on a single data node device. For example, if transaction T only needs to operate data items on RM1, the transaction T is a local transaction.
[0023] Fig. 1 is a schematic diagram of an implementation environment of a transaction processing method provided by an embodiment of the present application. As shown in Fig. 1, the embodiment of the present application may be applied to a distributed database system based on a share-disk framework, which may include a gateway server 101, a transaction allocation device 102, a distributed storage cluster 103, and a global timestamp generation cluster 104. The distributed storage cluster 103 includes m (m is an integer equal to or greater than 2) node devices, and the m node devices share the same storage system.
[0024] The gateway server 101 is used for receiving external read / write requests, and delivering read / write transactions corresponding to the read / write requests to the transaction allocation device 102 or the distributed storage cluster 103. For example, after a user logs in to an application client terminal on a terminal, the user triggers the application client terminal to generate a read / write request, and calls an API (Application Programming Interface) provided by the distributed database system to send a read / write transaction corresponding to the read / write request to the gateway server 101.
[0025] In some embodiments, the gateway server 101 may be merged onto the same physical machine as any one of the node devices in the distributed storage cluster 103 , ie, causing a node device to function as the gateway server 101 .
[0026] In some embodiments, the terminal on which the application client terminal resides can directly establish a communication connection with the transaction allocation device 102 and the distributed storage cluster 103 in the distributed database system. In such a case, the gateway server 101 may not be present in the distributed database system.
[0027] The transaction allocation device 102 is used to allocate appropriate node devices to new transactions as cooperative node devices. In an exemplary embodiment, the transaction allocation device is in a distributed coordination system (e.g., ZooKeeper). The distributed coordination system may be used to manage at least one of the gateway server 101, the distributed storage cluster 103, and the global timestamp generation cluster 104. Alternatively, a technician can access the distributed coordination system through a scheduler on a terminal, and thereby control the back-end distributed coordination system based on the front-end scheduler to realize management for each cluster or server. For example, the technician can control ZooKeeper through the scheduler to remove a certain node device from the distributed storage cluster 103, i.e., disable a certain node device.
[0028] The distributed storage cluster 103 may include data node devices and cooperative node devices, and each cooperative node device may correspond to at least one data node device. The division of data node devices and cooperative node devices is for different transactions. Taking a distributed transaction as an example, a node device that issues the distributed transaction may be called a cooperative node device, and other node devices related to the distributed transaction are called data node devices. The number of data node devices or cooperative node devices may be one or more, and the embodiment of the present application does not specifically limit the number of data node devices or cooperative node devices in the distributed storage cluster 103.
[0029] In the distributed database system provided by the embodiment of the present application, since there is no global transaction manager, the system adopts XA (eXtended Architecture, a distributed transaction standard of the X / Open organization) / 2PC (Two-Phase Commit) technology to support transactions (distributed transactions) between nodes and ensure the atomicity and consistency of data when writing between nodes. At this time, the cooperative node device is used to function as a coordinator in the 2PC algorithm, and each data node device corresponding to the cooperative node device is used to function as a participant in the 2PC algorithm.
[0030] Each data node device or cooperative node device may be a standalone device, or may adopt a master-standby structure (i.e., one-master multi-standby cluster). As shown in FIG. 1, taking the node device (data node device or cooperative node device) as an example of a one-master dual-standby cluster, each node device includes one master and two standbys, and optionally, each master or standby is correspondingly arranged with an agent device. The agent device may be physically independent from the master or standby, and of course, the agent device may further be used as an agent module in the master or standby. Taking the node device 1 as an example, the node device 1 includes one master database and an agent device (abbreviated as master database+agent, master DB+agent), and further includes two standby databases and agent devices (abbreviated as standby database+agent, standby DB+agent). The master database is the above-mentioned master, and the standby database is the above-mentioned standby.
[0031] The global timestamp generation cluster 104 is used to generate a global commit timestamp (Gts) for a distributed transaction, which may refer to a transaction involving multiple data node devices, for example, a distributed read transaction may involve reading data stored in multiple data node devices, and for example, a distributed write transaction may involve writing data in multiple data node devices. The global timestamp generation cluster 104 may be logically considered as a single point, but in some embodiments, a one-master, three-slave architecture can provide a higher availability service, and the generation of the global commit timestamp in the form of a cluster can prevent single point failures, thereby avoiding single point bottleneck problems.
[0032] Optionally, the global commit timestamp is a timestamp identifier that is globally unique and monotonically increasing in the distributed database system, and marks the global commit order of each transaction, which can be used to reflect the actual time context between transactions (total order relationship of transactions), and the global commit timestamp may adopt at least one of a physical clock, a logical clock, or a hybrid physical clock, and the embodiment of the present application does not specifically limit the type of the global commit timestamp.
[0033] In some embodiments, the global timestamp generation cluster 104 may be physically independent or may be integrated with a distributed cooperative system (eg, ZooKeeper).
[0034] The above FIG. 1 is merely an architecture diagram for providing lightweight transaction processing, and is one exemplary description of a distributed database system based on a share-disk architecture. In some embodiments, the distributed database system composed of the gateway server 101, the transaction allocation device 102, the distributed storage cluster 103, and the global timestamp generation cluster 104 may be regarded as a server that provides data services to a user terminal. The server may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data, as well as artificial intelligence platforms. Optionally, the user terminal may be, but is not limited to, a smartphone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc. The terminal and the server may be directly or indirectly connected by a wired or wireless communication method, and the present application is not limited thereto.
[0035] Based on the implementation environment shown in Fig. 1, an embodiment of the present application provides a transaction processing method. As shown in Fig. 2, the method provided by the embodiment of the present application includes the following steps 201 to 209.
[0036] In step 201, in response to an allocation request for a target transaction, the transaction allocation device determines transaction allocation indexes corresponding to at least two node devices, and the transaction allocation index corresponding to a node device is used to indicate a matching degree for allocating a new transaction to the node device.
[0037] The transaction allocation device and the at least two node devices are both in a distributed database system, and the at least two node devices share the same storage system. The embodiments of the present application do not limit the specific structure of the distributed database system, and may include a transaction allocation device and at least two node devices sharing the same storage system.
[0038] The target transaction refers to a transaction to be processed, and the target transaction may be a distributed transaction or a local transaction, but the embodiment of the present application is not limited thereto. The allocation request of the target transaction is used to assign an appropriate node device to the target transaction as a cooperative node device, and to instruct the assigned cooperative node device to cooperatively process the target transaction.
[0039] The target transaction allocation request is issued by the terminal, and the target transaction allocation request issued by the terminal is directly sent to the transaction allocation device by the terminal or forwarded to the transaction allocation device by the gateway server, but the embodiment of the present application does not limit this. The terminal may be any electronic device corresponding to a user, including but not limited to at least one of a smartphone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, or a smart watch, and the embodiment of the present application does not specifically limit the type of the terminal. Optionally, an application client terminal is installed on the terminal, and the application client terminal may be any client terminal that allows providing data services, for example, the application client terminal may be at least one of a payment application client terminal, a food delivery application client terminal, a taxi application client terminal, or a social application client terminal, and the embodiment of the present application does not specifically limit the type of the application client terminal.
[0040] At least two node devices refer to node devices that enable cooperative processing of transactions as distributed node devices in a distributed database system, and each individual node device can be used to cooperatively process distributed transactions using a distributed algorithm.
[0041] After receiving an allocation request for a target transaction, the transaction allocation device needs to allocate a suitable node device to the target transaction as a cooperative node device to ensure the efficiency of transaction processing. In the process of allocating a suitable node device to the target transaction as a cooperative node device, the transaction allocation device first determines transaction allocation indexes corresponding to at least two node devices. The transaction allocation index corresponding to a node device is used to indicate the matching degree of allocating a new transaction to the node device. It is explained that the higher the matching degree of allocating a new transaction to a node device, the more suitable it is for allocating a new transaction to the node device.
[0042] The transaction allocation index is an index determined from the perspective of the transaction and used to evaluate whether it is appropriate to allocate a new transaction to a node device. In one possible implementation form, the process of determining transaction allocation indexes corresponding to at least two node devices includes the following steps 2011 and 2012.
[0043] Step 2011: Determine a transaction allocation mode, where the transaction allocation mode includes any one of transaction busyness-based allocation, device busyness-based allocation, and hybrid busyness-based allocation.
[0044] The transaction allocation mode is used to indicate a determination manner for determining a transaction allocation index corresponding to a node device. In some embodiments, the transaction allocation mode is set by a developer and uploaded to the transaction allocation device. As should be explained, the transaction allocation modes adopted at different times may be different. Here, what is determined in step 2011 is the transaction allocation mode to be adopted when receiving an allocation request for a target transaction.
[0045] The transaction allocation mode includes any one of allocation based on transaction busyness, allocation based on device busyness, and allocation based on hybrid busyness. Here, the transaction busyness-based allocation mode refers to determining a transaction allocation index from the viewpoint of considering the number of transactions processed by a node device, and the number of transactions processed by a node device can reflect the transaction busyness of the node device. The device busyness-based allocation mode refers to determining a transaction allocation index from the viewpoint of considering the device resource usage rate of a node device, and the device resource usage rate of a node device can reflect the device busyness of the node device. The hybrid busyness-based allocation mode refers to determining a transaction allocation index from the viewpoint of comprehensively considering the number of transactions processed by a node device and the device resource usage rate of a node device, and the number of transactions processed by a node device and the device resource usage rate of a node device can reflect the hybrid busyness of a node device.
[0046] Step 2012: Determine transaction allocation indicators corresponding to each of the at least two node devices according to a determination manner indicated by the transaction allocation mode.
[0047] The determination methods indicated by different transaction allocation modes are different, and after determining the transaction allocation mode, a transaction allocation index corresponding to each of the at least two node devices is determined based on the determination method indicated by the transaction allocation mode. Next, methods for determining a transaction allocation index corresponding to a first node device of the at least two node devices under different transaction allocation modes are respectively introduced, where the first node device is any one of the at least two node devices.
[0048] In some embodiments, the transaction allocation mode is allocation based on the busyness of the transaction, and in this case, the transaction allocation index corresponding to the first node device is determined based on the transaction processing number of the first node device according to the determination method indicated by the transaction allocation mode.
[0049] The transaction processing number of the first node device refers to the number of transactions that the first node device needs to process per unit time. As should be explained, the transactions that need to be processed here refer to transactions that have already been assigned and processed by the first node device. It should be explained that the more transactions the first node device needs to process per unit time, the less suitable it is for the first node device to be assigned new transactions. In an exemplary embodiment, the transaction processing number of the first node device may be fed back to the transaction allocation device by the first node device, or may be determined by the transaction allocation device itself based on the transaction allocation status, but the embodiment of the present application is not limited thereto.
[0050] The embodiment of the present application does not limit the expression format of the transaction allocation indicator, and illustratively, the expression format of the transaction allocation indicator is a busy level or a numerical value.
[0051] For example, when the transaction allocation index is expressed as a busy level, a method for determining a transaction allocation index corresponding to the first node device based on the transaction processing number of the first node device is to set different ranges of the transaction processing number for different busy levels, and use a busy level corresponding to a certain transaction processing range of the transaction processing number of the first node device as the busy level corresponding to the first node device. For example, the busy levels include "busy", "partial busy" and "idle", the range of the transaction processing number corresponding to "busy" is [10, +∞), the range of the transaction processing number corresponding to "partial busy" is [3, 10), and the range of the transaction processing number corresponding to "idle". If the transaction processing number of the first node device is 2, "idle" is used as the transaction allocation index corresponding to the first node device. It is explained that the closer the transaction allocation index corresponding to the first node device is to "idle", the higher the matching degree of allocating new transactions to the first node device.
[0052] Exemplarily, when the transaction allocation index is expressed in a numerical form, a method for determining a transaction allocation index corresponding to the first node device based on the transaction processing number of the first node device is to digitize the transaction processing number of the first node device, and the numerical value obtained after the digitization is used as the transaction allocation index corresponding to the first node device. The method for digitizing the transaction processing number is set based on experience or flexibly adjusted based on an application scenario, but the embodiment of the present application is not limited thereto. Exemplarily, a method for digitizing the transaction processing number is to calculate the product of the transaction processing number and the reference weight. In this method, the larger the transaction processing number is, the larger the numerical value obtained after the digitization is. It is explained that the smaller the transaction allocation index corresponding to the first node device is, the higher the matching degree for allocating new transactions to the first node device is.
[0053] In some embodiments, the transaction allocation mode is device busyness-based allocation, and in this case, the transaction allocation index corresponding to the first node device is determined based on the device resource utilization rate of the first node device according to the determination method indicated by the transaction allocation mode.
[0054] The device resource usage rate of the first node device refers to the ratio of the device resources already used by the first node device to the total device resources, and for example, the device resources refer to CPU (Central Processing Unit) resources. It is explained that the higher the device resource usage rate of the first node device, the less suitable it is for allocating new transactions to the first node device. As is necessary to explain, the device resource usage rate of the first node device may be monitored in real time by the first node device and fed back to the transaction allocation device, or may be monitored and obtained by the transaction allocation device itself, but the embodiment of the present application is not limited thereto.
[0055] The method for determining a transaction allocation index corresponding to the first node device based on the device resource utilization rate of the first node device can be referred to the method for determining a transaction allocation index corresponding to the first node device based on the number of transactions processed by the first node device, and detailed explanation will be omitted here.
[0056] In some embodiments, the transaction allocation mode is a hybrid busyness-based allocation, and in this case, the transaction allocation index corresponding to the first node device is determined based on the determination method instructed by the transaction allocation mode, by determining the transaction allocation index corresponding to the first node device based on the transaction processing count of the first node device, the device resource utilization rate of the first node device, the weight of the transaction processing count, the weight of the device resource utilization rate, and the weight adjustment parameter.
[0057] In an exemplary embodiment, the weight of the transaction processing number and the weight of the device resource utilization rate are used to adjust the percentages of the two parameters, the transaction processing number and the device resource utilization rate, and can be obtained by actual measurement, and for example, the default values of the weight of the transaction processing number and the weight of the device resource utilization rate are both 1. The weight adjustment parameter refers to a relative proportion coefficient between the device resource utilization rate and the transaction processing number, and is used to adjust the weight allocation of the device resource utilization rate and the transaction processing number, and can be obtained by actual measurement, and for example, the default value of the weight adjustment parameter is 0.33.
[0058] For example, if p1 is used to represent the weight of device resource utilization rate, p2 is used to represent the weight of the number of transactions processed, and w is used to represent the weight adjustment parameter, then the transaction allocation index Q corresponding to the first node device may be expressed as Q=p1×device resource utilization rate+p2×w×number of transactions processed.
[0059] In some embodiments, in the hybrid busyness-based allocation mode, in addition to comprehensively considering the number of transactions processed and the device resource utilization rate, other factors, such as the number of long transactions among the transactions that need to be processed, can be considered. In such a case, the transaction allocation index Q corresponding to the first node device may be expressed as Q=p1×device resource utilization rate+p2×w×number of transactions processed+p3×other factors. Here, p3 represents the weight of the other factors, and p3 can be obtained by actual measurement based on the type of the other factors, and exemplarily, the default value of p3 is 1. It will be explained that the smaller the transaction allocation index Q corresponding to the first node device, the higher the matching degree of allocating new transactions to the first node device.
[0060] As needed to explain, the above introduces the process of determining the transaction allocation index corresponding to the first node device only from the perspective of the first node device, and enables the above method to determine the transaction allocation index corresponding to each of at least two node devices in the distributed database system, and further to perform step 202.
[0061] In step 202, the transaction allocation device determines a cooperative node device of the target transaction among the at least two node devices based on the transaction allocation indicators corresponding to each of the at least two node devices, and cooperatively processes the target transaction by the cooperative node devices.
[0062] The coordinating node device of the target transaction refers to a node device among at least two node devices that is suitable for allocating a new transaction. The coordinating node device of the target transaction is used to coordinatingly process the target transaction, i.e., the coordinating node device of the target transaction refers to a coordinator of the target transaction. Exemplarily, the process of coordinatingly processing the target transaction refers to a process of issuing a target transaction in a distributed database system and then organizing data node devices of the target transaction to jointly process the target transaction. The data node device of the target transaction refers to a node device among at least two node devices that is used to participate in the processing of the target transaction, i.e., the data node device of the target transaction refers to a participant of the target transaction.
[0063] As needs to be explained, the cooperative node devices and data node devices mentioned in the embodiments of the present application are both relative to the target transaction, and for different transactions, the cooperative node devices or data node devices are not fixed, i.e., the same node device may belong to a cooperative node device for some transactions, but belong to a data node device for some other transactions.
[0064] The method of determining a cooperative node device of a target transaction among the at least two node devices based on the transaction allocation indicators corresponding to each of the at least two node devices differs based on the difference in the expression format of the transaction allocation indicators, and the embodiments of the present application are not limited thereto, as long as it is possible to ensure that the cooperative node device is a node device that is currently suitable for allocating a new transaction.
[0065] In some embodiments, the transaction allocation indicator is expressed as a busy level, and the busy levels are “busy”, “partially busy”, and “idle”, respectively. In such a case, a method for determining a cooperative node device of a target transaction among at least two node devices based on a transaction allocation indicator corresponding to each of the at least two node devices is to use a node device of which the corresponding transaction allocation indicator is “idle” among the at least two node devices as a candidate node device, and arbitrarily select one node device from the candidate node devices as a cooperative node device of the target transaction.
[0066] Exemplarily, if there is no node device whose corresponding transaction allocation indicator is "idle", then among the at least two node devices, a node device whose corresponding transaction allocation indicator is "partially busy" is used as a candidate node device, and one of the candidate node devices is arbitrarily selected as a cooperative node device for the target transaction. Exemplarily, if the transaction allocation indicators corresponding to the at least two node devices are all "busy", then the determination of the cooperative node device for the target transaction is temporarily stopped, and after waiting for a reference period, the transaction allocation indicators corresponding to each of the at least two node devices are redetermined, and then the cooperative node device for the target transaction is redetermined. The reference period is set based on experience, for example, the reference period is an actually measured average period for completing one transaction.
[0067] In some embodiments, it is described that the transaction allocation index is expressed as a numerical value, and the smaller the transaction allocation index corresponding to one node device, the higher the matching degree of allocating a new transaction to the one node device. In this case, the method of determining the cooperative node device of the target transaction among the at least two node devices based on the transaction allocation index corresponding to each of the at least two node devices is to use the node devices corresponding to the first s (s is an integer equal to or greater than 1) smallest transaction allocation indexes among the at least two node devices as candidate node devices, and arbitrarily select one node device among the candidate node devices as the cooperative node device of the target transaction. The value of s is set based on experience, or flexibly adjusted based on the total number of the at least two node devices, and the embodiment of the present application is not limited thereto, for example, the value of s is 1, or the value of s is 3, etc.
[0068] As is necessary to explain, the above is merely an exemplary description of a method for determining a cooperative node device of a target transaction among at least two node devices based on a transaction allocation index corresponding to each of the at least two node devices, and the embodiment of the present application is not limited thereto. For example, in a case where the transaction allocation index is expressed in a numerical form and the larger the transaction allocation index corresponding to one node device, the higher the matching degree of allocating a new transaction to the one node device is, the node devices corresponding to the first t (t is an integer equal to or greater than 1) larger transaction allocation indexes among the at least two node devices are used as candidate node devices, and one node device is arbitrarily selected from the candidate node devices as a cooperative node device of the target transaction.
[0069] The cooperative node device of the target transaction determined based on the transaction allocation index is a node device among at least two node devices that is suitable for allocating a new transaction, and it is further advantageous to allocate the target transaction to the cooperative node device and have the cooperative node device cooperatively process the target transaction, thereby ensuring the processing efficiency of the target transaction.
[0070] In the related art, each node device serves a certain number of regions, and each node device maintains distribution information of data items in the area served by the node device, and the distribution information of data items is used to indicate the storage location of the data items. In addition, meta information of the areas is maintained in the transaction allocation device. In such an architecture, in the related art, the transaction allocation device determines the node device used to serve the area where the data items related to the target transaction are located based on the maintained area meta information, and then independently processes the target transaction by the node device. This method greatly limits the transaction processing efficiency, cannot support true distributed transactions, and does not have the ability of global consistent multi-read and consistent multi-write with good transaction attribute characteristics.
[0071] In the embodiment of the present application, the node device does not serve a specific fixed area, the node device does not maintain distribution information of data items, and the transaction allocation device does not maintain meta information of the area. Illustratively, the meta information of the area is distributed throughout the shared storage system in the distributed database system. Based on such an improvement, the transaction allocation device can assign an appropriate node device to a target transaction as a cooperative node device based on a transaction allocation index, without needing to consider data items related to the transaction, and without needing to consider the distribution status of the data items. The node device can automatically call data from the shared storage system based on the needs of a Structured Query Language (SQL) statement in the transaction. In this manner, each individual node device can cooperatively process a distributed transaction as a distributed node device, so that the distributed database system has a distributed distributed transaction processing capability.
[0072] In one possible implementation form, after the step of determining the cooperative node device of the target transaction, the method further includes a step of transmitting device identification information of the cooperative node device to the terminal that issued the allocation request, and the terminal transmits transaction information of the target transaction to the cooperative node device based on the device identification information of the cooperative node device, which is used to cooperatively process the target transaction based on the transaction information by the cooperative node device.
[0073] The device identification information of the cooperative node device is used to uniquely identify the cooperative node device, and the device identification information of the cooperative node device is sent to the terminal that issued the allocation request, thereby enabling the terminal to be informed of the cooperative node device used to cooperatively process the target transaction. After the terminal knows the cooperative node device used to cooperatively process the target transaction based on the device identification information, it sends the transaction information of the target transaction to the cooperative node device. The transaction information of the target transaction is used to indicate the processing operation related to the target transaction, and for example, the transaction information of the target transaction refers to an SQL statement.
[0074] In one possible implementation form, the terminal sends transaction information of the target transaction directly to the cooperative node device, or the terminal sends the transaction information of the target transaction and device identification information of the cooperative node device to a gateway server, and the gateway server forwards the transaction information of the target transaction to the cooperative node device.
[0075] After receiving the transaction information of the target transaction, the cooperative node devices cooperatively process the target transaction based on the transaction information, and the cooperative node devices analyze the transaction information, e.g., SQL statements, generate a transaction execution plan, and then communicate with associated data node devices to complete the processing of the target transaction.
[0076] In an exemplary embodiment, the cooperative node devices of the target transaction are determined based on the transaction allocation index, and different transactions can be cooperatively processed using different node devices, so that the method provided by the embodiment of the present application can realize a distributed transaction processing process. In the distributed transaction processing process, multiple distributed transactions are each cooperatively processed by multiple node devices. In the process in which the cooperative node devices of the target transaction cooperatively process the target transaction, if there are multiple distributed transactions, the cooperative node devices establish communication with other node devices to obtain data information generated in the process in which the other node devices cooperatively process other distributed transactions, and further perform data anomaly or serializable authentication based on the obtained data information to determine whether the target transaction meets transaction consistency, and ensure that the transaction processing technology is accurate. In an exemplary embodiment, the cooperative node devices buffer the data information sent from the other node devices in a temporary data buffer area, and clean up after the target transaction is completed.
[0077] In one possible implementation form, for a terminal that issues an allocation request for a target transaction, after the terminal accesses the distributed database system, when other transactions occur, each of the other transactions is coordinated and processed by the cooperative node device, or each of the other transactions is coordinated and processed by a suitable cooperative node device that is assigned in real time by the transaction allocation device based on the transaction allocation index of the node device, but the embodiments of the present application are not limited to this.
[0078] In step 203, the cooperative node device obtains transaction information of the target transaction.
[0079] The transaction information of the target transaction may be directly sent to the cooperative node device by the creator of the target transaction, or may be forwarded to the cooperative node device by the gateway server, but the embodiment of the present application is not limited thereto. Illustratively, the transaction information of the target transaction refers to an SQL statement used to realize the target transaction.
[0080] In one possible implementation, after the cooperative node device obtains the transaction information of the target transaction, it initializes the target transaction. The phase of initializing the target transaction may be regarded as a snapshot phase of establishing the transaction. This phase establishes a global consistency snapshot point, making it possible to guarantee global read consistency.
[0081] In one possible implementation, in the process of initializing a target transaction, a cooperative node device can perform at least one of the following two initialization operations.
[0082] Initialization operation 1: A cooperative node device assigns one globally unique transaction identifier TID to the target transaction.
[0083] The transaction identifier TID is used to uniquely identify the target transaction.
[0084] Initialization operation 2: The cooperative node device records the initial status information of the target transaction in the first transaction status list.
[0085] In an embodiment of the present application, the transaction status list maintained by the cooperative node device is referred to as a first transaction status list, and the first transaction status list is a global status list used to record the global status of the target transaction under the distributed framework.
[0086] In an exemplary embodiment, the status information of the target transaction recorded in the first transaction status list includes, but is not limited to, a transaction identifier of the target transaction, a global transaction status of the target transaction, and a logical lifecycle of the target transaction, where the logical lifecycle is composed of a timestamp lower limit and a timestamp upper limit. The timestamp lower limit of the logical lifecycle is called the beginning timestamp (Begintimestamp, Bts) of the target transaction, and the timestamp upper limit of the logical lifecycle is called the end timestamp (Endtimestamp, Ets) of the target transaction, i.e., the logical lifecycle is composed of a timestamp lower limit Bts and a timestamp upper limit Ets.
[0087] In the initial status information of the target transaction, the transaction identifier TID of the target transaction is assigned in initialization operation 1, the global transaction status Status of the target transaction is Grunning (running globally), the logical lifecycle of the target transaction is a first logical lifecycle, the timestamp lower limit Bts of the first logical lifecycle is a globally uniquely increasing timestamp value, and the timestamp upper limit Ets of the first logical lifecycle is +∞.
[0088] In an exemplary embodiment, the timestamp lower limit Bts and the timestamp upper limit Ets of the first logical life cycle are obtained in such a manner that for isolation levels above the serializable level, the cooperative node device obtains the timestamp value from a global clock, and for the serializable level and weaker isolation levels, the cooperative node device obtains the timestamp value from a local Hybrid Logical Clock (HLC). Of course, in some embodiments, for the serializable level and weaker isolation levels, the cooperative node device can also obtain the timestamp lower limit Bts and the timestamp upper limit Ets of the first logical life cycle by obtaining the timestamp value from a global clock. In an exemplary embodiment, for the serializable level and weaker isolation levels, the efficiency of obtaining the timestamp value from a local HLC is relatively high.
[0089] The global clock refers to a clock generated by a global logical clock generator, has a monotonically increasing characteristic, and may be formally a walltime or a natural number N. Exemplarily, the global clock is provided by a global timestamp generation cluster in a distributed database system. Exemplarily, for a distributed database system based on a share-disk architecture, the global clock is provided by a storage system in the distributed database system through an API method. Exemplarily, the global logical clock generator allows values to be assigned to a transaction start timestamp Bts and a transaction end timestamp Ets, and further allows values to be assigned to a global LSN (Log Sequence Number) of WAL (Write Ahead Logging).
[0090] In some embodiments, the global clock is a logical concept that provides a uniform monotonically increasing value for the entire system, and the physical form may be a global physical clock or a global logical clock. The implementation of the global clock may have multiple methods. For example, the global clock is a distributed clock similar to Google's "Truetime" mechanism, or the global clock is a clock provided uniformly by a master-standby system using multiple redundant nodes (e.g., a cluster constructed with a consistency protocol (such as Paxos / Raft)), or the global clock is a clock provided by a kind of algorithmic mechanism that combines a precise synchronization mechanism and a node logout mechanism.
[0091] In an exemplary embodiment, both the Bts and Ets of one transaction consist of 8 bytes. The 8 bytes are divided into two parts. The first part is the value of the physical timestamp (i.e., Unix (a type of operating system) timestamp, accurate to milliseconds), which is used to identify the global time (represented by gts). The second part is a monotonically increasing count within a millisecond, which is used to identify the relative time on the global time (i.e., local time, represented by lts). Exemplarily, the upper 44 bits in the 8 bytes are the first part, and thus a total of 2 44 unsigned integers can be represented. Therefore, theoretically, a physical timestamp of approximately 557.8 ([Equation 1]) years can be represented in total. The lower 20 bits in the 8 bytes are the second part, and thus there are 2 20 counts (about 1 million) per millisecond. In an exemplary embodiment, by adjusting the number of bits in the two parts, the ranges represented by the global time gts and the local time lts can also be changed.
[0092]
Equation
[0093] As needs to be explained, based on actual needs, the Bts and Ets of one transaction may consist of more bytes or fewer bytes than 8 bytes. Exemplarily, by adjusting the Bts and Ets to consist of 10 bytes, the local time lts can be increased to handle a larger number of parallel transactions.
[0094] Exemplarily, for two timestamps Ti.bts and Tj.bts composed of two parts of the global time gts and the local time lts, when Ti.bts.gts < Tj.bts.gts, or Ti.bts.gts = Tj.bts.gts and Ti.bts.lts < Tj.bts.lts, Ti.bts is considered to be less than Tj.bts.
[0095] In step 204, the cooperative node device sends a data read request to a data node device based on transaction information of the target transaction, where the data node device is one of the at least two node devices that is used to participate in processing the target transaction.
[0096] After a cooperative node device initializes a target transaction, it starts the execution phase of the target transaction, which may be regarded as the transaction semantics realization operation phase.
[0097] The data node device is a node device among at least two node devices that is used to participate in the processing of the target transaction, and the data node device enables obtaining data items related to the target transaction, i.e., the data node device in the embodiment of the present application is a data node device related to the target transaction. Carrying the relevant information of the data that needs to be read in the transaction information of the target transaction, the cooperative node device enables generating a data read request based on the transaction information of the target transaction, and then sending the data read request to the data node device.
[0098] In one possible implementation, a data read request is represented as a ReadRequestMessage, abbreviated as rrqm.
[0099] In one possible implementation, the data read request carries a first logical life cycle of the target transaction, a transaction identifier of the target transaction, and a read plan. The first logical life cycle is represented using a timestamp lower bound Bts and a timestamp upper bound Ets. The read plan refers to a data read plan corresponding to the target transaction, and is used to indicate the data items that need to be read. In an exemplary embodiment, the transaction identifier, the timestamp lower bound Bts, the timestamp upper bound Ets, and the read plan are recorded in four fields of rrqm, respectively.
[0100] As should be explained, the number of data node devices may be one or more, and the embodiment of the present application does not specifically limit the number of data node devices. When the number of data node devices is more than one, the data read requests sent to different data node devices may carry different read plans, indicating that different data items need to be read at different data node devices.
[0101] In step 205, the data node device acquires a data read result based on the data read request transmitted from the cooperative node device, and returns the data read result to the cooperative node device.
[0102] After the data node device obtains the data read request, the data node device obtains a data read result according to the data read request. In one possible implementation form, when the data read request carries a first logical life cycle of a target transaction, the process of the data node device obtaining a data read result according to the data read request includes the following steps 2051 to 2053.
[0103] Step 2051: Based on the first logical life cycle, determine the visible version data of the data item to be read indicated by the data read request.
[0104] The data node device determines the data items that the target transaction needs to read based on the read plan carried by the data read request, and enables the target transaction to use the data items that the target transaction needs to read as the data items to be read. The visible version data of the data items to be read refers to a certain version data that is visible to the target transaction among each version data corresponding to the data items to be read. For example, when a data buffer area is set in the data node device and each version data of the data items to be read exists in the data buffer area, the data node device directly obtains each version data of the data items to be read from the data buffer area, and when each version data of the data items to be read does not exist in the data buffer area, the data node device obtains each version data of the data items to be read from the shared storage system.
[0105] In an exemplary embodiment, after receiving a data read request, the data node device first checks whether the status information of the target transaction is included in a local transaction status list (Local TS). The local transaction status list is a transaction status list maintained by the data node device, and the status information of each uncommitted transaction involved in the data node device is recorded in the local transaction status list. In an exemplary embodiment, after receiving a data read request, the data node device checks whether the status information of the target transaction is included in the local transaction status list based on the transaction identifier of the target transaction carried in the data read request, and the check result includes the following two types:
[0106] Check result 1: The local transaction status list does not contain the status information of the target transaction.
[0107] In such a case, the status information of the target transaction can be initialized in the local transaction status list, i.e., one record related to the target transaction is inserted in Local TS, and the values in the record are the transaction identifier rrqm.TID of the target transaction carried by the data read request, the lower timestamp limit rrqm.Bts of the first logical lifecycle of the target transaction carried by the data read request, the upper timestamp limit rrqm.Ets of the first logical lifecycle of the target transaction carried by the data read request, and the current transaction status rrqm.Running of the target transaction indicated by the data read request.
[0108] In such a case, a method for determining the visible version data of the data item to be read indicated by the data read request based on the first logical lifecycle is to determine the visible version data for the first logical lifecycle of the data item to be read.
[0109] Check result 2: The local transaction status list contains the status information of the target transaction.
[0110] In this case, it is explained that the target transaction has already accessed the data node device before receiving the data read request. At this time, the status information of the target transaction on the data node device can be updated, and the updating method is to update the timestamp lower limit T.Bts of the logical life cycle of the target transaction to the maximum value of the queried timestamp lower limit T.Bts and the timestamp lower limit rrqm.Bts carried in the data read request (i.e., the timestamp lower limit of the first logical life cycle), i.e., T.Bts=max(T.Bts,rrqm.Bts). In addition, the timestamp upper limit T.Ets of the logical life cycle of the target transaction is updated to the minimum value of the queried timestamp upper limit T.Ets and the timestamp upper limit rrqm.Ets carried in the data read request (i.e., the timestamp upper limit of the first logical life cycle), i.e., T.Ets=min(T.Ets,rrqm.Ets). The logical life cycle composed of the updated timestamp lower limit and the updated timestamp upper limit is used as the updated logical life cycle.
[0111] In such a case, a method for determining visible version data of a data item to be read indicated by a data read request based on a first logical lifecycle includes determining an updated logical lifecycle based on the first logical lifecycle, and determining visible version data for the updated logical lifecycle of the data item to be read.
[0112] As should be explained, the implementation of determining visible version data for a first logical lifecycle of a data item being read is similar to the implementation of determining visible version data for an updated logical lifecycle of a data item being read, and in the embodiments of the present application, determining visible version data for a first logical lifecycle of a data item being read is described as an example.
[0113] In one possible implementation, before determining the visible version data for the first logical lifecycle of the data item to be read, a validity check is first performed on the first logical lifecycle to determine whether the first logical lifecycle is valid. Exemplarily, a manner of performing a validity check on the first logical lifecycle is to check whether the timestamp lower limit of the first logical lifecycle is smaller than the timestamp upper limit of the first logical lifecycle. If the timestamp lower limit of the first logical lifecycle is equal to or greater than the timestamp upper limit of the first logical lifecycle, it is explained that the first logical lifecycle is invalid, and at this time, the transaction status of the target transaction in the local transaction status list is updated from Running to Aborted. In addition, the data node device returns the data read result carrying an Abort message to the cooperative node device. The data read result is represented as a ReadReplyMessage, abbreviated as rrpm. If the data read result carries an Abort message, the IsAbort field in the rrpm message is equal to 1, that is, rrpm.IsAbort=1.
[0114] If the timestamp lower limit of the first logical lifecycle is less than the timestamp upper limit of the first logical lifecycle, then the first logical lifecycle is described as being valid, and then an operation is performed to determine visible version data for the first logical lifecycle of the data item being read.
[0115] In one possible implementation, the process of determining visible version data for the first logical lifecycle of the data item being read includes, in response to a creation timestamp of the latest version data of the data item being read being smaller than the timestamp upper limit of the first logical lifecycle, using the latest version data as the visible version data, and in response to a creation timestamp of the latest version data of the data item being read being greater than or equal to the timestamp upper limit of the first logical lifecycle, continually comparing previous version data of the data item being read with the timestamp upper limit of the first logical lifecycle until a version data whose initial creation timestamp is smaller than the timestamp upper limit of the first logical lifecycle is determined and using the version data as the visible version data.
[0116] That is, in the process of determining the visible version data for a certain logical life cycle of the data item x to be read, the data node device starts checking from the latest version data of the data item x to be read, and if the timestamp upper limit T.Ets of the logical life cycle is greater than the creation timestamp Wts of the latest version data, the latest version data is the visible version data for the logical life cycle. If not, the latest version data is not the visible version data for the logical life cycle, and it needs to search previous version data until it finds the first version data xv that satisfies T.Ets>Wts, and uses the version data xv as the visible version data for the logical life cycle.
[0117] In one possible implementation, after determining the visible version data, store the visible version data xv in the read set of the target transaction. Optionally, the read set here can be a local read set or a global read set. In the embodiment of the present application, the read set is described as a local read set as an example, which can avoid communication overhead caused by synchronization of the global read set.
[0118] In an exemplary embodiment, the read set of a transaction records the visible version data of the data item that the transaction needs to read. As should be explained, for a distributed read transaction, the read set of the distributed read transaction may be divided into a local read set and a global read set, where the local read set exists on the data node device and the global read set exists on the cooperative node device. Of course, the cooperative node device can periodically synchronize the global read set on each data node device, thereby allowing the data node device to maintain the global read set of the transaction.
[0119] Step 2052: Determine a second logical lifecycle of the target transaction based on the creation timestamp of the visible version data and the first logical lifecycle.
[0120] After determining the visible version data, the data node device determines a second logical lifecycle of the target transaction based on the creation timestamp of the visible version data and the first logical lifecycle.
[0121] In some embodiments, when the visible version data refers to the visible version data for the first logical lifecycle, the implementation of step 2052 is to determine the second logical lifecycle of the target transaction directly based on the creation timestamp of the visible version data and the first logical lifecycle. When the visible version data refers to the visible version data for the updated logical lifecycle determined based on the first logical lifecycle, the implementation of step 2052 is to determine the second logical lifecycle of the target transaction based on the creation timestamp of the visible version data and the updated logical lifecycle determined based on the first logical lifecycle. The embodiments of the present application will be described taking as an example the determination of the second logical lifecycle of the target transaction directly based on the creation timestamp of the visible version data and the first logical lifecycle.
[0122] In one possible implementation, a method for determining the second logical lifecycle of the target transaction directly based on the creation timestamp of the visible version data and the first logical lifecycle is to adjust the lower limit of the timestamp of the first logical lifecycle so that the lower limit of the timestamp of the first logical lifecycle is greater than the creation timestamp of the visible version data xv, i.e., T.Bts>xvWts, to eliminate read and write anomalies, and use the logical lifecycle obtained after the adjustment as the second logical lifecycle.
[0123] In another possible implementation, when the visible version data is the latest version data of the data item to be read, for the method of determining the second logical life cycle of the target transaction based on the creation timestamp of the visible version data and the first logical life cycle, the lower limit of the timestamp of the first logical life cycle is adjusted, and the lower limit of the timestamp of the first logical life cycle is made larger than the creation timestamp of the visible version data x.v, that is, T.Bts > x.v.Wts, to remove read-write anomalies. In response to the fact that the transaction to be written corresponding to the visible version data is not null, the upper limit of the timestamp of the first logical life cycle is adjusted, and the upper limit of the timestamp of the first logical life cycle is made smaller than the lower limit of the timestamp of the logical life cycle of the transaction to be written corresponding to the visible version data, that is, T.Ets < T0.Bts (T0 represents the transaction to be written corresponding to the visible version data), to remove read-write conflicts. The logical life cycle obtained after adjustment is used as the second logical life cycle.
[0124] The transaction WT to be written corresponding to the visible version data modifies the data item corresponding to the visible version data and is a transaction that has passed authentication. Exemplarily, the transaction to be written is recorded by recording the transaction identifier of the transaction to be written. In some embodiments, when the visible version data is the latest version data, the transaction identifier of the target transaction is added to the active transaction set of the visible version data, and the visible version data is added to the local read set of the target transaction.
[0125] The active transaction set (RTlist) is used to record the active transactions that have accessed the latest version data, and may be referred to as a read transaction list. The active transaction set may be in the form of an array, or in the form of a list, queue, stack, etc., and the embodiments of the present application do not specifically limit the form of the active transaction set. Each element in the RTlist may be a transaction identifier (TID) of the transaction that has read the latest version data.
[0126] Step 2053: The second logical life cycle and the result carrying the visible version data are used as the data reading result.
[0127] After determining the second logical life cycle and the visible version data, the data node device uses the result carrying the second logical life cycle and the visible version data as a data read result, and then returns the data read result carrying the second logical life cycle and the visible version data to the collaborative node device, allowing the collaborative node device to obtain the second logical life cycle and the visible version data. Exemplarily, the data read result is represented as a ReadReplyMessage (read feedback message), and is abbreviated as rrpm. Exemplarily, the rrpm carrying the second logical life cycle and the visible version data includes Bts, Ets, and Value fields, where the Bts field and the Ets field respectively record the timestamp lower limit of the second logical life cycle and the timestamp upper limit of the second logical life cycle, and the Value field records the value of the visible version data.
[0128] In step 206, in response to the data read result returned from the data node device satisfying the transaction authentication condition, the cooperative node device transmits a transaction authentication request and a local write set to the data node device.
[0129] After the data node device returns the data read result to the cooperative node device, the cooperative node device determines whether the data read result satisfies the transaction authentication condition, and then, if it determines that the data read result satisfies the transaction authentication condition, it sends a transaction authentication request and a local write set to the data node device, causing the data node device to authenticate the target transaction.
[0130] For example, in the process of determining whether the data read result satisfies the transaction authentication condition, the cooperative node device first determines whether the data read result carries an Abort message, i.e., checks whether the IsAbort field in rrpm is equal to 1. If the data read result carries an Abort message, i.e., rrpm.IsAbort=1, it is determined that the data read result does not satisfy the transaction authentication condition, and at this time, it enters a global abort phase.
[0131] If the data read result does not carry an Abort message, update the logical life cycle of the target transaction in the first transaction status list, and the update method is to use the maximum value of the timestamp lower limit of the first logical life cycle and the timestamp lower limit of the second logical life cycle as the timestamp lower limit of the third logical life cycle of the target transaction, and the minimum value of the timestamp upper limit of the first logical life cycle and the timestamp upper limit of the second logical life cycle as the timestamp upper limit of the third logical life cycle of the target transaction. That is, T.Bts=max(T.Bts,rrpm.Bts) and T.Ets=min(T.Ets,rrpm.Ets), where T.Bts and T.Ets in parentheses are the timestamp lower limit and timestamp upper limit of the logical life cycle before the update (i.e., the first logical life cycle), respectively, and rrpm.Bts and rrpm.Ets are the timestamp lower limit and timestamp upper limit of the second logical life cycle carried by the data read result, respectively.
[0132] After updating the logical life cycle of the target transaction in the first transaction status list, check whether T.Bts in the first transaction status list is smaller than T.Ets, i.e., check whether the timestamp lower limit of the third logical life cycle is smaller than the timestamp upper limit of the third logical life cycle, to determine whether the third logical life cycle is valid. If the timestamp lower limit of the third logical life cycle is equal to or greater than the timestamp upper limit of the third logical life cycle, the third logical life cycle is invalid, in this case, the data read result is deemed not to satisfy the transaction authentication condition, and enter a global abort phase; if the timestamp lower limit of the third logical life cycle is smaller than the timestamp upper limit of the third logical life cycle, the third logical life cycle is valid, in this case, the data read result is deemed to satisfy the transaction authentication condition, and send a transaction authentication request carrying the third logical life cycle to the data node device.
[0133] In an exemplary embodiment, if a cooperative node device decides to abort the target transaction, it needs to modify the global transaction status of the target transaction in the first transaction status list to Gaborting (globally aborting) and notify relevant subnodes (i.e., data node devices) to perform local aborts.
[0134] In an exemplary embodiment, before sending the transaction validation request, the cooperative node device modifies the global transaction status of the target transaction in the first transaction status list to Gvalidating. Illustratively, the transaction validation request is represented as a ValidateRequestMessage, abbreviated as vrm. Illustratively, vrm includes Bts and Ets fields, where the Bts and Ets fields respectively record the timestamp lower limit and timestamp upper limit of the latest logical lifecycle in the first transaction status list of the target transaction, i.e., the timestamp lower limit and timestamp upper limit of the third logical lifecycle.
[0135] In some embodiments, the number of data node devices is multiple, and in such a case, each data node device returns one data read result, and the data read result satisfying the transaction authentication condition means that each data read result returned from each data node device satisfies the transaction authentication condition. In such a case, the third logical lifecycle is a logical lifecycle determined by comprehensively considering each data read result.
[0136] In some embodiments, after reading all the required data and writing the updates in the local internal memory, the transaction authentication condition is deemed to be satisfied. That is, the cooperative node device responds that the third logical life cycle is valid, and stores the global write set of the target transaction in the local internal memory, and sends a transaction authentication request to the data node device. The global write set of the target transaction is generated by the terminal and transmitted to the cooperative node device, or is generated by the cooperative node device itself, and the embodiments of the present application are not limited thereto.
[0137] In the write set of a transaction, data items that the transaction needs to update are stored, which is similar to the read set structure, and an internal memory chain table structure can be used to maintain the write set of the transaction as well. As should be explained, for a distributed write transaction, the write set of the distributed write transaction may be divided into a local write set and a global write set, where the local write set exists on the data node device, and the global write set exists on the cooperative node device. Of course, the cooperative node device can periodically synchronize the global write set on each data node device, thereby enabling the global write set of the transaction to be maintained on the data node device as well.
[0138] After writing the global write set of the target transaction to the local internal memory of the cooperative node device, the cooperative node device determines a local write set of the data node device based on the global write set, and sends a transaction authentication request together with the local write set to the data node device. The local write set of the data node device refers to the write set of the global write set of the target transaction that needs to be written by the data node device.
[0139] In the read phase of the target transaction, the communication mainly occurs between the cooperative node equipment and the associated data node equipment, and each successful data read requires two communications, where the cooperative node equipment sends a data read request on the associated data node equipment, and the associated data node equipment returns the data read result to the cooperative node equipment. Thus, in the data read phase, assuming that n (n is an integer greater than 1) is the number of remote reads, a maximum of 2n communications need to be made, and the maximum communication amount may be expressed as n×(size of data read request message+size of data read result message). In an exemplary implementation, when the target transaction needs to read data of multiple data items of an associated data node equipment, the data read request for the data of multiple data items is packaged and sent, and these data are read in a batch, saving the number of communications and improving the data read efficiency.
[0140] In step 207, the data node device obtains an authentication result of the target transaction based on the transaction authentication request sent from the cooperative node device and the local write set, and returns the authentication result of the target transaction to the cooperative node device.
[0141] After receiving the transaction authentication request and the local write set sent from the cooperative node device, the data node device authenticates the validity of the target transaction and obtains the authentication result of the target transaction. This is a transaction validity authentication stage before committing the transaction.
[0142] The authentication process of the data node device is a local authentication process, and the process in which the data node device obtains the authentication result of the target transaction based on the transaction authentication request and the local write set is a process in which the data node device performs a local authentication operation. In one possible implementation form, the transaction authentication request carries a third logical lifecycle, and the third logical lifecycle is an effective logical lifecycle determined by the collaborative node device based on the first logical lifecycle and the second logical lifecycle. The third logical lifecycle is the latest logical lifecycle of the target transaction maintained by the collaborative node device before sending the transaction authentication request.
[0143] In one possible implementation, in the process of the data node device obtaining the authentication result of the target transaction based on the transaction authentication request and the local write set, the data node device first updates the status information of the target transaction T in the local transaction status list, in the updating manner: T.Bts=max(T.Bts,vrm.Bts), T.Ets=min(T.Ets,vrm.Ets), where vrm.Bts and vrm.Ets in the parentheses are respectively the timestamp lower limit and timestamp upper limit of the third logical lifecycle carried by the transaction authentication request. In the embodiment of the present application, before receiving the transaction authentication request, the logical lifecycle of the target transaction maintained in the local transaction status list of the data node device is the second logical lifecycle, and for ease of distinction, after receiving the transaction authentication request and updating the status information of the target transaction, the logical lifecycle of the target transaction maintained in the local transaction status list is called the fourth logical lifecycle.
[0144] That is, the data node device uses the maximum of the timestamp lower limit of the third logical lifecycle and the timestamp lower limit of the second logical lifecycle as the lower limit of the fourth logical lifecycle of the target transaction, and uses the minimum of the timestamp upper limit of the third logical lifecycle and the timestamp upper limit of the second logical lifecycle as the timestamp upper limit of the fourth logical lifecycle of the target transaction, thereby obtaining a fourth logical lifecycle.As should be explained, what is updated here is the logical lifecycle of the target transaction maintained in the data node device's local transaction status list, and such updates can be used for transaction parallel access control, i.e. to ensure transaction consistency.
[0145] In an exemplary embodiment, for the serializable isolation level, after determining the fourth logical lifecycle, verify whether the fourth logical lifecycle is valid by checking whether the timestamp lower limit of the fourth logical lifecycle is less than the timestamp upper limit of the fourth logical lifecycle.
[0146] In response to the timestamp lower limit of the fourth logical lifecycle being equal to or greater than the timestamp upper limit of the fourth logical lifecycle, the fourth logical lifecycle is described as being invalid, in which case the local authentication of the target transaction does not pass, and the data node device returns an authentication result carrying an Abort message to the cooperative node device. The Abort message is used to initiate a global abort. The process of returning the authentication result of the target transaction to the cooperative node device may be regarded as a process of sending a local authentication feedback message lvm to the cooperative node device, and when the authentication result of the target transaction is an authentication result carrying an Abort message, the IsAbort field in the local authentication feedback message lvm is equal to 1, i.e., lvm.IsAbort=1.
[0147] In response to the timestamp lower limit of the fourth logical lifecycle being smaller than the timestamp upper limit of the fourth logical lifecycle, the fourth logical lifecycle is explained as being valid, and in such a case, a fifth logical lifecycle of the target transaction is determined based on the read transaction related information and the fourth logical lifecycle of each write target data item corresponding to the local write set, where the fifth logical lifecycle refers to a logical lifecycle obtained by updating in the process of performing read / write conflict authentication for each write target data item in the local write set.
[0148] In one possible implementation, the read transaction related information of a written data item includes at least one of a maximum read transaction timestamp of the written data item and an end timestamp of a target read transaction of the written data item, where the maximum read transaction timestamp of the written data item (denoted as Rts) is used to indicate the maximum value in the logical commit timestamps of the read transactions that read the written data item, the target read transaction of the written data item is a read transaction that has passed local authentication or is in the commit phase corresponding to the written data item, and the end timestamp of the target read transaction is the timestamp upper limit of the logical life cycle of the target read transaction.
[0149] In an exemplary embodiment, a target read transaction of a data item to be written is a read transaction that has passed local authentication or is in the commit phase in the set of active transactions corresponding to the data item to be written. The target read transaction of the data item to be written can be determined by detecting the transaction status of each read transaction in the set of active transactions corresponding to the data item to be written.
[0150] In one possible implementation form, when the three types of read transaction-related information of one write target data item are different, the process of determining the fifth logical lifecycle of the target transaction based on the read transaction-related information and the fourth logical lifecycle of each write target data item corresponding to the local write set is also different.
[0151] Case 1: The read transaction related information of one written data item includes the maximum read transaction timestamp of the one written data item.
[0152] In such a case 1, the process of determining the fifth logical lifecycle of the target transaction based on the read transaction related information and the fourth logical lifecycle of each write target data item corresponding to the local write set includes determining the fifth logical lifecycle of the target transaction based on the maximum read transaction timestamp and the fourth logical lifecycle of each write target data item, wherein the lower limit of the timestamp of the fifth logical lifecycle is greater than the maximum value of the maximum read transaction timestamp of each write target data item.
[0153] The fourth logical lifecycle is the latest logical lifecycle of the target transaction maintained in the local transaction status list of the data node device before determining the fifth logical lifecycle. In one possible implementation, a method for determining the fifth logical lifecycle of the target transaction based on the maximum read transaction timestamp of each data item to be written and the fourth logical lifecycle includes adjusting a timestamp lower limit of the fourth logical lifecycle based on the maximum read transaction timestamp of each data item to be written, and using the logical lifecycle obtained after the adjustment as the fifth logical lifecycle.
[0154] For example, a method for adjusting the timestamp lower limit of the fourth logical lifecycle based on the maximum read transaction timestamp of each data item to be written is as follows: the adjusted timestamp lower limit T.Bts=max(T.Bts, y.Rts+1), where T.Bts in parentheses represents the timestamp lower limit of the fourth logical lifecycle, y.Rts represents the maximum value in the maximum read transaction timestamp of each data item to be written, and the number 1 is used to ensure that the obtained timestamp lower limit of the fifth logical lifecycle is greater than the maximum value in the maximum read transaction timestamp of each data item to be written.
[0155] In some embodiments, after receiving the local write set, the data node device first detects whether the write transaction WT of each write target data item corresponding to the local write set is null. If the write transaction WT of a certain write target data item is not null, it is explained that another transaction has modified the write target data item and the transaction has already entered the authentication phase. At this time, it is necessary to abort the target transaction to remove the write conflict, that is, to return the authentication result carrying the Abort message to the cooperative node device. If the write transaction WT of each write target data item is null, the transaction identifier value of the target transaction is assigned to the write transaction WT of each write target data item, which indicates that the target transaction that has entered the authentication phase needs to modify each write target data item. In the implementation, a non-locking CAS (Compare and Swap) technique is used to assign a value to the write transaction WT of the write target data item y to improve performance, or the write transaction WT of the write target data item y is first locked to prevent other concurrent transactions from concurrently modifying y, and then the locked write transaction WT is assigned a value. Illustratively, an advisory lock is applied on the write target data item y, which is used to indicate mutual exclusion of modification operations on the write target data item y for the write target transaction WT.
[0156] Case 2: The read transaction related information of one written data item includes the end timestamp of the target read transaction of the one written data item.
[0157] In such case 2, the process of determining the fifth logical lifecycle of the target transaction based on the read transaction related information and the fourth logical lifecycle of each write target data item corresponding to the local write set includes determining the fifth logical lifecycle of the target transaction based on the end timestamp of the target read transaction of each write target data item and the fourth logical lifecycle, wherein the lower limit of the timestamp of the fifth logical lifecycle is greater than the maximum value of the end timestamp of the target read transaction of each write target data item.
[0158] In one possible implementation, the manner of determining the fifth logical life cycle of the target transaction based on the end timestamp of the target read transaction of each write target data item and the fourth logical life cycle is to adjust the timestamp lower limit of the fourth logical life cycle based on the end timestamp of the target read transaction of each write target data item, and use the adjusted logical life cycle as the fifth logical life cycle. Illustratively, the manner of adjusting the timestamp lower limit of the fourth logical life cycle based on the end timestamp of the target read transaction of each write target data item is to adjust the adjusted timestamp lower limit T.Bts=max(T.Bts,T1.Ets+1), where T.Bts in the brackets represents the timestamp lower limit of the fourth logical life cycle, T1.Ets represents the maximum value of the end timestamp of the target read transaction of each write target data item, and the number 1 is used to ensure that the timestamp lower limit of the obtained fifth logical life cycle is greater than the maximum value of the end timestamp of the target read transaction of each write target data item.
[0159] As should be explained, the number of target read transactions for one write target data item may be one or more, and when the number of target read transactions for one write target data item is more than one, the above T1.Ets refers to the maximum value of the end timestamps of all target read transactions for all write target data items.
[0160] Based on this scheme, the write operation of the target transaction can be delayed until after the read operation of the target read transaction, thereby making it possible to avoid read / write conflicts.
[0161] Case 3: The read transaction related information of a single written data item includes the maximum read transaction timestamp of the single written data item and the end timestamp of the target read transaction of the single written data item.
[0162] In this case 3, the process of determining the fifth logical life cycle of the target transaction based on the read transaction related information and the fourth logical life cycle of each write target data item corresponding to the local write set includes adjusting the fourth logical life cycle twice consecutively based on the maximum read transaction timestamp of each write target data item and the end timestamp of the target read transaction of each write target data item, and using the logical life cycle obtained after the two adjustments as the fifth logical life cycle of the target transaction. The embodiment of the present application does not limit the order of the two adjustments, and for example, first adjust the fourth logical life cycle based on the maximum read transaction timestamp of each write target data item, and then adjust the logical life cycle obtained after one adjustment based on the end timestamp of the target read transaction of each write target data item. Of course, in some embodiments, it is also possible to first adjust the fourth logical life cycle based on the end timestamp of the target read transaction of each write target data item, and then adjust the logical life cycle obtained after one adjustment based on the maximum read transaction timestamp of each write target data item.
[0163] For example, in the case where the logical life cycle obtained after two adjustments is used as the fifth logical life cycle, after obtaining the logical life cycle after one adjustment, if the isolation level is serializable, first authenticate whether the timestamp lower limit of the obtained logical life cycle is smaller than the timestamp upper limit, and if yes, continue with the next adjustment, and if no, directly regard the local authentication as having failed, and return the authentication result carrying an Abort message to the cooperative node device.
[0164] After obtaining the fifth logical life cycle, it is determined whether the fifth logical life cycle is valid by verifying whether the timestamp lower limit of the fifth logical life cycle is smaller than the timestamp upper limit of the fifth logical life cycle. In response to the fifth logical life cycle being valid, the authentication result used to indicate that the authentication has been passed is used as the authentication result of the target transaction, and in response to the fifth logical life cycle being invalid, the authentication result used to indicate that the authentication has not been passed is used as the authentication result of the target transaction. In the case where the authentication result used to indicate that the authentication has been passed is used as the authentication result of the target transaction, the timestamp lower limit Bts and the timestamp upper limit Ets of the latest logical life cycle (i.e., the fifth logical life cycle) obtained on the data node device of the target transaction are recorded in the local authentication feedback message lvm of the data node device. Exemplarily, the authentication result used to indicate that the authentication has not been passed is an authentication result carrying an Abort message.
[0165] In an exemplary embodiment, if it is determined that the fifth logical life cycle is valid, it is deemed that the local authentication of the target transaction is passed, and the data node device updates the status information of the target transaction in the local transaction status list, and updates the transaction status of the target transaction to Validated (passes authentication), i.e., T.Status=Validated. In an exemplary embodiment, after determining that the local authentication of the target transaction is passed, the data node device creates new version data of the data item to be written based on the updated value of the data item to be written. In an exemplary embodiment, the created new version data is set with a first mark, which is used to indicate that the new version data has not been globally committed. The new version data with the first mark is invisible to the outside.
[0166] As should be explained, if the target transaction does not pass local authentication in the data node device, the transaction status of the target transaction in the data node device's local transaction status list should be updated to Aborted, i.e., T.Status=Aborted.
[0167] In one possible implementation, in addition to including a target read transaction in the active transaction set of a data item to be written, it is necessary to further include a running read transaction, and adjust the logical life cycle of the running read transaction according to the fifth logical life cycle of the target transaction, so that the running read transaction cannot read the data newly written by the target transaction, thereby avoiding the read / write conflict phenomenon and ensuring that the transaction is executed correctly. Illustratively, the running read transaction refers to a transaction whose transaction status in the active transaction set is Running. The manner of adjusting the logical life cycle of the running read transaction is to make the upper timestamp limit of the logical life cycle of the running read transaction smaller than the lower timestamp limit of the fifth logical life cycle of the target transaction. Suppose the running read transaction is T2, the update manner is T2.Ets=min(T2.Ets,T.Bts-1). If the lower timestamp limit of the updated logical life cycle of a certain running read transaction is equal to or greater than the upper timestamp limit, the running read transaction is notified to be aborted.
[0168] As can be seen from the above transaction authentication phase, in the authentication process of the target transaction, communication mainly occurs between the cooperative node devices and the associated data node devices, and the communication mainly includes a step of the cooperative node device sending a transaction authentication request and a local write set to each associated data node device, and a step of the associated data node device feeding back the authentication result to the cooperative node device. Therefore, in the authentication phase of the target transaction, assuming that m (m is an integer equal to or greater than 1) is the number of data node devices associated with the target transaction T, a maximum of 2m communications need to be performed, and the maximum communication amount may be expressed as m×(size of transaction authentication request message+size of authentication result message)+size of global write set.
[0169] In step 208, the cooperative node device determines a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device, and sends the processing command to the data node device, where the processing command is a commit command or an abort command.
[0170] After receiving the authentication result returned from the data node device, the cooperative node device determines whether the target transaction passes global authentication based on the received authentication result, and further determines a processing command for the target transaction and sends the processing command to the data node device, where the processing command is a commit command or an abort command.
[0171] In one possible implementation form, the number of data node devices is one or more, and when the number of data node devices is more than one, each data node device returns one authentication result.
[0172] In a case where the number of data node devices is at least two, the process of determining a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device includes using an abort command as a processing command for the target transaction in response to the presence of an authentication result used to indicate that the authentication was not passed in at least two authentication results returned from at least two data node devices, using a common part of the logical lifecycles carried by the at least two authentication results as a target logical lifecycle in response to both of the at least two authentication results returned from the at least two data node devices indicating that the authentication was passed, using a commit command as a processing command for the target transaction in response to the target logical lifecycle being valid, and using an abort command as a processing command for the target transaction in response to the target logical lifecycle being invalid.
[0173] In an exemplary embodiment, the authentication result used to indicate that the authentication is not passed is an authentication result carrying an Abort message, and if an authentication result does not carry an Abort message but carries a logical life cycle (i.e., the fifth logical life cycle determined in step 207), the authentication result indicates that the authentication is passed. That is, in the process of determining whether the target transaction can pass the global authentication based on the received authentication results, if there is at least one authentication result carrying an Abort message in the received authentication results, i.e., there is an lvm with an IsAbort field equal to 1, it is declared that the target transaction does not pass all local authentications, the global authentication of the target transaction is not passed, and the target transaction needs to perform a global abort. In this case, an abort command is used as a processing command for the target transaction. The cooperative node device updates the global transaction status of the target transaction in the first transaction status list to Gaborting (globally aborting). The cooperative node device sends an abort command to the data node device to notify the data node device to perform a local abort. Illustratively, a processing instruction is sent by writing a commit / abort message coarm, and if the processing instruction is an abort instruction, the IsAbort field in coarm is equal to 1, ie coarm.IsAbort=1.
[0174] If there is no authentication result carrying an Abort message in the received authentication results, or if all of the received authentication results carry a logical lifecycle, the target transaction passes all local authentications. In this case, the cooperative node device calculates the intersection of the logical lifecycles carried by each of the received authentication results to obtain the target logical lifecycle. If the lower timestamp limit of the target logical lifecycle is equal to or greater than the upper timestamp limit of the target logical lifecycle, the target logical lifecycle is invalid, and it is determined that the target transaction does not pass global authentication, and the target transaction needs to perform a global abort, and the cooperative node device uses the abort command as a processing command for the target transaction. In addition, the cooperative node device further updates the global transaction status of the target transaction in the first transaction status list to Gaborting (globally aborting), and the cooperative node device sends an abort command to the data node device to notify the data node device to perform a local abort.
[0175] If the timestamp lower limit of the target logical lifecycle is smaller than the timestamp upper limit of the target logical lifecycle, the target logical lifecycle is explained as valid, and it is determined that the global authentication of the target transaction has passed, and the cooperative node device randomly selects one timestamp from the target logical lifecycle to assign a value to the logical commit timestamp Cts of the target transaction, for example, selecting the timestamp lower limit of the target logical lifecycle as the logical commit timestamp of the target transaction.
[0176] After determining the logical commit timestamp, the cooperative node device updates the lower limit of the logical life cycle timestamp and the upper limit of the logical life cycle timestamp of the target transaction T in the first transaction status list to the logical commit timestamp, i.e., T.Bts=T.Ets=T.Cts. In addition, the cooperative node device updates the global transaction status of the target transaction in the first transaction status list to Gcommitted (passes global authentication), requests the global timestamp generating cluster to assign a global commit timestamp to the target transaction, and records it in the global commit timestamp Gts field of the target transaction in the first transaction status list. In addition, the cooperative node device uses the commit command as a processing command for the target transaction, and sends a commit command to the data node device to notify the data node device to commit the target transaction. Illustratively, for the case where a processing instruction is sent by writing a commit / abort message coarm, if the processing instruction is a commit instruction, the IsAbort field in coarm is equal to 0, i.e., coarm.IsAbort=0, and the logical commit timestamp of the target transaction and the global commit timestamp of the target transaction are recorded in the Cts and Gts fields in coarm, respectively.
[0177] In step 209, in response to receiving the processing instruction for the target transaction transmitted from the cooperative node device, the data node device executes the processing instruction, which is a commit instruction or an abort instruction.
[0178] After receiving the processing command, the data node device executes the processing command, which is a transaction commit or abort operation completion stage.
[0179] If the processing command is a commit command, it is described that the global authentication of the target transaction is passed and the commit phase is entered, that is, the update to the data of the target transaction is persisted in the database, and some subsequent cleanup work is performed. In an exemplary embodiment, after receiving the commit command sent from the cooperative node device, the data node device can perform the following operations A to E.
[0180] Operation A: For each data item x corresponding to the local read set of the target transaction, modify the maximum read transaction timestamp Rts of data item x so that the maximum read transaction timestamp Rts of data item x is greater than or equal to the logical commit timestamp Cts of the target transaction, i.e., x.Rts=max(x.Rts, T.Cts), and remove the transaction identifier TID of the target transaction from the active transaction list RTlist of data item x.
[0181] Operation B: For each data item y corresponding to the local write set of the target transaction, perform the following operations: a) modify the original creation timestamp Wts of the data item y to the logical commit timestamp T.Cts of the target transaction; b) update the max read transaction timestamp of the data item y to the maximum of the original max read transaction timestamp and the logical commit timestamp of the target transaction, i.e., y.Rts=max(y.Rts,T.Cts); c) persist the data item y in the database and modify the mark of the data item y from the first mark to the second mark, where the second mark is used to indicate that the data item y is visible to the outside; d) clear the contents of the active transaction list RTlist of the data item y; e) clear the contents of the transaction WT that writes to the data item y.
[0182] Operation C: Clear the local read set and local write set of the target transaction.
[0183] Operation D: Update the lower and upper timestamp bounds of the logical lifecycle of the target transaction in the local transaction status list to the logical commit timestamp of the target transaction, i.e., T.Bts=T.Ets=T.Cts. Update the transaction status of the target transaction in the local transaction status list to Committed. As should be explained, at this time, the local transaction status list is used to ensure transaction consistency, and there is no need for global transaction status synchronization.
[0184] Operation E: Acknowledge Character (ACK) indicating successful commit is returned to the cooperative node device.
[0185] After receiving ACKs indicating successful commit returned from all data node devices, the cooperative node device modifies the global transaction status of the target transaction in the first transaction status list to Gcommitted (global commit completed), and then the cooperative node device sends a status information cleanup command to the data node device to cause the data node device to delete the status information of the target transaction from its local transaction status list.
[0186] If the processing command is an abort command, it is described that the target transaction does not pass the global authentication, and needs to enter the global abort phase, that is, abort the target transaction, and perform corresponding cleanup operations. Illustratively, the contents of the cleanup operations include: deleting the transaction identifier TID of the target transaction from the active transaction list RTlist of each data item x corresponding to the local read set of the target transaction; cleaning up the newly created data corresponding to each data item y corresponding to the local write set of the target transaction, and clearing the contents of the transaction WT that is the write target of the data item y; clearing the local read set and local write set of the target transaction; updating the transaction status of the target transaction in the local transaction status list to Aborted (abortion is completed); and returning an ACK that the abort is completed to the cooperative node device.
[0187] After receiving the ACKs indicating that the abort is completed from all the data node devices, the cooperative node device modifies the global transaction status of the target transaction in the first transaction status list to Gaborted (global abort is completed), and then the cooperative node device sends a status information cleanup command to the data node devices to cause the data node devices to delete the status information of the target transaction from their local transaction status lists. In one possible implementation form, the cooperative node device sends the status information cleanup command to the data node devices in bulk to reduce the number of communications.
[0188] As is clear from the above, in the commit / abort phase of the target transaction, communication mainly occurs between the cooperative node devices and the associated data node devices, and the communication mainly includes the steps of the cooperative node devices sending a commit / abort command to each associated data node device, and each associated data node device sending a corresponding commit / abort completion message (ACK) to the cooperative node device. Therefore, in the commit / abort phase, a maximum of 2m communications are performed, and the size of the communication amount is m×(size of the commit / abort command message+size of the commit / abort completion message), where m (m is an integer equal to or greater than 1) is the number of data node devices associated with the target transaction T.
[0189] As is necessary to explain, the embodiments of the present application are presented using an example in which the target transaction relates to a read / write operation, but the embodiments of the present application are not limited to this, and in the case in which the target transaction relates only to a read operation or only to a write operation, it is still possible to realize processing for the transaction based on the transaction processing method provided by the embodiments of the present application, but detailed explanations of the embodiments of the present application will be omitted.
[0190] The process of processing transactions based on the above steps 201 to 209 realizes distributed processing of transactions, and makes it possible to solve the problem of data abnormality caused by conflicting operations between parallel transactions. From the viewpoint of implementation principle, the transaction processing method provided by the embodiment of the present application mainly applies the algorithm framework of OCC (Optimistic Concurrency Control) and combines DTA (Dynamic Timestamp Allocation) algorithm to reduce transaction data information transmitted in the network, improve the authentication efficiency of distributed transactions, and enhance the parallel processing ability of distributed transactions. In addition, MVCC (Multi-Version Concurrency Control) is further combined to realize unlocked data reading and writing, thereby enhancing the parallel processing ability of local node devices. Here, the DTA algorithm belongs to the TO (Timestamp Ordering) algorithm, and can dynamically adjust the timestamp lower limit and timestamp upper limit of the logical life cycle of a transaction.
[0191] The method provided by the embodiments of the present application is independent of data storage format, and the distributed database system in the embodiments of the present application not only supports a key-value data storage format (KV data storage format) (e.g., the data storage format in the HBase database system), but also supports a segment page data storage format (e.g., the data storage format in the PostgreSQL and MsSQL / InnoDB database systems).
[0192] In an exemplary embodiment, for a segment page type data storage format, a data buffer area is established in the node equipment to buffer data transmitted from the shared storage system, thereby accelerating the speed at which the data is next retrieved, and the buffer format is maintained to be consistent with the underlying data storage format. Data transmitted from the shared storage system is buffered in a local data buffer area and is not cleaned up at the end of the transaction until the local data buffer area becomes full, or dirty data needs to be flushed back to the shared storage system, or the buffer becomes invalid (e.g., similar data is modified on another node equipment).
[0193] Before a transaction is committed, each node device calculates a transaction log (e.g., a WAL log) in the shared storage system, and the transaction log requests an LSN value from the shared storage system, which is a globally unique and increasing value. In different data storage formats, the transaction log generated in the transaction processing process has different formats. Illustratively, when the data storage format is the KV data storage format, the format of the transaction log is shown in FIG. 3.
[0194] Each region divided in a large table maintained by a database system shares one log file, and a single region is stored in the log in chronological order, but multiple regions may not be completely chronological. The smallest unit of each log consists of two parts: a log key (HLogKey) and a log edit (WALEdit). Here, the HLogKey consists of a sequence number (sequenceid), a timestamp (timestamp), cluster numbers (cluster ids), a region name (region name), and a table name (table name), and the WALEdit consists of a series of key-value pairs (Key Value), and all update operations for all columns in a row (i.e., all Key Values) are all contained in the same WALEdit object, mainly to achieve atomicity when writing to multiple columns in a row. The sequenceid is a self-increasing sequence number of one storage level, and both data recovery of the area and clearing of expired logs depend on it, and illustratively, the sequenceid refers to the LSN value of the transaction log.
[0195] For example, when the data storage format is a segment page type data storage format, the format of the transaction log is shown in Figure 4. Each Region shares one log file, a single Region is stored in the log in chronological order, and multiple Regions may not be completely chronological. The smallest unit of each log is one log record (XLog Record) instead of two parts, HLogkey and WALEdit.
[0196] An XLog Record consists of two parts, the first part is the header information, which has a fixed size (e.g., 24B (Bytes) and the corresponding structure is XLogRecord, and the second part is the log record data.
[0197] XLog Records are divided according to the stored data content and are mainly divided into three types:
[0198] The first type: Record for backup block: It is a block that stores a full-write-page, this type of record is used to solve the problem of writing part of a page. It writes the whole page when modifying a data page for the first time after a checkpoint is completed, and records this change and writes it to the transaction log file (need to set the corresponding initialization parameter, which is enabled by default).
[0199] The second type: Record for tuple data block: Used to store tuple changes in a page.
[0200] The third type: Record for Checkpoint: When a checkpoint occurs, the checkpoint information (including the Redo point) is recorded in the transaction log file.
[0201] XLog Record data is where the actual data is stored and consists of the following four parts:
[0202] Part 1: 0-N XLogRecordBlockHeaders, each corresponding to one block data. If the BKPBLOCK_HAS_IMAGE mark is set, the XLogRecordBlockHeader structure is followed by an XLogRecordBlockImageHeader structure, if the BKPBLOCK_HAS_HOLE&BKPIMAGE_IS_COMPRESSED mark is set, the XLogRecordBlockHeader structure is followed by an XLogRecordBlockCompressHeader structure, if the BKPBLOCK_SAME_REL mark is not set, the XLogRecordBlockHeader structure is followed by a RelFileNode. Exemplarily, the XLogRecordBlockHeader structure may further be followed by a BlockNumber.
[0203] Second part: XLogRecordDataHeader[Short|Long]. If the size of the data is < 256 Bytes, use the Short format, otherwise use the Long format.
[0204] Third part: block data: full-write-page data and tuple data. For full-write-page data, if compression is enabled, the data is stored compressed and the metadata associated with the page after compression is stored in the XLogRecordBlockCompressHeader.
[0205] Part 4: Main data: Records log data such as checkpoints.
[0206] Illustratively, an XLog Record is defined as follows: Header information (fixed size XLogRecord structure) XLogRecordBlockHeader Structure XLogRecordBlockHeader Structure ... XLogRecordDataHeader[Short|Long] Structure block data block data ... Main data
[0207] In one possible implementation, when the data storage format is a segment page type data storage format, if concurrent transactions are processed on different node devices (ES) and modify different data items on the same page, a page level conflict occurs, which causes a data overwrite problem. For example, transaction Ta modifies a data item X=2 on node device ES-1, and transaction Tb modifies a data item X=3 on node device ES-2, and the data items X=2 and X=3 are on the same page, at this time, the transaction processing mechanism operates in parallel, executes the transactions simultaneously, and there is no data anomaly at the transaction level. However, at the page level, there is a choice of which transaction log flushed out in ES-1 or ES-2 should be selected, which leads to the appearance of a problem that modifications to the same physical page are incompatible.
[0208] In a transaction log that supports a segment page type data storage format, a list of one segment page type is incremented and the address of the page in this segment log (e.g., file number, table space number, relative offset in the file, etc.) and the transaction identifier performing the write operation on each page are marked. When the transaction log is flushed out to the lowest tier shared storage system, the authentication device checks whether the committed pages in the list of transactions in the shared storage system of all concurrent transactions overlap. If they overlap, it is asserted that the concurrent transactions have written the same page (if the same data item is written, the transaction authentication stage has detected that there is a transaction conflict and has already resolved the conflict by aborting), and the writes are different data items on the same page, at which time a page-level conflict exists, a data overwrite event occurs, and the transaction corresponding to one of the node devices ES needs to be aborted, and the corresponding transaction will not flush out the transaction log of the aborted node device ES, thereby avoiding the occurrence of a problem.
[0209] In an exemplary embodiment, the subject that performs the page-level competitive authentication is an authentication device in a distributed database system, which may be on the same physical machine as any of the node devices, or may be an independent device, and the embodiment of the present application is not limited thereto.
[0210] Based on the transaction processing method provided by the embodiment of the present application, it is possible for a distributed database system to not only support distributed transactions, but also achieve globally consistent multiple reads, and to take performance into consideration through distributed transaction processing technology. It has globally consistent multiple read and consistent multiple write capabilities with good transaction attribute characteristics. Based on the transaction processing method provided by the embodiment of the present application, it is possible to provide a distributed distributed transaction processing means for a distributed database system based on a shared-disk architecture, such as the well-known HBase database system under NoSQL (Non-relational SQL, generally referring to non-relational database), so that a database system similar to HBase has a highly efficient transaction processing capability between areas and nodes.
[0211] In the embodiment of the present application, the cooperative node devices used to cooperatively process the target transaction are determined based on the transaction allocation index corresponding to each node device, and the transaction allocation process does not need to take into account the data items related to the transaction, nor the distribution of the data items. Based on this method, each node device can cooperatively process the transaction as a distributed device, thereby enabling the transaction to be processed between nodes, which is favorable for improving the transaction processing efficiency, making the transaction processing more reliable, and improving the system performance of the database system.
[0212] An embodiment of the present application provides a transaction processing system, the transaction processing system including a cooperative node device and a data node device, the cooperative node device being a node device among at least two node devices sharing the same storage system, used to cooperatively process a target transaction, the cooperative node device being determined based on a transaction allocation index corresponding to each of the at least two node devices, and the data node device being a node device among the at least two node devices, used to participate in processing the target transaction; Wherein, the cooperative node device is used for obtaining transaction information of the target transaction and transmitting a data read request to the data node device based on the transaction information of the target transaction; The data node device is used for obtaining a data read result according to the data read request transmitted from the cooperative node device, and returning the data read result to the cooperative node device; The cooperative node device is further used to send a transaction authentication request and a local write set to the data node device in response to the data read result returned from the data node device satisfying the transaction authentication condition; The data node device is further used for obtaining an authentication result of the target transaction according to the transaction authentication request sent from the cooperative node device and the local write set, and returning the authentication result of the target transaction to the cooperative node device; The cooperative node device is further used for determining a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device, and sending the processing command to the data node device, the processing command being a commit command or an abort command; The data node device is further used for executing the processing instruction in response to receiving the processing instruction for the target transaction transmitted from the cooperative node device.
[0213] In one possible implementation form, the data read result carries a second logical lifecycle, the second logical lifecycle being determined by the data node device based on a first logical lifecycle of a target transaction carried in the data read request, the first logical lifecycle being composed of a timestamp lower limit and a timestamp upper limit, and the cooperative node device is further used to use a maximum value of the timestamp lower limit of the first logical lifecycle and the timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a third logical lifecycle of the target transaction, and to use a minimum value of the timestamp upper limit of the first logical lifecycle and the timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the third logical lifecycle of the target transaction, and in response to the third logical lifecycle being valid, to send a transaction authentication request carrying the third logical lifecycle to the data node device, wherein the validity of the third logical lifecycle is used to indicate that the timestamp lower limit of the third logical lifecycle is less than the timestamp upper limit of the third logical lifecycle.
[0214] In one possible implementation form, the number of data node devices is at least two, and the cooperative node device is further used to: use an abort command as a processing command for the target transaction in response to the presence of an authentication result used to indicate that authentication was not passed in at least two authentication results returned from the at least two data node devices; use a common portion of the logical lifecycles carried by the at least two authentication results as a target logical lifecycle in response to indicating that all of the at least two authentication results returned from the at least two data node devices passed authentication; use a commit command as a processing command for the target transaction in response to the target logical lifecycle being valid; and use an abort command as a processing command for the target transaction in response to the target logical lifecycle being invalid.
[0215] In one possible implementation form, the data read request carries a first logical lifecycle of the target transaction, the first logical lifecycle consisting of a timestamp lower limit and a timestamp upper limit, and the data node device is used to determine visible version data of the data item to be read indicated by the data read request based on the first logical lifecycle, determine a second logical lifecycle of the target transaction based on a creation timestamp of the visible version data and the first logical lifecycle, and use the result carrying the second logical lifecycle and the visible version data as a data read result.
[0216] In one possible implementation form, the transaction authentication request carries a third logical lifecycle of the target transaction, the third logical lifecycle being a valid logical lifecycle determined by the collaborative node device based on the first logical lifecycle and the second logical lifecycle, and the data node device is further used for: using a maximum value of a timestamp lower limit of the third logical lifecycle and a timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a fourth logical lifecycle of the target transaction; using a minimum value of a timestamp upper limit of the third logical lifecycle and a timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the fourth logical lifecycle of the target transaction; in response to the fourth logical lifecycle being valid, determining a fifth logical lifecycle of the target transaction based on the read transaction-related information and the fourth logical lifecycle of each write target data item corresponding to the local write set; in response to the fifth logical lifecycle being valid, using the authentication result used for indicating that the authentication has been passed as an authentication result of the target transaction; and in response to the fifth logical lifecycle being invalid, using the authentication result used for indicating that the authentication has not been passed as an authentication result of the target transaction.
[0217] In one possible implementation, the read transaction related information of one of the written data items includes a maximum read transaction timestamp of one of the written data items, where the maximum read transaction timestamp of one of the written data items is used to indicate a maximum value among the logical commit timestamps of each of the read transactions that read one of the written data items, and the data node device is further used to determine a fifth logical lifecycle of the target transaction based on the maximum read transaction timestamp of each of the written data items and the fourth logical lifecycle, where the lower timestamp limit of the fifth logical lifecycle is greater than the maximum value among the maximum read transaction timestamps of the written data items.
[0218] In one possible implementation form, the read transaction related information of one written data item includes an end timestamp of a target read transaction of one written data item, where the target read transaction is a read transaction that has passed local authentication or is in the commit phase, the end timestamp of the target read transaction is an upper timestamp limit of the logical lifecycle of the target read transaction, and the data node device is further used to determine a fifth logical lifecycle of the target transaction based on the end timestamp of the target read transaction of each written data item and the fourth logical lifecycle, and the lower timestamp limit of the fifth logical lifecycle is greater than the maximum value of the end timestamps of the target read transactions of each written data item.
[0219] The system provided by the above embodiment belongs to the same concept as the method embodiment, and the specific implementation process thereof can be referred to the method embodiment for details, so a detailed description thereof will be omitted here.
[0220] Referring to FIG. 5 , an embodiment of the present application provides a transaction processing device, the device comprising: A first determination unit 501 is used to determine a transaction allocation index corresponding to each of at least two node devices sharing the same storage system in response to an allocation request of a target transaction, and the transaction allocation index corresponding to one node device is used to indicate a matching degree of allocating a new transaction to the one node device; and a second determination unit 502, which is used to determine a cooperative node device of the target transaction among the at least two node devices based on the transaction allocation indicators corresponding to each of the at least two node devices, and to cooperatively process the target transaction by the cooperative node devices.
[0221] In one possible implementation form, the first determination unit 501 is used for determining a transaction allocation mode, where the transaction allocation mode includes any one of transaction busyness-based allocation, device busyness-based allocation, and hybrid busyness-based allocation, and determining transaction allocation indicators corresponding to each of the at least two node devices based on a determination method indicated by the transaction allocation mode.
[0222] In one possible implementation, the transaction allocation mode includes a hybrid busyness-based allocation, and the first determination unit 501 is further used for determining a transaction allocation index corresponding to the first node equipment based on the transaction processing number of the first node equipment, the equipment resource utilization rate of the first node equipment, the weight of the transaction processing number, the weight of the equipment resource utilization rate, and the weight adjustment parameter, and the first node equipment is any one of the at least two node equipments.
[0223] In one possible implementation, the device comprises: The terminal further includes a transmitting unit used for transmitting device identification information of the cooperative node device to the terminal that issued the allocation request, the transmitting unit being used by the terminal to transmit transaction information of the target transaction to the cooperative node device based on the device identification information of the cooperative node device, and for cooperatively processing the target transaction based on the transaction information by the cooperative node device.
[0224] In one possible implementation, the distributed database system supports a key-value based data storage format and a segment page based data storage format.
[0225] In the embodiment of the present application, the cooperative node devices used to cooperatively process the target transaction are determined based on the transaction allocation index corresponding to each node device, and the transaction allocation process does not need to take into account the data items related to the transaction, nor the distribution of the data items. Based on this method, each node device can cooperatively process the transaction as a distributed device, thereby enabling the transaction to be processed between nodes, which is favorable for improving the transaction processing efficiency, making the transaction processing more reliable, and improving the system performance of the database system.
[0226] Referring to FIG. 6 , an embodiment of the present application provides a transaction processing device, the device comprising: An acquiring unit 601, which is used for acquiring transaction information of a target transaction; A first sending unit 602 used for sending a data read request to a data node device according to transaction information of a target transaction, where the data node device is a node device used to participate in processing the target transaction among at least two node devices sharing the same storage system; and A second sending unit 603 is used for sending a transaction authentication request and a local write set to the data node device in response to the data read result returned from the data node device satisfying the transaction authentication condition; A determination unit 604, which is used for determining a processing instruction of the target transaction according to the authentication result of the target transaction returned from the data node device; A third sending unit 605 used to send a processing command to the data node device, where the processing command is a commit command or an abort command, and the data node device is used to execute the processing command.
[0227] In one possible implementation form, the data read result carries a second logical lifecycle, the second logical lifecycle being determined by the data node device based on a first logical lifecycle of a target transaction carried in the data read request, the first logical lifecycle being composed of a timestamp lower limit and a timestamp upper limit, the second sending unit 603 being used for: using a maximum value of the timestamp lower limit of the first logical lifecycle and the timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a third logical lifecycle of the target transaction; using a minimum value of the timestamp upper limit of the first logical lifecycle and the timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the third logical lifecycle of the target transaction; and in response to the third logical lifecycle being valid, sending a transaction authentication request carrying the third logical lifecycle to the data node device, where the validity of the third logical lifecycle is used to indicate that the timestamp lower limit of the third logical lifecycle is less than the timestamp upper limit of the third logical lifecycle.
[0228] In one possible implementation form, the number of data node devices is at least two, and the decision unit 604 is used to use an abort command as a processing command for the target transaction in response to the presence of an authentication result used to indicate that authentication was not passed in at least two authentication results returned from the at least two data node devices, use a common part of the logical lifecycles carrying the at least two authentication results as a target logical lifecycle in response to indicating that all of the at least two authentication results returned from the at least two data node devices passed authentication, use a commit command as a processing command for the target transaction in response to the target logical lifecycle being valid, and use an abort command as a processing command for the target transaction in response to the target logical lifecycle being invalid.
[0229] In the embodiment of the present application, the cooperative node devices used to cooperatively process the target transaction are determined based on the transaction allocation index corresponding to each node device, and the transaction allocation process does not need to take into account the data items related to the transaction, nor the distribution of the data items. Based on this method, each node device can cooperatively process the transaction as a distributed device, thereby enabling the transaction to be processed between nodes, which is favorable for improving the transaction processing efficiency, making the transaction processing more reliable, and improving the system performance of the database system.
[0230] Referring to FIG. 7, an embodiment of the present application provides a transaction processing device, the device comprising: A first acquiring unit 701 used for acquiring a data read result according to a data read request sent from a cooperative node device, where the cooperative node device is a node device used for cooperatively processing a target transaction among at least two node devices sharing the same storage system, and the cooperative node device is determined based on a transaction allocation index corresponding to each of the at least two node devices; A reply unit 702, which is used for replying the data reading result to the cooperative node device; A second acquiring unit 703 is used for acquiring an authentication result of a target transaction according to a transaction authentication request sent from a cooperative node device and a local write set; an execution unit 704 adapted to execute a processing command in response to receiving a processing command for a target transaction transmitted from a cooperative node device, the processing command being a commit command or an abort command; The reply unit 702 is further used for replying the authentication result of the target transaction to the cooperative node device.
[0231] In one possible implementation form, the data read request carries a first logical lifecycle of the target transaction, the first logical lifecycle consisting of a timestamp lower limit and a timestamp upper limit, and the first acquisition unit 701 is used to determine visible version data of the data item to be read indicated by the data read request based on the first logical lifecycle, determine a second logical lifecycle of the target transaction based on the creation timestamp of the visible version data and the first logical lifecycle, and use the result carrying the second logical lifecycle and the visible version data as a data read result.
[0232] In one possible implementation form, the transaction authentication request carries a third logical lifecycle of the target transaction, and the third logical lifecycle is a valid logical lifecycle determined by the cooperative node device based on the first logical lifecycle and the second logical lifecycle, and the second acquisition unit 703 is used to: use a maximum value of the timestamp lower limit of the third logical lifecycle and the timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a fourth logical lifecycle of the target transaction; use a minimum value of the timestamp upper limit of the third logical lifecycle and the timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the fourth logical lifecycle of the target transaction; in response to the fourth logical lifecycle being valid, determine a fifth logical lifecycle of the target transaction based on the read transaction-related information and the fourth logical lifecycle of each write target data item corresponding to the local write set; in response to the fifth logical lifecycle being valid, use the authentication result used for indicating that the authentication has been passed as an authentication result of the target transaction; and in response to the fifth logical lifecycle being invalid, use the authentication result used for indicating that the authentication has not been passed as an authentication result of the target transaction.
[0233] In one possible implementation form, the read transaction related information of a write target data item includes a maximum read transaction timestamp of the write target data item, and the maximum read transaction timestamp of the write target data item is used to indicate the maximum value of the logical commit timestamps of each read transaction that reads the write target data item; the second acquisition unit 703 is further used to determine a fifth logical lifecycle of the target transaction based on the maximum read transaction timestamp of each write target data item and a fourth logical lifecycle, and the timestamp lower limit of the fifth logical lifecycle is greater than the maximum value of the maximum read transaction timestamps of each write target data item.
[0234] In one possible implementation form, the read transaction related information of a written data item includes an end timestamp of a target read transaction of the written data item, where the target read transaction is a read transaction that has passed local authentication or is in the commit phase, and the end timestamp of the target read transaction is an upper timestamp limit of the logical lifecycle of the target read transaction, and the second acquisition unit 703 is further used to determine a fifth logical lifecycle of the target transaction based on the end timestamp of the target read transaction of each written data item and the fourth logical lifecycle, and the lower timestamp limit of the fifth logical lifecycle is greater than the maximum value of the end timestamps of the target read transactions of each written data item.
[0235] In the embodiment of the present application, the cooperative node devices used to cooperatively process the target transaction are determined based on the transaction allocation index corresponding to each node device, and the transaction allocation process does not need to take into account the data items related to the transaction, nor the distribution of the data items. Based on this method, each node device can cooperatively process the transaction as a distributed device, thereby enabling the transaction to be processed between nodes, which is favorable for improving the transaction processing efficiency, making the transaction processing more reliable, and improving the system performance of the database system.
[0236] As is necessary to explain, the above embodiment provides an apparatus for implementing its functions, and only takes the above-mentioned functional units as an example for description, but in actual application, the above-mentioned functions can be assigned to different functional units to be completed according to need, that is, the internal structure of the device can be divided into different functional units to complete all or part of the above-mentioned functions. In addition, the above embodiment provides an apparatus according to the same concept as the method embodiment, and the specific implementation process thereof can be referred to the method embodiment for details, and detailed description thereof will be omitted here.
[0237] 8 is a structural schematic diagram of a computer device provided by an embodiment of the present application, which may be relatively different due to different layouts or performances, and may include one or more processors (Central Processing Units, CPU) 801 and one or more memories 802, where at least one computer program is stored in the one or more memories 802, and the at least one computer program is loaded and executed by the one or more processors 801 to make the computer device realize the transaction processing method provided by each of the above method embodiments. Of course, the computer device may further have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input / output, and the computer device may further include other components used to realize the functions of the device, which will not be described in detail here.
[0238] In an exemplary embodiment, a non-transitory computer-readable storage medium is further provided, in which at least one computer program is stored, and the at least one computer program is loaded and executed by a processor of a computing device to cause the computer to realize any one of the transaction processing methods described above.
[0239] In one possible implementation, the non-transitory computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a Compact Disc Read-Only Memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0240] In an exemplary embodiment, a computer program product or a computer program is further provided, the computer program product or the computer program including computer instructions stored in a computer readable storage medium, the computer instructions being read by a processor of the computer device from the computer readable storage medium, and the processor executing the computer instructions, thereby causing the computer device to perform any one of the above transaction processing methods.
[0241] As should be understood, the term "at least one" in this application refers to one or more, and the meanings of "multiple" or "at least two" refer to two or more. "And / or" is used to describe the relationship between related objects, and can represent the existence of three types of relationships, for example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents that the related objects before and after are in an "or" relationship.
[0242] The above are merely illustrative examples of the present application and are not used to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included within the protection scope of the present application. [Explanation of symbols]
[0243] 101 Gateway Server 102 Equipment 103 Distributed Memory Cluster 104 Global Timestamp Generation Cluster 501 First Decision Unit 502 Second Decision Unit 601 Acquired Units 602 First transmitting unit 603 Second transmitting unit 604 Decision Unit 605 3rd transmitting unit 701 First Acquisition Unit 702 Reply Unit 703 2nd Acquisition Unit 704 Execution Unit 801 Processor 802 Memory
Claims
1. A transaction processing method executed by a cooperative node device, the cooperative node device being a node device used to cooperatively process a target transaction among at least two node devices sharing the same storage system, the cooperative node device being determined based on a transaction allocation index corresponding to each of the at least two node devices, the method comprising: obtaining transaction information of the target transaction; sending a data read request to a data node device based on transaction information of the target transaction, the data node device being one of the at least two node devices that is used to participate in processing the target transaction; In response to the data read result returned from the data node device satisfying a transaction authentication condition, transmitting a transaction authentication request and a local write set to the data node device; determining a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device, and sending the processing command to the data node device, the processing command being a commit command or an abort command, and the data node device being used to execute the processing command; the data read result carries a second logical lifecycle, the second logical lifecycle being determined by the data node device based on a first logical lifecycle of the target transaction carried by the data read request, the first logical lifecycle comprising a timestamp lower limit and a timestamp upper limit; the step of transmitting a transaction authentication request and a local write set to the data node device in response to the data read result returned from the data node device satisfying a transaction authentication condition, using the maximum value of the timestamp lower limit of the first logical lifecycle and the timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a third logical lifecycle of the target transaction, and using the minimum value of the timestamp upper limit of the first logical lifecycle and the timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the third logical lifecycle of the target transaction; in response to the third logical lifecycle being valid, sending a transaction authentication request carrying the third logical lifecycle to the data node device, wherein the validity of the third logical lifecycle is used to indicate that a timestamp lower limit of the third logical lifecycle is less than a timestamp upper limit of the third logical lifecycle.
2. A transaction processing method executed by a cooperative node device, the cooperative node device being a node device used to cooperatively process a target transaction among at least two node devices sharing the same storage system, the cooperative node device being determined based on a transaction allocation index corresponding to each of the at least two node devices, the method comprising: obtaining transaction information of the target transaction; sending a data read request to a data node device based on transaction information of the target transaction, the data node device being one of the at least two node devices that is used to participate in processing the target transaction; In response to the data read result returned from the data node device satisfying a transaction authentication condition, transmitting a transaction authentication request and a local write set to the data node device; determining a processing command for the target transaction based on the authentication result of the target transaction returned from the data node device, and sending the processing command to the data node device, the processing command being a commit command or an abort command, and the data node device being used to execute the processing command; The number of the data node devices is at least two, and the step of determining a processing instruction for the target transaction based on an authentication result of the target transaction returned from the data node device and transmitting the processing instruction to the data node device includes: using the abort command as a processing command for the target transaction in response to the presence of an authentication result used to indicate that authentication has not been passed in at least two authentication results returned from the at least two data node devices; in response to at least two authentication results returned from the at least two data node devices indicating that authentication has been passed, using a common portion of logical lifecycles carried by the at least two authentication results as a target logical lifecycle; in response to the target logical lifecycle being valid, using the commit instruction as a processing instruction for the target transaction, and in response to the target logical lifecycle being invalid, using the abort instruction as a processing instruction for the target transaction.
3. A transaction processing method executed by a data node device, the data node device being one of at least two node devices sharing the same storage system that is used to participate in processing a target transaction, the method comprising: A step of acquiring a data read result based on a data read request sent from a cooperative node device, and returning the data read result to the cooperative node device, the cooperative node device being determined based on a transaction allocation indicator corresponding to each of the at least two node devices; obtaining an authentication result of the target transaction based on a transaction authentication request and a local write set transmitted from the cooperative node device, and returning the authentication result of the target transaction to the cooperative node device; in response to receiving a processing command for the target transaction transmitted from the cooperative node device, executing the processing command, the processing command being a commit command or an abort command; the data read request carries a first logical life cycle of the target transaction, the first logical life cycle comprising a timestamp lower bound and a timestamp upper bound; The step of acquiring a data read result based on a data read request transmitted from a cooperative node device and returning the data read result to the cooperative node device includes: determining, based on the first logical lifecycle, visible version data of the data item to be read indicated by the data read request; determining a second logical lifecycle of the target transaction based on a creation timestamp of the visible version data and the first logical lifecycle; using the second logical life cycle and the result of the visible version data being delivered as the data read result.
4. the transaction authentication request carries a third logical life cycle of the target transaction, the third logical life cycle being a valid logical life cycle determined by the cooperative node device based on the first logical life cycle and the second logical life cycle; The step of obtaining an authentication result of the target transaction based on a transaction authentication request and a local write set transmitted from the cooperative node device includes: using the maximum value of the timestamp lower limit of the third logical lifecycle and the timestamp lower limit of the second logical lifecycle as a timestamp lower limit of a fourth logical lifecycle of the target transaction, and using the minimum value of the timestamp upper limit of the third logical lifecycle and the timestamp upper limit of the second logical lifecycle as a timestamp upper limit of the fourth logical lifecycle of the target transaction; in response to the fourth logical lifecycle being valid, determining a fifth logical lifecycle of the target transaction based on read transaction related information of each write target data item corresponding to the local write set and the fourth logical lifecycle; and in response to the fifth logical lifecycle being invalid, using an authentication result used to indicate that authentication was not passed as an authentication result for the target transaction.
5. The read transaction related information of a data item to be written includes a maximum read transaction timestamp of the data item to be written, and the maximum read transaction timestamp of the data item to be written is used to indicate a maximum value of logical commit timestamps of all read transactions that have read the data item to be written; determining a fifth logical life cycle of the target transaction based on read transaction related information of each write target data item corresponding to the local write set and the fourth logical life cycle in response to the fourth logical life cycle being valid, 5. The method of claim 4, further comprising: determining a fifth logical lifecycle of the target transaction based on a maximum read transaction timestamp of each of the written data items and the fourth logical lifecycle, wherein a lower timestamp limit of the fifth logical lifecycle is greater than a maximum value among the maximum read transaction timestamps of each of the written data items.
6. The read transaction related information of a data item to be written includes an end timestamp of a target read transaction of the data item to be written, the target read transaction is a read transaction that has passed local authentication or is in a commit phase, and the end timestamp of the target read transaction is a timestamp upper limit of a logical life cycle of the target read transaction; determining a fifth logical life cycle of the target transaction based on read transaction related information of each write target data item corresponding to the local write set and the fourth logical life cycle in response to the fourth logical life cycle being valid, 5. The method of claim 4, further comprising: determining a fifth logical lifecycle of the target transaction based on an end timestamp of a target read transaction of each of the written data items and the fourth logical lifecycle, wherein a lower timestamp limit of the fifth logical lifecycle is greater than a maximum value of end timestamps of target read transactions of each of the written data items.
7. A computer device comprising a processor and a memory, at least one computer program being stored in the memory, the at least one computer program being loaded and executed by the processor, causing the computer device to realize the transaction processing method described in claim 1.
8. A computer device comprising a processor and a memory, at least one computer program being stored in the memory, the at least one computer program being loaded and executed by the processor, causing the computer device to realize the transaction processing method described in claim 2.
9. A computer device comprising a processor and a memory, at least one computer program being stored in the memory, the at least one computer program being loaded and executed by the processor, causing the computer device to realize the transaction processing method described in claim 3.
10. A transaction processing system, the transaction processing system comprising: a computer device according to claim 7; and a computer device according to claim 9.
11. A transaction processing system, comprising: a computer device as described in claim 8; and a computer device as described in claim 9.
12. further comprising a transaction processing device; The transaction processing device includes: a first determination unit used to determine a transaction allocation index corresponding to each of at least two node devices sharing the same storage system in response to an allocation request of the target transaction, the transaction allocation index corresponding to one node device being used to indicate a matching degree of allocating a new transaction to the one node device; a second determination unit for determining a cooperative node device of the target transaction among the at least two node devices based on a transaction allocation indicator corresponding to each of the at least two node devices, and for allowing the cooperative node devices to cooperatively process the target transaction; 12. A transaction processing system according to claim 10 or 11.
13. 2. A computer program product arranged to cause a computer device to carry out the transaction processing method according to claim 1 when a processor executes the computer program product.
14. A computer program configured to cause a computer device to execute the transaction processing method described in claim 2 when a processor executes the computer program.
15. A computer program configured to cause a computer device to execute the transaction processing method described in claim 3 when a processor executes the computer program.
Citation Information
Patent Citations
Method, system and router for originating the authentication request via the user terminal
CN101034989A
A scheduling method and system for a base station task
CN109842947A
Scheduling node selection method and device, storage medium and server
CN110287022A
Data reading method, data reading device, computer equipment and storage medium
CN111190935A
Transaction processing method and device, computer equipment and storage medium
CN111597015A
