CN102135980A - Real-time transaction processing method and device - Google Patents

Real-time transaction processing method and device Download PDF

Info

Publication number
CN102135980A
CN102135980A CN 201010615080 CN201010615080A CN102135980A CN 102135980 A CN102135980 A CN 102135980A CN 201010615080 CN201010615080 CN 201010615080 CN 201010615080 A CN201010615080 A CN 201010615080A CN 102135980 A CN102135980 A CN 102135980A
Authority
CN
China
Prior art keywords
affairs
collection
lock
value
group
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
CN 201010615080
Other languages
Chinese (zh)
Other versions
CN102135980B (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.)
Beijing Yunhu Times Technology Co., Ltd.
Original Assignee
Beijing Grandison & Jm Information Technology Co Ltd
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 Beijing Grandison & Jm Information Technology Co Ltd filed Critical Beijing Grandison & Jm Information Technology Co Ltd
Priority to CN 201010615080 priority Critical patent/CN102135980B/en
Publication of CN102135980A publication Critical patent/CN102135980A/en
Application granted granted Critical
Publication of CN102135980B publication Critical patent/CN102135980B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a real-time transaction processing method, which belongs to the field of database control. The method comprises the following steps of: acquiring transactions accessing a data item at a current time; if the data item is locked, calculating the current time, a first optimal execution sequence of a transaction set and a first expected maximum value of a system; combining the group of transactions and the transaction set occupying a lock, and calculating a second optimal execution sequence of the transaction set and a second expected maximum value of the system; if the summation of the first maximum value and a value obtained by the system after the transaction set occupying the lock is finished is greater than the second maximum value, not restarting the group of transactions; and if the summation of the first maximum value and the value obtained by the system after the transaction set occupying the lock is finished is not greater than the second maximum value, starting the group of transactions. The invention also discloses a real-time transaction processing device. The data item is dynamically judged to be locked or not and the currently executed transaction set is dynamically judged to be restarted or not so as to ensure that an optimal policy can be made every time a node allocates the lock in the system with a plurality of concurrent transactions to further make highest the expected system performance and improve the system performance.

Description

A kind of method and device of handling Real-time Transaction
Technical field
The present invention relates to the Database Systems of computing machine, particularly a kind of method and device of handling Real-time Transaction.
Background technology
DRTDBS (Distributed Real Time Database System, the distributing real-time data bank system) be to be based upon RTDBS (Real Time Database System, real-time dataBase system) on the basis, its system performance index comprises two parts of affairs ratio that satisfy the timing restriction in Network Transmission cost and the global transaction, therefore, among the DRTDBS the concurrent control of Real-time Transaction be one crucial.
In realizing process of the present invention, the inventor finds that there is following problem at least in prior art:
In the concurrent control of existing DRTDBS, restarting of affairs may comprise dying young of a plurality of participation affairs, thereby wastes a large amount of system resource, and increased the weight of the burden of Network Transmission.
Because the affairs after restarting might cause restarting of another affairs, so that another affairs also can't be finished in the off period.
In addition, also may occur uselessly restarting, promptly the affairs of being restarted can't have been finished in its off period, such restart the shake that will cause system performance.
Summary of the invention
In order better Real-time Transaction to be carried out concurrent control, the embodiment of the invention provides a kind of method of handling Real-time Transaction.Described technical scheme is as follows:
Described method comprises:
Obtain current time and visit one group of affairs of same data item, and calculate the value of each affairs;
When this data item is locked by other affairs, then:
With the affairs collection of these group affairs as application lock, calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
The affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
Judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value
If then do not restart these group affairs;
Otherwise, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
The embodiment of the invention also provides a kind of device of handling Real-time Transaction.
This device comprises:
Acquisition module is used to obtain one group of affairs collection that current time is visited same data item, and calculates the value of each affairs;
First operational module is used for being locked by other affairs when this data item, then:
With the affairs collection of these group affairs as application lock, calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
The affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
Judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value
If then do not restart these group affairs;
Otherwise, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
The beneficial effect that the technical scheme that the embodiment of the invention provides is brought is: judge by dynamic whether this data item is locked and whether restart the affairs collection of carrying out, guarantee in the many systems of concurrent transaction, when making node distribute lock at every turn, can make the decision-making of current time optimum, the performance of the system of feasible expection reaches the highest, thereby improves the performance of system.
Description of drawings
Fig. 1 is a kind of schematic flow sheet of handling the method for Real-time Transaction that the embodiment of the invention 1 provides;
Fig. 2 is a kind of schematic flow sheet of handling the method for Real-time Transaction that the embodiment of the invention 2 provides;
Fig. 3 is a kind of structural representation of handling the device of Real-time Transaction that the embodiment of the invention 3 provides;
Fig. 4 is the structural representation that the another kind that provides of the embodiment of the invention 3 is handled the device of Real-time Transaction;
Fig. 5 is the structural representation of first operational module in the embodiment of the invention 3.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.
Embodiment 1
The embodiment of the invention provides a kind of method of handling Real-time Transaction, and referring to Fig. 1, this method comprises:
101: obtain one group of affairs that current time is visited same data item, and calculate the value of each affairs;
102: when this data item is locked by other affairs, then:
103: will organize the affairs collection of affairs as application lock, and calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
104: the affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
105: judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether greater than second maximum value;
106: if first maximum value with finish system obtains behind the affairs collection that occupies lock value and, then do not restart these group affairs greater than second maximum value;
107: if first maximum value with finish system obtains behind the affairs collection that occupies lock value and, then restart this group affairs collection and discharge lock less than described second maximum value, lock is distributed to the affairs collection that should carry out at first in the second optimum execution sequence.
Present embodiment judges by dynamic whether this data item is locked and whether restart the affairs collection of carrying out, guarantee in the many systems of concurrent transaction, when making node distribute lock at every turn, can make the decision-making of current time optimum, the performance of the system of feasible expection reaches the highest, thereby improves the performance of system.
Embodiment 2
The embodiment of the invention provides a kind of method of handling Real-time Transaction, and referring to Fig. 2, this method comprises:
201: obtain one group of affairs that current time is visited same data item, and calculate the value of each affairs;
At first, system obtains one group of affairs that current time is visited same data item, can represent current time with t, represents affairs with T, and for example, these group affairs can be T 1, T 2..., T n
Affairs are not divided into following three classes according to finishing the influence that system is brought above the off period:
The hard real-time affairs: surpassing the off period does not finish and can cause disastrous effect, is the affairs that must finish before the off period.
Soft Real-time Transaction: surpassing the off period also has certain value, but can constantly descend, up to 0.Can not cause disastrous effect.
Affairs when solid: surpassing its value of off period is 0 immediately.Affairs are the special case of soft Real-time Transaction when in fact, solid.
Affairs T is at the cost function V of current time t t(T) be defined as follows:
V t(T)=C(T)(W 1*(t-B(T))+W 2*P t(T))
W wherein 1=W 2=1;
If T is the hard real-time affairs, C (T)=50;
If T is soft Real-time Transaction or affairs when solid, C (T)=1.
The time that B (T) begins to carry out for affairs T;
Pt (T) is for ending t constantly, the time that affairs T has put into operation.
And t is the vacant time S of affairs constantly t(T)=D (T)-(t+E (T)-P t(T)).
By cost function, can calculate the value of the current time of each affairs.
202: judge whether this data item is locked by other affairs, if locked by other affairs, execution in step 203-207 then; If do not locked by other affairs, then execution in step 208;
Judge whether this data item is locked, for example, in the formation of depositing this data item, come to lock and release for data item by before and after formation, Q-character being set.If this data item is locked by other affairs, can identify this data item by the forward and backward Q-character (preceding Q-character is 1, and back Q-character is 0) of depositing this data item formation and be locked by other affairs; If this data item is unlocked, the preceding Q-character of depositing this data item formation is 0, and back Q-character is 1.
203: will organize the affairs collection of affairs as application lock, and calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
If this data item is locked by other affairs, system will determine this moment be to carry out these group affairs, still restart this affairs collection, system can determine according to the priority of affairs, the priority of affairs and the characteristics of affairs and the relation of current time and off period etc., in the present embodiment, system is by comparing under two kinds of situations, the obtainable expectancy of system determines whether to carry out this group affairs, still restart this group affairs,, will determine to carry out which affairs in these group affairs so if carry out this group affairs, that is first of the described affairs collection optimum sequence of carrying out;
To describe the first optimum method of carrying out sequence that obtains below in detail:
Suppose that at moment t it is T that the transaction sequence that needs to visit certain data item is simultaneously arranged in the node 1, T 2..., T n, each affairs all has its expected time E (T in the sequence i) and off period DL (T I)We calculate its value according to cost function to each affairs, and affairs were submitted in its off period, and then system obtains its value, otherwise system benefit is 0.Read affairs and can obtain lock simultaneously, and write affairs, can only have affairs to obtain lock.Because allow a plurality of affairs of reading to obtain lock simultaneously, we introduce affairs collection notion.
We are defined as one or more set of reading affairs that obtain lock, visit data simultaneously with affairs collection TS, or are one and write affairs.
E (TS) is defined as the expected time that affairs are concentrated the longest affairs of expected time in all affairs.
The optimal sequence that describes below is affairs collection sequence.
Choose the current time to DL Max=MAX I=1~n(DL (T i)) be a time period.
By the following target of finding the solution, that is, provide affairs and carry out sequence, make that system can obtain maximum value in this time period, so just can obtain first affairs that are performed in this optimal sequence, this moment affairs that should obtain locking exactly.Other affairs are then restarted.
Can whether optimal sequence exists so,, obtain optimal sequence that is, can prove by following proof to have such optimal sequence.
Optimum minor structure character proof is as follows:
Suppose Y 1, Y 2..., Y nOptimum solution, then a Y for this problem 2-Y nBe the optimum solution of following corresponding subproblem: (Y 1, Y 2..., Y nBe the affairs collection).
At t+E (Y 1) to DL MaxTime in, except Y 1Outside affairs in choose execution transaction queues to obtain maximum value.
Otherwise, suppose Y ' 2-Y ' nBe the optimum solution of this subproblem, then carry out Y ' 2-Y ' nThe value ratio that sequential system obtains is carried out Y 2-Y nThe value that sequence obtains is bigger.
So add Y 1, execution Y is arranged 1, Y ' 2-Y ' nThe value ratio that sequential system obtains is carried out Y 1~Y nThe value that sequence obtains is big, with Y 1~Y nSequence is former problem optimal sequence contradiction.Thereby proof, this problem has optimum minor structure character.
Therefore, with the affairs collection of these group affairs as application lock, can calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of this affairs collection, that is, system can obtain maximum value in this time period.
To describe in detail below, and with the affairs collection of these group affairs as application lock, obtain current time, the process of getable first maximum value is expected by first optimum sequence and the system of carrying out of this affairs collection:
Wherein will organize the affairs collection of affairs as application lock, and calculate current time, first optimum sequence and the system of carrying out of described affairs collection expects and comprises getable first maximum value:
Read the affairs collection and write the affairs collection applying for that the affairs collection of locking is divided into;
Calculate if read the affairs collection and obtain lock, execute and submit to, first value that system obtains;
Calculate if write the affairs collection and obtain lock, execute and submit to, second value that system obtains;
Calculating does not have affairs to execute and submits the 3rd value that system obtains to;
Relatively first be worth, second be worth and the 3rd be worth, getable first maximum value is expected by the system of obtaining.
At first, system can set in advance a time parameter value tt according to the off period of affairs, and sets:
If current time is greater than time parameter tt, system continues to carry out current affairs, and the value that obtains is minus infinity (catastrophic effect).
If current time equals time parameter tt, system continues to carry out current affairs, and the value that obtains is zero (not being worth).
Less than time parameter tt, system carries out following operation at current time for current time:
At first, should organize affairs by reading affairs and write affairs and be divided into two formations, and according to the off period ordering of affairs, for example, read transaction queues and be: T this moment 11, T 12..., T 1m, write transaction queues and be: T 21, T 22..., T 2nWherein, m, n are respectively simultaneously reading affairs and writing the number of affairs of application lock.
Suppose that current time is made as t, the longest off period is DL in these group affairs MaxIf will calculate (i=1~DL wherein constantly so at t+i Max), read affairs and obtain lock, the value that system obtains; Obtain lock if write affairs, if the value that system obtains and do not have affairs to submit the value that system obtains to.
So it is as follows to be carved with three kinds of situations during to t+i: (t is the current time, i=1~DLmax-t)
1. for reading transaction sequence:
If constantly at t+i, obtain lock if read affairs collection TS, execute and successfully submit to, can pass through following function (1), the value Value that the system of calculating obtains, that is, first is worth.
Value(t+i-max(E(T 1j)))+∑V(T 1j) (1)
J=j wherein 1~j 2, j 2For reading the affairs subscript of off period=t+i in the transaction sequence;
Read affairs collection TS (TS={T 1j1, T 1 (j1+1)..., T 1j2) obtain lock, execute and successfully submit to;
(E (T1j) is for reading affairs collection { T for max 1j1, T 1 (j1+1)..., T 1j2In maximum estimated execution time of affairs;
T+i-max (E (T 1j)) maximum estimated of expression from t+i to affairs arbitrary moment in the execution time;
Value (t+i-max (E (T 1j))) the expression system continue to carry out the maximum estimated execution time from t+i to affairs, finishes the value that the affairs collection that occupies lock obtains;
∑ V (T 1j) obtain lock for reading the affairs collection, execute and successfully submit to, these things collection be system increase adding up of being worth and.
If do not read the off period=t+i of affairs, Value (t+i-max (E (T then 1j)))+∑ V (T 1j) (j=j 1->j 2))=Value (t+i-1-max (E (T 1j)))+∑ V (T 1j) (j=j 1->j 2), j 2The affairs of reading for off period=t+i-1.
Value (t+i-1-max (E (T 1j))) to the maximum estimated of affairs arbitrary moment in the execution time, system finishes the value that obtains behind the affairs collection that occupies lock from t+i-1 in expression;
∑ V (T 1j) (j=j 1->j 2)) for reading in the transaction sequence off period less than the affairs subscript of t+i; Reading off period in the transaction sequence obtains lock less than the affairs of t+i, execute and successfully submit to, these read the affairs collection be adding up of system's added value and.
2. for writing transaction sequence:
If constantly at t+i, obtain lock if write affairs, by following function (2), the value that the system that can calculate obtains, that is, second is worth.
Value(t+i-E(T 2k))+V(T 2k) (2)
Wherein k is a subscript of writing the affairs of off period=t+i in the transaction queues;
Value (t+i-E (T 2k)) maximum estimated of expression from t+i to affairs is in the execution time, system finishes the value that obtains behind the affairs collection that occupies lock;
V (T 2k) for the affairs of writing in the transaction sequence obtain lock, execute and successfully submit to, be system's added value.
3. if do not have affairs to submit to constantly at t+i
By following function (3), the value that the system that can calculate obtains, that is, the 3rd is worth.
Value(t+i-1) (3)
Wherein Value (t+i-1) is illustrated in less than t+i constantly, and system finishes the value that obtains behind the affairs collection that occupies lock;
The value that system obtains under more above-mentioned three kinds of situations by following recurrence relation, can obtain the optimal selection in this moment and Value (DLmax) and is system that we ask and expect available maximum value.
Its recurrence relation is as follows:
Value(tt)=-∞ if?tt<t;
Value(tt)=0 if?tt=t;
Value ( tt ) = max (
max j 1 = 1 - > j 2 ( Value ( tt - max j = j 1 - > j 2 ( E ( T 1 j ) ) ) + Σ j = j 1 j 2 V ( T 1 j ) ) , Value ( tt - E ( T 2 k ) ) + V ( T 2 k ) , Value ( tt - 1 ) )
Figure BSA00000404557300083
(tt is a time parameter).
Because we only need return first group of execution affairs collection that affairs are carried out sequence, so use an array a[t], t is the time, deposits the affairs collection of carrying out at first that t obtains optimum subsequence constantly, can be obtained by the algorithm recurrence.Thereby, a[DL Max] be the t optimal selection constantly that we ask.
The concrete computation process of said process can following dynamic programming algorithm be represented, and is specific as follows:
One group of affairs (transaction queues of expression request lock) that current time is visited same data item are made as T List
With T ListIn affairs, read affairs and write in the transaction queues and, calculate the value V (T of each affairs simultaneously according to reading affairs, write the classification of affairs, assign to by the off period descending sort Ij).(wherein i is 1 or 2, and i is that transaction queues is read in 1 expression; I is that transaction queues is write in 2 expressions; J reads affairs and the transaction sequence of writing in the transaction queues number.)
Value (time) is illustrated in time constantly, and system finishes the value that obtains behind the affairs collection that occupies lock, constructs the optimum transaction queues of carrying out by Value (time), and is specific as follows:
The value that 1 initialization system obtains, Value (time)=0
2 are provided with by the end of current time, do not have affairs to submit to, and the value that system obtains is for being made as V 1, V 1=Value (time-1) is provided with by the end of current time, does not have affairs to submit to, and the affairs collection of carrying out at first of the optimum subsequence that obtains is a 1, a 1=a[time-1]
3 read the head of the queue element T from writing transaction queues 2k
4 judge whether current time surpasses D (T in this off period of writing affairs 2k)<time, if surpassed the off period, then the value that obtains of system is V 2, that is, and V 2=V 1By the end of current time, the affairs collection of carrying out at first of the optimum subsequence that obtains is made as a 2, a 2=a 1=a[time-1];
5 if current time in this writes the off period of affairs, i.e. D (T 2k)>=time then leaves out these affairs from formation, and will be by the end of current time, the value V that system obtains 2And by the end of current time, the affairs collection of carrying out at first of the optimum subsequence that obtains is a 2Upgrade as follows:
V 2=Value(time-E(T 2k))+V(T 2k),a 2=a[time-E(T 2k)]
Value (t+i-E (T wherein 2k)) to this maximum estimated of writing affairs in the execution time, system finishes the value that obtains behind the affairs collection that occupies lock from current time in expression;
V (T 2k) for writing affairs T 2kObtain lock, execute and successfully submit to, be system's added value.
a 2=a[time-E (T 2k)] be by the end of current time, the affairs collection of carrying out at first of the optimum subsequence that obtains
6 read the head of the queue element T from reading transaction queues 1m, and from formation, leave out these affairs
Following computing system is carried out the value that these affairs obtain, and by relatively calculating, determines to read to obtain at first in the affairs affairs of lock:
7 will read the affairs collection obtains lock, and the value of the value that system obtains is V 3, V 3For reading the maximal value in each concentrated affairs acquisition value of affairs, this maximal value is made as V 3maxThe maximum execution time is Emax.
At first with maximal value V 3maxInitialization, V 3max=0, Emax=0
When calculating each and reading affairs and obtain locking, the value that system obtains, the maximal value that extraction system obtains is as V 3Value; Detailed process is as follows:
8 j=m?down?to?1
9 E=max(T 1n)
10 V 3=Value (D (T 1m)-E)+∑ V (T 1n) (n is from j to m)
If 11 V 3>V 3max, V then 3max=V 3, E Max=E
12?V 3=V 3max,a 3=a[D(T 1m)-E]
By aforementioned calculation, relatively determine the value of V3.
Compare V 1, V 2And V 3Value, get maximal value, will be than V 1, V 2And V 3The middle pairing affairs of maximal value are as the affairs collection that should obtain locking in these group affairs of current time.
13 V Max=max{V 1, V 2, V 3, promptly get V 1, V 2And V 3Maximal value, the affairs collection a[time that should obtain locking in decision current time these group affairs], a[time]=a 1Or a 2Perhaps a 3, that is, and a[time] be V 1, V 2And V 3In the pairing a of maximal value 1Or a 2Or a 3
14?return?V max
204: the affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
If restart this group affairs, because system restart, the affairs rally that has occupied lock discharges lock, and at this moment system can determine which affairs that lock should be distributed in these group affairs in these affairs (these group affairs add the affairs collection that occupies lock).
If carry out this group affairs, will determine to carry out which affairs in these group affairs so, that is, and the first optimum sequence of carrying out of described affairs collection; If restart this group affairs, because system restarts, the affairs rally that has occupied lock discharges lock, and at this moment system can determine which affairs that lock should be distributed in these group affairs in these affairs (these group affairs add the affairs collection that occupies lock).
Step 204 is similar substantially to step 203, just will organize the affairs collection that the affairs collection after affairs merge with the affairs collection that occupies lock is locked as application, calculate current time, getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection.
The affairs collection that wherein merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and second optimum sequence and the system of carrying out of described affairs collection expects and comprise getable second maximum value:
Read the affairs collection and write the affairs collection applying for that the affairs collection of locking is divided into;
Calculate if read the affairs collection and obtain lock, execute and submit to, the tetravalence value that system obtains;
Calculate if write the affairs collection and obtain lock, execute and submit to, the pentavalent value that system obtains;
Calculating does not have affairs to execute and submits the sexavalence value that system obtains to;
Relatively tetravalence value, pentavalent value and sexavalence value, the system of obtaining are expected getable second maximum value.
The computation process of step 204 is similar substantially to step 203, and its specific implementation process sees step 203 for details, repeats no more here.
205: judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value;
The value sum and second maximum value that obtain by system after judging first maximum value and finishing the affairs collection that occupies lock compare, system is according to expecting the value that obtains under the both of these case, determine that current time is to continue to carry out these group affairs, still restarts this group affairs.
206: if first maximum value with finish system obtains behind the affairs collection that occupies lock value and, then do not restart these group affairs more than or equal to second maximum value;
If finish and carry out these group affairs behind the affairs collection that occupies lock, the value that system's expection obtains is more than or equal to restarting the value that system's expection obtains after these group affairs, and system can determine these group affairs of current time continuation execution so, does not restart this group affairs.
207: if first maximum value with finish system obtains behind the affairs collection that occupies lock value and, then restart this group affairs collection and discharge lock less than described second maximum value, lock is distributed to the affairs collection that should carry out at first in the second optimum execution sequence.
If restart under the situation of the affairs collection that occupies lock, system expects that getable value is greater than under the situation that does not restart the affairs collection that occupies lock, getable value is expected by system, restart the affairs collection that this occupies lock, discharge lock, and try to achieve the optimum of concentrating in these group affairs that restart and the affairs of occupying lock and carry out the affairs collection that should carry out at first in the sequence, this affairs collection of carrying out at first locks for this data item, carries out this affairs collection carried out at first and submission.
Wherein under the situation that restarts the affairs collection that occupies lock, try to achieve the optimum affairs collection that should carry out at first in the sequence of carrying out, the second optimum sequence of carrying out can repeat no more here referring to step 203.
This shows, when the affairs of the same data item of a group access arrive at, at first calculate the value of each affairs with cost function.If this data item is not lockable, then call dynamic programming algorithm, the optimum that obtains these group affairs is carried out sequence, and lock is distributed to the affairs collection of carrying out at first in the sequence; Otherwise, by dynamic programming algorithm find the solution respectively restart with following of the situation of not restarting the affairs collection that occupies lock can getable optimum system performance, and compare, if the performance of not restarting is higher, then this affairs collection will continue to carry out, otherwise, restart this group affairs, discharge lock, and lock is distributed to the optimum under the situation of restarting the thing diversity of occupying lock of trying to achieve in the dynamic programming algorithm carry out the affairs collection that to carry out at first in the sequence.
The concrete computation process of step 201-step 207 can be expressed as follows:
1, judge at first whether this data item locks, if this data item is not locked, then:
2, call above-mentioned dynamic programming algorithm, try to achieve the affairs collection that should obtain locking;
3, this affairs collection obtains lock;
Thus, when data item is not locked,, determined the affairs collection that should obtain locking by dynamic planning algorithm.
4, if this data item is locked by certain affairs collection, then to carry out following calculating:
5, at first, use T List1The affairs collection of=application lock;
Wherein the affairs collection of application lock is the affairs of the same data item of this group access.
6, t 1These affairs of=t-/transaction sequence residue execution time (t is the current time, down together);
Use t 1The expression current time is to arbitrary moment of the residue execution time of this affairs/transaction sequence.
7, by carrying out above-mentioned dynamic programming algorithm, calculate current time t 1, to T List1In the affairs collection, do not restarted under the situation of the affairs collection that occupies lock the getable value V of system expection Max1
8, T List2The transaction sequence ∪ of=application lock occupies the affairs collection of lock;
9、t 2=t;
10, by carrying out above-mentioned dynamic programming algorithm, calculate current time t 2, to T List2In the affairs collection, obtain restarting the affairs collection that occupies lock after, the getable value V of system expection Max2
11, if V Max1+ finish the getable value>V of system behind the affairs collection that occupies lock Max2
12, then, continue to carry out these affairs, do not restart;
13, if V Max1+ finish the getable value<V of system behind the affairs collection that occupies lock Max2, then, restart this group affairs;
Thus, when data item is locked, if restart or do not restart under the situation of the affairs collection that occupies lock by calculating respectively, getable value is expected by system, by comparing under the both of these case, expect according to system and the bigger value of getable value to determine whether to restart the affairs collection that occupies lock.
14, the optimum that is obtained by dynamic programming is carried out the affairs collection that should carry out at first in the sequence and is obtained lock, carries out the optimum affairs collection that should carry out at first in the sequence of carrying out, and submits to.
208: if this data item is not locked, obtain the affairs collection that should obtain locking in these group affairs of current time, described this data item of affairs set pair locks.
The method of calculating the affairs collection that should obtain locking in these group affairs of current time is identical with said method, does not repeat them here.
Present embodiment judges by dynamic whether this data item is locked and whether restart the affairs collection of carrying out, guarantee in the many systems of concurrent transaction, when making node distribute lock at every turn, can make the decision-making of current time optimum, the performance of the system of feasible expection reaches the highest, thereby improves the performance of system.
Embodiment 3
The embodiment of the invention provides a kind of device 300 that is used for the processing Real-time Transaction of distributing real-time data bank system, and referring to Fig. 3, this device comprises:
Acquisition module 310 is used to obtain one group of affairs collection that current time is visited same data item, and calculates the value of each affairs;
First operational module 320 is used for being locked by other affairs when this data item, then:
With the affairs collection of these group affairs as application lock, calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
The affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
Judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value
If then do not restart these group affairs;
Otherwise, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
Referring to Fig. 4, this device 300 also comprises:
Second operational module 330 is used for not locked when this data item, obtains the affairs collection that should obtain locking in these group affairs of current time, and described this data item of affairs set pair locks.
Referring to Fig. 5, first operational module 320 comprises:
First computing unit 321 is used for the affairs collection of these group affairs as application lock calculated current time, and getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
Second computing unit 322 is used to merge these group affairs and occupies the affairs collection of the affairs collection of lock as the application lock, calculates current time, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
First performance element 323, be used for when first maximum value with finish the affairs collection that occupies lock after the value that obtains of system and more than or equal to second maximum value, then do not restart these group affairs;
Second performance element 324, be used for when first maximum value with finish the affairs collection that occupies lock after the value that obtains of system and less than described second maximum value, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
The device that present embodiment provides belongs to same design with method embodiment, and its specific implementation process sees method embodiment for details, repeats no more here.
Present embodiment judges by dynamic whether this data item is locked and whether restart the affairs collection of carrying out, guarantee in the many systems of concurrent transaction, when making node distribute lock at every turn, can make the decision-making of current time optimum, the performance of the system of feasible expection reaches the highest, thereby improves the performance of system.
All or part of content in the technical scheme that above embodiment provides can realize that its software program is stored in the storage medium that can read by software programming, storage medium for example: the hard disk in the computing machine, CD or floppy disk.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (7)

1. a method of handling Real-time Transaction is characterized in that, described method comprises:
Obtain current time and visit one group of affairs of same data item, and calculate the value of each affairs;
When this data item is locked by other affairs, then:
With the affairs collection of these group affairs as application lock, calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
The affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
Judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value
If then do not restart these group affairs;
Otherwise, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
2. device according to claim 1 is characterized in that, the described current time that obtains is visited after one group of affairs of same data item, and this method also comprises:
If this data item is not locked, obtain the affairs collection that should obtain locking in these group affairs of current time, described this data item of affairs set pair locks.
3. device according to claim 1 is characterized in that, the described affairs collection that will organize affairs as application lock calculates current time, and first optimum sequence and the system of carrying out of described affairs collection expects and comprise getable first maximum value:
Read the affairs collection and write the affairs collection applying for that the affairs collection of locking is divided into;
Calculate if read the affairs collection and obtain lock, execute and submit to, first value that system obtains;
Calculate if write the affairs collection and obtain lock, execute and submit to, second value that system obtains;
Calculating does not have affairs to execute and submits the 3rd value that system obtains to;
Relatively first be worth, second be worth and the 3rd be worth, getable first maximum value is expected by the system of obtaining.
4. device according to claim 1, it is characterized in that these group affairs of described merging and the affairs collection of the affairs collection that occupies lock as the application lock are calculated current time, second optimum sequence and the system of carrying out of described affairs collection expects and comprises getable second maximum value:
Read the affairs collection and write the affairs collection applying for that the affairs collection of locking is divided into;
Calculate if read the affairs collection and obtain lock, execute and submit to, the tetravalence value that system obtains;
Calculate if write the affairs collection and obtain lock, execute and submit to, the pentavalent value that system obtains;
Calculating does not have affairs to execute and submits the sexavalence value that system obtains to;
Relatively tetravalence value, pentavalent value and sexavalence value, the system of obtaining are expected getable second maximum value.
5. a device of handling Real-time Transaction is characterized in that, this device comprises:
Acquisition module is used to obtain one group of affairs collection that current time is visited same data item, and calculates the value of each affairs;
First operational module is used for being locked by other affairs when this data item, then:
With the affairs collection of these group affairs as application lock, calculate current time, getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
The affairs collection that merges these group affairs and occupy lock calculates current time as the affairs collection of application lock, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
Judge first maximum value and finish system obtains behind the affairs collection that occupies lock value and whether more than or equal to second maximum value
If then do not restart these group affairs;
Otherwise, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
6. device according to claim 5 is characterized in that, this device also comprises:
Second operational module is used for not locked when this data item, obtains the affairs collection that should obtain locking in these group affairs of current time, and described this data item of affairs set pair locks.
7. device according to claim 5 is characterized in that, described first operational module comprises:
First computing unit is used for the affairs collection of these group affairs as application lock calculated current time, and getable first maximum value is expected by first optimum sequence and the system of carrying out of described affairs collection;
Second computing unit is used to merge these group affairs and occupies the affairs collection of the affairs collection of lock as the application lock, calculates current time, and getable second maximum value is expected by second optimum sequence and the system of carrying out of described affairs collection;
First performance element, be used for when first maximum value with finish the affairs collection that occupies lock after the value that obtains of system and more than or equal to second maximum value, then do not restart these group affairs;
Second performance element, be used for when first maximum value with finish the affairs collection that occupies lock after the value that obtains of system and less than described second maximum value, then restart this group affairs collection and discharge lock, lock is distributed to the second optimum affairs collection that should carry out at first in the sequence of carrying out.
CN 201010615080 2010-12-21 2010-12-21 Real-time transaction processing method and device Expired - Fee Related CN102135980B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201010615080 CN102135980B (en) 2010-12-21 2010-12-21 Real-time transaction processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201010615080 CN102135980B (en) 2010-12-21 2010-12-21 Real-time transaction processing method and device

Publications (2)

Publication Number Publication Date
CN102135980A true CN102135980A (en) 2011-07-27
CN102135980B CN102135980B (en) 2013-03-13

Family

ID=44295768

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201010615080 Expired - Fee Related CN102135980B (en) 2010-12-21 2010-12-21 Real-time transaction processing method and device

Country Status (1)

Country Link
CN (1) CN102135980B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104850631A (en) * 2015-05-21 2015-08-19 天津大学 Security concurrency control method applicable to real-time database
CN107526629A (en) * 2016-06-22 2017-12-29 中兴通讯股份有限公司 A kind of transacter and concurrency control method
WO2018077073A1 (en) * 2016-10-24 2018-05-03 腾讯科技(深圳)有限公司 Distributed database system, transaction processing method, lock server and storage medium
CN108595251A (en) * 2018-05-10 2018-09-28 腾讯科技(深圳)有限公司 Dynamic Graph update method, device, storage engines interface and program medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1975675A (en) * 2006-12-13 2007-06-06 天津理工大学 Safety real-time concurrent control protocol adapted to moving distributing real-time data bank
CN101067823A (en) * 2006-05-02 2007-11-07 国际商业机器公司 System and method for optimizing federated databases magagement

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067823A (en) * 2006-05-02 2007-11-07 国际商业机器公司 System and method for optimizing federated databases magagement
CN1975675A (en) * 2006-12-13 2007-06-06 天津理工大学 Safety real-time concurrent control protocol adapted to moving distributing real-time data bank

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
《上海理工大学学报》 20090630 孙红等 一种基于两阶段封锁的分布式实时提交协议 第31卷, 第03期 *
《南昌大学学报(理科版)》 20060831 肖水晶等 分布式混合实时事务处理 第30卷, 第04期 *
《计算机应用与软件》 20071130 刘育芳等 时标排序并发控制算法在移动分布式实时数据库中的应用分析 第24卷, 第11期 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104850631A (en) * 2015-05-21 2015-08-19 天津大学 Security concurrency control method applicable to real-time database
CN104850631B (en) * 2015-05-21 2018-08-07 天津大学 A kind of secure concurrency control method suitable for real-time data base
CN107526629A (en) * 2016-06-22 2017-12-29 中兴通讯股份有限公司 A kind of transacter and concurrency control method
CN107526629B (en) * 2016-06-22 2023-04-14 中兴通讯股份有限公司 Transaction processing system and concurrency control method
WO2018077073A1 (en) * 2016-10-24 2018-05-03 腾讯科技(深圳)有限公司 Distributed database system, transaction processing method, lock server and storage medium
US11243920B2 (en) 2016-10-24 2022-02-08 Tencent Technology (Shenzhen) Company Limited Distributed database system, transaction processing method, lock server and storage medium
CN108595251A (en) * 2018-05-10 2018-09-28 腾讯科技(深圳)有限公司 Dynamic Graph update method, device, storage engines interface and program medium
CN108595251B (en) * 2018-05-10 2022-11-22 腾讯科技(深圳)有限公司 Dynamic graph updating method, device, storage engine interface and program medium

Also Published As

Publication number Publication date
CN102135980B (en) 2013-03-13

Similar Documents

Publication Publication Date Title
CN107038069B (en) Dynamic label matching DLMS scheduling method under Hadoop platform
Nykiel et al. MRShare: sharing across multiple queries in MapReduce
US9852204B2 (en) Read-only operations processing in a paxos replication system
CN100517219C (en) Resource managing apparatus and method in a multicore architecture, and multicore processor
CN109408229B (en) Scheduling method and device
US10275400B1 (en) Systems and methods for forming a fault-tolerant federated distributed database
CN114610474B (en) Multi-strategy job scheduling method and system under heterogeneous supercomputing environment
CN102521265B (en) Dynamic consistency control method in massive data management
CN102135980B (en) Real-time transaction processing method and device
CN103310460A (en) Image characteristic extraction method and system
CN103294558A (en) MapReduce scheduling method supporting dynamic trust evaluation
CN111782627B (en) Task and data cooperative scheduling method for wide-area high-performance computing environment
CN105550351A (en) Passenger travel data ad-hoc query system and method
Silberstein Building an online domain-specific computing service over non-dedicated grid and cloud resources: The superlink-online experience
Rai et al. Blockguard: Adaptive blockchain security
Zhang et al. Txallo: Dynamic transaction allocation in sharded blockchain systems
US20090282418A1 (en) Method and system for integrated scheduling and replication in a grid computing system
CN115755785A (en) Autonomous task scheduling method and system based on multi-level dynamic priority
Benoit et al. Optimizing the latency of streaming applications under throughput and reliability constraints
Shen et al. Communication management using abstraction in distributed Bayesian networks
US20030177166A1 (en) Scalable scheduling in parallel processors
Reddy et al. Reducing the blocking in two-phase commit with backup sites
Mohapatra Dynamic real-time task scheduling on hypercubes
CN116610725B (en) Entity enhancement rule mining method and device applied to big data
CN117806801A (en) Cluster scheduling method and system for federal learning tasks

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20180201

Address after: 100176 Beijing Beijing economic and Technological Development Zone Culture Park, No. 6, courtyard No. 30, No. 18, 1803

Patentee after: Beijing Yunhu Times Technology Co., Ltd.

Address before: 100020 Chaoyang District, Chaoyang District, Beijing, Beijing

Patentee before: Beijing Grandison & JM Information Technology Co., Ltd.

TR01 Transfer of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130313

Termination date: 20201221

CF01 Termination of patent right due to non-payment of annual fee