CN105446993A - Cross-database transaction processing method and device - Google Patents

Cross-database transaction processing method and device Download PDF

Info

Publication number
CN105446993A
CN105446993A CN201410326639.9A CN201410326639A CN105446993A CN 105446993 A CN105446993 A CN 105446993A CN 201410326639 A CN201410326639 A CN 201410326639A CN 105446993 A CN105446993 A CN 105446993A
Authority
CN
China
Prior art keywords
database
business transaction
transaction
state
account
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.)
Pending
Application number
CN201410326639.9A
Other languages
Chinese (zh)
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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201410326639.9A priority Critical patent/CN105446993A/en
Publication of CN105446993A publication Critical patent/CN105446993A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a cross-database transaction processing method and device; the method comprises the following steps: receiving a business request comprising transaction information related to business transaction; respectively recording action information, related to the business transaction, of a plurality of databases participating the business transaction according to the transaction information, labeling a business transaction process state as to be submitted state, wherein the to be submitted state refers to a business process state in which all databases satisfy business transaction participation conditions and each database can be operated; carrying out at least one operation for each database under the to be submitted state according to the action information of each database participating the business transaction, until actions of all databases participating the business transaction become consistent. The method and device can realize cross-database transaction processing.

Description

Inter-library transaction methods and device
[technical field]
The present invention relates to database technical field, particularly relate to a kind of inter-library transaction methods and device.
[background technology]
Database fractionation is a kind of effective means of capacity, mainly the data processed in a database is broken in multiple database according to certain rule, reduces the pressure in individual data storehouse.Current database splits and comprises vertical fractionation and level fractionation.Wherein, vertical fractionation divides according to function, and the data of difference in functionality are put in different databases respectively; Level split be by one table Data Division in multiple same tables, generally adopt the modes such as Hash (hash) hash to ensure the homogeneity of split result.
In the application scenarios in above-mentioned point of storehouse, likely relate to inter-library affairs, namely need the affairs carrying out operating between disparate databases.Inter-library business requirements meets consistance, namely all successful or all failed to the operating result of disparate databases, otherwise just there will be mistake.Owing to seldom there are inter-library affairs under existing vertical fractionation or level fractionation mode, so still there is not the ripe scheme of the inter-library affairs of process in prior art.
[summary of the invention]
Many aspects of the present invention provide a kind of inter-library transaction methods and device, in order to realize the process of inter-library affairs.
An aspect of of the present present invention, provides a kind of inter-library transaction methods, comprising:
Receive service request, described service request comprises the Transaction Information that business transaction relates to;
According to described Transaction Information, record the behavioural information that multiple databases that described business transaction relates to participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, described state to be committed refers to the business processing status that can operate each database after all databases all meet the condition of the described business transaction of participation;
Under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent.
Another aspect of the present invention, provides a kind of inter-library transacter, comprising:
Receiver module, for receiving service request, described service request comprises the Transaction Information that business transaction relates to;
First processing module, for according to described Transaction Information, record the behavioural information that multiple databases that described business transaction relates to participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, described state to be committed refers to the business processing status that can operate each database after all databases all meet the condition of the described business transaction of participation;
Second processing module, under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent.
In technical solution of the present invention, after receiving service request, according to the Transaction Information that service request comprises, conclude the business multiple databases of relating to of record traffic participate in the behavioural information of this business transaction respectively, and the treatment state of this business transaction is labeled as state to be committed, under state to be committed, the behavioural information according to above-mentioned record carries out at least single job to each database respectively, until the behavior outcome that all databases participate in business transaction reaches consistent.The behavioural information of business transaction is participated in by recording each database, and the treatment state of business transaction is marked, can ensure that each database of multiple exercise participates in the behavior of business transaction until the behavior outcome that all databases participate in business transaction reaches consistent, therefore, there will not be the unsuccessful situation of submission result of some database of submission result success of some database, ensure that affairs submit the consistance of result to.
[accompanying drawing explanation]
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
The schematic flow sheet of the inter-library transaction methods that Fig. 1 provides for one embodiment of the invention;
The schematic flow sheet of the inter-library transaction methods that Fig. 2 provides for another embodiment of the present invention;
The schematic flow sheet of the inter-library transaction methods that Fig. 3 provides for further embodiment of this invention;
The schematic flow sheet of the inter-library transaction methods that Fig. 4 provides for further embodiment of this invention;
The structural representation of the inter-library transacter that Fig. 5 provides for one embodiment of the invention;
The structural representation of the inter-library transacter that Fig. 6 provides for another embodiment of the present invention.
[embodiment]
For making the object of the embodiment of the present invention, technical scheme and advantage clearly, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
In the application scenarios of single database, after the capacity of database reaches bottleneck, normally by the Data Division in database in multiple database, to tackle the demand for services of more high power capacity.Method for splitting comprises vertical fractionation and level fractionation.For account business, because business model is very simple, mainly provide and do account service and account information inquiry service.Wherein do account service comprise stored in (as bank cash stored in, or money is beaten to the inter-bank of one's own profession by other banks), withdraw deposit (cash as bank is withdrawn deposit, or manage it to him remit money) and transfer accounts (allocation of the funds as between bank internal customer).Therefore, for the vertical stripping cannot accomplishing business account business, so be not suitable for adopting the vertical mode split.For reaching, the affairs focus of account service and storage focus are evenly spread on each point of storehouse, for the mode that accounting data can adopt level to split.The present embodiment provides a kind of horizontal method for splitting newly for accounting data, namely splits according to account number.
Suppose that the create-rule of account number is: 6 business prefixes+10 increase progressively numbering, then account number generation example such as following table 1 is shown:
Table 1
Rear 10 generating modes increasing progressively numbering are often produce a new account number, the basis of a upper account number adds 1 and increases progressively.
Based on above-mentioned, if expect, database is splitted into 100 by 1, then press 100 deliverys with account number, the foundation that the result obtained splits as database level, just on average can split according to account number accounting data in 100 databases in this way.If capacity requirement promotes further, also can consider further to account number by 1000 deliverys, so just according to account number, accounting data can be split in 1000 databases by 1 database.The explanation of value, specifically presses much numerical value to account number delivery, can determine according to the requirement assessment of practical business scale to capacity.
Illustrate, suppose that accounting data corresponding to current account needs to be split in 100 storehouses by original 1 storehouse.To account number M:1000010009988012, account number N:1000010239168099 carries out 100 deliverys respectively, then the modulo operation result of account number M is: 1000010009988012%100=12; The modulo operation result of account number N is: 1000010239168099%100=99.Then according to operation result, we need the accounting data of account number M to insert the database being numbered 12, and library name can be set to ACCOUNT_12; The accounting data of account number N inserts the database being numbered 99, and library name can be set to ACCOUNT_99.
No matter be after point storehouse is carried out to above-mentioned account business, or to of the prior art point of storehouse scene, all can occur inter-library affairs, occur that the scene of inter-library affairs is more for behind account business point storehouse.Such as, the account fund for two clients is transferred, account number M transfer accounts 100 yuan give account number N, the accounting data of account number M and account number N in different databases, so there are inter-library affairs.
Transfer accounts, following guarantee must be made for one for account number M and account number N generation:
Account number M withholds successfully, and account number N adds money success, externally returns successful result of transferring accounts;
Account number M withholds unsuccessfully, and account number N does not add money, externally returns failure result of transferring accounts;
Following situation then forbids occurring:
Account number M withholds successfully, and account number N does not add money;
Account number M does not withhold, and account number N adds money success;
That is, in transfer procedure, account number M withholds and account number N adds this part thing of money and must meet consistance, or success simultaneously, or failure simultaneously, otherwise there will be fund allocation and make mistakes.Because prior art does not exist the technical scheme solved the problem, the embodiment of the present invention provides a kind of inter-library transaction methods.
The schematic flow sheet of the inter-library transaction methods that Fig. 1 provides for one embodiment of the invention.As shown in Figure 1, the method comprises:
101, receive service request, this service request comprises the Transaction Information that business transaction relates to.
102, according to above-mentioned Transaction Information, record the behavioural information of multiple databases participation business transactions that above-mentioned business transaction relates to respectively, and the treatment state of above-mentioned business transaction being labeled as (C) to be committed state, this C state refers to the business processing status that can operate each database after all databases all meet the condition of the above-mentioned business transaction of participation.
103, under above-mentioned C state, the behavioural information participating in above-mentioned business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in above-mentioned business transaction reaches consistent.
The executive agent of the present embodiment can be inter-library transacter, such as, can be the various servers or client etc. that need to process inter-library affairs.
Such as, inter-library transacter can receive the service request that business transaction system sends, but is not limited to business transaction system one.Service request comprises the Transaction Information that business transaction relates to.Illustrate, for transferred account service, Transaction Information includes but not limited to flow into account, flow out the information such as account and dealing money.
After inter-library transacter receives service request, can resolve this service request, therefrom obtain Transaction Information.Then, inter-library transacter, according to this Transaction Information, records the behavioural information that multiple databases that this business transaction relates to participate in this business transaction respectively.Owing to being inter-library affairs, therefore this business transaction at least relates to two databases, and that is described multiple database refers to two or more database.The behavioural information of this business transaction is participated in by recording each database, and business processing status is marked, like this can under specific transactions treatment state (such as C state), participating in the behavior outcome of this business transaction and other databases at certain or some databases, to participate in the behavior outcome of above-mentioned business transaction inconsistent, such as this database participates in the behavior outcome of business transaction is unsuccessfully, but other databases participate in the behavior outcome of business transaction be successfully time, the behavioural information being participated in business transaction by this database extracting record is operated this database again, until the behavior outcome that this database participates in this business transaction is consistent with the behavior outcome that other databases participate in above-mentioned business transaction.
What deserves to be explained is, the behavior outcome that all databases participate in above-mentioned business transaction reaches that can be unanimously that all databases participate in the behavior outcome of above-mentioned business transaction all successful, or it is all failed to be that all databases participate in the behavior outcome of above-mentioned business transaction.
Inter-library transacter participates in except the behavioural information of this business transaction except recording above-mentioned multiple database, also can mark the treatment state of business transaction.Such as when just starting to process, the treatment state of this business transaction can be labeled as beginning (P) state; Again such as, in ready work, namely be recorded to after each database participates in the behavioural information of this business transaction, the treatment state of this business transaction can be labeled as C state, mean that all databases all meet the condition participating in above-mentioned business transaction, can operate each database, namely be about to enter affairs presentation stage.By marking the treatment state of business transaction, just can enter next treatment state after only having last treatment state to complete, preventing processing procedure from making a mistake.
Further, in an Alternate embodiments, if the behavior outcome that all databases participate in above-mentioned business transaction reaches, unanimously to refer to that all databases participate in the behavior outcome of above-mentioned business transaction all successful, then inter-library transacter when all database some databases participate in the behavior outcome success of above-mentioned business transaction, can also delete the behavioural information that this partial database participates in business transaction.The benefit done like this is: when there is other databases and participating in the behavior outcome failure of business transaction, inter-library transacter can only obtain the behavioural information of the database participation business transaction of above-mentioned behavior outcome failure again from the information of record, and also only can operate the database of participative behavior result failure, be conducive to the processing load alleviating inter-library transacter, and be conducive to improving treatment effeciency.
Further, inter-library transacter can also participate in the behavior outcome of above-mentioned business transaction all successfully at above-mentioned all databases, after namely above-mentioned business transaction completes, the treatment state of business transaction has been labeled as (S) state.Like this, under S state, inter-library transacter will know this business transaction success, no longer performs any operation.
As can be seen here, the method that the present embodiment provides, the behavioural information of business transaction is participated in by recording each database, and the treatment state of business transaction is marked, can all databases all meet participate in business transaction condition after can under the business processing status of each database executable operations, ensure that each database of multiple exercise participates in the behavior of business transaction until the behavior outcome that all databases participate in business transaction reaches consistent, therefore, there will not be the unsuccessful situation of submission result of some database of submission result success of some database, ensure that affairs submit the consistance of result to.
Optionally, a kind of embodiment of above-mentioned steps 103 comprises: inter-library transacter after the treatment state of above-mentioned business transaction is labeled as state to be committed, can be waited for according to the time span preset; After the time span preset terminates, perform the operation described in above-mentioned steps 103, namely after the time span preset terminates, under state to be committed, the behavioural information participating in above-mentioned business transaction according to each database performs each database again and operates at least one times, until the behavior outcome that all databases participate in above-mentioned business transaction reaches the operation of consistance.In the present embodiment, by arranging the time span of wait, the presentation stage of business transaction can be delayed and does or be suspended temporarily, the time period that the presentation stage of business transaction is put into affairs less can be performed like this, be conducive to the processing load of balanced inter-library transacter, especially can alleviate the pressure of inter-library transacter in affairs peak period greatly.
For inter-library affairs, what relate to is mutual between two databases more, even if inter-library affairs relate to two or more database, but mutual at a time between general or two databases, based on this, following examples of the present invention relate to two databases for inter-library affairs and are described.For ease of describing, these two databases are designated as the first database and the second database respectively.
The schematic flow sheet of the inter-library transaction methods that Fig. 2 provides for another embodiment of the present invention.As shown in Figure 2, the method comprises:
201, receive service request, this service request comprises the Transaction Information that business transaction relates to.
202, the treatment state of tagged traffic transaction is P-state.
203, according to above-mentioned Transaction Information, judge whether the first database that above-mentioned business transaction relates to meets the condition participating in above-mentioned business transaction, and if so, namely the first database meets the condition participating in above-mentioned business transaction, then perform step 204; If not, namely the first database does not meet the condition participating in above-mentioned business transaction, then perform step 208.
204, record the behavioural information that the first database participates in above-mentioned business transaction, and continue to perform step 205.
205, according to above-mentioned Transaction Information, judge whether the second database that above-mentioned business transaction relates to meets the condition participating in above-mentioned business transaction; If so, namely the second database meets the condition participating in above-mentioned business transaction, then perform step 206, and if not, namely the second database does not meet the condition participating in above-mentioned business transaction, then perform step 208.
206, record the behavioural information that the second database participates in above-mentioned business transaction, and the treatment state of above-mentioned business processing is labeled as C state, and perform step 207.
This C state means that all databases all meet the condition participating in above-mentioned business transaction, can operate each database.
207, under above-mentioned C state, the behavioural information participating in above-mentioned business transaction according to the first database carries out at least single job to the first database, and the behavioural information participating in above-mentioned business transaction according to the second database carries out at least single job to two databases, until the behavior outcome that the first database and the second database participate in above-mentioned business transaction reaches consistent.
Optionally, inter-library transacter can arrange timing mechanism, and the behavioural information that namely timing participates in business transaction according to each database operates according to storehouse each, until the behavior outcome that all databases participate in above-mentioned business transaction reaches consistent.
208, the treatment state of above-mentioned business transaction is labeled as rollback (R) state, and rollback process is carried out to operation before.
Illustrate at this, when forwarding step 208 to by step 203, rolling back action here mainly refers to and carries out rollback to step 203 and operation before.When forwarding step 208 to by step 205, rolling back action here mainly refers to and carries out rollback to step 205 and operation before.
The method that the present embodiment provides, the behavioural information of business transaction is participated in by recording each database, and the treatment state of business transaction is marked, can all databases all meet participate in business transaction condition after can under the business processing status of each database executable operations, ensure that each database of multiple exercise participates in the behavior of business transaction until the behavior outcome that all databases participate in business transaction reaches consistent, therefore, there will not be the unsuccessful situation of submission result of some database of submission result success of some database, ensure that affairs submit the consistance of result to.
The schematic flow sheet of the inter-library transaction methods that Fig. 3 provides for further embodiment of this invention.As shown in Figure 3, the method comprises:
301, receive service request, this service request comprises the Transaction Information that business transaction relates to.
302, distributing can the service request number of the above-mentioned business transaction of unique identification, the mark of the first database that this service request of corresponding stored number and above-mentioned business transaction relate to, and the treatment state marking above-mentioned business transaction is P-state.
In the present embodiment, be the request number of business transaction distribution services, for unique identification business transaction process.By the mark of corresponding stored service request number and the first database, in order to record the participant of this business transaction.
303, according to above-mentioned Transaction Information, judge whether the first database that above-mentioned business transaction relates to meets the condition participating in above-mentioned business transaction, and if so, namely the first database meets the condition participating in above-mentioned business transaction, then perform step 304; If not, namely the first database does not meet the condition participating in above-mentioned business transaction, then perform step 310.
304, record the behavioural information that the first database participates in above-mentioned business transaction, and continue to perform step 305.
In the present embodiment, the first database can be participated in the behavioural information of above-mentioned business transaction and the service request corresponding stored of above-mentioned business transaction, so that distinguish behavioural information corresponding to different business transaction.
305, the mark of the second database that relates to of the above-mentioned service request of corresponding stored number and above-mentioned business transaction, and continue to perform step 306.
In like manner, the mark of the second database above-mentioned business transaction related to here and service request corresponding stored, in order to record the participant of this business transaction.
306, according to above-mentioned Transaction Information, judge whether the second database that above-mentioned business transaction relates to meets the condition participating in above-mentioned business transaction; If so, namely the second database meets the condition participating in above-mentioned business transaction, then perform step 307, and if not, namely the second database does not meet the condition participating in above-mentioned business transaction, then perform step 310.
307, record the behavioural information that the second database participates in above-mentioned business transaction, and the treatment state of above-mentioned business processing is updated to C state, and continue to perform step 308.
C state refers to the business processing status that can operate each database after all databases all meet the condition of the above-mentioned business transaction of participation.
In the present embodiment, the second database can be participated in the behavioural information of above-mentioned business transaction and the service request corresponding stored of above-mentioned business transaction, so that distinguish behavioural information corresponding to different business transaction.
308, under above-mentioned C state, the behavioural information participating in above-mentioned business transaction according to the first database carries out at least single job to the first database, and the behavioural information participating in above-mentioned business transaction according to the second database carries out at least single job to two databases, until the first database and the second database participate in behavior outcome all successes of above-mentioned business transaction, to complete above-mentioned business transaction, and continue to perform step 309.
The present embodiment reaches consistent for the behavior outcome that the first database and the second database participate in above-mentioned business transaction and refers to that the first database and the second database participate in the behavior outcome of above-mentioned business transaction all successfully, but is not limited thereto.
309, delete the behavioural information of the mark of the first database, the first database the participation behavioural information of business transaction, the mark of the second database and the second database participation business transaction, and the treatment state of above-mentioned business transaction is updated to S state.
310, the treatment state of above-mentioned business transaction is labeled as R state, and rollback process is carried out to operation before.
Illustrate at this, if forward step 310 to by step 303, then the information such as the mark of the service request stored in above-mentioned steps 302 number and the first database and the P-state that marks specifically all are deleted by rollback process here.
If forward step 310 to by step 306, then the first database of record in the mark of the service request stored in above-mentioned steps 302 number and the first database and the P-state information marked, above-mentioned steps 304 is specifically participated in the information such as the mark of the service request that stores in the behavioural information of above-mentioned business transaction and above-mentioned steps 305 number and the second database and all deletes by rollback process here.What deserves to be explained is, if also perform relevant operational in above-mentioned steps 303, then rolling back action also needs operation performed in back-off procedure 303 here.
In an Alternate embodiments, can by the independently above-mentioned information relevant with service request of database purchase, such as above-mentioned service request number, the mark of the first database, the mark of the second database, the first database participate in the behavioural information of business transaction, the second database participates in the behavioural information of business transaction, the treatment state etc. of business transaction.
Further, for the ease of managing above-mentioned information, can be managed by different tables.Such as, can by the treatment state of the above-mentioned service request of first information table record number and business transaction; The behavioural information that the behavioural information of business transaction and the second database participate in business transaction is participated in by the mark of the mark of the second information table record first database, the second database, the first database.
First information table and the second information table are respectively as shown in following table 2 and table 3.
Table 2
Table 3
In an Alternate embodiments, above-mentioned business transaction can be the transferred account service in billing and accounting system.Above-mentioned Transaction Information comprises outflow account, flows into account and dealing money.
Based on this, a kind of embodiment of above-mentioned steps 102 comprises:
According to the first database that outflow account determination business transaction relates to, freeze according to the amount of money that dealing money goes out in account to the first database application convection current.
If the avail in outflow account is more than or equal to dealing money, determine that the first database meets the condition participating in transferred account service, and freeze dealing money from outflow account, record the behavioural information that the first database participates in account transferred account service;
Whether according to the second database that inflow account determination business transaction relates to, and it is legal to flow into account to the second database application inspection;
If it is legal to flow into account, determine that the second database meets the condition participating in account transferred account service, record the behavioural information that the second database participates in transferred account service, and the treatment state of transferred account service is labeled as C state.
For transferred account service, then the detailed implementing procedure of technical solution of the present invention as shown in Figure 4.The schematic flow sheet of the inter-library transaction methods that Fig. 4 provides for further embodiment of this invention.As shown in Figure 4, the method comprises:
401, receive service request, this service request comprises the Transaction Information that transferred account service relates to, and this Transaction Information comprises outflow account, flows into account and dealing money.
402, according to the outflow account in above-mentioned Transaction Information, the first database that above-mentioned transferred account service relates to is determined.
Concrete, determine that the database at above-mentioned outflow account place is as the first database.
403, distributing can the service request number of the above-mentioned transferred account service of unique identification, the mark of this service request of corresponding stored number and above-mentioned first database, and the treatment state marking above-mentioned transferred account service is P-state.
In conjunction with above-mentioned table 2 and table 3, then the service request of transferred account service number can be stored in table 2, and the current processing status P of transferred account service is marked in table 2; That service request in table 3 number is arranged to table 2 is identical, and the mark of the first database is stored in table 3.
404, according to the outflow account in above-mentioned Transaction Information and dealing money, application is freezed to flow out above-mentioned dealing money in account in the first database.
Concrete, this step is that application freezes above-mentioned dealing money from outflow account.
405, judge that whether above-mentioned freeze operation is successful; If so, then step 406 is performed; If not, then step 415 is performed.
Concrete, judge whether the avail flowed out in account is more than or equal to above-mentioned dealing money, if so, then above-mentioned freeze operation success; If not, then above-mentioned freeze operation failure.
Illustrate at this, if judge whether the avail flowed out in account is more than or equal to outside above-mentioned dealing money, can also judge that whether flow out account meets other rules, such as, can also verify the state flowing out account current and whether be in pay status etc.Those skilled in the art can according to practical application scene, and Adaptable extension is carried out on the basis of the relevant verification mode provided at the present embodiment.
406, the behavioural information that the first database participates in transferred account service is recorded.
Concrete, the behavioural information that the first database participates in transferred account service can be: flow out account, dealing money, pretreated state of concluding the business is frozen state., can illustrate that flowing out the external avail of account needs to deduct above-mentioned dealing money by these information, and indicate follow-up needs and thaw and the amount of money of reducing.Optionally, the behavioural information that above-mentioned first database participates in transferred account service can be recorded in the identification field of participant in table 3, but be not limited thereto.
407, according to the inflow account in above-mentioned Transaction Information, the second database that above-mentioned transferred account service relates to is determined, the mark of the above-mentioned service request of corresponding stored number and the second database.
Concrete, determine that the database flowing into account place is as the second database.After determining the second database, the mark of the second database can be stored in table 3.
408, judge that whether the inflow account in the second database is legal, if so, perform step 409, if not, perform step 415.
409, record the behavioural information that the second database participates in transferred account service, the treatment state of above-mentioned transferred account service is updated to C state.
Concrete, the behavioural information that the second database participates in transferred account service can be: flow into account, dealing money, the preprocessed state of transaction waits to proceed to.The treatment state of business in table 2 can be updated to C state.C state refers to the business processing status that can operate each database after all databases all meet the condition of the above-mentioned business transaction of participation.
Optionally, the behavioural information that above-mentioned second database participates in transferred account service can be recorded in the identification field of participant in table 3, but be not limited thereto.
410, when the treatment state determining above-mentioned transferred account service is C state, thaw flowing out the dealing money freezed in account in the first database, and deduct this dealing money.
Illustrate at this, under C state, inter-library transacter can thaw flowing out the dealing money freezed in account in the first database by multiple exercise, and deducts the operation of this dealing money, until successfully deduct this dealing money from outflow account.
411, the mark of the first database and the behavioural information of the first database participation transferred account service is deleted.
412, flow in account in the second database and increase above-mentioned dealing money.
Concrete, inter-library transacter can under C state, and multiple exercise flows in account the operation increasing above-mentioned dealing money in the second database, until successfully increase above-mentioned dealing money in inflow account.
413, the mark of the second database and the behavioural information of the second database participation transferred account service is deleted.
414, the treatment state of above-mentioned transferred account service is upgraded S state.
415, the treatment state of transferred account service is labeled as R state, and rollback process is carried out to operation before.
If forward this step 415 to by step 405, then rollback process here specifically refers to and the data in above-mentioned table 2 and table 3 is deleted, and the information of feedback trading freezing of funds failure.
If forward this step 415 to by step 408, then rollback process here specifically refers to and the data in above-mentioned table 2 and table 3 is deleted, and will flow out the dealing money reduction freezed in account.
In this embodiment, can also comprise before proceeding and being stored into flowing out account and flowing into account in corresponding database according to preceding method.Concrete: modulo operation is carried out to the account number of described outflow account, according to delivery result, this outflow account is stored in the first database; The account number that convection current enters account carries out modulo operation, this inflow account is stored in the second database according to delivery result.
The method that the present embodiment provides, the behavioural information of business transaction is participated in by recording each database, and the treatment state of business transaction is marked, can all databases all meet participate in business transaction condition after can under the business processing status of each database executable operations, ensure that each database of multiple exercise participates in the behavior of business transaction until success, therefore, there will not be the unsuccessful situation of submission result of some database of submission result success of some database, ensure that affairs submit the consistance of result to.
It should be noted that, for aforesaid each embodiment of the method, in order to simple description, therefore it is all expressed as a series of combination of actions, but those skilled in the art should know, the present invention is not by the restriction of described sequence of movement, because according to the present invention, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and involved action and module might not be that the present invention is necessary.
In the above-described embodiments, the description of each embodiment is all emphasized particularly on different fields, in certain embodiment, there is no the part described in detail, can see the associated description of other embodiments.
The structural representation of the inter-library transacter that Fig. 5 provides for one embodiment of the invention.As shown in Figure 5, this device comprises: receiver module 51, first processing module 52 and the second processing module 53.
Receiver module 51, for receiving service request, this service request comprises the Transaction Information that business transaction relates to.
First processing module 52, be connected with receiver module 51, for the Transaction Information in the service request that receives according to receiver module 51, record the behavioural information that multiple databases that this business transaction relates to participate in this business transaction respectively, and the treatment state of this business transaction is labeled as state to be committed.This state to be committed refers to the business processing status that can operate each database after all databases all meet the condition of the above-mentioned business transaction of participation.
Second processing module 53, be connected with the first processing module 52, for under the state to be committed of the first processing module 52 mark, the behavioural information participating in above-mentioned business transaction according to each database of the first processing module 52 record carries out at least single job to each database, until the behavior outcome that all databases participate in above-mentioned business transaction reaches consistent.
In an Alternate embodiments, as shown in Figure 6, this device also comprises: removing module 54 and mark module 55.
Removing module 54, be connected with the second processing module 53, if the behavior outcome participating in above-mentioned business transaction for all databases reaches, unanimously to refer to that all databases participate in the behavior outcome of above-mentioned business transaction all successful, then when above-mentioned all database some databases participate in the behavior outcome success of above-mentioned business transaction, delete the behavioural information that this partial database participates in above-mentioned business transaction.
Mark module 55, is connected with the second processing module 53, after the behavior outcome for participating in above-mentioned business transaction at all databases is all successful, the treatment state of above-mentioned business transaction is labeled as completion status.
In an Alternate embodiments, after second processing module 53 is specifically used in and the treatment state of above-mentioned business transaction is labeled as state to be committed, wait for according to the time span preset, after this time span preset terminates, execution is under state to be committed, the behavioural information participating in business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in business transaction reaches consistent operation.
In an Alternate embodiments, above-mentioned multiple database comprises the first database and the second database.
Then the first processing module 52 specifically can be used for according to above-mentioned Transaction Information, judge whether the first database meets the condition participating in above-mentioned business transaction, if the first database meets the condition participating in above-mentioned business transaction, record the behavioural information that the first database participates in above-mentioned business transaction, according to above-mentioned Transaction Information, judge whether the second database meets the condition participating in above-mentioned business transaction, if the second database meets the condition participating in above-mentioned business transaction, record the behavioural information that the second database participates in above-mentioned business transaction, and the treatment state of above-mentioned business processing is labeled as state to be committed.
In an Alternate embodiments, first processing module 52 is not also for when the first database or the second database meet the condition participating in above-mentioned business transaction, the treatment state of above-mentioned business transaction is labeled as and treats rollback state, and rollback process is carried out to operation before.
In an Alternate embodiments, above-mentioned business transaction is transferred account service, and above-mentioned Transaction Information comprises inflow account, flows out account and dealing money.Then the first processing module 52 specifically can be used for determining the first database according to stating outflow account, freezes according to the amount of money that dealing money goes out in account to the first database application convection current; If the avail in outflow account is more than or equal to dealing money, determine that the first database meets the condition participating in transferred account service, and freeze dealing money from outflow account, record the behavioural information that the first database participates in transferred account service; Determine the second database according to inflow account, and whether flow into account to the second database application inspection legal; If it is legal to flow into account, determine that the second database meets the condition participating in transferred account service, record the behavioural information that the second database participates in transferred account service, and the treatment state of transferred account service is labeled as state to be committed.
Further, the device of the present embodiment also comprises: the 3rd processing module, before receiving service request at receiver module 51, the account number that convection current goes out account carries out modulo operation, according to delivery result, outflow account is stored in the first database, and the account number that convection current enters account carries out modulo operation, inflow account is stored in the second database according to delivery result.
The inter-library transacter that the present embodiment provides, the behavioural information of business transaction is participated in by recording each database, and the treatment state of business transaction is marked, can all databases all meet participate in business transaction condition after can under the business processing status of each database executable operations, ensure that each database of multiple exercise participates in the behavior of business transaction until the behavior outcome that all databases participate in business transaction reaches consistent, therefore, there will not be the unsuccessful situation of submission result of some database of submission result success of some database, ensure that affairs submit the consistance of result to.
Those skilled in the art can be well understood to, and for convenience and simplicity of description, the system of foregoing description, the specific works process of device and unit, with reference to the corresponding process in preceding method embodiment, can not repeat them here.
In several embodiment provided by the present invention, should be understood that, disclosed system, apparatus and method, can realize by another way.Such as, device embodiment described above is only schematic, such as, the division of described unit, be only a kind of logic function to divide, actual can have other dividing mode when realizing, such as multiple unit or assembly can in conjunction with or another system can be integrated into, or some features can be ignored, or do not perform.Another point, shown or discussed coupling each other or direct-coupling or communication connection can be by some interfaces, and the indirect coupling of device or unit or communication connection can be electrical, machinery or other form.
The described unit illustrated as separating component or can may not be and physically separates, and the parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of unit wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, also can be that the independent physics of unit exists, also can two or more unit in a unit integrated.Above-mentioned integrated unit both can adopt the form of hardware to realize, and the form that hardware also can be adopted to add SFU software functional unit realizes.
The above-mentioned integrated unit realized with the form of SFU software functional unit, can be stored in a computer read/write memory medium.Above-mentioned SFU software functional unit is stored in a storage medium, comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) or processor (processor) perform the part steps of method described in each embodiment of the present invention.And aforesaid storage medium comprises: USB flash disk, portable hard drive, ROM (read-only memory) (Read-OnlyMemory, ROM), random access memory (RandomAccessMemory, RAM), magnetic disc or CD etc. various can be program code stored medium.
Last it is noted that above embodiment is only in order to illustrate technical scheme of the present invention, be not intended to limit; Although with reference to previous embodiment to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein portion of techniques feature; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (12)

1. an inter-library transaction methods, is characterized in that, comprising:
Receive service request, described service request comprises the Transaction Information that business transaction relates to;
According to described Transaction Information, record the behavioural information that multiple databases that described business transaction relates to participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, described state to be committed refers to the business processing status that can operate each database after all databases all meet the condition of the described business transaction of participation;
Under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent.
2. method according to claim 1, is characterized in that, if the behavior outcome that all databases participate in described business transaction reaches, unanimously to refer to that all databases participate in the behavior outcome of described business transaction all successful, and described method also comprises:
When all database some databases participate in the behavior outcome success of described business transaction, delete the behavioural information that described partial database participates in described business transaction;
The treatment state of described business transaction, all after success, is labeled as completion status by the behavior outcome participating in described business transaction at all databases.
3. method according to claim 1, it is characterized in that, under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches unanimously, comprising:
After the treatment state of described business transaction is labeled as described state to be committed, wait for according to the time span preset;
When execution after described time span terminates is under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent operation.
4. method according to claim 1, is characterized in that, described multiple database comprises the first database and the second database;
Described according to described Transaction Information, record the behavioural information that multiple databases that described business transaction relates to participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, comprising:
According to described Transaction Information, judge whether described first database meets the condition participating in described business transaction;
If described first database meets the condition participating in described business transaction, record the behavioural information that described first database participates in described business transaction;
According to described Transaction Information, judge whether described second database meets the condition participating in described business transaction;
If described second database meets the condition participating in described business transaction, record the behavioural information that described second database participates in described business transaction, and the treatment state of described business processing is labeled as described state to be committed.
5. method according to claim 4, is characterized in that, also comprises:
When described first database or described second database do not meet the condition participating in described business transaction, the treatment state of described business transaction is labeled as and treats rollback state, and rollback process is carried out to operation before.
6. the method according to any one of claim 1-5, is characterized in that, described business transaction is transferred account service, and described Transaction Information comprises inflow account, flows out account and dealing money;
Described according to described Transaction Information, record the behavioural information that the first database that described business transaction relates to and the second database participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, comprising:
Determine described first database according to described outflow account, to described first database application, the amount of money in described outflow account is freezed according to described dealing money;
If the avail in described outflow account is more than or equal to described dealing money, determine that described first database meets the condition participating in described transferred account service, and described dealing money is freezed from described outflow account, record the behavioural information that described first database participates in described transferred account service;
Determine described second database according to described inflow account, and check that whether described inflow account is legal to described second database application;
If described inflow account is legal, determine that described second database meets the condition participating in described transferred account service, record the behavioural information that described second database participates in described transferred account service, and the treatment state of described transferred account service is labeled as described state to be committed.
7. method according to claim 6, it is characterized in that, described according to described Transaction Information, record the behavioural information that the first database that described business transaction relates to and the second database participate in described business transaction respectively, and before the treatment state of described business transaction is labeled as state to be committed, comprising:
Modulo operation is carried out to the account number of described outflow account, according to delivery result, described outflow account is stored in described first database;
Modulo operation is carried out to the account number of described inflow account, according to delivery result, described inflow account is stored in described second database.
8. an inter-library transacter, is characterized in that, comprising:
Receiver module, for receiving service request, described service request comprises the Transaction Information that business transaction relates to;
First processing module, for according to described Transaction Information, record the behavioural information that multiple databases that described business transaction relates to participate in described business transaction respectively, and the treatment state of described business transaction is labeled as state to be committed, described state to be committed refers to the business processing status that can operate each database after all databases all meet the condition of the described business transaction of participation;
Second processing module, under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent.
9. device according to claim 8, is characterized in that, also comprises:
Removing module, if the behavior outcome participating in described business transaction for all databases reaches, unanimously to refer to that all databases participate in the behavior outcome of described business transaction all successful, then when all database some databases participate in the behavior outcome success of described business transaction, delete the behavioural information that described partial database participates in described business transaction;
Mark module, after the behavior outcome for participating in described business transaction at all databases is all successful, is labeled as completion status by the treatment state of described business transaction.
10. device according to claim 8, it is characterized in that, described second processing module is specifically for after being labeled as described state to be committed by the treatment state of described business transaction, wait for according to the time span preset, when execution after described time span terminates is under described state to be committed, the behavioural information participating in described business transaction according to each database carries out at least single job to each database, until the behavior outcome that all databases participate in described business transaction reaches consistent operation.
Device described in 11. according to Claim 8 or 9 or 10, is characterized in that, described multiple database comprises the first database and the second database;
Described first processing module is specifically for according to described Transaction Information, judge whether described first database meets the condition participating in described business transaction, if described first database meets the condition participating in described business transaction, record the behavioural information that described first database participates in described business transaction, according to described Transaction Information, judge whether described second database meets the condition participating in described business transaction, if described second database meets the condition participating in described business transaction, record the behavioural information that described second database participates in described business transaction, and the treatment state of described business processing is labeled as described state to be committed.
12. devices according to claim 11, it is characterized in that, described first processing module is not also for when described first database or described second database meet the condition participating in described business transaction, the treatment state of described business transaction is labeled as and treats rollback state, and rollback process is carried out to operation before.
CN201410326639.9A 2014-07-10 2014-07-10 Cross-database transaction processing method and device Pending CN105446993A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410326639.9A CN105446993A (en) 2014-07-10 2014-07-10 Cross-database transaction processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410326639.9A CN105446993A (en) 2014-07-10 2014-07-10 Cross-database transaction processing method and device

Publications (1)

Publication Number Publication Date
CN105446993A true CN105446993A (en) 2016-03-30

Family

ID=55557190

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410326639.9A Pending CN105446993A (en) 2014-07-10 2014-07-10 Cross-database transaction processing method and device

Country Status (1)

Country Link
CN (1) CN105446993A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845866A (en) * 2018-06-28 2018-11-20 阿里巴巴集团控股有限公司 The method and apparatus for handling distributed transaction
CN109711989A (en) * 2018-12-15 2019-05-03 深圳壹账通智能科技有限公司 Refund transaction data processing method, device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020174108A1 (en) * 2001-05-15 2002-11-21 International Business Machines Corporation Method for managing distributed savepoints across multiple DBMS's within a distributed transaction
CN101673275A (en) * 2009-08-11 2010-03-17 东软集团股份有限公司 Method and device for ensuring consistent affairs inside database

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020174108A1 (en) * 2001-05-15 2002-11-21 International Business Machines Corporation Method for managing distributed savepoints across multiple DBMS's within a distributed transaction
CN101673275A (en) * 2009-08-11 2010-03-17 东软集团股份有限公司 Method and device for ensuring consistent affairs inside database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CJN1118: "分布式数据库系统及其应用", 《HTTPS://WENKU.BAIDU.COM/VIEW/820266ED856A561252D36F2F.HTML?SXTS=1526266502069》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845866A (en) * 2018-06-28 2018-11-20 阿里巴巴集团控股有限公司 The method and apparatus for handling distributed transaction
CN108845866B (en) * 2018-06-28 2021-06-29 创新先进技术有限公司 Method and apparatus for processing distributed transactions
CN109711989A (en) * 2018-12-15 2019-05-03 深圳壹账通智能科技有限公司 Refund transaction data processing method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN105447604B (en) Account processing method and device
CN109542980B (en) Data processing method, device, equipment and medium for block chain
CN107358524B (en) Method for leveling funds among multiple account management lines in same currency
CN104463611A (en) Agent management system
WO2020147484A1 (en) Transaction clearing method and transaction clearing system
CN110910230A (en) Accounting method, accounting system and storage medium
CN107992492B (en) Data block storage method, data block reading method, data block storage device, data block reading device and block chain
CN111030983B (en) Data processing method and device based on distributed distribution and related equipment
CN111738709B (en) Transaction processing method and device
CN106096926B (en) Event processing method, device, electronic device and storage medium
CN105528448A (en) Data association method and system
CN111311360B (en) Resource refund method and device, storage medium and electronic device
CN110889687A (en) Method and device for processing account balance under distributed architecture
CN105446993A (en) Cross-database transaction processing method and device
CN108762895B (en) Method and device for processing distributed transaction
CN112084201B (en) Distributed account book processing method and device, storage medium and electronic equipment
CN111179062A (en) Voucher additional printing method and device
CN115983991A (en) Flow adjusting method, device, equipment and medium
CN112053218B (en) Bill management system, bill management method, computer device, and storage medium
CN111144855B (en) Service data storage method and device
CN111160885B (en) Accounting processing method and device
CN110175179B (en) Data transmission method and system, service node and storage device
CN113177843A (en) Cross-bank loan service processing method and device based on block chain
CN111476671A (en) Block chain rollback insurance method, equipment and storage medium
EP3503011A1 (en) Data analytics engine

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160330