A kind of transaction methods and device
Technical field
The application is related to Internet technical field, more particularly to a kind of transaction methods and device.
Background technology
With the development and application of continuing to develop for Internet technology, and social networks, smart machine so that data volume
In explosive growth.In order to which the storage for tackling mass data is used, distributed data base is correspondingly generated.
Distributed data base can be made up of multiple database servers (database server), each
Database server can provide the read-write service of all or part of data.Generally, distributed data base supports affairs
Concurrent processing.Here affairs can refer to, the operations of data in database (is such as increased, deleted, changed, looked into).For example in processing
During concurrent transaction, distributed data base can distribute to different affairs different database server processes;Again for example can be with
Realize that transaction concurrency is handled by MVCC (Multi-Version Concurrency Control, Multi version concurrency control).
Specifically, being safeguarded in distributed data base has a global maximum version number, and global is generally referred to as in the industry
commited version.General, the size of version number can illustrate data modification in distributed data base (as newly-increased)
Time before and after, the more big then data modification of version number it is more late.Generally, (timestamp) such as Unix can be stabbed with use time
Timestamp is used as version number.The global maximum version number can determine last in the distributed data base
The data of modification.
In the prior art during issued transaction, the less efficient or reliability that there is the global maximum version number of acquisition is poor
Problem.
The content of the invention
, to solve during existing issued transaction, there is acquisition global in a kind of transaction methods and device that the application is provided
The problem of less efficient or poor reliability of maximum version number.
A kind of transaction methods provided according to the embodiment of the present application, methods described is applied in distributed data base
Database server, methods described includes:
For pending affairs, the acquisition for sending global maximum version number to version number's server group is asked;Wherein, institute
State version number's server group by least two be used to safeguarding the database server group of global maximum version number into;
After the response message that version number's server group is returned is received, global maximum version is obtained based on the response message
This number;
The maximum version number of the acquired overall situation is specified to be the snapshot version number of the pending affairs, so as to perform described
Pending affairs.
Optionally, the acquisition for sending global maximum version number to version number's server group is asked, and is specifically included:
Major version number server into version number's server group sends the acquisition request of global maximum version number;
It is described that global maximum version number is obtained based on the response message, specifically include:
Obtain the maximum version number of the overall situation carried in the response message.
Optionally, the acquisition for sending global maximum version number to version number's server group is asked, and is specifically included:
The acquisition request of the global maximum version number of all version number's server broadcasts into version number's server group;
It is described after the response message that version number server group is returned is received, based on the response message obtain it is global most
Major release, is specifically included:
Within default waiting time, the ratio of the response message quantity and all version number's number of servers returned is judged
Whether preset ratio is reached;Wherein, the response message carries the local maxima version number of version number's server;
If so, maximum local maxima version number is defined as into global maximum version number.
Optionally, methods described also includes:
After the affairs are finished, affairs version one bigger than the global maximum version number is distributed to the affairs
This number;
The renewal request of global maximum version number is sent to version number's server group;Wherein, it is described to update in request
The transactional version number is carried, and for asking global maximum version number being updated to the transactional version number;
The affairs being finished described in submitting.
Optionally, it is described after the affairs are finished, one is distributed than the global maximum version to the affairs
Number big transactional version number, is specifically included:
After the affairs are finished, global maximum version number is obtained to version number's server group again;
Distribute the maximum version number of the overall situation got again described in a ratio big transactional version number to the affairs.
Optionally, the renewal for sending global maximum version number to version number's server group is asked, and is specifically included:
Into version number's server group, major version number server sends the renewal request of global maximum version number.
Optionally, the affairs being finished described in the submission, are specifically included:
After the second response message of the major version number server return is received, the affairs being finished described in submission;
Wherein, second response message represents that the major version number server receives renewal request.
Optionally, the renewal for sending global maximum version number to version number's server group is asked, and is specifically included:
The renewal request of the global maximum version number of all version number's server broadcasts into version number's server group.
Optionally, the affairs being finished described in the submission, are specifically included:
Within default second waiting time, the second response message quantity and all version number's server counts returned is judged
Whether the ratio of amount reaches preset ratio;Wherein, second response message represents that version number's server receives renewal request.
If so, the affairs being finished described in submitting.
A kind of transaction methods provided according to the embodiment of the present application, methods described is applied in distributed data base
Version number's server group, version number's server group is by least two database services for safeguarding global maximum version number
Device is constituted, and methods described includes:
Receive the acquisition request of the maximum version number of the overall situation of database server transmission;
The maximum version number of the overall situation of maintenance is returned into the database server.
Optionally, the maximum version number of the overall situation by maintenance returns to the database server, specifically includes:
The maximum version number of the overall situation that major version number server is safeguarded returns to the database server.
Optionally, the maximum version number of the overall situation that major version number server is safeguarded returns to the database service
Device, is specifically included:
In the case of key plate book server is disabled, a standby version number is chosen from version number's server group
Server;
The maximum version number of the overall situation that standby version number's server is safeguarded returns to the database server.
Optionally, methods described also includes:
The major version number server receives the renewal request that the database server is sent, and is carried in renewal request
There is affairs version number;
The major version number server judges whether the transactional version number is more than the maximum version number of the overall situation of its maintenance;
If so, the transactional version number is defined as the maximum version number of the new overall situation by the major version number server.
Optionally, the major version number server by the transactional version number be defined as the maximum version number of the new overall situation it
Afterwards, methods described also includes:
The major version number server returns to the second response message to the database server;Wherein, described second answer
Answer message and represent that the major version number server receives renewal request.
Optionally, the maximum version number of the overall situation by maintenance returns to the database server, specifically includes:
The local maxima version number that all version number's servers are safeguarded returns to the database server.
Optionally, methods described also includes:
Each version number's server receives the renewal request of database server broadcast, and affairs are carried in renewal request
Version number;
Each version number's server judges whether the transactional version number is more than the local maxima version number of its maintenance;
If so, the transactional version number then is defined as into its new local maxima version number.
Optionally, methods described also includes:
In the case where the transactional version number is more than or be not more than the local maxima version number that it is safeguarded, to the number
The second response message is returned according to storehouse server;Wherein, second response message represents to receive renewal request.
A kind of transacter provided according to the embodiment of the present application, described device is applied in distributed data base
Database server, described device includes:
Transmitting element, for pending affairs, the acquisition for sending global maximum version number to version number's server group please
Ask;Wherein, version number's server group by least two be used to safeguarding the database server group of global maximum version number into;
Acquiring unit, after the response message that version number's server group is returned is received, is obtained based on the response message
Global maximum version number;
Execution unit, specifies the snapshot version number that the maximum version number of the acquired overall situation is the pending affairs, from
And perform the pending affairs.
A kind of transacter provided according to the embodiment of the present application, described device is applied in distributed data base
Version number's server group, version number's server group is by least two database services for safeguarding global maximum version number
Device is constituted, and described device includes:
Receiving unit, receives the acquisition request of the maximum version number of the overall situation of database server transmission;
Returning unit, the database server is returned to by the maximum version number of the overall situation of maintenance.
In the embodiment of the present application, it is used to safeguard global maximum version number by multiple (i.e. at least two) by setting one
Database server group into version number's server group, it is the multiple be much smaller than all database servers number.At place
It is all to avoid using due to there are multiple version number's servers when the database of director's business obtains global maximum version number
The problem of global maximum version number can not be obtained caused by generative center node is unavailable during Centroid.It is additionally, since multiple
Version number's server is much smaller than the number of all database servers, is obtained so can also avoid to all database servers
Take local maxima version number come efficiency caused by determining global maximum version number it is low the problem of;So data in the embodiment of the present application
Storehouse server is in affairs are performed, it is possible to achieve the efficiency and reliability for obtaining global maximum version number are taken into account, so as to be lifted
TC transaction capabilities.
Brief description of the drawings
The flow chart for the transaction methods that Fig. 1 provides for the embodiment of the application one;
The configuration diagram for the distributed data base that Fig. 2 provides for the embodiment of the application one;
Fig. 3 obtains the local maxima version of all version number's servers for the database server that the embodiment of the application one is provided
The schematic diagram of this number process;
Fig. 4 obtains the overall situation maximum version of major version number server for the database server that the embodiment of the application one is provided
The schematic diagram of number process;
The flow chart for the transaction methods that Fig. 5 provides for the embodiment of the application one;
The flow chart for the transaction methods that Fig. 6 provides for the embodiment of the application one;
Fig. 7 is a kind of hardware structure diagram of equipment where the transacter that the application is provided;
The module diagram for the transacter that Fig. 8 provides for the embodiment of the application one;
The module diagram for the transacter that Fig. 9 provides for the embodiment of the application one.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects be described in detail in claims, the application.
It is the purpose only merely for description specific embodiment in term used in this application, and is not intended to be limiting the application.
" one kind ", " described " and "the" of singulative used in the application and appended claims are also intended to including majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wrapped
It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used for same type of information being distinguished from each other out.For example, not departing from
In the case of the application scope, the first information can also be referred to as the second information, similarly, and the second information can also be referred to as
One information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determining ".
In correlation technique, database server can distribute a snapshot version number to the affairs, lead to before processing affairs
Often it is referred to as snapshot version in the industry;The snapshot version number is used to represent the data area that the affairs can be read
(data corresponding to the version number smaller than snapshot version can only be read).General, the snapshot version number is just
It is the global maximum version number, such affairs can just read current all data.That is, database server
, it is necessary to first obtain the maximum version number of the current overall situation, the corresponding snapshot version number of reallocation affairs before really processing affairs.
In the prior art, it is primarily present the following two kinds and safeguards global maximum version number (global commited
Version mode):
Each database server (database server) is local in first way, in distributed data base can
Safeguard a local maxima version number (local_max_commited_version).Can be same between disparate databases server
Local maxima version number is walked, so that ensure that the local maxima version number that each database server is safeguarded is identical, i.e., each office
Maximum version number of portion is consistent with global maximum version number all the time.Specifically, each database server updates the part of itself most
During major release, it is required for the local maxima version number after renewal being broadcast to all database servers;Any one number
Receive after broadcast, if it find that the local maxima version number of local maintenance is smaller than broadcast, then can also update according to storehouse server.
For the database server of pending affairs, when it obtains global maximum version number, directly by local maintenance
Local maxima version number is used as global maximum version number.
In the second way, distributed data base can regard a database server as Centroid, the Centroid
For specially safeguarding global maximum version number (global commited version).
, only need to be to the Centroid when it obtains global maximum version number for the database server of pending affairs
Obtain corresponding global maximum version number.
However, for first way, although can directly using the local maxima version number of local maintenance as the overall situation most
Major release, but synchronous local maxima version number is less efficient, such as the database server in distributed data base is got over
It is many, then it is also more the time required to broadcast;Moreover, only after all database servers return responses are received, just can be with complete
Into synchronization.
For the second way, once Centroid go wrong cause it is unavailable such as the machine of delaying, then also will be unable to
Get global maximum version number.
In summary, in the prior art issued transaction when, exist and obtain the less efficient of global maximum version number or can
By property it is poor the problem of.
In order to solve the above problems, Fig. 1 is referred to, the flow of the transaction methods provided for the embodiment of the application one
Figure, comprises the following steps:
Step 110:Database server is directed to pending affairs, and global maximum version is sent to version number's server group
Number acquisition request.
As previously described database server before the pending affairs are handled, it is necessary to the pending affairs
A snapshot version number (snapshot version) is distributed, and the snapshot version number is to be based on safeguarding in distributed data base
The overall situation maximum version number (global commited version) determine.That is, the database server is at place
Before the pending affairs of reason, in addition it is also necessary to obtain global maximum version number.
In the present embodiment, incorporated by reference to the configuration diagram of the distributed data base shown in Fig. 2, in the distributed data base
It can be made up of at least two database servers (database server), each database server may be used to place
Director is engaged in.As shown in Fig. 2 at least two database server group can be used into one to safeguard global maximum version number
Version number's server group.In this way, when some database server needs processing affairs, can be to version number's server group
Send the acquisition request of global version number.
For the ease of difference, the database server in version number's server group is referred to as version number's clothes herein
Business device.It is noted that version number's server is only the server on logical meaning, its essence can be database clothes
Business device.
In one embodiment, the acquisition that the step 110 sends global maximum version number to version number's server group please
Ask, can specifically include:
The acquisition request of the global maximum version number of all version number's server broadcasts into version number's server group.
In the present embodiment, one can have been safeguarded in each version number's server in version number's server group
Individual local maxima version number (local_max_commited_version).
General, the local maxima version number can be the integer of one 64, can be expressed as with nanosecond or delicate
For the Unix timestamps of unit.Version number's server safeguards the local maxima version number, can be recorded in internal memory, and hold
Longization data.
If it is noted that without persistence, after version number's server is restarted every time, in addition it is also necessary to synchronous to miss
Difference:Need to wait a clocking error (clock_diff_upper_limit), the clocking error represents different editions number
The clocking error upper limit between server;Then again Unix time stamp settings now be local maxima version number.
In the present embodiment, version number's server can provide one be used for obtain RPC (Remote Procedure
Call Protocol, remote procedure call protocol) interface:Obtain interface get_version ().The database server can
To obtain the local maxima version number of version number's server by get_version ().
In another embodiment, in version number's server group, version number's server can be regard as master
Version number's server, other version number's servers are used as backup version server.
, specifically can be with this way, the acquisition that the step 110 sends global maximum version number to version number server group is asked
Including:
Major version number server into version number's server group sends the acquisition request of global maximum version number.
In the present embodiment, the major version number server, which is safeguarded, a global maximum version number.
General, the global maximum version number can be the integer of one 64, can be expressed as with nanosecond or delicate
For the Unix timestamps of unit.The major version number server safeguards the maximum version number of the overall situation, can be recorded in internal memory,
And perdurable data.
If it is noted that without persistence, after version number's server is restarted every time, in addition it is also necessary to synchronous to miss
Difference:Need to wait a clocking error (clock_diff_upper_limit), the clocking error represents different editions number
The clocking error upper limit between server;Then Unix time stamp settings now it is again global maximum version number.
In the present embodiment, major version number server can provide one be used for obtain RPC (Remote Procedure
Call Protocol, remote procedure call protocol) interface:
Obtain interface get_version ():Database server can obtain key plate by broadcasting get_version ()
The local maxima version of this number server.
It is noted that if version number's server is not major version number server, its receive acquisition request or
Update after request, an error code can also be returned;And receive can be again to major version number after error code for database server
Server sends request.So, it can be ensured that database server is to send to ask to major version number server all the time.
Step 120:Version number's server group receives the acquisition request for the maximum version number of the overall situation that database server is sent.
Step 121:The maximum version number of the overall situation of maintenance is returned to the database server by version number's server group.
In the present embodiment, if in step 120, each version number's server in version number's server group have received
The acquisition request of the maximum version number of the overall situation of database server broadcast;
Then, the step 121, can specifically include:
The local maxima version number that all version number's servers are safeguarded is returned to the database by version number's server group
Server.
If in step 120, it is wide that the major version number server in version number's server group have received database server
The acquisition request for the maximum version number of the overall situation broadcast;
Then, the step 121, can specifically include:
The maximum version number of the overall situation that major version number server is safeguarded returns to the database server.
Step 130:The database server is after the response message that version number's server group is returned is received, based on institute
State response message and obtain global maximum version number.
For in step 110, the global maximum version numbers of all version number's server broadcasts into version number's server group
Obtain request;
Then the step 130, can specifically include:
Within default waiting time, the ratio of the response message quantity and all version number's number of servers returned is judged
Whether preset ratio is reached;Wherein, the response message carries the local maxima version number of version number's server;
If so, maximum local maxima version number is defined as into global maximum version number.
In the present embodiment, as it was previously stated, database server to all version number's server broadcasts get_version
After () request, the response of each version number's server may then wait for.In the response message quantity and all versions of return
The ratio of number number of servers is reached after preset ratio, the office that the database server can be carried from these response messages
A maximum is chosen in maximum version number of portion, this maximum is exactly global maximum version number global commited
version.If it should be noted that the ratio in the response message quantity and all version number's number of servers of return does not have
In the case of reaching preset ratio, then current obtain is asked just to have failed, and the database server can be obtained again.
The waiting time can be the empirical value artificially set.Such as 30 seconds.
The preset ratio can be the empirical value artificially set.Generally, 1/2 is could be arranged to, that is, judges to return
The ratio of response message quantity and all version number's number of servers whether reach 1/2.
Database server as shown in Figure 3 obtains the signal of the local maxima version number process of all version number's servers
Figure.Version number's server group includes 3 version number's servers;
T1 moment, database server is asked to all 3 version server broadcast get_version ();
The response of version number's server 1 is received within default waiting time, when t2, the response message carries part most
Major release v1;
The t3 moment receives the response of version number's server 2, and the response message carries local maxima version number v2;
Because the t3 moment has received the response of version number's server more than half, it is possible to from the two responses
The big local maxima version number of selected value, i.e. max (v1, v2) is used as global maximum version number.
For in step 110, the major version number server into version number's server group sends global maximum version number
Obtain request.
The step 130, can specifically include:
Obtain the maximum version number of the overall situation carried in the response message.
Database server as shown in Figure 4 obtains the schematic diagram of the maximum version number's process of the overall situation of major version number server.
Version number's server group includes 2 version number's servers, and version number's server 1 is major version number server, version number's server 2
It is standby version number's server;
T1 moment, database server sends get_version () to version number's server 1 and asked;
At the t2 moment, the response of version number's server 1 is have received, the response message carries global maximum version number;
Then, database server can just obtain the maximum version number of the overall situation of response carrying.
If machine or network interruption become unavailable it is noted that version number's server 1 is delayed after instant t 2;
T3 moment, database server still sends get_version () to the request of version number's server 1 and asked, but version
This number server 1 has been delayed machine, so current request have failed;
But version number's server 2 is elected as new major version number server quickly;
So, at the t4 moment, database server can issue request new major version number server, and current request can
With success.From the example can draw only version number's server 1 be not applicable to version number's server 2 take up an official post between this section
The request of temporal database server is only possible to fail;And this period is very short, so version number's server group can
It is higher by property.
Step 131:The database server specifies the maximum version number of the acquired overall situation to be the pending affairs
Snapshot version number, so as to perform the pending affairs.
In the present embodiment, database server is got after global maximum version number, it is possible to specify the acquired overall situation
Maximum version number is the snapshot version number of the pending affairs, so as to perform the pending affairs.
In the embodiment of the present application, by setting one by multiple database servers for being used to safeguard global maximum version number
Version number's server group of composition, the multiple is the number much smaller than all database servers.In the data of processing affairs
It is all to avoid sending out when using Centroid due to there are multiple version number's servers when storehouse obtains global maximum version number
The problem of global maximum version number can not being obtained caused by raw Centroid is unavailable.It is additionally, since multiple version number's servers
Much smaller than the number of all database servers, local maxima version is obtained so can also avoid to all database servers
This number come efficiency caused by determining global maximum version number it is low the problem of;So database server is being held in the embodiment of the present application
Act in business, it is possible to achieve the efficiency and reliability for obtaining global maximum version number are taken into account, so as to lift TC transaction capabilities.
In actual applications, database server is after issued transaction has been performed, if the affairs need to change database
In data (such as increase newly data), then also need to submit the affairs.Now, the database server also needs to distribution one
Transactional version number, is generally referred to as in the industry commit version.General, the transactional version number is needed than global maximum version
It is number big;The affairs of transactional version number are only assigned with distributed data base can just be submitted.
As shown in figure 1, after the step 131, methods described can also include:
Step 140:After the affairs are finished, the database server is distributed described in a ratio to the affairs
The big transactional version number of global maximum version number.
In the present embodiment, database server can Jia 1 on the basis of the global maximum version number and obtain affairs version
This number.
Step 141:The database server sends the renewal of global maximum version number to version number's server group
Request.
In the present embodiment, described update carries the transactional version number in request, and for asking global maximum version
This number is updated to the transactional version number.
It is similar to version number's server group transmission acquisition request with database server:
The step 141, can specifically include:
The renewal request of the global maximum version number of all version number's server broadcasts into version number's server group.
In the present embodiment, version number's server in version number's server group can also provide one be used for update
RPC interfaces:More new interface update_version (cv).Database server can be asked by update_version (cv)
Obtain the maximum version number of the overall situation that all version number's server updates are safeguarded.Wherein, the affairs version that cv is carried in being asked for renewal
This number.
It is corresponding, shown in the following A1-A3 of process of each version number's server process renewal request:
A1:Each version number's server receives the renewal request of database server broadcast;Wherein, it is described to update in request
The transactional version number is carried, and for asking global maximum version number being updated to the transactional version number;
A2:Each version number's server judges whether the transactional version number is more than the local maxima version number of its maintenance;
A3:If so, the transactional version number then is defined as into its new local maxima version number.
In the present embodiment, if transactional version number is more than the local maxima version number that version number's server is safeguarded, need
The transactional version number is defined as to new local maxima version number;, whereas if transactional version number takes less than or equal to version number
The local maxima version number that business device is safeguarded, then do not update.
With in foregoing version number's server group, can be other using version number's server as major version number server
Version number's server it is corresponding as the embodiment of backup version server, the step 141 can specifically include:
Into version number's server group, major version number server sends the renewal request of global maximum version number.
In the present embodiment, version number's server in version number's server group can also provide one be used for update
RPC interfaces:More new interface update_version (cv).Database server can be asked by update_version (cv)
The maximum version number of the overall situation that major version number server update is safeguarded.Wherein, the transactional version number that cv is carried in being asked for renewal.
It is corresponding, shown in the following B1-B3 of process of major version number server process renewal request:
B1:The major version number server receives the renewal request that the database server is sent, in renewal request
Carry transactional version number;
B2:The major version number server judges whether the transactional version number is more than the maximum version of the overall situation of its maintenance
Number;
B3:If so, the transactional version number is defined as the maximum version number of the new overall situation by the major version number server.
In the present embodiment, if transactional version number is more than the maximum version number of the overall situation that major version number server is safeguarded, need
The transactional version number is defined as the maximum version number of the new overall situation;, whereas if transactional version number is less than or equal to key plate sheet
The maximum version number of the overall situation that number server is safeguarded, then do not update.
Step 150:The affairs being finished described in the database server submission.
In the present embodiment, the step 150 can be performed after the step 141.That is, in the number
After the renewal request for sending global maximum version number to version number's server group according to storehouse server, it is possible to submit described
The affairs being finished.
By the present embodiment, database service can realize the submission to affairs.
In actual applications, issued transaction may have passed through the long period between being submitted to affairs, and such as the previous day is handled
Affairs, just need affairs to submit after one day;So, at database server is got the maximum version number of the overall situation or the previous day
Before director's business, and because distributed data base supports concurrent transaction, the maximum version number of the overall situation in this day really leads to
It is often updated;So, during transactional version based on the maximum version number's distribution of the out-of-date overall situation, it is more likely that than real
The maximum version number of the overall situation it is small.
In order to solve this problem, in another embodiment of the application, the step 140 is specifically included:
After the affairs are finished, global maximum version number is obtained to version number's server group again;
Distribute the maximum version number of the overall situation got again described in a ratio big transactional version number to the affairs.
In the present embodiment, global maximum version number is obtained to version number's server group again, with the phase of above-mentioned steps 110
Together, here is omitted.
By the present embodiment, when affairs are submitted, the maximum version number of the overall situation newest by obtaining, it is ensured that the affairs of distribution
Version number is naturally larger than really global maximum version number.
In another embodiment of the application, version number's server please in the renewal for receiving database server transmission
, can be with reply data storehouse server, so as to notify the database server to have received it and update request after asking.
Specifically, after A1, in addition to:
In the case where receiving the renewal request of database server broadcast, returning to second to the database server should
Answer message;Wherein, second response message represents to receive renewal request.
Specifically, after B1, in addition to:
In the case that the major version number server receives the renewal request that the database server is sent, to the number
The second response message is returned according to storehouse server;Wherein, second response message represents that the major version number server receives this
Update request.
Corresponding, the step 150 can specifically include:
Within default second waiting time, the second response message quantity and all version number's server counts returned is judged
Whether the ratio of amount reaches preset ratio;Wherein, second response message represents that version number's server receives renewal request.
If so, the affairs being finished described in submitting.
In the present embodiment, second waiting time can be the empirical value artificially set.It is noted that institute
Stating for the second waiting time can also be equal with above-mentioned waiting time.
By the present embodiment, it is with former step 150 difference, database server is only being achieved more than default
After version number's server response of ratio, affairs can be just submitted.
In one of the application specifically embodiment, for the major version number server into version number's server group
Send the renewal request of global maximum version number.
Correspondingly, the step 150, can specifically include:
After the second response message of the major version number server return is received, the affairs being finished described in submission.
By the present embodiment, it is that database server is only achieving major version number with former step 150 difference
After server response, affairs can be just submitted.
Below in conjunction with Fig. 5 introduce the application in a distributed manner wide area information server server be main body embodiment of the method,
The embodiment can be with corresponding diagram 1:
Step 210:For pending affairs, the acquisition for sending global maximum version number to version number's server group please
Ask;Wherein, version number's server group by least two be used to safeguarding the database server group of global maximum version number into;
Step 220:After the response message that version number's server group is returned is received, obtain complete based on the response message
Maximum version number of office;
Step 230:The snapshot version number that the maximum version number of the acquired overall situation is the pending affairs is specified, so that
Perform the pending affairs.
With the identical of above-mentioned steps 110, the step 210 is specifically included:
For pending affairs, the major version number server into version number's server group sends global maximum version number
Acquisition request;
Corresponding, global maximum version number is obtained based on the response message in the step 220, specifically included:
Obtain the maximum version number of the overall situation carried in the response message.
With the identical of above-mentioned steps 110, the step 210 is specifically included:
The acquisition request of the global maximum version number of all version number's server broadcasts into version number's server group;
Corresponding, global maximum version number is obtained based on the response message in the step 220, specifically included:
Within default waiting time, the ratio of the response message quantity and all version number's number of servers returned is judged
Whether preset ratio is reached;Wherein, the response message carries the local maxima version number of version number's server;
If so, maximum local maxima version number is defined as into global maximum version number.
As shown in Figure 5 after the step 230, step 240,250 and 260 can also be included, the embodiment can be right
Answer step 140 in embodiment described in Fig. 1,141 and 150.
Step 240:After the affairs are finished, distribute one bigger than the global maximum version number to the affairs
Transactional version number;
Step 250:The renewal request of global maximum version number is sent to version number's server group;It is described to update request
In carry the transactional version number, and for asking global maximum version number being updated to the transactional version number;
Step 260:The affairs being finished described in submitting.
With one of above-mentioned steps 140 specifically embodiment identical, described 240, it can specifically include:
After the affairs are finished, global maximum version number is obtained to version number's server group again;
Distribute the maximum version number of the overall situation got again described in a ratio big transactional version number to the affairs.
With one of above-mentioned steps 141 specifically embodiment identical, the step 250, specifically include:
Into version number's server group, major version number server sends the renewal request of global maximum version number.
And the step 260, specifically include:
After the second response message of the major version number server return is received, the affairs being finished described in submission;
Wherein, second response message represents that the major version number server receives renewal request.
With one of above-mentioned steps 141 specifically embodiment identical, the step 250, specifically include:
The renewal request of the global maximum version number of all version number's server broadcasts into version number's server group.
And the step 260, specifically include:
Within default second waiting time, the second response message quantity and all version number's server counts returned is judged
Whether the ratio of amount reaches preset ratio;Wherein, second response message represents that version number's server receives renewal request.
Below in conjunction with Fig. 6 introduce the application in a distributed manner database version number's server group for main body method implement
Example, the embodiment can be with corresponding diagram 1:
Step 310:Receive the acquisition request of the maximum version number of the overall situation of database server transmission.
Step 320:The maximum version number of the overall situation of maintenance is returned into the database server.
Specifically, the step 320, can include:
The maximum version number of the overall situation that major version number server is safeguarded returns to the database server.
In another embodiment, the maximum version number of the overall situation that major version number server is safeguarded returns to the number
According to storehouse server, specifically include:
In the case of key plate book server is disabled, a standby version number is chosen from version number's server group
Server;
The maximum version number of the overall situation that standby version number's server is safeguarded returns to the database server.
Specifically, after step 320, methods described also includes:
C1:The major version number server receives the renewal request that the database server is sent, in renewal request
Carry transactional version number;
Major version number server described in C2 judges whether the transactional version number is more than the maximum version number of the overall situation of its maintenance;
C3:If so, the transactional version number is defined as the maximum version number of the new overall situation by the major version number server.
The C1-C3 is identical with foregoing B1-B3, and here is omitted.
After C1, methods described also includes:
In the case that the major version number server receives the renewal request that the database server is sent, to the number
The second response message is returned according to storehouse server;Wherein, second response message represents that the major version number server receives this
Update request.
Specifically, the step 320, can include:
The local maxima version number that all version number's servers are safeguarded returns to the database server.
Specifically, after step 320, methods described also includes:
D1:Each version number's server receives the renewal request of database server broadcast, is carried in renewal request
Transactional version number;
D2:Each version number's server judges whether the transactional version number is more than the local maxima version number of its maintenance;
D3:If so, the transactional version number then is defined as into its new local maxima version number.
The D1-D3 is identical with foregoing A1-A3, and here is omitted.
After D1, methods described also includes:
In the case where receiving the renewal request of database server broadcast, second is returned to the database server
Response message;Wherein, second response message represents to receive renewal request.
Corresponding with foregoing transaction methods embodiment, present invention also provides a kind of implementation of transacter
Example.
The embodiment of the application transacter can be applied in distributed data base respectively.Device embodiment can lead to
Software realization is crossed, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, a logic is used as
Device in meaning, is to be read corresponding computer program instructions in nonvolatile memory by the processor of equipment where it
Get what operation in internal memory was formed.For hardware view, as shown in fig. 7, the equipment where the application transacter
A kind of hardware structure diagram, in addition to the processor shown in Fig. 7, network interface, internal memory and nonvolatile memory, embodiment
Equipment where middle device can also include other hardware, this is repeated no more generally according to the actual functional capability of the issued transaction.
Referring to Fig. 8, the module map of the transacter provided for the embodiment of the application one, the embodiment is from distributed number
It is described according to the database server side in storehouse, described device includes:Transmitting element 410, acquiring unit 420 and execution unit
430。
Wherein, transmitting element 410, for pending affairs, global maximum version number is sent to version number's server group
Acquisition request;Wherein, version number's server group is used to safeguard that the database of global maximum version number takes by least two
Business device composition;
Acquiring unit 420, after the response message that version number's server group is returned is received, is obtained based on the response message
Take global maximum version number;
Execution unit 430, specifies the snapshot version number that the maximum version number of the acquired overall situation is the pending affairs,
So as to perform the pending affairs.
In an optional implementation:
The transmitting element 410, is specifically included:
Transmission sub-unit, the major version number server into version number's server group sends the acquisition of global maximum version number
Request;
Correspondingly, the acquiring unit 420, is specifically included:
Subelement is obtained, after the response message that version number's server group is returned is received, is obtained in the response message
The maximum version number of the overall situation of carrying.
In an optional implementation:
The transmitting element 410, is specifically included:
Transmission sub-unit, the acquisition of the global maximum version number of all version number's server broadcasts into version number's server group
Request;
Correspondingly, the acquiring unit 420, is specifically included:
Judgment sub-unit, within default waiting time, judges that the response message quantity returned is serviced with all version numbers
Whether the ratio of device quantity reaches preset ratio;Wherein, the response message carries the local maxima version of version number's server
This number;
Determination subelement, will most in the case of the response message that the version number's server for getting preset ratio is returned
Big local maxima version number is defined as global maximum version number.
In an optional implementation:
Described device also includes:
Allocation unit, after the affairs are finished, one is distributed than the global maximum version number to the affairs
Big transactional version number;
Updating block, the renewal for sending global maximum version number to version number's server group is asked;The renewal please
The transactional version number is carried in asking, and for asking global maximum version number being updated to the transactional version number;
Submit unit, submit described in the affairs that are finished.
In an optional implementation:
The allocation unit, is specifically included:
Transmission sub-unit, after the affairs are finished, obtains global maximum to version number's server group again
Version number;
Subelement is distributed, distributes the maximum version number of the overall situation got again described in a ratio big affairs to the affairs
Version number.
In an optional implementation:
Updating block, is specifically included:
Subelement is updated, major version number server sends global maximum version number more into version number's server group
New request.
In an optional implementation:
The submission unit, is specifically included:
Subelement is submitted, after the second response message of the major version number server return is received, described perform is submitted
The affairs finished;Wherein, second response message represents that the major version number server receives renewal request.
In an optional implementation:
Updating block, is specifically included:
Subelement is updated, the global maximum version number of all version number's server broadcasts into version number's server group
Update request.
In an optional implementation:
The submission unit, is specifically included:
Judgment sub-unit, within default second waiting time, judges the second response message quantity and all versions returned
Whether the ratio of this number number of servers reaches preset ratio;Wherein, second response message represents version number's server receipts
To renewal request.
Subelement is submitted, in the case of the second response message that the version number's server for getting preset ratio is returned,
The affairs being finished described in submitting.
Referring to Fig. 9, the module map of the transacter provided for the embodiment of the application one, the embodiment is from distributed number
It is described according to version number's server group side in storehouse, version number's server group is used to safeguard global maximum by least two
The database server group of version number is into described device includes:Receiving unit 510 and returning unit 520.
Wherein, receiving unit 510, receive the acquisition request of the maximum version number of the overall situation of database server transmission;
Returning unit 520, the database server is returned to by the maximum version number of the overall situation of maintenance.
In an optional implementation:
The returning unit 520, is specifically included:
Subelement is returned to, the maximum version number of the overall situation that major version number server is safeguarded returns to the database service
Device.
In an optional implementation:
The return subelement, is specifically included:
Subelement is chosen, in the case of key plate book server is disabled, one is chosen from version number's server group
Individual standby version number's server;
Second returns to subelement, and the maximum version number of the overall situation that standby version number's server is safeguarded returns to the number
According to storehouse server.
In an optional implementation:
Described device also includes:
Receive and update request unit, the renewal that the major version number server receives the database server transmission please
Ask, transactional version number is carried in renewal request;
Judging unit, the major version number server judges whether the transactional version number is more than the overall situation maximum of its maintenance
Version number;
Updating block, in the case of the maximum version number of the overall situation that the transactional version number is more than its maintenance, the key plate
The transactional version number is defined as the maximum version number of the new overall situation by this number server.
In an optional implementation:
After the updating block, described device also includes:
Response unit, the major version number server returns to the second response message to the database server;Wherein, institute
State the second response message and represent that the major version number server receives renewal request.
In an optional implementation:
The returning unit, is specifically included:
Subelement is returned to, the local maxima version number that all version number's servers are safeguarded returns to the database service
Device.
In an optional implementation:
Described device also includes:
Receive and update request unit, each version number's server receives the renewal request of database server broadcast, and this is more
Transactional version number is carried in new request;
Judging unit, each version number's server judges whether the transactional version number is more than the local maxima version of its maintenance
This number;
Updating block, in the case of the maximum version number of the overall situation that the transactional version number is more than its maintenance, by the thing
Business version number is defined as its new local maxima version number.
In an optional implementation:
After the updating block, described device also includes:
Response unit, is more than or is not more than the situation of its local maxima version number safeguarded in the transactional version number
Under, return to the second response message to the database server;Wherein, second response message represents that receiving the renewal asks
Ask.
System, device, module or unit that above-described embodiment is illustrated, can specifically be realized by computer chip or entity,
Or realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cell phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet PC, wearable device or these equipment
The combination of any several equipment.
The function of unit and the implementation process of effect specifically refer to correspondence step in the above method in said apparatus
Implementation process, will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method
Apply the part explanation of example.Device embodiment described above is only schematical, wherein described be used as separating component
The unit of explanation can be or may not be physically separate, and the part shown as unit can be or can also
It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality
Selection some or all of module therein is needed to realize the purpose of application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, you can to understand and implement.
Those skilled in the art will readily occur to its of the application after considering specification and putting into practice invention disclosed herein
Its embodiment.The application is intended to any modification, purposes or the adaptations of the application, these modifications, purposes or
Person's adaptations follow the general principle of the application and including the undocumented common knowledge in the art of the application
Or conventional techniques.Description and embodiments are considered only as exemplary, and the true scope of the application and spirit are by following
Claim is pointed out.
It should be appreciated that the precision architecture that the application is not limited to be described above and is shown in the drawings, and
And various modifications and changes can be being carried out without departing from the scope.Scope of the present application is only limited by appended claim.