CN115544037A - Transaction execution method and distributed database system - Google Patents
Transaction execution method and distributed database system Download PDFInfo
- Publication number
- CN115544037A CN115544037A CN202211204699.4A CN202211204699A CN115544037A CN 115544037 A CN115544037 A CN 115544037A CN 202211204699 A CN202211204699 A CN 202211204699A CN 115544037 A CN115544037 A CN 115544037A
- Authority
- CN
- China
- Prior art keywords
- transaction
- timestamp
- target
- list
- tso
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2308—Concurrency control
- G06F16/2315—Optimistic concurrency control
- G06F16/2322—Optimistic concurrency control using timestamps
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请提供了一种事务执行方法和分布式数据库系统,涉及云计算领域,本实施例中,协调节点CN和数据节点DN利用授时节点TSO提供的目标事务的第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务。本实施例融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。
This application provides a transaction execution method and a distributed database system, which relate to the field of cloud computing. In this embodiment, the coordination node CN and the data node DN use the first start timestamp and timestamp list of the target transaction provided by the timing node TSO , modify the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction; execute the target transaction according to the globally consistent active transaction information. This embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the time stamp assigned by the TSO to achieve global transaction consistency.
Description
技术领域technical field
本申请涉及云计算技术领域,尤其涉及一种事务执行方法和分布式数据库系统。The present application relates to the technical field of cloud computing, and in particular to a transaction execution method and a distributed database system.
背景技术Background technique
在主流的单机关系型数据库中,一般采用多版本并发控制(Multi-VersionConcurrency Control,MVCC)作为并发控制技术来满足事务的一致性。通过多版本并发控制,为每一个数据库会话提供事务隔离。随着数据日益增长,单机数据库已经不能满足需求,分布式数据库得到迅速的发展,分布式数据库可以通过扩展节点来扩展存储和吞吐。In mainstream stand-alone relational databases, Multi-Version Concurrency Control (MVCC) is generally used as a concurrency control technology to satisfy transaction consistency. Provide transaction isolation for each database session through multi-version concurrency control. With the increasing data, stand-alone databases can no longer meet the demand, and distributed databases have developed rapidly. Distributed databases can expand storage and throughput by expanding nodes.
然而,分布式架构下,数据分布和事务处理会涉及不同的物理机器,原有单机MVCC技术无法保证全局事务的一致性,从而导致事务无法正确执行。However, under the distributed architecture, data distribution and transaction processing will involve different physical machines. The original stand-alone MVCC technology cannot guarantee the consistency of global transactions, resulting in incorrect execution of transactions.
发明内容Contents of the invention
本申请实施例提供一种事务执行方法和分布式数据库系统,以实现分布式数据库中全局事务的一致性,保证事务正确执行。The embodiment of the present application provides a transaction execution method and a distributed database system, so as to realize the consistency of the global transaction in the distributed database and ensure the correct execution of the transaction.
第一方面,本申请实施例提供了一种事务执行方法,该方法应用于数据库中的协调节点CN,该方法包括:In the first aspect, the embodiment of the present application provides a transaction execution method, the method is applied to the coordination node CN in the database, and the method includes:
接收目标事务的执行请求,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;Receive the execution request of the target transaction and obtain the local active transaction information; the transactions in the local active transaction information include the uncommitted transactions;
从数据库中的授时节点TSO获取目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;Obtain the first start timestamp and the timestamp list of the target transaction from the timing node TSO in the database, the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the submission before the first start timestamp;
根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;According to the first start timestamp and the timestamp list, modify the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction;
根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。According to the global consistent active transaction information, the target transaction is executed to achieve the consistency of the global transaction.
第二方面,本申请实施例提供了一种事务执行方法,该方法应用于数据库中的数据节点DN,该方法包括:In the second aspect, the embodiment of the present application provides a transaction execution method, the method is applied to the data node DN in the database, and the method includes:
接收CN或者TSO发送的目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;Receive the first start time stamp and time stamp list of the target transaction sent by CN or TSO, the time stamp list includes the second start time stamp of the transaction that has completed the preparation and has not completed the commit before the first start time stamp;
获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;Obtain local active transaction information; transactions in local active transaction information include uncommitted transactions;
根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;According to the first start timestamp and the timestamp list, modify the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction;
根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。According to the global consistent active transaction information, the target transaction is executed to achieve the consistency of the global transaction.
第三方面,本申请实施例提供了一种事务执行方法,该方法应用于数据库中的授时节点TSO,该方法包括:In the third aspect, the embodiment of the present application provides a transaction execution method, the method is applied to the timing node TSO in the database, and the method includes:
接收CN或者DN发送的目标事务的开始时间戳获取请求;Receive the start timestamp acquisition request of the target transaction sent by CN or DN;
向CN或者DN发送目标事务的第一开始时间戳和时间戳列表,以使CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;全局一致性活跃事务信息用于CN或者DN执行目标事务,以实现全局事务的一致性。Send the first start timestamp and timestamp list of the target transaction to CN or DN, so that CN or DN can modify the local active transaction information according to the first start timestamp and timestamp list, and obtain the globally consistent active transaction corresponding to the target transaction Information; the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; the global consistency active transaction information is used for CN or DN to execute the target transaction to achieve the consistency of the global transaction sex.
第四方面,本申请实施例提供了一种事务执行方法,该方法包括:In a fourth aspect, the embodiment of the present application provides a transaction execution method, the method including:
授时节点TSO接收协调节点CN或者数据节点DN发送的目标事务的开始时间戳获取请求;The timing node TSO receives the start timestamp acquisition request of the target transaction sent by the coordination node CN or data node DN;
TSO向CN或者DN发送目标事务的第一开始时间戳和时间戳列表;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;TSO sends the first start timestamp and timestamp list of the target transaction to the CN or DN; the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp;
CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;CN or DN modifies the local active transaction information according to the first start timestamp and the timestamp list, and obtains the globally consistent active transaction information corresponding to the target transaction;
CN或者DN根据全局一致性活跃事务信息执行目标事务,以实现全局事务的一致性。CN or DN executes the target transaction according to the globally consistent active transaction information to achieve global transaction consistency.
第五方面,本申请实施例提供了一种分布式数据库系统,该系统包括上述任一实施例的协调节点CN、数据节点DN和授时节点TSO。In a fifth aspect, an embodiment of the present application provides a distributed database system, which includes the coordination node CN, data node DN, and timing node TSO in any of the above embodiments.
第六方面,本申请实施例提供了一种电子设备,包括存储器、处理器及存储在存储器上的计算机程序,处理器在执行计算机程序时实现上述任一项的方法。In a sixth aspect, the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory, and the processor implements any one of the methods above when executing the computer program.
第七方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质内存储有计算机程序,计算机程序被处理器执行时实现上述任一项的方法。In a seventh aspect, the embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, any one of the methods above is implemented.
与现有技术相比,本申请具有如下优点:Compared with the prior art, the present application has the following advantages:
本申请实施例提供了一种事务执行方法和分布式数据库系统,协调节点CN和数据节点DN利用授时节点TSO提供的目标事务的第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务。本实施例中,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The embodiment of the present application provides a transaction execution method and a distributed database system. The coordination node CN and the data node DN use the first start timestamp and timestamp list of the target transaction provided by the timing node TSO to modify the local active transaction information to obtain The globally consistent active transaction information corresponding to the target transaction; execute the target transaction according to the globally consistent active transaction information. In this embodiment, the TSO and local active transaction information are integrated, and the local active transaction information is modified according to the time stamp assigned by the TSO to achieve global transaction consistency. Through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
上述说明仅是本申请技术方案的概述,为了能够更清楚了解本申请的技术手段,可依照说明书的内容予以实施,并且为了让本申请的上述和其他目的、特征和优点能够更明显易懂,以下特举本申请的具体实施方式。The above description is only an overview of the technical solution of the present application. In order to understand the technical means of the present application more clearly, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, Specific embodiments of the present application are enumerated below.
附图说明Description of drawings
在附图中,除非另外规定,否则贯穿多个附图相同的附图标记表示相同或相似的部件或元素。这些附图不一定是按照比例绘制的。应该理解,这些附图仅描绘了根据本申请的一些实施方式,而不应将其视为是对本申请范围的限制。In the drawings, unless otherwise specified, the same reference numerals designate the same or similar parts or elements throughout the several drawings. The drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some implementations according to the application, and should not be considered as limiting the scope of the application.
图1为本申请提供的事务执行方法的场景示意图;FIG. 1 is a schematic diagram of a scenario of a transaction execution method provided by the present application;
图2为本申请一实施例的事务执行方法的流程图;FIG. 2 is a flowchart of a transaction execution method according to an embodiment of the present application;
图3为本申请一实施例的事务执行方法的流程图;FIG. 3 is a flowchart of a transaction execution method according to an embodiment of the present application;
图4为本申请一实施例的事务执行方法的流程图;FIG. 4 is a flowchart of a transaction execution method according to an embodiment of the present application;
图5为本申请一实施例的RR/SSI隔离级别的分布式事务执行过程的交互图;FIG. 5 is an interaction diagram of a distributed transaction execution process at an RR/SSI isolation level according to an embodiment of the present application;
图6为本申请一实施例的RC隔离级别的分布式事务执行过程的交互图;FIG. 6 is an interaction diagram of a distributed transaction execution process at an RC isolation level according to an embodiment of the present application;
图7为本申请一实施例的RR/SSI隔离级别的非分布式事务执行过程的交互图;FIG. 7 is an interaction diagram of a non-distributed transaction execution process at the RR/SSI isolation level according to an embodiment of the present application;
图8为本申请一实施例的RC隔离级别的非分布式事务执行过程的交互图;FIG. 8 is an interaction diagram of a non-distributed transaction execution process at an RC isolation level according to an embodiment of the present application;
图9为本申请一实施例的事务执行装置的结构框图;FIG. 9 is a structural block diagram of a transaction execution device according to an embodiment of the present application;
图10为本申请一实施例的事务执行装置的结构框图;FIG. 10 is a structural block diagram of a transaction execution device according to an embodiment of the present application;
图11为本申请一实施例的事务执行装置的结构框图;以及FIG. 11 is a structural block diagram of a transaction execution device according to an embodiment of the present application; and
图12为用来实现本申请实施例的电子设备的框图。FIG. 12 is a block diagram of an electronic device used to implement an embodiment of the present application.
具体实施方式detailed description
在下文中,仅简单地描述了某些示例性实施例。正如本领域技术人员可认识到的那样,在不脱离本申请的构思或范围的情况下,可通过各种不同方式修改所描述的实施例。因此,附图和描述被认为本质上是示例性的,而非限制性的。In the following, only some exemplary embodiments are briefly described. As those skilled in the art would realize, the described embodiments may be modified in various different ways, all without departing from the spirit or scope of the present application. Accordingly, the drawings and descriptions are to be regarded as illustrative in nature, and not restrictive.
为便于理解本申请实施例的技术方案,以下对本申请实施例的相关技术进行说明。以下相关技术作为可选方案与本申请实施例的技术方案可以进行任意结合,其均属于本申请实施例的保护范围。In order to facilitate understanding of the technical solutions of the embodiments of the present application, the related technologies of the embodiments of the present application are described below. The following related technologies may be optionally combined with the technical solutions of the embodiments of the present application as optional solutions, and all of them belong to the protection scope of the embodiments of the present application.
图1为示例性的用于实现本申请实施例的方法的一个应用场景的示意图。如图1所示,数据库系统包括授时节点(Timerstamp Oracle,TSO)、协调节点(Coordinator node,CN)1、协调节点2、数据节点(Data node,DN)1和数据节点2,其中,协调节点和数据节点可以为多个,可以根据具体需要进行配置。各节点可以部署在各自对应的设备中,授时节点可以为组件的形式,可以和协调节点或者数据节点部署在同一台设备中,也可以单独部署。协调节点或数据节点中可以存储有多个数据表,每个数据表可以用于存储一个或多个数据项。Fig. 1 is a schematic diagram of an exemplary application scenario for implementing the method of the embodiment of the present application. As shown in Figure 1, the database system includes a timing node (Timerstamp Oracle, TSO), a coordination node (Coordinator node, CN) 1, a coordination node 2, a data node (Data node, DN) 1 and a data node 2, wherein the coordination node There can be multiple and data nodes, which can be configured according to specific needs. Each node can be deployed in its corresponding device, and the timing node can be in the form of a component, which can be deployed in the same device as the coordination node or data node, or can be deployed separately. Multiple data tables can be stored in the coordinating node or data node, and each data table can be used to store one or more data items.
协调节点接收应用发送的目标事务的执行请求,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;从TSO获取目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。其中,本地活跃事务信息可以是本地活跃事务列表的快照,本地活跃事务列表中包括本地活跃事务的标识信息。目标事务可以为分布式事务,也可以为非分布式事务。事务(Transaction)是指作为单个逻辑工作单元执行的一系列操作,可以包括多个语句,要么完全执行,要么完全不执行。通过将一组相关操作组合为一个要么全部成功要么全部失败的单元,可以简化错误恢复并使应用程序更加可靠。一个逻辑工作单元要成为事务,需要满足原子性、一致性、隔离性和持久性的属性。分布式事务(Distributed Transaction)是指事务的参与者、支持事务的设备、资源设备以及事务管理器分别位于不同的分布式系统的不同节点之上。The coordinating node receives the execution request of the target transaction sent by the application, and obtains the local active transaction information; the transaction in the local active transaction information includes the uncommitted transaction; obtains the first start timestamp and timestamp list of the target transaction from the TSO, and the timestamp The list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; according to the first start timestamp and the timestamp list, modify the local active transaction information to obtain the global consistency corresponding to the target transaction Active transaction information; according to the global consistency active transaction information, execute the target transaction to achieve the consistency of the global transaction. Wherein, the local active transaction information may be a snapshot of the local active transaction list, and the local active transaction list includes identification information of the local active transaction. The target transaction can be a distributed transaction or a non-distributed transaction. Transaction (Transaction) refers to a series of operations performed as a single logical unit of work, which can include multiple statements, either completely executed or not executed at all. By grouping a set of related operations into an all-or-nothing unit, error recovery is simplified and applications are made more reliable. For a logical unit of work to be a transaction, it needs to satisfy the properties of atomicity, consistency, isolation, and durability. Distributed Transaction means that transaction participants, transaction-supporting devices, resource devices, and transaction managers are located on different nodes of different distributed systems.
若目标事务为分布式事务,则DN接收CN发送的目标事务的第一开始时间戳和时间戳列表,若目标事务为非分布式事务,则CN或DN接收TSO发送的目标事务的第一开始时间戳和时间戳列表。其中,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳。CN或DN获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。若目标事务为分布式事务,在目标事务完成准备后,CN从TSO获取提交时间戳;向数据库中的数据节点DN发送提交操作请求,提交操作请求中携带提交时间戳,在接收到DN发送的提交成功通知消息后,执行提交操作。If the target transaction is a distributed transaction, the DN receives the first start timestamp and timestamp list of the target transaction sent by the CN, and if the target transaction is a non-distributed transaction, then the CN or DN receives the first start of the target transaction sent by the TSO Timestamp and list of timestamps. Wherein, the time stamp list includes the second start time stamp of the transactions that have been prepared but not yet committed before the first start time stamp. CN or DN obtains the local active transaction information; the transactions in the local active transaction information include uncommitted transactions; according to the first start timestamp and the timestamp list, modify the local active transaction information to obtain the globally consistent active transaction corresponding to the target transaction Information; according to the global consistent active transaction information, execute the target transaction to achieve the consistency of the global transaction. If the target transaction is a distributed transaction, after the preparation of the target transaction is completed, CN obtains the submission timestamp from TSO; sends a submission operation request to the data node DN in the database, and the submission operation request carries the submission timestamp. After submitting the successful notification message, execute the submit operation.
TSO接收CN或者DN发送的目标事务的开始时间戳获取请求;向CN或者DN发送目标事务的第一开始时间戳和时间戳列表,以使CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;全局一致性活跃事务信息用于CN或者DN执行目标事务,以实现全局事务的一致性。TSO receives the start timestamp acquisition request of the target transaction sent by CN or DN; sends the first start timestamp and timestamp list of the target transaction to CN or DN, so that CN or DN according to the first start timestamp and timestamp list, Modify the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction; the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; the global consistency active transaction The information is used for CN or DN to execute the target transaction to achieve global transaction consistency.
在一种相关技术中,通过全局活跃事务表的全局事务管理器(GlobalTransaction Manager,GTM)集中式地维护集群中所有事务状态,并为各个事务生成它们的活跃事务表快照snapshot。各节点事务通过snapshot判断数据可见性,来维持全局事务一致性。然而,随着节点的增加,全局活跃事务数变大,导致snapshot数据变大,进而导致中心节点网络成为瓶颈,制约了集群的扩展性,无法扩展更多的节点,限制了分布式数据库集群的规模。In a related technology, the global transaction manager (GlobalTransaction Manager, GTM) of the global active transaction table centrally maintains the state of all transactions in the cluster, and generates snapshots of their active transaction tables for each transaction. Each node transaction judges data visibility through snapshot to maintain global transaction consistency. However, with the increase of nodes, the number of global active transactions increases, resulting in larger snapshot data, which in turn causes the central node network to become a bottleneck, restricting the scalability of the cluster, unable to expand more nodes, and limiting the distributed database cluster. scale.
在另一种相关技术中,由TSO提供单调递增的时间戳,基于时间戳实现MVCC。如果数据库内核中是基于活跃事务表的MVCC,需要重新开发MVCC机制,对内核侵入性很强,开发难度高,兼容性和稳定性不如原有MVCC机制好,同时,基于时间戳MVCC方案中,当写时间戳小于最新读时间戳时,事务将被终止(Abort),增加了并发冲突。In another related technology, TSO provides a monotonically increasing timestamp, and MVCC is implemented based on the timestamp. If the MVCC based on the active transaction table is used in the database kernel, the MVCC mechanism needs to be redeveloped, which is very intrusive to the kernel, difficult to develop, and not as good in compatibility and stability as the original MVCC mechanism. At the same time, in the timestamp-based MVCC scheme, When the write timestamp is less than the latest read timestamp, the transaction will be terminated (Abort), increasing concurrency conflicts.
另外,在基于时间戳的MVCC方案中,TSO需要为每个提交的事务分配提交时间戳,用于可见一致性判断,降低了事务执行效率。本实施例融合了活跃事务表的MVCC,每个非分布式事务提交时,在本地都已分配了事务全局标识,非分布式事务提交不需要获取提交时间戳,根据本地活跃事务表,即可完成可见一致性判断,提高了事务执行效率。In addition, in the timestamp-based MVCC scheme, TSO needs to assign a commit timestamp to each submitted transaction for visible consistency judgment, which reduces transaction execution efficiency. This embodiment integrates the MVCC of the active transaction table. When each non-distributed transaction is submitted, the transaction global identifier has been allocated locally. The non-distributed transaction submission does not need to obtain the submission timestamp. According to the local active transaction table, it can Complete the visible consistency judgment and improve the efficiency of transaction execution.
本实施例中,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。In this embodiment, the TSO and local active transaction information are integrated, and the local active transaction information is modified according to the time stamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
本申请实施例提供了一种事务执行方法,如图2所示为本申请一实施例的事务执行方法的流程图,该方法应用于数据库中的协调节点CN,该方法包括:The embodiment of the present application provides a transaction execution method, as shown in Figure 2 is a flow chart of the transaction execution method in an embodiment of the present application, the method is applied to the coordination node CN in the database, the method includes:
步骤S201,接收目标事务的执行请求,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务。Step S201, receiving an execution request of a target transaction, and acquiring local active transaction information; the transactions in the local active transaction information include uncommitted transactions.
步骤S202,从数据库中的授时节点TSO获取目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳。Step S202, obtain the first start timestamp and the timestamp list of the target transaction from the timing node TSO in the database, the timestamp list includes the second start timestamp of the transaction that has completed the preparation but has not yet completed the commit before the first start timestamp .
步骤S203,根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息。Step S203, according to the first start timestamp and the timestamp list, modify the local active transaction information to obtain globally consistent active transaction information corresponding to the target transaction.
步骤S204,根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。Step S204, execute the target transaction according to the globally consistent active transaction information, so as to realize the consistency of the global transaction.
其中,协调节点CN接收目标事务的执行请求,该执行请求可以是应用程序发送的,也可以是通过其他形式发送的。CN接收到目标事务执行请求之后,获取本地活跃事务信息,本地活跃事务信息的具体形式不作限定,例如,可以是本地活跃事务列表的快照。本地活跃事务列表中包括活跃事务的标识信息。Wherein, the coordinating node CN receives the execution request of the target transaction, and the execution request may be sent by an application program or in other forms. After the CN receives the target transaction execution request, it acquires the local active transaction information. The specific form of the local active transaction information is not limited, for example, it may be a snapshot of the local active transaction list. The local active transaction list includes the identification information of the active transaction.
其中,目标事务可以是分布式事务,也可以是非分布式事务。事务(Transaction)是指作为单个逻辑工作单元执行的一系列操作,可以包括多个语句,要么完全执行,要么完全不执行。通过将一组相关操作组合为一个要么全部成功要么全部失败的单元,可以简化错误恢复并使应用程序更加可靠。一个逻辑工作单元要成为事务,需要满足原子性、一致性、隔离性和持久性的属性。分布式事务(Distributed Transaction)是指事务的参与者、支持事务的设备、资源设备以及事务管理器分别位于不同的分布式系统的不同节点之上。分布式事务可以实现跨节点查询数据,非分布式事务是在单一节点内完成数据查询的事务。Wherein, the target transaction may be a distributed transaction or a non-distributed transaction. Transaction (Transaction) refers to a series of operations performed as a single logical unit of work, which can include multiple statements, either completely executed or not executed at all. By grouping a set of related operations into an all-or-nothing unit, error recovery is simplified and applications are made more reliable. For a logical unit of work to be a transaction, it needs to satisfy the properties of atomicity, consistency, isolation, and durability. Distributed Transaction means that transaction participants, transaction-supporting devices, resource devices, and transaction managers are located on different nodes of different distributed systems. Distributed transactions can query data across nodes, and non-distributed transactions are transactions that complete data queries within a single node.
事务的状态信息包括:执行中(Inprocess)、完成准备(prepared)、提交中(committing)、完成提交(committed)。本地活跃事务信息中包括未完成提交的事务的标识信息,未完成提交的事务包括状态信息为执行中、完成准备和提交中的事务。The status information of the transaction includes: in process (Inprocess), completed preparation (prepared), committing (committing), and completed committing (committed). The local active transaction information includes the identification information of the uncommitted transaction, and the uncommitted transaction includes the transaction whose state information is executing, completing preparation and committing.
CN向授时节点TSO发送目标事务的时间戳获取请求,接收TSO发送的目标事务的开始时间戳和时间戳列表。TSO提供全局集中授时服务,通过线性递增方式为每个事务提供开始时间戳,以及为分布式事务提供提交时间戳。CN sends the timestamp acquisition request of the target transaction to the timing node TSO, and receives the start timestamp and timestamp list of the target transaction sent by TSO. TSO provides global centralized timing services, provides start timestamps for each transaction in a linear increment manner, and provides commit timestamps for distributed transactions.
示例性的,CN根据TSO发送的开始时间戳和时间戳列表,修改本地活跃事务列表的快照,得到目标事务对应的全局一致性活跃事务列表的快照,根据全局一致性活跃事务列表的快照,执行目标事务,以实现多个事务在至少一个节点中并发执行时的数据一致性。Exemplarily, the CN modifies the snapshot of the local active transaction list according to the start timestamp and the timestamp list sent by the TSO, obtains the snapshot of the globally consistent active transaction list corresponding to the target transaction, and executes according to the snapshot of the globally consistent active transaction list Target transaction to achieve data consistency when multiple transactions are executed concurrently in at least one node.
本实施例提供的事务执行方法,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution method provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the time stamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
其中,步骤S203的具体实现方式见如下实施例:Wherein, the specific implementation of step S203 is shown in the following embodiments:
在一种可能的实现方式中,根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, the local active transaction information is modified according to the first start timestamp and the timestamp list to obtain globally consistent active transaction information corresponding to the target transaction, including:
根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息。According to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted and/or added to the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained.
在实际应用中,CN从共享缓存区间中获取事务的状态信息,事务的状态信息包括:执行中(Inprocess)、完成准备(prepared)、提交中(committing)、完成提交(committed)。根据事务的状态信息、时间戳列表中的时间戳和目标事务的开始时间戳,对事务进行筛选,将筛选出的事务的标识信息在本地活跃事务列表的快照中删除,和/或将筛选出的事务的标识信息添加到本地活跃事务列表的快照中,事务的标识信息可以是事务的全局标识xid。本实施例中,通过在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息,用于目标事务的执行,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。In practical applications, the CN obtains transaction status information from the shared cache interval, and the transaction status information includes: in-process, prepared, committed, and committed. According to the status information of the transaction, the timestamp in the timestamp list and the start timestamp of the target transaction, filter the transaction, delete the identification information of the filtered transaction in the snapshot of the local active transaction list, and/or filter out The identification information of the transaction is added to the snapshot of the local active transaction list, and the identification information of the transaction may be the global identification xid of the transaction. In this embodiment, by deleting and/or adding transactions in the local active transaction information, the globally consistent active transaction information corresponding to the target transaction is obtained, which is used for the execution of the target transaction. By modifying the local active transaction information, the stand-alone database kernel is retained The MVCC based on the active transaction table in the middle does not need the MVCC development based on the time stamp, which reduces the modification of the kernel, and avoids the concurrency conflict caused by the dislocation of the write time stamp and the read time stamp, and realizes high expansion and high compatibility of the database kernel and high stability.
其中,在本地活跃事务信息中确定需要删除的事务,具体见如下实施例:Among them, the transaction to be deleted is determined in the local active transaction information, see the following embodiments for details:
在一种可能的实现方式中,根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除事务,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, according to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted from the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained, including:
在本地活跃事务信息中,进行以下至少一项操作,得到目标事务对应的全局一致性活跃事务信息:删除状态信息为提交中且提交时间戳小于第一开始时间戳的事务;提交时间戳是从TSO获取的;删除状态信息为已完成准备且开始时间戳在时间戳列表中的事务。In the local active transaction information, perform at least one of the following operations to obtain the globally consistent active transaction information corresponding to the target transaction: delete the transaction whose status information is submitting and whose commit timestamp is less than the first start timestamp; the commit timestamp is from Obtained by TSO; delete the transaction whose status information is completed and whose start timestamp is in the timestamp list.
示例性的,遍历共享内存中的事务的状态信息,在本地活跃事务列表的快照中删除的事务包括以下至少一项:事务的状态信息为提交中,并且提交时间戳小于目标事务的开始时间戳;事务的状态信息为完成准备,并且事务的开始时间戳在时间戳列表中。Exemplarily, traversing the status information of the transactions in the shared memory, the transactions deleted in the snapshot of the local active transaction list include at least one of the following: the status information of the transaction is submitting, and the commit timestamp is less than the start timestamp of the target transaction ; The status information of the transaction is ready for completion, and the start timestamp of the transaction is in the timestamp list.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
将在本地活跃事务信息中删除的事务设置为对目标事务可见。Make transactions deleted in the local active transaction information visible to the target transaction.
在实际应用中,对从本地活跃事务列表的快照中删除的事务,执行预可见设置,因从快照中删除代表该事务对目标事务是可见的,但由于其仍未完成提交,根据全局一致性判定准则,认为数据可见,将事务提前设置为对目标事务可见。In practical applications, pre-visibility settings are performed for transactions deleted from the snapshot of the local active transaction list, because deletion from the snapshot means that the transaction is visible to the target transaction, but because it has not yet completed the commit, according to global consistency Judgment criteria, the data is considered visible, and the transaction is set in advance to be visible to the target transaction.
示例性的,全局事务一致性判定准则包括:比较一个事务的提交时间戳commit_ts和另一个事务的开始时间戳start_ts,进行可见性判定,若事务T1.commit_ts<事务T2.start_ts.判定事务T1对于事务T2可见,否则不可见。Exemplarily, the global transaction consistency judgment criterion includes: comparing the commit timestamp commit_ts of one transaction with the start timestamp start_ts of another transaction, and performing visibility judgment, if transaction T1.commit_ts<transaction T2.start_ts. Transaction T2 is visible, otherwise not.
通过全局一致性判断,从活跃事务表中删除的事务,表示这个事务已经提交,但由于对应分布式事务的两阶段提交,其提交阶段还未在本节点执行,所以本地这个事务依然在活跃事务表中。在全局一致性判定未完成提交的事务设置为可见之后,即提前将该未提交事务状态设置为提交完成。后续这个未提交事务的提交流程到来时,在事务提交流程中,不需要再次设置为可见。本实施例中,通过预先设置可见,满足了全局一致可见性判定的同时,避免了等待提交带来的低效率。Judging by the global consistency, the transaction deleted from the active transaction table indicates that the transaction has been committed, but due to the two-phase commit corresponding to the distributed transaction, the commit phase has not been executed on the local node, so the local transaction is still active table. After the global consistency determines that the uncommitted transaction is set to be visible, the uncommitted transaction status is set to commit completed in advance. When the subsequent submission process of this uncommitted transaction comes, it does not need to be set to be visible again during the transaction submission process. In this embodiment, by setting the visibility in advance, the globally consistent visibility determination is satisfied, and the inefficiency caused by waiting for submission is avoided.
其中,确定需要添加到本地活跃事务信息中的事务,具体见如下实施例:Among them, determine the transactions that need to be added to the local active transaction information, see the following embodiments for details:
在一种可能的实现方式中,根据事务的状态信息和第一开始时间戳,在本地活跃事务信息中添加事务,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, according to the status information of the transaction and the first start timestamp, the transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction, including:
确定状态信息为提交完成且提交时间戳大于第一开始时间戳的已提交事务,若已提交事务的标识号小于本地活跃事务信息中的最小标识号,且已提交事务的旧版本数据已经被清除,则终止执行目标事务,否则,将已提交事务添加到本地活跃事务信息中,得到目标事务对应的全局一致性活跃事务信息。Determine the submitted transaction whose status information is completed and the commit timestamp is greater than the first start timestamp, if the identification number of the committed transaction is less than the minimum identification number in the local active transaction information, and the old version data of the submitted transaction has been cleared , the execution of the target transaction is terminated, otherwise, the committed transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction.
在实际应用中,遍历共享内存中的事务的状态信息,筛选出状态信息为提交完成,并且提交时间戳大于目标事务的开始时间戳的已提交事务,由于事务的标识号为递增分配的,已提交事务的标识号小于本地活跃事务列表的快照中的最小标识号,则表明已提交事务的开始执行的时间早于当前的本地活跃事务信息中的事务。如果已提交事务的旧版本数据已经被清除,则终止执行目标事务。如果将其加入到活跃事务表的快照中,根据活跃事务表MVCC机制,当前版本数据对于目标事务不可见,但是旧版本数据又已经被清理,会导致数据错误。否则,将已提交事务添加到本地活跃事务列表的快照中。In practical applications, the status information of transactions in the shared memory is traversed, and the committed transactions whose status information is submitted and whose submission timestamp is greater than the start timestamp of the target transaction are filtered out. Since the identification number of the transaction is allocated incrementally, it has If the identification number of the committed transaction is less than the minimum identification number in the snapshot of the local active transaction list, it indicates that the execution time of the committed transaction is earlier than the transaction in the current local active transaction information. If the old version data of the committed transaction has been cleared, the execution of the target transaction is terminated. If it is added to the snapshot of the active transaction table, according to the MVCC mechanism of the active transaction table, the current version of the data is invisible to the target transaction, but the old version of the data has been cleaned up, which will lead to data errors. Otherwise, the committed transaction is added to the snapshot of the local list of active transactions.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
根据隔离级别,确定本地活跃事务信息的修改次数。According to the isolation level, determine the modification times of the local active transaction information.
在实际应用中,若目标事务为分布式事务,则CN需要多次修改本地活跃事务信息。In practical applications, if the target transaction is a distributed transaction, the CN needs to modify the local active transaction information multiple times.
其中,隔离级别表示一个事务必须与由其他事务进行的资源或数据更改相隔离的程度。本实施例中,隔离级别可以包括:读提交(Read Commit,RC)、可重复读(RepeatableRead,RR)和可序列化快照隔离(Serializable Snapshot Isolation,SSI)。隔离级别可以根据根据具体需要进行配置。Among them, the isolation level indicates the degree to which a transaction must be isolated from resource or data changes made by other transactions. In this embodiment, the isolation levels may include: Read Commit (Read Commit, RC), Repeatable Read (RepeatableRead, RR) and Serializable Snapshot Isolation (Serializable Snapshot Isolation, SSI). The isolation level can be configured according to specific needs.
示例性的,对于RR或者SSI隔离级别的分布式事务和非分布式事务,可以在执行事务的第一个语句时,修改本地活跃事务信息,得到全局一致性活跃事务信息,在执行事务之后的语句时,直接使用该全局一致性活跃事务信息,不需要再次生成。对于RC隔离级别的分布式事务和非分布式事务,在执行事务的每个语句时,都要修改本地活跃事务信息,生成一次全局一致性活跃事务信息。Exemplarily, for distributed transactions and non-distributed transactions at the RR or SSI isolation level, you can modify the local active transaction information when executing the first statement of the transaction to obtain globally consistent active transaction information. After executing the transaction statement, directly use the globally consistent active transaction information without regenerating it. For distributed transactions and non-distributed transactions at the RC isolation level, when each statement of the transaction is executed, the local active transaction information must be modified to generate a globally consistent active transaction information.
在一种可能的实现方式中,目标事务为分布式事务,该方法还包括:In a possible implementation manner, the target transaction is a distributed transaction, and the method further includes:
在目标事务完成准备后,从TSO获取提交时间戳;向数据库中的数据节点DN发送提交操作请求,提交操作请求中携带提交时间戳,在接收到DN发送的提交成功通知消息后,执行提交操作。After the target transaction is ready, obtain the submission timestamp from TSO; send a submission operation request to the data node DN in the database, the submission operation request carries the submission timestamp, and execute the submission operation after receiving the submission success notification message sent by DN .
在实际应用中,若目标事务为分布式事务,事务的语句执行完成需要进行提交时,向TSO发送提交时间戳获取请求,接收TSO发送的提交时间戳,向DN发送提交操作请求,提交操作请求中携带提交时间戳,DN记录提交时间戳和目标事务的标识信息,执行提交操作,提交完成后向CN发送提交成功通知消息,CN执行提交操作,并携带第一开始时间戳,同步提交目标事务的状态信息到TSO,TSO从缓存中删除已提交事务。In practical applications, if the target transaction is a distributed transaction, when the statement execution of the transaction needs to be committed, send a submission timestamp acquisition request to TSO, receive the submission timestamp sent by TSO, send a submission operation request to DN, and submit the operation request Carry the submission timestamp in DN, record the submission timestamp and the identification information of the target transaction, execute the submission operation, send a submission success notification message to CN after the submission is completed, CN executes the submission operation, and carries the first start timestamp, and submits the target transaction synchronously state information to TSO, TSO deletes the committed transaction from the cache.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
同一时间从TSO获取多个目标事务的开始时间戳或提交时间戳时,将多个时间戳获取请求合并为一个请求发送至TSO,接收TSO发送的多个目标事务的同一开始时间戳或提交时间戳。When obtaining the start timestamp or commit timestamp of multiple target transactions from TSO at the same time, combine multiple timestamp acquisition requests into one request and send it to TSO, and receive the same start timestamp or commit time of multiple target transactions sent by TSO stamp.
在实际应用中,CN中某个事务要申请开始时间戳时,有可能同时间也有其他的事务也在申请开始时间戳,也有可能另一个事务在申请提交时间戳,或者同步提交状态信息到TSO,这些操作可以合并成一个请求消息发送到TSO。TSO回复合并请求时,可以统一发送一个开始时间戳作为同一时间申请的多个事务的开始时间戳,提交时间戳同样方式处理。本实施例中,通过合并申请,可以降低申请频率,减轻TSO的压力。TSO不需要为每一个事务分配一个时间戳,可以减少TSO的压力,节省网络带宽。In practical applications, when a transaction in CN wants to apply for a start time stamp, it is possible that other transactions are also applying for a start time stamp at the same time, or another transaction may be applying for a submission time stamp, or synchronously submitting status information to TSO , these operations can be combined into one request message sent to TSO. When TSO replies to the merge request, it can uniformly send a start timestamp as the start timestamp of multiple transactions applied at the same time, and the commit timestamp is handled in the same way. In this embodiment, by merging applications, the application frequency can be reduced and the pressure on TSO can be reduced. TSO does not need to assign a timestamp to each transaction, which can reduce the pressure on TSO and save network bandwidth.
本申请实施例提供了一种事务执行方法,如图3所示为本申请一实施例的事务执行方法的流程图,该方法应用于数据库中的数据节点DN,该方法包括:The embodiment of the present application provides a transaction execution method, as shown in Figure 3 is a flow chart of the transaction execution method in an embodiment of the present application, the method is applied to the data node DN in the database, the method includes:
步骤S301,接收CN或者TSO发送的目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳。Step S301, receiving the first start time stamp and the time stamp list of the target transaction sent by the CN or TSO, the time stamp list includes the second start time stamp of the transaction that has completed the preparation but has not completed the commit before the first start time stamp.
步骤S302,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务。Step S302, acquiring local active transaction information; the transactions in the local active transaction information include uncommitted transactions.
步骤S303,根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息。Step S303, according to the first start time stamp and the time stamp list, modify the local active transaction information to obtain globally consistent active transaction information corresponding to the target transaction.
步骤S304,根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。Step S304, execute the target transaction according to the globally consistent active transaction information, so as to realize the consistency of the global transaction.
其中,若目标事务为分布式事务,则DN接收CN发送的目标事务的第一开始时间戳和时间戳列表,第一开始时间戳和时间戳列表为CN从TSO获取到的。TSO提供全局集中授时服务,通过线性递增方式为每个事务提供开始时间戳,以及为分布式事务提供提交时间戳。若目标事务为非分布式事务,则DN接收TSO发送的目标事务的第一开始时间戳和时间戳列表。Wherein, if the target transaction is a distributed transaction, the DN receives the first start timestamp and the timestamp list of the target transaction sent by the CN, and the first start timestamp and the timestamp list are acquired by the CN from the TSO. TSO provides global centralized timing services, provides start timestamps for each transaction in a linear increment manner, and provides commit timestamps for distributed transactions. If the target transaction is a non-distributed transaction, the DN receives the first start timestamp and the timestamp list of the target transaction sent by the TSO.
DN接收到第一开始时间戳和时间戳列表之后,获取本地活跃事务信息,本地活跃事务信息的具体形式不作限定,例如,可以是本地活跃事务列表的快照。本地活跃事务列表中包括活跃事务的标识信息。After receiving the first start timestamp and the timestamp list, the DN acquires local active transaction information. The specific form of the local active transaction information is not limited, for example, it may be a snapshot of the local active transaction list. The local active transaction list includes the identification information of the active transaction.
其中,目标事务可以是分布式事务,也可以是非分布式事务。事务(Transaction)是指作为单个逻辑工作单元执行的一系列操作,可以包括多个语句,要么完全执行,要么完全不执行。通过将一组相关操作组合为一个要么全部成功要么全部失败的单元,可以简化错误恢复并使应用程序更加可靠。一个逻辑工作单元要成为事务,需要满足原子性、一致性、隔离性和持久性的属性。分布式事务(Distributed Transaction)是指事务的参与者、支持事务的设备、资源设备以及事务管理器分别位于不同的分布式系统的不同节点之上。分布式事务可以实现跨节点查询数据,非分布式事务是在单一节点内完成数据查询的事务。Wherein, the target transaction may be a distributed transaction or a non-distributed transaction. Transaction (Transaction) refers to a series of operations performed as a single logical unit of work, which can include multiple statements, either completely executed or not executed at all. By grouping a set of related operations into an all-or-nothing unit, error recovery is simplified and applications are made more reliable. For a logical unit of work to be a transaction, it needs to satisfy the properties of atomicity, consistency, isolation, and durability. Distributed Transaction means that transaction participants, transaction-supporting devices, resource devices, and transaction managers are located on different nodes of different distributed systems. Distributed transactions can query data across nodes, and non-distributed transactions are transactions that complete data queries within a single node.
事务的状态信息包括:执行中(Inprocess)、完成准备(prepared)、提交中(committing)、完成提交(committed)。本地活跃事务信息中包括未完成提交的事务的标识信息,未完成提交的事务包括状态信息为执行中、完成准备和提交中的事务。The status information of the transaction includes: in process (Inprocess), completed preparation (prepared), committing (committing), and completed committing (committed). The local active transaction information includes the identification information of the uncommitted transaction, and the uncommitted transaction includes the transaction whose state information is executing, completing preparation and committing.
示例性的,DN根据CN发送的开始时间戳和时间戳列表,修改本地活跃事务列表的快照,得到目标事务对应的全局一致性活跃事务列表的快照,根据全局一致性活跃事务列表的快照,执行目标事务,以实现多个事务在至少一个节点中并发执行时的数据一致性。Exemplarily, the DN modifies the snapshot of the local active transaction list according to the start timestamp and the timestamp list sent by the CN, obtains the snapshot of the globally consistent active transaction list corresponding to the target transaction, and executes according to the snapshot of the globally consistent active transaction list Target transaction to achieve data consistency when multiple transactions are executed concurrently in at least one node.
本实施例提供的事务执行方法,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution method provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the time stamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
其中,步骤S303的具体实现方式见如下实施例:Wherein, the specific implementation of step S303 is shown in the following embodiments:
在一种可能的实现方式中,根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, the local active transaction information is modified according to the first start timestamp and the timestamp list to obtain globally consistent active transaction information corresponding to the target transaction, including:
根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息。According to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted and/or added to the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained.
在实际应用中,DN从共享缓存区间中获取事务的状态信息,事务的状态信息包括:执行中(Inprocess)、完成准备(prepared)、提交中(committing)、完成提交(committed)。根据事务的状态信息、时间戳列表中的时间戳和目标事务的开始时间戳,对事务进行筛选,将筛选出的事务的标识信息在本地活跃事务列表的快照中删除,和/或将筛选出的事务的标识信息添加到本地活跃事务列表的快照中,事务的标识信息可以是事务的全局标识xid。本实施例中,通过在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息,用于目标事务的执行,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。In practical application, the DN obtains the status information of the transaction from the shared cache interval, and the status information of the transaction includes: Inprocess, Prepared, Committing, Committed. According to the status information of the transaction, the timestamp in the timestamp list and the start timestamp of the target transaction, filter the transaction, delete the identification information of the filtered transaction in the snapshot of the local active transaction list, and/or filter out The identification information of the transaction is added to the snapshot of the local active transaction list, and the identification information of the transaction may be the global identification xid of the transaction. In this embodiment, by deleting and/or adding transactions in the local active transaction information, the globally consistent active transaction information corresponding to the target transaction is obtained, which is used for the execution of the target transaction. By modifying the local active transaction information, the stand-alone database kernel is retained The MVCC based on the active transaction table in the middle does not need the MVCC development based on the timestamp, which reduces the modification of the kernel, and avoids the concurrency conflict caused by the misalignment of the write timestamp and the read timestamp, and realizes high expansion and high compatibility of the database kernel. and high stability.
其中,在本地活跃事务信息中确定需要删除的事务,具体见如下实施例:Among them, the transaction to be deleted is determined in the local active transaction information, see the following embodiments for details:
在一种可能的实现方式中,根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除事务,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, according to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted from the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained, including:
在本地活跃事务信息中,进行以下至少一项操作,得到目标事务对应的全局一致性活跃事务信息:删除状态信息为提交中且提交时间戳小于第一开始时间戳的事务;提交时间戳是从TSO获取的;删除状态信息为已完成准备且开始时间戳在时间戳列表中的事务。In the local active transaction information, perform at least one of the following operations to obtain the globally consistent active transaction information corresponding to the target transaction: delete the transaction whose status information is submitting and whose commit timestamp is less than the first start timestamp; the commit timestamp is from Obtained by TSO; delete the transaction whose status information is completed and whose start timestamp is in the timestamp list.
示例性的,遍历共享内存中的事务的状态信息,在本地活跃事务列表的快照中删除的事务包括以下至少一项:事务的状态信息为提交中,并且提交时间戳小于目标事务的开始时间戳;事务的状态信息为完成准备,并且事务的开始时间戳在时间戳列表中。Exemplarily, traversing the status information of the transactions in the shared memory, the transactions deleted in the snapshot of the local active transaction list include at least one of the following: the status information of the transaction is submitting, and the commit timestamp is less than the start timestamp of the target transaction ; The status information of the transaction is ready for completion, and the start timestamp of the transaction is in the timestamp list.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
将在本地活跃事务信息中删除的事务设置为对目标事务可见。Make transactions deleted in the local active transaction information visible to the target transaction.
在实际应用中,对从本地活跃事务列表的快照中删除的事务,执行预可见设置,因从快照中删除代表该事务对目标事务是可见的,但由于其仍未完成提交,根据全局一致可见性判断,认为数据可见,将事务提前设置为对目标事务可见。In practical applications, pre-visibility settings are performed for transactions deleted from the snapshot of the local active transaction list, because deletion from the snapshot means that the transaction is visible to the target transaction, but because it has not yet completed the commit, it is visible according to the global consensus It is determined that the data is visible, and the transaction is set in advance to be visible to the target transaction.
通过全局一致性判断,从活跃事务表中删除的事务,表示这个事务已经提交,但由于对应分布式事务的两阶段提交,其提交阶段还未在本节点执行,所以本地这个事务依然在活跃事务表中。在全局一致性判定未完成提交的事务设置为可见之后,即提前将该未提交事务状态设置为提交完成。后续这个未提交事务的提交流程到来时,在事务提交流程中,不需要再次设置为可见。本实施例中,通过预先设置可见,满足了全局一致可见性判定的同时,避免了等待提交带来的低效率。Judging by the global consistency, the transaction deleted from the active transaction table indicates that the transaction has been committed, but due to the two-phase commit corresponding to the distributed transaction, the commit phase has not been executed on the local node, so the local transaction is still active table. After the global consistency determines that the uncommitted transaction is set to be visible, the uncommitted transaction status is set to commit completed in advance. When the subsequent submission process of this uncommitted transaction comes, it does not need to be set to be visible again during the transaction submission process. In this embodiment, by setting the visibility in advance, the globally consistent visibility determination is satisfied, and the inefficiency caused by waiting for submission is avoided.
其中,确定需要添加到本地活跃事务信息中的事务,具体见如下实施例:Among them, determine the transactions that need to be added to the local active transaction information, see the following embodiments for details:
在一种可能的实现方式中,根据事务的状态信息和第一开始时间戳,在本地活跃事务信息中添加事务,得到目标事务对应的全局一致性活跃事务信息,包括:In a possible implementation, according to the status information of the transaction and the first start timestamp, the transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction, including:
确定状态信息为提交完成且提交时间戳大于第一开始时间戳的已提交事务,若已提交事务的标识号小于本地活跃事务信息中的最小标识号,且已提交事务的旧版本数据已经被清除,则终止执行目标事务,否则,将已提交事务添加到本地活跃事务信息中,得到目标事务对应的全局一致性活跃事务信息。Determine the submitted transaction whose status information is completed and the commit timestamp is greater than the first start timestamp, if the identification number of the committed transaction is less than the minimum identification number in the local active transaction information, and the old version data of the submitted transaction has been cleared , the execution of the target transaction is terminated, otherwise, the committed transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction.
在实际应用中,遍历共享内存中的事务的状态信息,筛选出状态信息为提交完成,并且提交时间戳大于目标事务的开始时间戳的已提交事务,由于事务的标识号为递增分配的,已提交事务的标识号小于本地活跃事务列表的快照中的最小标识号,则表明已提交事务的开始执行的时间早于当前的本地活跃事务信息中的事务。如果已提交事务的旧版本数据已经被清除,则终止执行目标事务。如果将其加入到活跃事务表的快照中,根据活跃事务表MVCC机制,当前版本数据对于目标事务不可见,但是旧版本数据又已经被清理,会导致数据错误。否则,将已提交事务添加到本地活跃事务列表的快照中。In practical applications, the status information of transactions in the shared memory is traversed, and the committed transactions whose status information is submitted and whose submission timestamp is greater than the start timestamp of the target transaction are filtered out. Since the identification number of the transaction is allocated incrementally, it has If the identification number of the committed transaction is less than the minimum identification number in the snapshot of the local active transaction list, it indicates that the execution time of the committed transaction is earlier than the transaction in the current local active transaction information. If the old version data of the committed transaction has been cleared, the execution of the target transaction is terminated. If it is added to the snapshot of the active transaction table, according to the MVCC mechanism of the active transaction table, the current version data is invisible to the target transaction, but the old version data has been cleaned up, which will cause data errors. Otherwise, the committed transaction is added to the snapshot of the local list of active transactions.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
根据隔离级别,确定本地活跃事务信息的修改次数。According to the isolation level, determine the modification times of the local active transaction information.
在实际应用中,若目标事务为分布式事务,则DN需要多次修改本地活跃事务信息。In practical applications, if the target transaction is a distributed transaction, the DN needs to modify the local active transaction information multiple times.
其中,隔离级别表示一个事务必须与由其他事务进行的资源或数据更改相隔离的程度。本实施例中,隔离级别可以包括:读提交(Read Commit,RC)、可重复读(RepeatableRead,RR)和可序列化快照隔离(Serializable Snapshot Isolation,SSI)。隔离级别可以根据根据具体需要进行配置。Among them, the isolation level indicates the degree to which a transaction must be isolated from resource or data changes made by other transactions. In this embodiment, the isolation levels may include: Read Commit (Read Commit, RC), Repeatable Read (RepeatableRead, RR) and Serializable Snapshot Isolation (Serializable Snapshot Isolation, SSI). The isolation level can be configured according to specific needs.
示例性的,对于RR或者SSI隔离级别的分布式事务和非分布式事务,可以在执行事务的第一个语句时,修改本地活跃事务信息,得到全局一致性活跃事务信息,在执行事务之后的语句时,直接使用该全局一致性活跃事务信息,不需要再次生成。对于RC隔离级别的分布式事务和非分布式事务,在执行事务的每个语句时,都要修改本地活跃事务信息,生成一次全局一致性活跃事务信息。Exemplarily, for distributed transactions and non-distributed transactions at the RR or SSI isolation level, you can modify the local active transaction information when executing the first statement of the transaction to obtain globally consistent active transaction information. After executing the transaction statement, directly use the globally consistent active transaction information without regenerating it. For distributed transactions and non-distributed transactions at the RC isolation level, when each statement of the transaction is executed, the local active transaction information must be modified to generate a globally consistent active transaction information.
在一种可能的实现方式中,目标事务为分布式事务,该方法还包括:In a possible implementation manner, the target transaction is a distributed transaction, and the method further includes:
接收CN发送的提交操作请求,提交操作请求中携带目标事务的提交时间戳,记录提交时间戳,并执行提交操作,向CN发送提交成功通知消息,以使CN执行提交操作。Receive the commit operation request sent by CN, carry the commit timestamp of the target transaction in the commit operation request, record the commit timestamp, execute the commit operation, and send a commit success notification message to CN, so that CN can execute the commit operation.
在实际应用中,若目标事务为分布式事务,事务的语句执行完成需要进行提交时,CN向TSO发送提交时间戳获取请求,接收TSO发送的提交时间戳,向DN发送提交操作请求,提交操作请求中携带提交时间戳,DN接收CN发送的提交操作请求,记录提交时间戳和目标事务的标识信息,执行提交操作,提交完成后向CN发送提交成功通知消息,CN执行提交操作,并携带第一开始时间戳,同步提交目标事务的状态信息到TSO,TSO从缓存中删除已提交事务。In practical applications, if the target transaction is a distributed transaction, when the statement execution of the transaction needs to be submitted, CN sends a submission timestamp acquisition request to TSO, receives the submission timestamp sent by TSO, sends a submission operation request to DN, and submits the operation The request carries the submission timestamp, and the DN receives the submission operation request sent by the CN, records the submission timestamp and the identification information of the target transaction, executes the submission operation, and sends a submission success notification message to the CN after the submission is completed, and the CN executes the submission operation and carries the first At the beginning of the timestamp, the status information of the target transaction is synchronously submitted to the TSO, and the TSO deletes the committed transaction from the cache.
在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:
同一时间从TSO获取多个目标事务的开始时间戳或提交时间戳时,将多个时间戳获取请求合并为一个请求发送至TSO,接收TSO发送的多个目标事务的同一开始时间戳或提交时间戳。When obtaining the start timestamp or commit timestamp of multiple target transactions from TSO at the same time, combine multiple timestamp acquisition requests into one request and send it to TSO, and receive the same start timestamp or commit time of multiple target transactions sent by TSO stamp.
在实际应用中,DN中某个事务要申请开始时间戳时,有可能同时间也有其他的事务也在申请开始时间戳,也有可能另一个事务在申请提交时间戳,或者同步提交状态信息到TSO,这些操作可以合并成一个请求消息发送到TSO。TSO回复合并请求时,可以统一发送一个开始时间戳作为同一时间申请的多个事务的开始时间戳,提交时间戳同样方式处理。本实施例中,通过合并申请,可以降低申请频率,减轻TSO的压力。TSO不需要为每一个事务分配一个时间戳,可以减少TSO的压力,节省网络带宽。In practical applications, when a transaction in the DN wants to apply for a start timestamp, it is possible that other transactions are also applying for a start timestamp at the same time, or another transaction may apply for a commit timestamp, or submit status information to TSO synchronously , these operations can be combined into one request message sent to TSO. When TSO replies to the merge request, it can uniformly send a start timestamp as the start timestamp of multiple transactions applied at the same time, and the commit timestamp is handled in the same way. In this embodiment, by merging applications, the application frequency can be reduced and the pressure on TSO can be reduced. TSO does not need to assign a timestamp to each transaction, which can reduce the pressure on TSO and save network bandwidth.
本申请实施例提供了一种事务执行方法,如图4所示为本申请一实施例的事务执行方法的流程图,方法应用于数据库中的授时节点TSO,该方法包括:The embodiment of the present application provides a transaction execution method, as shown in Figure 4 is a flow chart of the transaction execution method in an embodiment of the present application, the method is applied to the timing node TSO in the database, the method includes:
步骤S401,接收CN或者DN发送的目标事务的开始时间戳获取请求。Step S401, receiving the start timestamp acquisition request of the target transaction sent by CN or DN.
步骤S402,向CN或者DN发送目标事务的第一开始时间戳和时间戳列表,以使CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;全局一致性活跃事务信息用于CN或者DN执行目标事务,以实现全局事务的一致性。Step S402, send the first start timestamp and timestamp list of the target transaction to CN or DN, so that CN or DN can modify the local active transaction information according to the first start timestamp and timestamp list, and obtain the global consistency corresponding to the target transaction Sexually active transaction information; the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; the globally consistent active transaction information is used for CN or DN to execute the target transaction to achieve global transactional consistency.
其中,若目标事务为分布式事务,则TSO接收CN发送的目标事务的开始时间戳获取请求,向CN发送目标事务的第一开始时间戳和时间戳列表。若目标事务为非分布式事务,TSO接收CN或者DN发送的目标事务的开始时间戳获取请求,向CN或者DN发送目标事务的第一开始时间戳和时间戳列表。Wherein, if the target transaction is a distributed transaction, the TSO receives the start timestamp acquisition request of the target transaction sent by the CN, and sends the first start timestamp and the timestamp list of the target transaction to the CN. If the target transaction is a non-distributed transaction, the TSO receives the start timestamp acquisition request of the target transaction sent by the CN or DN, and sends the first start timestamp and timestamp list of the target transaction to the CN or DN.
本实施例提供的事务执行方法,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution method provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the time stamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
在一种可能的实现方式中,目标事务为分布式事务,该方法还包括:In a possible implementation manner, the target transaction is a distributed transaction, and the method further includes:
接收CN发送的目标事务的提交时间戳获取请求,生成目标事务的提交时间戳发送至CN。Receive the submission timestamp acquisition request of the target transaction sent by CN, generate the submission timestamp of the target transaction and send it to CN.
在实际应用中,若目标事务为分布式事务,事务的语句执行完成需要进行提交时,CN向TSO发送提交时间戳获取请求,TSO生成目标事务的提交时间戳发送至CN,CN执行提交操作,并携带第一开始时间戳,同步提交目标事务的状态信息到TSO,TSO从缓存中删除已提交事务。In practical applications, if the target transaction is a distributed transaction, when the statement execution of the transaction needs to be submitted, CN sends a submission timestamp acquisition request to TSO, TSO generates the submission timestamp of the target transaction and sends it to CN, and CN executes the submission operation. And carry the first start time stamp, synchronously submit the state information of the target transaction to TSO, and TSO deletes the committed transaction from the cache.
在一示例中,TSO的各字段的含义以及服务功能如下:In an example, the meanings and service functions of each field of TSO are as follows:
i.数据结构:i.Data structure:
1.current_ts//用于记录当前时间戳。1.current_ts//used to record the current timestamp.
2.tso_prepared//用于缓存完成准备注册事务的start_ts。2.tso_prepared//Used to cache the start_ts for completing the registration transaction.
ii.集中授时服务:ii. Centralized time service:
1.TSO通过线性递增的方式为每个事务内SQL语句统一分配SQL语句开始时间戳start_ts=current_ts++。1. TSO uniformly assigns the SQL statement start timestamp start_ts=current_ts++ for each SQL statement in a transaction in a linearly increasing manner.
2.TSO通过线性递增的方式统一为每个完成准备的分布式事务分配提交时间戳commit_ts=current_ts++。2. TSO uniformly assigns a commit timestamp commit_ts=current_ts++ to each prepared distributed transaction in a linearly increasing manner.
iii.完成准备的事务注册管理服务:iii. Completion of the prepared transaction registration management service:
1.TSO为每个完成准备的分布式事务,提供注册服务,即分配提交时间戳commit_ts的同时,将事务的开始时间戳start_ts,即事务开启后第一条语句获得的时间戳,记录到tso_prepared中。1. TSO provides registration services for each prepared distributed transaction, that is, at the same time as assigning the commit timestamp commit_ts, the transaction start timestamp start_ts, which is the timestamp obtained by the first statement after the transaction is opened, is recorded in tso_prepared middle.
2.TSO为每个完成提交的分布式事务,提供注销服务,即注销之前申请commit_ts时记录的start_ts,即清除tso_prepared对应记录。2. TSO provides a logout service for each distributed transaction that has been submitted, that is, the start_ts recorded when applying for commit_ts before logout, that is, clearing the corresponding record of tso_prepared.
TSO为每个申请start_ts的事务,提供准备事务通知服务,即将tso_prepared中缓存的所有start_ts作为时间戳列表start_ts_plist返回给申请start_ts的事务。TSO provides a prepared transaction notification service for each transaction that applies for start_ts, that is, returns all start_ts cached in tso_prepared as a timestamp list start_ts_plist to the transaction that applies for start_ts.
在一示例中,CN或者DN修改本地活跃事务列表的快照过程中涉及的字段的含义如下:In an example, the meanings of the fields involved in the process of modifying the snapshot of the local active transaction list by CN or DN are as follows:
数据结构:data structure:
1.tso_status//用于各个节点中事务开启之后,记录TSO中事务的状态信息和全局一致性列表的快照snapshot。1.tso_status//It is used to record the status information of the transaction in TSO and the snapshot of the global consistency list after the transaction is started in each node.
2.status.//用于记录当前事务状态信息。包括Inprocess、prepared、committing和committed。2.status.//Used to record the current transaction status information. Including Inprocess, prepared, committing, and committed.
3.current_start_ts//用于记录事务的当前事务的开始时间戳。3.current_start_ts//The start timestamp of the current transaction used to record the transaction.
4.commit_ts//用于记录当前事务的提交时间戳。4.commit_ts//Used to record the commit timestamp of the current transaction.
5.snapshot//用于记录符合开始时间戳start_ts和时间戳列表start_ts_plist的本地全局一致性活跃事务表的快照。5.snapshot//Used to record the snapshot of the local global consistency active transaction table that conforms to the start timestamp start_ts and the timestamp list start_ts_plist.
6.tso_commit//用于记录完成提交之后的事务信息,包括事务的commit_ts,和对应事务的全局标识xid信息。6.tso_commit//Used to record the transaction information after the commit is completed, including the commit_ts of the transaction, and the global identifier xid information of the corresponding transaction.
在分布式事务中,每条结构化查询语言(Structured Query Language,SQL)语句在其各个参与节点采用统一的start_ts和start_ts_plist.即SQL语句开始时间戳和当前时刻TSO中注册的完成准备未完成提交的事务的开始时间戳列表。In a distributed transaction, each Structured Query Language (SQL) statement adopts a unified start_ts and start_ts_plist at each of its participating nodes. That is, the start timestamp of the SQL statement and the completed preparation registered in the TSO at the current moment are not yet submitted. A list of start timestamps for transactions.
与上述各方法实施例相对应的,本申请实施例还提供了一种事务执行方法,该方法包括:Corresponding to the above method embodiments, the embodiment of the present application also provides a transaction execution method, the method includes:
步骤S11,授时节点TSO接收协调节点CN或者数据节点DN发送的目标事务的开始时间戳获取请求。Step S11, the timing node TSO receives the start timestamp acquisition request of the target transaction sent by the coordinating node CN or the data node DN.
步骤S12,TSO向CN或者DN发送目标事务的第一开始时间戳和时间戳列表;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳。In step S12, the TSO sends the first start time stamp and the time stamp list of the target transaction to the CN or DN; the time stamp list includes the second start time stamp of the transaction that has completed the preparation but has not completed the commit before the first start time stamp.
步骤S13,CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息。In step S13, the CN or DN modifies the local active transaction information according to the first start timestamp and the timestamp list, and obtains globally consistent active transaction information corresponding to the target transaction.
步骤S14,CN或者DN根据全局一致性活跃事务信息执行目标事务,以实现全局事务的一致性。In step S14, the CN or DN executes the target transaction according to the globally consistent active transaction information, so as to achieve global transaction consistency.
其中,若目标事务为分布式事务,则TSO接收CN发送的目标事务的开始时间戳获取请求,向CN发送目标事务的第一开始时间戳和时间戳列表。若目标事务为非分布式事务,TSO接收CN或者DN发送的目标事务的开始时间戳获取请求,向CN或者DN发送目标事务的第一开始时间戳和时间戳列表。Wherein, if the target transaction is a distributed transaction, the TSO receives the start timestamp acquisition request of the target transaction sent by the CN, and sends the first start timestamp and the timestamp list of the target transaction to the CN. If the target transaction is a non-distributed transaction, the TSO receives the start timestamp acquisition request of the target transaction sent by the CN or DN, and sends the first start timestamp and timestamp list of the target transaction to the CN or DN.
协调节点CN接收目标事务的执行请求,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;从数据库中的授时节点TSO获取目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。The coordination node CN receives the execution request of the target transaction and obtains the local active transaction information; the transaction in the local active transaction information includes the uncommitted transaction; obtains the first start timestamp and timestamp list of the target transaction from the timing node TSO in the database , the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; according to the first start timestamp and the timestamp list, modify the local active transaction information to obtain the target transaction corresponding Global consistency active transaction information; according to the global consistency active transaction information, execute the target transaction to achieve global transaction consistency.
数据节点DN接收CN或者TSO发送的目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。The data node DN receives the first start timestamp and timestamp list of the target transaction sent by CN or TSO, and the timestamp list includes the second start timestamp of the transaction that has completed the preparation and has not completed the commit before the first start timestamp; obtain Local active transaction information; the transactions in the local active transaction information include uncompleted committed transactions; according to the first start timestamp and timestamp list, modify the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction; according to the global Consistency active transaction information, execute the target transaction to achieve global transaction consistency.
其中,授时节点TSO、协调节点CN和数据节点DN的具体工作过程与上述各方法实施例的过程相同,此处不再赘述。Wherein, the specific working processes of the timing node TSO, the coordinating node CN and the data node DN are the same as those of the above-mentioned method embodiments, and will not be repeated here.
本实施例提供的事务执行方法,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution method provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the time stamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
为了能够更加清晰的介绍本申请技术方案的技术思路,下面将分别按照不同隔离级别介绍分布式事务以及非分布式事务的执行流程:In order to introduce the technical idea of the technical solution of this application more clearly, the following will introduce the execution process of distributed transactions and non-distributed transactions according to different isolation levels:
图5为本申请实施例提供的RR/SSI隔离级别的分布式事务执行过程的交互图。如图5所示,执行过程包括:FIG. 5 is an interaction diagram of a distributed transaction execution process at the RR/SSI isolation level provided by the embodiment of the present application. As shown in Figure 5, the execution process includes:
步骤501,协调节点CN接收目标事务的执行请求,开始执行第一SQL语句。Step 501, the coordinating node CN receives the execution request of the target transaction, and starts to execute the first SQL statement.
步骤502,协调节点CN获取本地活跃事务列表的快照。Step 502, the coordinating node CN obtains a snapshot of the local active transaction list.
步骤503,向授时节点发送目标事务的开始时间戳获取请求。Step 503, sending a request for acquiring the start timestamp of the target transaction to the timing node.
步骤504,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 504, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤505,发送目标事务的开始时间戳和时间戳列表。Step 505, sending the start time stamp and time stamp list of the target transaction.
步骤506,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照,即全局一致性活跃事务信息。Step 506, setting the state of the target transaction as executing. According to the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list, a global snapshot is generated, that is, globally consistent active transaction information.
步骤507,发送目标事务的开始时间戳和时间戳列表。Step 507, sending the start time stamp and time stamp list of the target transaction.
步骤508,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照。Step 508, setting the status of the target transaction as executing. Generate a global snapshot based on the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list.
步骤509,发送第一SQL语句。Step 509, sending the first SQL statement.
步骤510,使用全局快照作为目标事务的快照执行第二SQL语句。Step 510, using the global snapshot as the snapshot of the target transaction to execute the second SQL statement.
步骤511,发送第二SQL语句。Step 511, sending the second SQL statement.
步骤512,使用全局快照作为目标事务的快照执行第一SQL语句。Step 512, using the global snapshot as the snapshot of the target transaction to execute the first SQL statement.
步骤513,使用全局快照作为目标事务的快照执行第二SQL语句。Step 513, using the global snapshot as the snapshot of the target transaction to execute the second SQL statement.
步骤514,发送准备提交请求消息。Step 514, sending a prepare to submit request message.
步骤515,执行目标事务准备过程,执行完成后将目标事务的状态信息设置为完成准备。Step 515, execute the preparation process of the target transaction, and set the state information of the target transaction as preparation completed after the execution is completed.
步骤516,发送准备成功通知消息。Step 516, sending a preparation success notification message.
步骤517,将目标事务的状态信息设置为完成准备。Step 517, set the status information of the target transaction as ready.
步骤518,携带目标事务的开始时间戳,申请提交时间戳。Step 518, carry the start timestamp of the target transaction, and apply for the commit timestamp.
步骤519,记录目标事务的开始时间戳,计算提交时间戳。Step 519, record the start timestamp of the target transaction, and calculate the commit timestamp.
步骤520,返回目标事务的提交时间戳。Step 520, return the commit timestamp of the target transaction.
步骤521,将目标事务的状态设置为提交中,记录提交时间戳和标识信息。Step 521, set the state of the target transaction as committing, and record the commit timestamp and identification information.
步骤522,携带提交时间戳,申请提交操作。Step 522, carry the submission time stamp, and apply for the submission operation.
步骤523,将目标事务的状态信息设置为提交中。记录目标事务的提交时间戳和标识信息,并执行提交操作,删除目标事务的状态信息。Step 523, setting the status information of the target transaction as submitting. Record the commit timestamp and identification information of the target transaction, and execute the commit operation to delete the status information of the target transaction.
步骤524,发送提交成功通知消息。Step 524, sending a submission success notification message.
步骤525,执行提交操作。Step 525, perform a submit operation.
步骤526,携带目标事务的开始时间戳,提交目标事务的状态信息。Step 526, carrying the start time stamp of the target transaction, submitting the state information of the target transaction.
步骤527,在缓存中删除已提交事务。Step 527, delete the committed transaction in the cache.
步骤528,在缓存中删除目标事务的状态信息。Step 528, delete the status information of the target transaction in the cache.
图6为本申请实施例提供的RC隔离级别的分布式事务执行过程的交互图。如图6所示,执行过程包括:FIG. 6 is an interactive diagram of the distributed transaction execution process at the RC isolation level provided by the embodiment of the present application. As shown in Figure 6, the execution process includes:
步骤601,接收目标事务的执行请求,开始执行第一SQL语句。Step 601, receiving an execution request of a target transaction, and starting to execute a first SQL statement.
步骤602,获取本地活跃事务列表的快照。Step 602, acquire a snapshot of the local active transaction list.
步骤603,向授时节点发送目标事务的开始时间戳获取请求。Step 603, sending a request for acquiring the start timestamp of the target transaction to the timing node.
步骤604,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 604, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤605,发送目标事务的开始时间戳和时间戳列表。Step 605, sending the start time stamp and time stamp list of the target transaction.
步骤606,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照,即全局一致性活跃事务信息。Step 606, setting the status of the target transaction as executing. According to the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list, a global snapshot is generated, that is, globally consistent active transaction information.
步骤607,发送目标事务的开始时间戳和时间戳列表。Step 607, sending the start time stamp and time stamp list of the target transaction.
步骤608,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照。Step 608, setting the status of the target transaction as executing. Generate a global snapshot based on the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list.
步骤609,发送第一SQL语句。Step 609, sending the first SQL statement.
步骤610,使用全局快照作为目标事务的快照执行第一SQL语句。Step 610, using the global snapshot as the snapshot of the target transaction to execute the first SQL statement.
步骤611,执行第二SQL语句,获取本地活跃事务列表的快照。Step 611, execute the second SQL statement to obtain a snapshot of the local active transaction list.
步骤612,向授时节点发送目标事务的开始时间戳获取请求。Step 612, sending a request for obtaining the start timestamp of the target transaction to the timing node.
步骤613,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 613, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤614,发送目标事务的开始时间戳和时间戳列表。Step 614, sending the start time stamp and time stamp list of the target transaction.
步骤615,根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照。Step 615: Generate a global snapshot according to the target transaction's start time stamp, the time stamp list and the snapshot of the local active transaction list.
步骤616,发送目标事务的开始时间戳和时间戳列表。Step 616, sending the start time stamp and time stamp list of the target transaction.
步骤617,根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照。Step 617, generate a global snapshot according to the snapshot of the target transaction start timestamp, timestamp list, and local active transaction list.
步骤618,发送第二SQL语句。Step 618, sending the second SQL statement.
步骤619,使用全局快照作为目标事务的快照执行第二SQL语句。Step 619, using the global snapshot as the snapshot of the target transaction to execute the second SQL statement.
步骤620,发送准备提交通知消息。Step 620, sending a ready-to-submit notification message.
步骤621,执行事务准备过程,将目标事务的状态信息设置为完成准备。Step 621, execute the transaction preparation process, and set the state information of the target transaction as preparation completed.
步骤622,发送提交成功通知消息。Step 622, sending a submission success notification message.
步骤623,将目标事务的状态信息设置为完成准备。Step 623, set the status information of the target transaction as ready.
步骤624,携带目标事务的开始时间戳,申请提交时间戳。Step 624, carry the start timestamp of the target transaction, and apply for the commit timestamp.
步骤625,记录目标事务的开始时间戳,计算提交时间戳。Step 625, record the start timestamp of the target transaction, and calculate the commit timestamp.
步骤626,返回目标事务的提交时间戳。Step 626, return the commit timestamp of the target transaction.
步骤627,将目标事务的状态信息设置为提交中,记录提交时间戳和目标事务的标识信息。Step 627, set the state information of the target transaction as submitting, and record the commit timestamp and identification information of the target transaction.
步骤628,携带提交时间戳,申请提交操作。Step 628, carry the submission time stamp, and apply for the submission operation.
步骤629,将目标事务的状态信息设置为提交中。记录目标事务的提交时间戳和标识信息,并执行提交操作,删除目标事务的状态信息。Step 629, setting the status information of the target transaction as submitting. Record the commit timestamp and identification information of the target transaction, and execute the commit operation to delete the status information of the target transaction.
步骤630,发送提交成功通知消息。Step 630, sending a submission success notification message.
步骤631,执行提交操作。Step 631, perform a submit operation.
步骤632,携带目标事务的开始时间戳,同步提交状态信息。Step 632, carry the start timestamp of the target transaction, and commit the state information synchronously.
步骤633,在缓存中删除已提交事务。Step 633, delete the committed transaction in the cache.
步骤634,在缓存中删除目标事务的状态信息。Step 634, delete the state information of the target transaction in the cache.
图7为本申请实施例提供的RR/SSI隔离级别的非分布式事务执行过程的交互图。如图7所示,执行过程包括:FIG. 7 is an interaction diagram of a non-distributed transaction execution process at the RR/SSI isolation level provided by the embodiment of the present application. As shown in Figure 7, the execution process includes:
步骤701,接收目标事务的执行请求,开始执行第一SQL语句。Step 701, receiving an execution request of a target transaction, and starting to execute a first SQL statement.
步骤702,获取本地活跃事务列表的快照。Step 702, acquire a snapshot of the local active transaction list.
步骤703,向授时节点发送目标事务的开始时间戳获取请求。Step 703, sending a request for obtaining the start timestamp of the target transaction to the timing node.
步骤704,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 704, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤705,发送目标事务的开始时间戳和时间戳列表。Step 705, sending the start time stamp and time stamp list of the target transaction.
步骤706,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照,即全局一致性活跃事务信息。Step 706, setting the state of the target transaction as executing. According to the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list, a global snapshot is generated, that is, globally consistent active transaction information.
步骤707,使用全局快照作为目标事务的快照执行第二SQL语句。Step 707, using the global snapshot as the snapshot of the target transaction to execute the second SQL statement.
步骤708,执行目标事务提交操作,删除目标事务的状态信息。Step 708, execute the commit operation of the target transaction, and delete the state information of the target transaction.
图8为本申请实施例提供的RC隔离级别的非分布式事务执行过程的交互图。如图8所示,执行过程包括:FIG. 8 is an interactive diagram of the non-distributed transaction execution process at the RC isolation level provided by the embodiment of the present application. As shown in Figure 8, the execution process includes:
步骤801,接收目标事务的执行请求,开始执行第一SQL语句。Step 801, receiving an execution request of a target transaction, and starting to execute a first SQL statement.
步骤802,获取本地活跃事务列表的快照。Step 802, acquire a snapshot of the local active transaction list.
步骤803,向授时节点发送目标事务的开始时间戳获取请求。Step 803, sending a request for obtaining the start timestamp of the target transaction to the timing node.
步骤804,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 804, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤805,发送目标事务的开始时间戳和时间戳列表。Step 805, sending the start time stamp and time stamp list of the target transaction.
步骤806,将目标事务的状态设置为执行中。根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照,即全局一致性活跃事务信息。Step 806, setting the status of the target transaction as being executed. According to the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list, a global snapshot is generated, that is, globally consistent active transaction information.
步骤807,执行第二SQL语句,获取本地活跃事务列表的快照。Step 807, execute the second SQL statement to obtain a snapshot of the local active transaction list.
步骤808,向授时节点发送目标事务的开始时间戳获取请求。Step 808, sending a request for acquiring the start timestamp of the target transaction to the timing node.
步骤809,生成目标事务的开始时间戳,从缓存中获取时间戳列表。Step 809, generate the start timestamp of the target transaction, and obtain the timestamp list from the cache.
步骤810,发送目标事务的开始时间戳和时间戳列表。Step 810, sending the start time stamp and time stamp list of the target transaction.
步骤811,根据目标事务的开始时间戳、时间戳列表和本地活跃事务列表的快照,生成全局快照。Step 811 , generate a global snapshot according to the start timestamp of the target transaction, the timestamp list and the snapshot of the local active transaction list.
步骤812,执行目标事务提交操作,删除目标事务的状态信息。Step 812, execute the commit operation of the target transaction, and delete the state information of the target transaction.
与本申请实施例提供的应用于CN的方法相对应地,本申请实施例还提供一种事务执行装置。如图9所示为本申请一实施例的事务执行装置的结构框图,可以包括:Corresponding to the method applied to the CN provided in the embodiment of the present application, the embodiment of the present application further provides a transaction execution apparatus. FIG. 9 is a structural block diagram of a transaction execution device according to an embodiment of the present application, which may include:
接收模块901,用于接收目标事务的执行请求,获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;The receiving
获取模块902,用于从数据库中的授时节点TSO获取目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;The acquiring
修改模块903,用于根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;The
执行模块904,用于根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。The
本实施例提供的事务执行装置,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution device provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the timestamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
在一种可能的实现方式中,修改模块903,用于:In a possible implementation,
根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息。According to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted and/or added to the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained.
在一种可能的实现方式中,修改模块903在根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除事务,得到目标事务对应的全局一致性活跃事务信息时,用于:In a possible implementation, the
在本地活跃事务信息中,进行以下至少一项操作,得到目标事务对应的全局一致性活跃事务信息:删除状态信息为提交中且提交时间戳小于第一开始时间戳的事务;提交时间戳是从TSO获取的;删除状态信息为已完成准备且开始时间戳在时间戳列表中的事务。In the local active transaction information, perform at least one of the following operations to obtain the globally consistent active transaction information corresponding to the target transaction: delete the transaction whose status information is submitting and whose commit timestamp is less than the first start timestamp; the commit timestamp is from Obtained by TSO; delete the transaction whose status information is completed and whose start timestamp is in the timestamp list.
在一种可能的实现方式中,装置还包括设置模块,用于:In a possible implementation manner, the device further includes a setting module, configured to:
将在本地活跃事务信息中删除的事务设置为对目标事务可见。Make transactions deleted in the local active transaction information visible to the target transaction.
在一种可能的实现方式中,修改模块903在根据事务的状态信息和第一开始时间戳,在本地活跃事务信息中添加事务,得到目标事务对应的全局一致性活跃事务信息时,用于:In a possible implementation, the
确定状态信息为提交完成且提交时间戳大于第一开始时间戳的已提交事务,若已提交事务的标识号小于本地活跃事务信息中的最小标识号,且已提交事务的旧版本数据已经被清除,则终止执行目标事务,否则,将已提交事务添加到本地活跃事务信息中,得到目标事务对应的全局一致性活跃事务信息。Determine the submitted transaction whose status information is completed and the commit timestamp is greater than the first start timestamp, if the identification number of the committed transaction is less than the minimum identification number in the local active transaction information, and the old version data of the submitted transaction has been cleared , the execution of the target transaction is terminated, otherwise, the committed transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction.
在一种可能的实现方式中,修改模块903还用于:In a possible implementation, the modifying
根据隔离级别,确定本地活跃事务信息的修改次数。According to the isolation level, determine the modification times of the local active transaction information.
在一种可能的实现方式中,目标事务为分布式事务,获取模块902还用于:In a possible implementation, the target transaction is a distributed transaction, and the
在目标事务完成准备后,从TSO获取提交时间戳;向数据库中的数据节点DN发送提交操作请求,提交操作请求中携带提交时间戳,在接收到DN发送的提交成功通知消息后,执行提交操作。After the target transaction is ready, obtain the submission timestamp from TSO; send a submission operation request to the data node DN in the database, the submission operation request carries the submission timestamp, and execute the submission operation after receiving the submission success notification message sent by DN .
在一种可能的实现方式中,该装置还包括合并模块,用于:In a possible implementation, the device further includes a merging module, configured to:
同一时间从TSO获取多个目标事务的开始时间戳或提交时间戳时,将多个时间戳获取请求合并为一个请求发送至TSO,接收TSO发送的多个目标事务的同一开始时间戳或提交时间戳。When obtaining the start timestamp or commit timestamp of multiple target transactions from TSO at the same time, combine multiple timestamp acquisition requests into one request and send it to TSO, and receive the same start timestamp or commit time of multiple target transactions sent by TSO stamp.
本申请实施例各装置中的各模块的功能可以参见上述方法中的对应描述,并具备相应的有益效果,在此不再赘述。The functions of each module in each device in the embodiment of the present application can refer to the corresponding description in the above method, and have corresponding beneficial effects, and will not be repeated here.
与本申请实施例提供的应用于DN的方法相对应地,本申请实施例还提供一种事务执行装置。如图10所示为本申请一实施例的事务执行装置的结构框图,可以包括:Corresponding to the method applied to the DN provided by the embodiment of the present application, the embodiment of the present application further provides a transaction execution apparatus. FIG. 10 is a structural block diagram of a transaction execution device according to an embodiment of the present application, which may include:
接收模块1001,用于接收CN或者TSO发送的目标事务的第一开始时间戳和时间戳列表,时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;The
获取模块1002,用于获取本地活跃事务信息;本地活跃事务信息中的事务包括未完成提交的事务;An
修改模块1003,用于根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;The modifying
执行模块1004,用于根据全局一致性活跃事务信息,执行目标事务,以实现全局事务的一致性。The
本实施例提供的事务执行装置,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution device provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the timestamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
在一种可能的实现方式中,修改模块1003,用于:In a possible implementation,
根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除和/或添加事务,得到目标事务对应的全局一致性活跃事务信息。According to the status information of the transaction, the first start timestamp and the timestamp list, the transaction is deleted and/or added to the local active transaction information, and the globally consistent active transaction information corresponding to the target transaction is obtained.
在一种可能的实现方式中,修改模块1003在根据事务的状态信息、第一开始时间戳和时间戳列表,在本地活跃事务信息中删除事务,得到目标事务对应的全局一致性活跃事务信息时,用于:In a possible implementation, the
在本地活跃事务信息中,进行以下至少一项操作,得到目标事务对应的全局一致性活跃事务信息:删除状态信息为提交中且提交时间戳小于第一开始时间戳的事务;提交时间戳是从TSO获取的;删除状态信息为已完成准备且开始时间戳在时间戳列表中的事务。In the local active transaction information, perform at least one of the following operations to obtain the globally consistent active transaction information corresponding to the target transaction: delete the transaction whose status information is submitting and whose commit timestamp is less than the first start timestamp; the commit timestamp is from Obtained by TSO; delete the transaction whose status information is completed and whose start timestamp is in the timestamp list.
在一种可能的实现方式中,装置还包括设置模块,用于:In a possible implementation manner, the device further includes a setting module, configured to:
将在本地活跃事务信息中删除的事务设置为对目标事务可见。Make transactions deleted in the local active transaction information visible to the target transaction.
在一种可能的实现方式中,修改模块1003在根据事务的状态信息和第一开始时间戳,在本地活跃事务信息中添加事务,得到目标事务对应的全局一致性活跃事务信息时,用于:In a possible implementation, the
确定状态信息为提交完成且提交时间戳大于第一开始时间戳的已提交事务,若已提交事务的标识号小于本地活跃事务信息中的最小标识号,且已提交事务的旧版本数据已经被清除,则终止执行目标事务,否则,将已提交事务添加到本地活跃事务信息中,得到目标事务对应的全局一致性活跃事务信息。Determine the submitted transaction whose status information is completed and the commit timestamp is greater than the first start timestamp, if the identification number of the committed transaction is less than the minimum identification number in the local active transaction information, and the old version data of the submitted transaction has been cleared , the execution of the target transaction is terminated, otherwise, the committed transaction is added to the local active transaction information to obtain the globally consistent active transaction information corresponding to the target transaction.
在一种可能的实现方式中,修改模块1003还用于:In a possible implementation, the modifying
根据隔离级别,确定本地活跃事务信息的修改次数。According to the isolation level, determine the modification times of the local active transaction information.
在一种可能的实现方式中,目标事务为分布式事务,接收模块1001,还用于:In a possible implementation, the target transaction is a distributed transaction, and the
接收CN发送的提交操作请求,提交操作请求中携带目标事务的提交时间戳,记录提交时间戳,并执行提交操作,向CN发送提交成功通知消息,以使CN执行提交操作。Receive the commit operation request sent by CN, carry the commit timestamp of the target transaction in the commit operation request, record the commit timestamp, execute the commit operation, and send a commit success notification message to CN, so that CN can execute the commit operation.
本申请实施例各装置中的各模块的功能可以参见上述方法中的对应描述,并具备相应的有益效果,在此不再赘述。The functions of each module in each device in the embodiment of the present application can refer to the corresponding description in the above method, and have corresponding beneficial effects, and will not be repeated here.
与本申请实施例提供的应用于TSO的方法相对应地,本申请实施例还提供一种事务执行装置。如图11所示为本申请一实施例的事务执行装置的结构框图,可以包括:Corresponding to the method applied to the TSO provided by the embodiment of the present application, the embodiment of the present application further provides a transaction execution device. FIG. 11 is a structural block diagram of a transaction execution device according to an embodiment of the present application, which may include:
接收模块1101,用于接收CN或者DN发送的目标事务的开始时间戳获取请求。The
发送模块1102,用于向CN或者DN发送目标事务的第一开始时间戳和时间戳列表,以使CN或者DN根据第一开始时间戳和时间戳列表,修改本地活跃事务信息,得到目标事务对应的全局一致性活跃事务信息;时间戳列表包括第一开始时间戳之前的已完成准备且未完成提交的事务的第二开始时间戳;全局一致性活跃事务信息用于CN或者DN执行目标事务,以实现全局事务的一致性。The sending
本实施例提供的事务执行装置,融合了TSO与本地活跃事务信息,根据TSO分配的时间戳对本地活跃事务信息进行修改,实现全局事务一致性。与相关技术相比,通过TSO全局集中授时服务,时间戳长度固定,不因事务增加而变大,不会影响分布式集群的扩展能力。而且,通过修改本地活跃事务信息,保留了单机数据库内核中基于活跃事务表的MVCC,无需基于时间戳的MVCC开发,减少了对内核的修改,同时避免了因写时间戳和读时间戳错位导致的并发冲突,实现了数据库内核高扩展,高兼容性和高稳定性。The transaction execution device provided in this embodiment integrates the TSO and local active transaction information, and modifies the local active transaction information according to the timestamp assigned by the TSO to achieve global transaction consistency. Compared with related technologies, through the TSO global centralized timing service, the length of the time stamp is fixed, and will not become larger due to the increase of transactions, and will not affect the scalability of the distributed cluster. Moreover, by modifying the local active transaction information, the MVCC based on the active transaction table in the kernel of the stand-alone database is retained, and there is no need for timestamp-based MVCC development, which reduces the modification of the kernel and avoids the misalignment of the write timestamp and the read timestamp. The concurrency conflict achieves high expansion, high compatibility and high stability of the database kernel.
在一种可能的实现方式中,目标事务为分布式事务,该装置还包括生成模块,用于:In a possible implementation, the target transaction is a distributed transaction, and the device further includes a generating module, configured to:
接收CN发送的目标事务的提交时间戳获取请求,生成目标事务的提交时间戳发送至CN。Receive the submission timestamp acquisition request of the target transaction sent by CN, generate the submission timestamp of the target transaction and send it to CN.
本申请实施例各装置中的各模块的功能可以参见上述方法中的对应描述,并具备相应的有益效果,在此不再赘述。The functions of each module in each device in the embodiment of the present application can refer to the corresponding description in the above method, and have corresponding beneficial effects, and will not be repeated here.
本申请实施例还提供了一种分布式数据库系统,系统包括上述任一实施例中的协调节点CN、数据节点DN和授时节点TSO。其中,协调节点CN、数据节点DN可以为至少一个。The embodiment of the present application also provides a distributed database system, and the system includes the coordination node CN, the data node DN and the timing node TSO in any of the above embodiments. Wherein, there may be at least one coordinating node CN and data node DN.
本申请实施例提供的系统中的各节点的功能可以参见上述方法中的对应描述,并具备相应的有益效果,在此不再赘述。For the functions of each node in the system provided by the embodiment of the present application, refer to the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.
图12为用来实现本申请实施例的电子设备的框图。如图12所示,该电子设备包括:存储器1210和处理器1220,存储器1210内存储有可在处理器1220上运行的计算机程序。处理器1220执行该计算机程序时实现上述实施例中的方法。存储器1210和处理器1220的数量可以为一个或多个。FIG. 12 is a block diagram of an electronic device used to implement an embodiment of the present application. As shown in FIG. 12 , the electronic device includes: a
该电子设备还包括:This electronic device also includes:
通信接口1230,用于与外界设备进行通信,进行数据交互传输。The
如果存储器1210、处理器1220和通信接口1230独立实现,则存储器1210、处理器1220和通信接口1230可以通过总线相互连接并完成相互间的通信。该总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(PeripheralComponent Interconnect,PCI)总线或扩展工业标准体系结构(Extended IndustryStandard Architecture,EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图12中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。If the
可选的,在具体实现上,如果存储器1210、处理器1220及通信接口1230集成在一块芯片上,则存储器1210、处理器1220及通信接口1230可以通过内部接口完成相互间的通信。Optionally, in a specific implementation, if the
本申请实施例提供了一种计算机可读存储介质,其存储有计算机程序,该程序被处理器执行时实现本申请实施例中提供的方法。The embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and implements the method provided in the embodiment of the present application when the program is executed by a processor.
本申请实施例还提供了一种芯片,该芯片包括处理器,用于从存储器中调用并运行存储器中存储的指令,使得安装有芯片的通信设备执行本申请实施例提供的方法。The embodiment of the present application also provides a chip, the chip includes a processor, configured to call and execute instructions stored in the memory from the memory, so that the communication device installed with the chip executes the method provided in the embodiment of the present application.
本申请实施例还提供了一种芯片,包括:输入接口、输出接口、处理器和存储器,输入接口、输出接口、处理器以及存储器之间通过内部连接通路相连,处理器用于执行存储器中的代码,当代码被执行时,处理器用于执行申请实施例提供的方法。The embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor, and a memory, the input interface, the output interface, the processor, and the memory are connected through an internal connection path, and the processor is used to execute the code in the memory , when the code is executed, the processor is used to execute the method provided by the embodiment of the application.
应理解的是,上述处理器可以是中央处理器(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(FieldProgrammable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者是任何常规的处理器等。值得说明的是,处理器可以是支持进阶精简指令集机器(Advanced RISC Machines,ARM)架构的处理器。It should be understood that the above-mentioned processor may be a central processing unit (Central Processing Unit, CPU), and may also be other general-purpose processors, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field Programmable Gate Array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or any conventional processor or the like. It should be noted that the processor may be a processor supporting Advanced RISC Machines (ARM) architecture.
进一步地,可选的,上述存储器可以包括只读存储器和随机访问存储器。该存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以包括只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以包括随机访问存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM均可用。例如,静态随机访问存储器(Static RAM,SRAM)、动态随机访问存储器(Dynamic Random Access Memory,DRAM)、同步动态随机访问存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机访问存储器(Double Data RateSDRAM,DDR SDRAM)、增强型同步动态随机访问存储器(Enhanced SDRAM,ESDRAM)、同步链接动态随机访问存储器(Sync link DRAM,SLDRAM)和直接内存总线随机访问存储器(DirectRambus RAM,DR RAM)。Further, optionally, the foregoing memory may include a read-only memory and a random access memory. The memory can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. Among them, the non-volatile memory can include read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), electrically programmable Erase Programmable Read-Only Memory (Electrically EPROM, EEPROM) or Flash. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, many forms of RAM are available. For example, static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic Random Access Memory, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data RateSDRAM, DDR SDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced SDRAM, ESDRAM), Synchronous Link Dynamic Random Access Memory (Sync link DRAM, SLDRAM) and Direct Memory Bus Random Access Memory (DirectRambus RAM, DR RAM).
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生依照本申请的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the present application are produced in whole or in part. A computer can be a general purpose computer, special purpose computer, computer network, or other programmable device. Computer instructions may be stored in, or transmitted from, one computer-readable storage medium to another computer-readable storage medium.
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包括于本申请的至少一个实施例或示例中。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of this specification, descriptions referring to the terms "one embodiment", "some embodiments", "example", "specific examples", or "some examples" mean that specific features described in connection with the embodiment or example , structure, material or characteristic is included in at least one embodiment or example of the present application. Furthermore, the described specific features, structures, materials or characteristics may be combined in any suitable manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine different embodiments or examples and features of different embodiments or examples described in this specification without conflicting with each other.
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或隐含地包括至少一个该特征。在本申请的描述中,“多个”的含义是两个或两个以上,除非另有明确具体的限定。In addition, the terms "first" and "second" are used for descriptive purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of these features. In the description of the present application, "plurality" means two or more, unless otherwise specifically defined.
流程图中描述的或在此以其他方式描述的任何过程或方法可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分。并且本申请的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能。Any process or method described in a flowchart or otherwise described herein may be understood as representing a module, segment, or code comprising one or more executable instructions for implementing a specific logical function or step of the process part. Also, the scope of preferred embodiments of the present application includes additional implementations in which functions may be performed out of the order shown or discussed, including substantially concurrently or in reverse order as the functions involved are involved.
在流程图中描述的或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。The logic and/or steps described in the flowcharts or otherwise described herein, for example, can be considered as a sequenced listing of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium , for use with an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, apparatus, or device and execute instructions), or in conjunction with such an instruction execution system, device or equipment.
应理解的是,本申请的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。上述实施例方法的全部或部分步骤是可以通过程序来指令相关的硬件完成,该程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。It should be understood that each part of the present application may be realized by hardware, software, firmware or a combination thereof. In the embodiments described above, various steps or methods may be implemented by software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the method in the above embodiments can be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. When the program is executed, it includes one of the steps of the method embodiment or its combination.
此外,在本申请各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。上述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读存储介质中。该存储介质可以是只读存储器,磁盘或光盘等。In addition, each functional unit in each embodiment of the present application may be integrated into one processing module, each unit may exist separately physically, or two or more units may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules. If the above-mentioned integrated modules are implemented in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk or an optical disk, and the like.
以上所述,仅为本申请的示例性实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请记载的技术范围内,可轻易想到其各种变化或替换,这些都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above is only an exemplary embodiment of the application, but the scope of protection of the application is not limited thereto, and any skilled person familiar with the technical field can easily think of its various changes within the technical scope of the application Or replacement, all of these should be covered within the scope of protection of this application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims (15)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211204699.4A CN115544037B (en) | 2022-09-29 | 2022-09-29 | Transaction execution method and distributed database system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211204699.4A CN115544037B (en) | 2022-09-29 | 2022-09-29 | Transaction execution method and distributed database system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115544037A true CN115544037A (en) | 2022-12-30 |
CN115544037B CN115544037B (en) | 2025-08-26 |
Family
ID=84732295
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211204699.4A Active CN115544037B (en) | 2022-09-29 | 2022-09-29 | Transaction execution method and distributed database system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115544037B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116107807A (en) * | 2023-01-10 | 2023-05-12 | 北京万里开源软件有限公司 | Method and device for acquiring global consistency point positions during data backup in database |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6848109B1 (en) * | 1996-09-30 | 2005-01-25 | Kuehn Eva | Coordination system |
CN110196760A (en) * | 2018-07-12 | 2019-09-03 | 腾讯科技(深圳)有限公司 | Distributed transaction consistency implementation method and device |
WO2021077934A1 (en) * | 2019-10-23 | 2021-04-29 | 广州巨杉软件开发有限公司 | Distributed transaction management method and system based on distributed logic timestamp |
CN113392157A (en) * | 2021-05-31 | 2021-09-14 | 阿里巴巴新加坡控股有限公司 | Distributed transaction processing method, device and storage medium |
CN113590273A (en) * | 2021-06-25 | 2021-11-02 | 阿里巴巴新加坡控股有限公司 | Transaction processing method, system, device and storage medium |
-
2022
- 2022-09-29 CN CN202211204699.4A patent/CN115544037B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6848109B1 (en) * | 1996-09-30 | 2005-01-25 | Kuehn Eva | Coordination system |
CN110196760A (en) * | 2018-07-12 | 2019-09-03 | 腾讯科技(深圳)有限公司 | Distributed transaction consistency implementation method and device |
WO2021077934A1 (en) * | 2019-10-23 | 2021-04-29 | 广州巨杉软件开发有限公司 | Distributed transaction management method and system based on distributed logic timestamp |
CN113392157A (en) * | 2021-05-31 | 2021-09-14 | 阿里巴巴新加坡控股有限公司 | Distributed transaction processing method, device and storage medium |
CN113590273A (en) * | 2021-06-25 | 2021-11-02 | 阿里巴巴新加坡控股有限公司 | Transaction processing method, system, device and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116107807A (en) * | 2023-01-10 | 2023-05-12 | 北京万里开源软件有限公司 | Method and device for acquiring global consistency point positions during data backup in database |
CN116107807B (en) * | 2023-01-10 | 2023-10-13 | 北京万里开源软件有限公司 | Method and device for acquiring global consistency point positions during data backup in database |
Also Published As
Publication number | Publication date |
---|---|
CN115544037B (en) | 2025-08-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3718024B1 (en) | High-throughput distributed transaction management for globally consistent sharded oltp system and method of implementing | |
US11556501B2 (en) | Determining differences between two versions of a file directory tree structure | |
CN111143389B (en) | Transaction execution method and device, computer equipment and storage medium | |
JP7549137B2 (en) | Transaction processing method, system, device, equipment, and program | |
JP7220807B2 (en) | Data reading method, device, computer device and computer program | |
US20160335310A1 (en) | Direct-connect functionality in a distributed database grid | |
CN112789606A (en) | Data redistribution method, device and system | |
US12204559B2 (en) | Database transactions across different domains | |
CN113392157A (en) | Distributed transaction processing method, device and storage medium | |
US12130796B2 (en) | Method and apparatus for distributed database transactions using global timestamping | |
CN111221907A (en) | A method and device for adding column synchronization to a database based on log parsing | |
US12235833B2 (en) | Distributed execution of transactional queries | |
CN114661690A (en) | Multiversion concurrency control and log purging methods, nodes, devices, and media | |
CN106648840B (en) | Method and device for determining time sequence between transactions | |
CN111240891A (en) | Data recovery method and device based on data consistency among multiple tables of database | |
CN111221909B (en) | Database modification column synchronization method and device based on log analysis | |
US8996484B2 (en) | Recursive lock-and-propagate operation | |
WO2024093543A1 (en) | Timestamp assignment method and apparatus applied to distributed database | |
CN115544037A (en) | Transaction execution method and distributed database system | |
CN107025257B (en) | Transaction processing method and device | |
CN114691307B (en) | Transaction processing method and computer system | |
CN113190281A (en) | ROWID interval-based initialization loading method and device | |
CN109299035B (en) | A kind of CHR file management method, system and computer readable storage medium | |
HK40037752A (en) | Transaction processing method, device and computer readable storage medium | |
HK40037752B (en) | Transaction processing method, device and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |