Movatterモバイル変換


[0]ホーム

URL:


CN112148930A - Method, system and medium for graph database system transaction processing based on RTM - Google Patents

Method, system and medium for graph database system transaction processing based on RTM
Download PDF

Info

Publication number
CN112148930A
CN112148930ACN202011041143.9ACN202011041143ACN112148930ACN 112148930 ACN112148930 ACN 112148930ACN 202011041143 ACN202011041143 ACN 202011041143ACN 112148930 ACN112148930 ACN 112148930A
Authority
CN
China
Prior art keywords
rtm
transaction
rollback
transaction processing
processing
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
Application number
CN202011041143.9A
Other languages
Chinese (zh)
Other versions
CN112148930B (en
Inventor
陈榕
李嘉麒
陈海波
臧斌宇
管海兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiao Tong University
Original Assignee
Shanghai Jiao Tong University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Jiao Tong UniversityfiledCriticalShanghai Jiao Tong University
Priority to CN202011041143.9ApriorityCriticalpatent/CN112148930B/en
Publication of CN112148930ApublicationCriticalpatent/CN112148930A/en
Application grantedgrantedCritical
Publication of CN112148930BpublicationCriticalpatent/CN112148930B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The invention discloses a graph database system transaction processing method based on RTM, which comprises the following steps: s1: using RTM to submit the transaction; s2: judging whether the transaction submission is successful, and finishing the transaction processing when the judgment result is successful; when the determination result is unsuccessful, the process proceeds to step S3: s3: judging the number of attempts, and when the number of attempts is more than or equal to the specified number, performing transaction processing by using a rollback method to finish the processing of the specified transaction; when the number of attempts is less than the specified number, the process returns to step S1. In addition, the invention discloses the system for the transaction processing of the graph database system based on the RTM and a computer readable storage medium storing a computer program. The invention completes most transactions by using RTM, compared with a large amount of expenditure and defects existing in the traditional locking mechanism, the invention realizes better graph database performance and expandability and increases the throughput of the system.

Description

Translated fromChinese
基于RTM的图数据库系统事务处理的方法、系统及介质Method, system and medium for transaction processing of graph database system based on RTM

技术领域technical field

本发明涉及图数据库系统的事务处理领域,具体地,涉及一种基于RTM的事务处理的优化型处理方法。The invention relates to the field of transaction processing of graph database systems, in particular, to an optimized processing method for RTM-based transaction processing.

背景技术Background technique

事务处理是现代图数据库系统的重要基础功能之一,其性能直接决定了整个图数据库系统的响应速度和吞吐率。现有的图数据库系统事务处理大多都基于传统锁机制进行。然而现实中的图数据复杂性较高,由于图数据表达方式的灵活性,任意数据节点之间都可能存在关联关系。假设点的数量为n,那么单一类型的关联关系即边的数量最多就能达到n2,在多类型的关系场景下,关联关系就更加丰富。Transaction processing is one of the important basic functions of modern graph database systems, and its performance directly determines the response speed and throughput of the entire graph database system. Most of the existing graph database system transaction processing is based on the traditional lock mechanism. However, the complexity of graph data in reality is high. Due to the flexibility of graph data expression, there may be associations between any data nodes. Assuming that the number of points is n, the number of a single type of association relationship, that is, the number of edges, can reach n2 at most, and in a multi-type relationship scenario, the association relationship is more abundant.

在这样的复杂数据背景下,锁机制难以达到其预期效果。粗粒度锁由于图数据的高关联性将会导致其并发执行时冲突十分严重,因为其本身也起不到多少分隔数据的作用。而粗粒度锁则更加难以实现,且容易造成难以发现的死锁等问题。另外由于图数据的幂律分布(power-law)特性,在不涉及到热节点时,其冲突可能性实际上比较小。而图数据中的大部分节点通常都不是热节点,这就导致一小部分锁竞争冲突严重,而大部分锁却基本没有发挥作用。因此在图数据库背景下,传统锁机制有着性能差、可扩展性低的缺点。In such a complex data background, the locking mechanism is difficult to achieve its expected effect. Due to the high correlation of graph data, coarse-grained locks will cause serious conflicts during concurrent execution, because they do not have much effect on separating data. Coarse-grained locks are more difficult to implement, and are prone to problems such as deadlocks that are hard to find. In addition, due to the power-law distribution of graph data, when no hot nodes are involved, the possibility of conflict is actually relatively small. Most of the nodes in the graph data are usually not hot nodes, which leads to serious contention and conflict of a small number of locks, while most of the locks are basically useless. Therefore, in the context of graph databases, traditional locking mechanisms have the disadvantages of poor performance and low scalability.

事务内存(Transactional Memory)则能够很好的解决以上问题。事务内存假设并发执行时大多数事务并不会相互冲突,只有在实际冲突时才将事务的提交取消,这假设十分实用于图数据的幂律分布特性。它通过将并行的不同进程事务化,用事务操作来代替锁机制能够显著降低编程复杂性,避免锁机制带来的缺陷,同时享受事务特性带来的好处。而RTM(即Restricted Transactional Memory,受限的事务性存储器)提供了CPU指令集级别的支持,以允许使用者方便的进行硬件事务性内存相关编程。Transactional Memory can solve the above problems very well. Transactional memory assumes that most transactions do not conflict with each other during concurrent execution, and only cancels the commit of a transaction when there is an actual conflict. This assumption is very practical for the power-law distribution characteristics of graph data. By transacting different parallel processes and replacing the lock mechanism with transaction operations, it can significantly reduce programming complexity, avoid the defects brought by the lock mechanism, and enjoy the benefits of the transaction feature. And RTM (that is, Restricted Transactional Memory, restricted transactional memory) provides support at the CPU instruction set level to allow users to easily perform hardware transactional memory-related programming.

虽然RTM相比于传统锁机制能够更加高效的处理并发程序,但由于硬件的局限性,也造成了其功能上的一些缺陷。比如某些系统事件(如中断,系统调用等)会无条件中止执行中的事务;另外,RTM维护的读写集也是有限的,如果一个RTM代码区块读写了过多数据,那么这块代码的执行就会被中止,系统状态将会回滚至RTM代码块执行之前。即使一切正常,RTM技术本身也并不保证所包含的事务一定会得到提交,所以仍然需要提供回退处理程序。通过与已有的基于锁的事务处理方法相结合,保证事务最终能够得到成功提交。Although RTM can handle concurrent programs more efficiently than traditional locking mechanisms, it also has some functional defects due to hardware limitations. For example, some system events (such as interrupts, system calls, etc.) will unconditionally abort the executing transaction; in addition, the read and write set maintained by RTM is also limited. If an RTM code block reads and writes too much data, then this code block 's execution will be aborted and the system state will be rolled back to before the execution of the RTM code block. Even if everything works, the RTM technology itself does not guarantee that the contained transaction will be committed, so a fallback handler still needs to be provided. By combining with the existing lock-based transaction processing methods, it is guaranteed that the transaction can finally be successfully committed.

因此,如何将RTM技术与传统方法相结合,发挥RTM在冲突较少情况下性能和可扩展性上的优势,避免锁机制在图数据库上的固有缺陷,并通过传统稳定方法保证事务最终能够得到处理,就成为了本领域技术人员亟待解决的技术难题。Therefore, how to combine RTM technology with traditional methods, give full play to the advantages of RTM in performance and scalability in the case of fewer conflicts, avoid the inherent defects of locking mechanism in graph databases, and ensure that transactions can eventually be obtained through traditional stable methods Processing has become a technical problem to be solved urgently by those skilled in the art.

发明内容SUMMARY OF THE INVENTION

针对现有技术的缺陷,本发明的目的是提供一种基于RTM的图数据库系统事务处理的优化型方法。In view of the defects of the prior art, the purpose of the present invention is to provide an optimized method for transaction processing of a graph database system based on RTM.

为了实现上述目的,本发明提出了如下所述的技术方案:In order to achieve the above object, the present invention proposes the following technical solutions:

第一方面,本发明提出了一种基于RTM的图数据库系统事务处理的方法,其包括步骤:In a first aspect, the present invention proposes a method for transaction processing of a graph database system based on RTM, which includes the steps:

步骤S1:进行RTM事务处理提交;Step S1: perform RTM transaction submission;

步骤S2:判断事务提交是否成功,当判断结果为成功时,则完成事务处理;当判断结果为不成功时,则进入步骤S3:Step S2: judge whether the transaction submission is successful, when the judgment result is successful, then complete the transaction processing; when the judgment result is unsuccessful, then enter step S3:

步骤S3:对事务提交的尝试次数进行判断,当尝试次数大于等于指定次数时,使用回退方法进行事务处理,以完成指定事务的处理;当尝试次数小于指定次数时,回到步骤S1。.Step S3: Judge the number of attempts of transaction submission. When the number of attempts is greater than or equal to the specified number of times, use the fallback method to perform transaction processing to complete the processing of the specified transaction; when the number of attempts is less than the specified number of times, return to step S1. .

在本发明所述的技术方案中,考虑到由于图结构数据存在大量的边作为关联信息,因此,传统基于锁机制的并发事务处理程序容易发生死锁和死锁位置难以检查等问题,因而极大地限制了应用的性能和可扩展性,而在本案发明人通过采用RTM技术对图数据库系统进行处理,从而解决了现有技术中的问题,从而使得本发明所述的方法可以在事务间数据冲突较少的场景中,通过使用RTM中的硬件事务内存来完成绝大部分事务,相比于传统锁机制存在的大量开销和不足,本发明实现了获得更好的图数据库性能、可扩展性,并增加系统的吞吐量。In the technical solution of the present invention, considering that there are a large number of edges in the graph structure data as associated information, the traditional concurrent transaction processing program based on the lock mechanism is prone to problems such as deadlock and the difficulty of checking the deadlock position. The performance and expansibility of the application are greatly limited, and the inventor of the present invention solves the problems in the prior art by using the RTM technology to process the graph database system, so that the method described in the present invention can process data between transactions. In scenarios with fewer conflicts, most transactions are completed by using the hardware transaction memory in the RTM. Compared with the large overhead and shortcomings of the traditional lock mechanism, the present invention achieves better graph database performance and scalability. , and increase the throughput of the system.

优选地,在步骤S1前还包括步骤:Preferably, before step S1, it also includes steps:

步骤S0:初始化RTM代码块参数。Step S0: Initialize RTM code block parameters.

优选地,在所述步骤S3中,所述尝试次数的阈值根据事务处理所采取的快慢方法的时间比例以及运行环境的稳定程度进行设定。Preferably, in the step S3, the threshold of the number of attempts is set according to the time ratio of the fast and slow methods adopted in the transaction processing and the stability of the operating environment.

优选地,在所述步骤S2中,在判断事务提交是否成功前,处理模块还执行以下步骤:Preferably, in the step S2, before judging whether the transaction submission is successful, the processing module further performs the following steps:

查询当前是否有回退程序正在执行当中,当存在有回退程序正在执行时,则自我阻塞等待回退程序执行完毕;Query whether there is a rollback program currently being executed, when there is a rollback program being executed, it will block itself and wait for the rollback program to finish executing;

当不存在回退程序执行时,则获取回退锁,并将其置入读写集中,进行事务处理,随后对读写集是否被改动过进行判断,当判断读写集有被改动时,则视为此次事务提交已经失败;直接进入步骤S3,当判断读写集没有被改动时,则进行事务提交后进入步骤S3。When there is no rollback program execution, the rollback lock is acquired, placed in the read-write set for transaction processing, and then it is judged whether the read-write set has been changed. When it is judged that the read-write set has been changed, Then it is considered that the transaction commit has failed; directly go to step S3, when it is judged that the read-write set has not been changed, then go to step S3 after the transaction is committed.

优选地,在所述步骤S3中,使用回退方法时,判断所述回退锁是否被线程持有,若未被持有,则获取回退锁,进行事务处理,再释放回退锁;若被其他线程持有,则需先等待回退锁被释放后再进行上述步骤。Preferably, in the step S3, when the rollback method is used, it is judged whether the rollback lock is held by the thread, if not, the rollback lock is acquired, transaction processing is performed, and then the rollback lock is released; If it is held by other threads, you need to wait for the rollback lock to be released before performing the above steps.

上述方案中,通过检查回退锁的值是否为空,以确定当前是否有其它回退程序正在执行,从而确保在回退处理程序执行过程中不会有任何RTM代码块开始执行,也同时以保证多个回退处理程序不会同时执行而产生冲突。In the above scheme, by checking whether the value of the rollback lock is empty, it is determined whether there are other rollback programs currently executing, so as to ensure that no RTM code block starts to execute during the execution of the rollback handler, and at the same time It is guaranteed that multiple fallback handlers will not execute concurrently and cause conflicts.

而当在RTM代码区块中新建变量并将回退锁赋给该代码区块时,通过读取外界的共享变量的方式,使得外界的共享变量自动置入RTM的读集中。而根据RTM管理机制的不同,将会在运行过程中或提交时对读写集中的值与外界变量进行比对检查,若产生冲突,则会产生RTM冲突异常,由此结束此次RTM执行。When a new variable is created in the RTM code block and the rollback lock is assigned to the code block, the external shared variable is automatically placed in the RTM read set by reading the external shared variable. Depending on the RTM management mechanism, the values in the read-write set and external variables will be compared and checked during the running process or at the time of submission. If there is a conflict, an RTM conflict exception will occur, thus ending the RTM execution.

并且在各个实施方式中,可以根据各实施方式的具体情况定义容许的RTM方法异常失败最大次数(即步骤S3中对尝试次数是否大于等于指定次数的判断),当连续失败超过规定指定次数的阈值时,则判断为RTM方法无法成功执行此次事务,转为使用回退处理程序。合理的阈值可以减少由系统偶然因素导致的回退处理次数,提高系统的吞吐量。其具体设置可以根据所采取的两种快慢方法的时间比例以及运行环境的稳定程度自行设定,比如20。And in each embodiment, the allowable maximum number of abnormal failures of the RTM method can be defined according to the specific situation of each embodiment (that is, the judgment of whether the number of attempts is greater than or equal to the specified number of times in step S3), when the continuous failure exceeds the specified number of times. , it is judged that the RTM method cannot successfully execute the transaction, and the fallback handler is used instead. A reasonable threshold can reduce the number of back-off processing caused by the accidental factors of the system and improve the throughput of the system. The specific setting can be set by yourself according to the time ratio of the two speed methods and the stability of the operating environment, such as 20.

考虑到RTM本身并不保证所包含的事务最终一定会得到成功提交,因此,在一些实施方式中,可以使用最稳定的方法来作为回退处理程序,以保证程序整体的成功提交率,例如:使用传统的锁机制事务处理作为回退处理程序,当然一些其它能够稳定进行事务处理的方法,只要速度在可接受范围内,显然也是可以进行替代的。Considering that the RTM itself does not guarantee that the included transaction will be successfully committed eventually, in some embodiments, the most stable method can be used as the fallback handler to ensure the overall successful commit rate of the program, for example: Using the traditional lock mechanism transaction processing as the fallback handler, of course, some other methods that can stably perform transaction processing, as long as the speed is within an acceptable range, obviously can be replaced.

优选地,所述回退锁为粗粒度锁,粒度值为表级。Preferably, the rollback lock is a coarse-grained lock, and the granularity value is table level.

第二方面,本发明提出了一种基于RTM的图数据库系统事务处理的系统,所述系统包括:In the second aspect, the present invention proposes a system for transaction processing of a graph database system based on RTM, the system comprising:

存储模块,所述存储模块存储数据;a storage module, the storage module stores data;

以及处理模块,所述处理模块执行上述的方法。and a processing module, the processing module executes the above-mentioned method.

优选地,所述处理模块采用内嵌于处理器中的指令集实现,例如可以采用Intel发布的内嵌于其处理器中的硬件事务内存功能。Preferably, the processing module is implemented using an instruction set embedded in the processor, for example, the hardware transactional memory function embedded in the processor issued by Intel may be used.

第三方面,本发明提出了一种存储有计算机程序的计算机可读存储介质,所述计算机程序被处理执行时实现上述的基于RTM的图数据库系统事务处理的方法。In a third aspect, the present invention provides a computer-readable storage medium storing a computer program, and when the computer program is processed and executed, the above-mentioned method for transaction processing of a graph database system based on RTM is implemented.

与现有技术相比,本发明具有如下的有益效果:Compared with the prior art, the present invention has the following beneficial effects:

1、本发明通过使用RTM来进行图数据库的大部分事务处理,避免了锁机制本身的缺陷,诸如优先级反转、死锁、活锁等一系列问题所带来的图数据库性能问题,同时,也避免了锁机制本身的高额开销。由于通过RTM来取代软件实现的锁机制,在数据冲突较少的图数据库场景下,能获得比锁机制更好更快的性能,提高整个图数据库系统的吞吐率,大大降低事务执行的延迟。1. The present invention uses RTM to perform most of the transaction processing of the graph database, avoiding the defects of the lock mechanism itself, such as the performance problems of the graph database caused by a series of problems such as priority inversion, deadlock, livelock, etc. , and also avoids the high overhead of the locking mechanism itself. Since the software-implemented lock mechanism is replaced by RTM, better and faster performance can be obtained than the lock mechanism in the graph database scenario with less data conflicts, the throughput of the entire graph database system is improved, and the transaction execution delay is greatly reduced.

2、本发明通过将新的基于的RTM事务处理方法与传统的基于锁的事务处理方法相结合,解决了RTM并不会确保事务一定会被提交的缺陷,同时获得了RTM本身的优势。在最差情况下,新的结合方法性能将会与传统方法相当。2. By combining the new RTM-based transaction processing method with the traditional lock-based transaction processing method, the present invention solves the defect that RTM does not ensure that the transaction will be committed, and at the same time obtains the advantages of RTM itself. In the worst case, the performance of the new combined method will be comparable to the traditional method.

附图说明Description of drawings

通过阅读参照以下附图对非限制性实施例所作的详细描述,本发明的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present invention will become more apparent by reading the detailed description of non-limiting embodiments with reference to the following drawings:

图1为本发明所述的基于RTM的图数据库系统事务处理的方法在一种实施方式中的总体逻辑流程图;Fig. 1 is the overall logic flow chart of the method for transaction processing in an RTM-based graph database system according to an embodiment of the present invention;

图2示意性地显示了本发明所述的基于RTM的图数据库系统事务处理的方法在一种实施方式中的RTM的部分逻辑流程;Fig. 2 schematically shows a part of the logic flow of the RTM in an embodiment of the method for transaction processing of the RTM-based graph database system according to the present invention;

图3示意性地显示了本发明所述的基于RTM的图数据库系统事务处理的方法在一种实施方式中的回退程序的部分逻辑。FIG. 3 schematically shows part of the logic of the fallback procedure in an embodiment of the method for transaction processing of the RTM-based graph database system according to the present invention.

具体实施方式Detailed ways

下面结合具体实施例对本发明进行详细说明。以下实施例将有助于本领域的技术人员进一步理解本发明,但不以任何形式限制本发明。应当指出的是,对本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进。这些都属于本发明的保护范围。The present invention will be described in detail below with reference to specific embodiments. The following examples will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

实施例1Example 1

需要说明的是,在本实施例中,RTM采用的是Intel,但需要指出的是,所有支持RTM指令集的处理器皆可用于本发明所述的技术方案。It should be noted that, in this embodiment, the RTM adopts Intel, but it should be pointed out that all processors supporting the RTM instruction set can be used for the technical solution described in the present invention.

图1为本发明所述的基于RTM的图数据库系统事务处理的方法在一种实施方式中的总体逻辑流程图。FIG. 1 is an overall logic flow chart of the method for transaction processing in an RTM-based graph database system according to an embodiment of the present invention.

如图1所示,在本实施例中,方法包括如下步骤:As shown in Figure 1, in this embodiment, the method includes the following steps:

步骤S1:使用RTM进行事务处理提交;Step S1: use RTM for transaction submission;

步骤S2:判断事务提交是否成功,当判断结果为成功时,则完成事务处理;当判断结果为不成功时,则进入步骤S3:Step S2: judge whether the transaction submission is successful, when the judgment result is successful, then complete the transaction processing; when the judgment result is unsuccessful, then enter step S3:

步骤S3:对事务提交的尝试次数进行判断,当尝试次数大于等于指定次数时,使用回退方法进行事务处理,以完成指定事务的处理;当尝试次数小于指定次数时,回到步骤S1。.Step S3: Judge the number of attempts of transaction submission. When the number of attempts is greater than or equal to the specified number of times, use the fallback method to perform transaction processing to complete the processing of the specified transaction; when the number of attempts is less than the specified number of times, return to step S1. .

其中,步骤S1进行事务处理提交时,采用的是RTM进行事务处理,关于该步骤的流程可以参见图2。Wherein, when the transaction processing is submitted in step S1, the RTM is used to perform the transaction processing. For the flow of this step, please refer to FIG. 2 .

如图2所示,使用RTM进行事务处理时,执行如下步骤:As shown in Figure 2, when using RTM for transaction processing, the following steps are performed:

S1.1:程序读取回退锁并判断当前是否被占用,若回退锁未被占用则程序调用_xbegin()方法进入RTM代码区块并进入S1.2,若回退锁已被占用则调用_xabort()方法显示中断此次RTM调用,并进入S2.1。S1.1: The program reads the rollback lock and determines whether it is currently occupied. If the rollback lock is not occupied, the program callsthe _xbegin( ) method to enter the RTM code block and enters S1.2. If the rollback lock is occupied Then call the _xabort() method to interrupt the RTM call and enter S2.1.

S1.2:在RTM代码区块中存入回退锁,使得它被置入读写集之中。S1.2: Store the rollback lock in the RTM code block so that it is placed in the read-write set.

S1.3:进行具体的事务处理代码部分执行。S1.3: Partial execution of specific transaction processing code.

S1.4:调用_xend()方法尝试提交,此时RTM会自动比对判断读写集中的所有内容包括回退锁是否被修改过,如果被修改,则强制中断此次RTM操作并视为此次事务处理失败。如若未被修改,则能够进入提交步骤。S1.4: Call the _xend() method to try to submit. At this time, the RTM will automatically compare and determine whether all the contents in the read-write set, including the rollback lock, have been modified. If modified, the RTM operation will be forced to be interrupted and treated as This transaction failed. If it has not been modified, you can enter the submission step.

需要注意的是,在RTM代码区域执行部分,如果其中所需要保存的值数量和大小超出了读写集的最大值,又或是任何类型的系统中断发生时,此次RTM操作将会被强制中断,视为一次事务处理失败。所以需要保证RTM区块中所涉及到的数据都是必要的,即尽可能减少此次事务所涉及到的需要读写的数据量,另外减少一次RTM代码区域的操作量,也能够显著减少执行过程中系统中断的发生可能性。必要时也可以将一次大的RTM操作拆分成若干次小的RTM操作进行执行。It should be noted that in the execution part of the RTM code area, if the number and size of the values that need to be saved exceeds the maximum value of the read-write set, or any type of system interrupt occurs, the RTM operation will be forced. Interrupted, regarded as a transaction failure. Therefore, it is necessary to ensure that the data involved in the RTM block is necessary, that is, to minimize the amount of data that needs to be read and written involved in this transaction, and to reduce the amount of operations in the RTM code area, which can also significantly reduce execution The possibility of a system interruption during the process. If necessary, a large RTM operation can also be split into several small RTM operations for execution.

使用回退处理程序进行事务处理的步骤如图3所示:The steps for transaction processing using a fallback handler are shown in Figure 3:

S2.1:程序读取回退锁,并判断当前是否被其它线程所占用。S2.1: The program reads the rollback lock and determines whether it is currently occupied by other threads.

S2.2:若回退锁当前若未被占用,则进入步骤2.3;若回退锁当前已被占用,则自我阻塞直到回退锁被释放。S2.2: If the rollback lock is not currently occupied, go to step 2.3; if the rollback lock is currently occupied, block itself until the rollback lock is released.

S2.3:程序取得并占用回退锁,然后进行具体的事务处理代码部分。S2.3: The program obtains and occupies the rollback lock, and then performs the specific transaction processing code part.

S2.4:提交事务,并释放回退锁。S2.4: Commit the transaction and release the rollback lock.

为了保证代码的低复杂度和回退处理程序的稳定性,回退处理程序通常为基于粗粒度锁实现的事务处理方法。在极大多数情况下,回退处理程序不应当被调用。大量的调用回退处理程序将使整个系统的性能回退至传统粗粒度锁方案上。另外此段方法应该保证,在系统正常运行情况下,事务在多次RTM方法执行尝试失败后能够依托回退处理程序稳定完成提交。In order to ensure the low complexity of the code and the stability of the fallback handler, the fallback handler is usually a transaction processing method implemented based on coarse-grained locks. In the vast majority of cases, fallback handlers should not be called. A large number of calls to fallback handlers will cause the performance of the entire system to fall back to traditional coarse-grained locking schemes. In addition, this method should ensure that under the normal operation of the system, the transaction can rely on the fallback handler to stably complete the submission after multiple RTM method execution attempts fail.

此外,需要说明的是,_xbegin()、_xabort()以及_xend()为Intel新处理器中的内置API(应用程序编程接口),其计算以及处理过程为本领域内技术人员所知晓,因此,在此不再赘述。In addition, it should be noted that _xbegin(), _xabort() and _xend() are built-in APIs (application programming interfaces) in new Intel processors, and their calculation and processing procedures are known to those skilled in the art, therefore , and will not be repeated here.

实施例2Example 2

在本实施例中,提供了一种基于RTM的图数据库系统事务处理的系统,所述系统包括:In this embodiment, an RTM-based graph database system transaction processing system is provided, and the system includes:

存储模块,所述存储模块存储数据;a storage module, the storage module stores data;

以及处理模块,所述处理模块执行如下所述步骤的方法:And a processing module, the processing module performs a method of the steps described below:

步骤S0:初始化RTM代码块参数;Step S0: initialize RTM code block parameters;

步骤S1:使用RTM进行事务处理提交;Step S1: use RTM for transaction submission;

步骤S2:判断事务提交是否成功,当判断结果为成功时,则完成事务处理;当判断结果为不成功时,则进入步骤S3:Step S2: judge whether the transaction submission is successful, when the judgment result is successful, then complete the transaction processing; when the judgment result is unsuccessful, then enter step S3:

步骤S3:对事务提交的尝试次数进行判断,当尝试次数大于等于指定次数时,使用回退方法进行事务处理,以完成指定事务的处理;当尝试次数小于指定次数时,回到步骤S1,其中,尝试次数的阈值根据事务处理所采取的快慢方法的时间比例以及运行环境的稳定程度进行设定,例如在本实施例中,其数值可以设置为20。.Step S3: Judging the number of attempts of transaction submission, when the number of attempts is greater than or equal to the specified number of times, use the fallback method to perform transaction processing to complete the processing of the specified transaction; when the number of attempts is less than the specified number of times, go back to step S1, wherein , the threshold of the number of attempts is set according to the time ratio of the fast-slow method adopted by the transaction processing and the stability of the operating environment. For example, in this embodiment, the value may be set to 20. .

并且,在所述步骤S2中,判断事务提交是否成功时,处理模块还执行以下步骤:Moreover, in the step S2, when judging whether the transaction submission is successful, the processing module also performs the following steps:

查询当前是否有回退程序正在执行当中,当存在有回退程序正在执行时,则自我阻塞等待回退程序执行完毕;Query whether there is a rollback program currently being executed, when there is a rollback program being executed, it will block itself and wait for the rollback program to finish executing;

当不存在回退程序执行时,则获取回退锁,并将其置入读写集中,进行事务处理,随后对读写集是否被改动过进行判断,当判断读写集有被改动时,则视为此次事务提交已经失败;直接进入步骤S3,当判断读写集没有被改动时,则进行事务提交后进入步骤S3。When there is no rollback program execution, the rollback lock is acquired, placed in the read-write set for transaction processing, and then it is judged whether the read-write set has been changed. When it is judged that the read-write set has been changed, Then it is considered that the transaction commit has failed; directly go to step S3, when it is judged that the read-write set has not been changed, then go to step S3 after the transaction is committed.

此外,在所述步骤S3中,使用回退方法时,判断所述回退锁是否被线程持有,若未被持有,则获取回退锁,进行事务处理,再释放回退锁;若被其他线程持有,则需先等待回退锁被释放后再进行上述步骤。In addition, in the step S3, when using the rollback method, it is judged whether the rollback lock is held by the thread, if not, the rollback lock is acquired, transaction processing is performed, and then the rollback lock is released; If it is held by other threads, you need to wait for the rollback lock to be released before performing the above steps.

在本实施例中,处理模块采用内嵌于处理器中的指令集实现。In this embodiment, the processing module is implemented using an instruction set embedded in the processor.

综上所述,本发明提出的基于RTM的图数据库系统事务处理优化型方法,能够在最大程度上避免RTM和锁机制两者的缺陷的同时,保留两种方法的优点。在数据冲突较少的图数据库场景中,这种结合性方法能够获得比传统方法更高的吞吐率和更好的性能。To sum up, the RTM-based graph database system transaction processing optimization method proposed by the present invention can avoid the defects of both the RTM and the lock mechanism to the greatest extent, while retaining the advantages of the two methods. In graph database scenarios with fewer data conflicts, this associative approach can achieve higher throughput and better performance than traditional methods.

以上对本发明的具体实施例进行了描述。需要理解的是,本发明并不局限于上述特定实施方式,本领域技术人员可以在权利要求的范围内做出各种变化或修改,这并不影响本发明的实质内容。在不冲突的情况下,本申请的实施例和实施例中的特征可以任意相互组合。Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above-mentioned specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essential content of the present invention. The embodiments of the present application and features in the embodiments may be combined with each other arbitrarily, provided that there is no conflict.

Claims (9)

Translated fromChinese
1.一种基于RTM的图数据库系统事务处理的方法,其特征在于,包括步骤:1. a method based on the graph database system transaction processing of RTM, is characterized in that, comprises the steps:步骤S1:进行RTM事务处理提交;Step S1: perform RTM transaction submission;步骤S2:使用RTM判断事务提交是否成功,当判断结果为成功时,则完成事务处理;当判断结果为不成功时,则进入步骤S3:Step S2: use RTM to judge whether the transaction submission is successful, when the judgment result is successful, then complete the transaction processing; when the judgment result is unsuccessful, then enter step S3:步骤S3:对事务提交的尝试次数进行判断,当尝试次数大于等于指定次数时,使用回退方法进行事务处理,以完成指定事务的处理;当尝试次数小于指定次数时,回到步骤S1。.Step S3: Judge the number of attempts of transaction submission. When the number of attempts is greater than or equal to the specified number of times, use the fallback method to perform transaction processing to complete the processing of the specified transaction; when the number of attempts is less than the specified number of times, return to step S1. .2.根据权利要求1所述的方法,其特征在于,在步骤S1前还包括步骤:2. method according to claim 1, is characterized in that, also comprises step before step S1:步骤S0:初始化RTM代码块参数。Step S0: Initialize RTM code block parameters.3.根据权利要求1所述的方法,其特征在于,在所述步骤S3中,尝试次数的阈值根据事务处理所采取的快慢方法的时间比例以及运行环境的稳定程度进行设定。3 . The method according to claim 1 , wherein, in the step S3 , the threshold of the number of attempts is set according to the time ratio of the fast and slow methods adopted in the transaction processing and the stability of the operating environment. 4 .4.根据权利要求1-3中任意一项所述的方法,其特征在于,在所述步骤S2中,在判断事务提交是否成功前,处理模块还执行以下步骤:4. The method according to any one of claims 1-3, wherein, in the step S2, before judging whether the transaction submission is successful, the processing module also performs the following steps:查询当前是否有回退程序正在执行当中,当存在有回退程序正在执行时,则自我阻塞等待回退程序执行完毕;Query whether there is a rollback program currently being executed, when there is a rollback program being executed, it will block itself and wait for the rollback program to finish executing;当不存在回退程序执行时,则获取回退锁,并将其置入读写集中,进行事务处理,随后对读写集是否被改动过进行判断,当判断读写集有被改动时,则视为此次事务提交已经失败,直接进入步骤S3;当判断读写集没有被改动时,则进行事务提交后进入步骤S3。When there is no rollback program execution, the rollback lock is acquired and placed in the read-write set for transaction processing, and then it is judged whether the read-write set has been changed. When it is judged that the read-write set has been changed, It is considered that the transaction submission has failed, and the process directly proceeds to step S3; when it is judged that the read-write set has not been changed, the transaction is submitted and then proceeds to step S3.5.根据权利要求4所述的方法,其特征在于,在所述步骤S3中,使用回退方法时,判断所述回退锁是否被其他线程持有,若未被持有,则获取回退锁,进行事务处理,再释放回退锁;若被其他线程持有,则需先等待回退锁被释放后再进行上述步骤。5. The method according to claim 4, characterized in that, in the step S3, when using the rollback method, it is judged whether the rollback lock is held by other threads, and if it is not held, the rollback lock is obtained. Unlock, perform transaction processing, and then release the rollback lock; if it is held by other threads, you need to wait for the rollback lock to be released before performing the above steps.6.根据权利要求4所述的方法,其特征在于,所述回退锁为粗粒度锁,粒度值为表级。6 . The method according to claim 4 , wherein the rollback lock is a coarse-grained lock, and the granularity value is table level. 7 .7.一种基于RTM的图数据库系统事务处理的系统,其特征在于,所述系统包括:7. A system for RTM-based graph database system transaction processing, wherein the system comprises:存储模块,所述存储模块存储数据;a storage module, the storage module stores data;以及处理模块,所述处理模块执行如权利要求1-6中任意一项所述的方法。and a processing module that performs the method of any one of claims 1-6.8.根据权利要求7所述的图数据库系统事务处理的系统,其特征在于,所述处理模块采用内嵌于处理器中的指令集实现。8. The system for graph database system transaction processing according to claim 7, wherein the processing module is implemented by an instruction set embedded in the processor.9.一种存储有计算机程序的计算机可读存储介质,其特征在于,所述计算机程序被处理执行时实现权利要求1-6中任意一项所述的基于RTM的图数据库系统事务处理的方法。9. A computer-readable storage medium storing a computer program is characterized in that, when the computer program is processed and executed, the RTM-based graph database system transaction processing method described in any one of claims 1-6 is realized .
CN202011041143.9A2020-09-282020-09-28Method, system and medium for graph database system transaction processing based on RTMActiveCN112148930B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202011041143.9ACN112148930B (en)2020-09-282020-09-28Method, system and medium for graph database system transaction processing based on RTM

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202011041143.9ACN112148930B (en)2020-09-282020-09-28Method, system and medium for graph database system transaction processing based on RTM

Publications (2)

Publication NumberPublication Date
CN112148930Atrue CN112148930A (en)2020-12-29
CN112148930B CN112148930B (en)2023-01-06

Family

ID=73895718

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202011041143.9AActiveCN112148930B (en)2020-09-282020-09-28Method, system and medium for graph database system transaction processing based on RTM

Country Status (1)

CountryLink
CN (1)CN112148930B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20100138836A1 (en)*2008-12-032010-06-03David DiceSystem and Method for Reducing Serialization in Transactional Memory Using Gang Release of Blocked Threads
US20110099335A1 (en)*2005-12-092011-04-28University Of RochesterSystem and method for hardware acceleration of a software transactional memory
US20110119452A1 (en)*2009-11-162011-05-19International Business Machines Corporation Hybrid Transactional Memory System (HybridTM) and Method
US20140310236A1 (en)*2013-04-152014-10-16International Business Machines CorporationOut-of-Order Execution of Strictly-Ordered Transactional Workloads
US20150242277A1 (en)*2014-02-272015-08-27International Business Machines CorporationSalvaging hardware transactions with instructions
WO2018194237A1 (en)*2017-04-212018-10-25전북대학교산학협력단Method and device for processing transaction in hybrid transactional memory system
CN110515707A (en)*2019-08-222019-11-29上海交通大学 Deterministic concurrency control method and system based on pre-transaction processing
US20200125392A1 (en)*2018-10-172020-04-23International Business Machines CorporationFilesystem using hardware transactional memory on non-volatile dual in-line memory module

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20110099335A1 (en)*2005-12-092011-04-28University Of RochesterSystem and method for hardware acceleration of a software transactional memory
US20100138836A1 (en)*2008-12-032010-06-03David DiceSystem and Method for Reducing Serialization in Transactional Memory Using Gang Release of Blocked Threads
US20110119452A1 (en)*2009-11-162011-05-19International Business Machines Corporation Hybrid Transactional Memory System (HybridTM) and Method
US20140310236A1 (en)*2013-04-152014-10-16International Business Machines CorporationOut-of-Order Execution of Strictly-Ordered Transactional Workloads
US20150242277A1 (en)*2014-02-272015-08-27International Business Machines CorporationSalvaging hardware transactions with instructions
WO2018194237A1 (en)*2017-04-212018-10-25전북대학교산학협력단Method and device for processing transaction in hybrid transactional memory system
US20200125392A1 (en)*2018-10-172020-04-23International Business Machines CorporationFilesystem using hardware transactional memory on non-volatile dual in-line memory module
CN110515707A (en)*2019-08-222019-11-29上海交通大学 Deterministic concurrency control method and system based on pre-transaction processing

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
CHARLES.F: "初识事务内存(Transactional Memory)", 《知乎》*
HILLEL AVNI等: "面向数据库的持久化事务内存", 《计算机研究与发展》*
李从午等: "事务内存机制在系统安全中的应用:现状与展望", 《信息安全学报》*
王大海等: "一种多粒度集群数据库并发控制新算法", 《河北工程大学学报(自然科学版)》*

Also Published As

Publication numberPublication date
CN112148930B (en)2023-01-06

Similar Documents

PublicationPublication DateTitle
US8881153B2 (en)Speculative thread execution with hardware transactional memory
JP5964382B2 (en) Performing mode switching in an infinite transactional memory (UTM) system
US8417897B2 (en)System and method for providing locale-based optimizations in a transactional memory
US9513959B2 (en)Contention management for a hardware transactional memory
JP2500101B2 (en) How to update the value of a shared variable
US9727369B2 (en)System and method for implementing reader-writer locks using hardware transactional memory
US8468526B2 (en)Concurrent thread execution using user-level asynchronous signaling
RU2501071C2 (en)Late lock acquire mechanism for hardware lock elision (hle)
US20090031310A1 (en)System and Method for Executing Nested Atomic Blocks Using Split Hardware Transactions
KR20160113207A (en)Enabling maximum concurrency in a hybrid transactional memory system
US8103838B2 (en)System and method for transactional locking using reader-lists
CN105955801B (en)A kind of distributed optimistic concurrency control method based on RDMA and HTM
Dhoked et al.An adaptive approach to recoverable mutual exclusion
EP2641171A1 (en)Preventing unintended loss of transactional data in hardware transactional memory systems
US10346196B2 (en)Techniques for enhancing progress for hardware transactional memory
CN109901913B (en) A multi-threaded transaction storage programming model method with controllable repeated execution times
WO2024098363A1 (en)Multicore-processor-based concurrent transaction processing method and system
CN105045563B (en)A kind of method for collision management for speculating nested software transaction storage
CN112148930B (en)Method, system and medium for graph database system transaction processing based on RTM
Wamhoff et al.RobuSTM: A robust software transactional memory
KR102007117B1 (en)Method and system for processing transaction
CN117076145B (en)Safe and efficient STM synchronization method based on fine-granularity read-write lock
Sugiura et al.Practical Persistent Multi-word Compare-and-Swap Algorithms for Many-core CPUs
Ghosh et al.Design of a new oftm algorithm towards abort-free execution
CN118820258A (en) A fair and efficient method for concurrent execution of strictly deterministic transactions

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp