CN110502319A - Processing method, device, electronic equipment and the storage medium of distributed transaction - Google Patents

Processing method, device, electronic equipment and the storage medium of distributed transaction Download PDF

Info

Publication number
CN110502319A
CN110502319A CN201910786076.4A CN201910786076A CN110502319A CN 110502319 A CN110502319 A CN 110502319A CN 201910786076 A CN201910786076 A CN 201910786076A CN 110502319 A CN110502319 A CN 110502319A
Authority
CN
China
Prior art keywords
node
snapshot
business
participant
target participant
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910786076.4A
Other languages
Chinese (zh)
Other versions
CN110502319B (en
Inventor
曹智颖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910786076.4A priority Critical patent/CN110502319B/en
Publication of CN110502319A publication Critical patent/CN110502319A/en
Application granted granted Critical
Publication of CN110502319B publication Critical patent/CN110502319B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0633Lists, e.g. purchase orders, compilation or processing
    • G06Q30/0635Processing of requisition or of purchase orders

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Quality & Reliability (AREA)
  • Strategic Management (AREA)
  • Software Systems (AREA)
  • Development Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Computing Systems (AREA)
  • Human Resources & Organizations (AREA)
  • Data Mining & Analysis (AREA)
  • Operations Research (AREA)
  • Tourism & Hospitality (AREA)
  • Hardware Redundancy (AREA)

Abstract

This application provides a kind of processing method of distributed transaction, device, electronic equipment and storage mediums, are related to computer field.This method comprises: the business operation that acquisition request method, apparatus is sent is requested, the operation mark of business operation is carried in business operation request;According to operation mark, at least two target participant's nodes for executing business operation are determined from all participant's nodes;The snapshot of each target participant node and preservation are obtained, snapshot is the snapshot of business datum corresponding with business operation in target participant's node;It calls each target participant node to execute the sub-operation of corresponding business operation respectively and obtains the implementing result of each target participant node;If there are the implementing results of a node in each target participant node to execute failure, snapshot corresponding to each node is then sent respectively to each target participant node, so that each target participant node restores corresponding business datum to the state executed before corresponding sub-operation according to snapshot.

Description

Processing method, device, electronic equipment and the storage medium of distributed transaction
Technical field
This application involves field of computer technology, specifically, this application involves a kind of processing method of distributed transaction, Device, electronic equipment and storage medium.
Background technique
In today that distributed deployment and micro services are propagated its belief on a large scale, distributed transaction widely exists in various interconnections In net system.The implementation procedure of distributed transaction generally comprises coordinator and participant's node, and coordinator can save to participant Point sends order, to control the operation that participant's node executes distributed transaction.The distributing real time system side of current industry In case, mainly there is two-phase commitment protocol (Two-Phase Commit protocol, 2PC) and attempt confirmation and cancel (Try- Confirm-Cancel, TCC) two schemes.
For 2PC scheme, after each participant's node of needs is when receiving inquiry, save required for executing transaction operation Undo log (for recording the data before being modified) and Redo log (for the data after record modification), needing to carry out When rollback, participant's node needs to carry out rollback using Undo log.As it can be seen that the realization of the program is mentioned dependent on participant's node The transaction rollback ability of confession, and have this ability is some relevant databases mostly, such as Oracle, MySql etc., for Do not have the database of the service of this characteristic, is then less applicable in.For TCC scheme, it is required that each thing of participant's node Business operation, it is necessary to there are corresponding rolling back action, very big development amount can be brought, and to service code have it is biggish enter It invades.
As it can be seen that the distributing real time system scheme of current industry, partly depends on the transaction capabilities of database offer, There is biggish intrusion in part to service code, not only general but also will not have larger intrusion to service code there is presently no one Scheme.
Summary of the invention
At least one of In order to solve the problems of in the prior art, the embodiment of the present application provides a kind of distribution Processing method, device, electronic equipment and the storage medium of formula affairs.Technical solution provided by the embodiment of the present application is as follows:
The embodiment of the present application in a first aspect, provide a kind of distributed transaction processing method, this method is applied to distribution In formula system, distributed system includes coordinator's node and at least two participant's nodes, coordinator's node and each ginseng It is communicated to connect with person's node, this method comprises:
The business operation that acquisition request method, apparatus is sent is requested, and the operation mark of business operation is carried in business operation request Know;
According to operation mark, determine that at least two targets for executing business operation are participated in from all participant's nodes Person's node;
Obtain the snapshot of each target participant node and preservation, wherein snapshot be in target participant's node with business Operate the snapshot of corresponding business datum;
It calls each target participant node to execute the sub-operation of corresponding business operation respectively, and obtains each target participant The implementing result of node;
If there are the implementing results of a node in each target participant node to execute failure, to each target participant Node sends snapshot corresponding to each node respectively, so that each target participant node is extensive by corresponding business datum according to snapshot It is multiple to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of first aspect, each target participant node is called to execute corresponding business respectively The sub-operation of operation, comprising:
If getting the snapshot of each target participant node, each target participant node is called to execute respectively corresponding Sub-operation;
This method further include:
If in each target participant node, there are the snapshots of a node to have not been obtained, and returns to operation to request method, apparatus Failure prompt information.
In a kind of alternative embodiment mode of first aspect, sent corresponding to each node respectively to each target participant node Snapshot so that each target participant node restores corresponding business datum to before executing corresponding sub-operation according to snapshot State, comprising:
According to the implementing result of each target participant node, participating in implementing result in node to each target is successful target It participates in node and sends corresponding snapshot, so that implementing result is that successfully each target participates in node according to snapshot for corresponding business Data are restored to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of first aspect, if the sub-operation of the corresponding business operation of target participant's node It is at least two, business datum corresponding with business operation in target participant's node is in target participant node and all The corresponding business datum of sub-operation;
Target participant node restores corresponding business datum to the shape executed before corresponding sub-operation according to snapshot State, refer to target participant node according to snapshot by business datum corresponding with all sub-operations in the node disposably restore to State before all sub-operations.
In a kind of alternative embodiment mode of first aspect, if business operation request includes at least two, and at least two Different business operations requests to include identical node in corresponding target participant node in business operation request, then right simultaneously The snapshot for the target participant's node that should be requested in different business operations is asked including corresponding to different business operations in node The snapshot for the business datum asked;
If implementing result is the mesh for executing the business operation request of failure and being while requesting corresponding to different business operations Operation requests corresponding to participant's node are marked, then send snapshot corresponding to each node respectively to each target participant node, Include:
To the target participant's node for corresponding to different business operation requests simultaneously, holding for target participant node is sent Row result is the corresponding snapshot of business operation request for executing failure.
In a kind of alternative embodiment mode of first aspect, according to operation mark, determines and use from all participant's nodes In at least two target participant's nodes for executing business operation, comprising:
According to the service mapping relations of operation mark and pre-configuration, at least two targets for executing business operation are determined Participant's node;
Wherein, service mapping relations be each operation mark be used for execute each of business operation corresponding to each operation mark The corresponding relationship of the node related information of participant's node.
In a kind of alternative embodiment mode of first aspect, node related information includes that the business operation of participant's node connects Mouth call address, snapshot generate interface call address and rollback interface call address.
In a kind of alternative embodiment mode of first aspect, if the sub-operation of the corresponding business operation of target participant's node It is at least two, snapshot generates at least one of interface call address and rollback interface call address satisfaction or less:
It is same that the corresponding snapshot of all sub-operations, which generates interface call address,;
The corresponding rollback interface call address of all sub-operations is same.
In a kind of alternative embodiment mode of first aspect, if business operation request includes at least two, and at least two Different business operations requests to include identical node in corresponding target participant node in business operation request, then right simultaneously Interface call address should be generated in the snapshot for target participant's node that different business operations is requested and rollback interface calls ground Location meets at least one of following:
It is same that target participant's node, which corresponds to the snapshot that different business operations is requested to generate interface call address,;
It is same that target participant's node, which corresponds to the rollback interface call address that different business operations is requested,.
In a kind of alternative embodiment mode of first aspect, each target participant node is called to execute corresponding business respectively The sub-operation of operation, comprising:
By calling business operation interface corresponding to the business operation interface call address of each target participant node, to Each target participant node sends the business operating instructions of corresponding sub-operation, so that each target participates in node and is based on business operation The corresponding sub-operation of instruction execution;
The snapshot of the above-mentioned each target participant node of acquisition, comprising:
For each target participant node, by calling the snapshot of each target participant node to generate interface call address institute Corresponding interface sends snapshot to each target participant node and generates instruction, and receives each target participant node according to snapshot Generate the snapshot that instruction returns;
This method further include:
By calling rollback interface corresponding to the rollback interface call address of each target participant node, join to each target Rollback instruction is sent with person's node, so that each target participant node is extensive by corresponding business datum according to rollback instruction and snapshot It is multiple to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of first aspect, participant's node in distributed system includes block chain link Point.
The second aspect of the embodiment of the present application, provides a kind of distributed transaction processing method, and this method is applied to distribution In formula system, distributed system includes coordinator's node and at least two participant's nodes, coordinator's node and each ginseng It is communicated to connect with person's node;This method comprises:
When the snapshot for receiving the transmission of coordinator's node generates instruction, generated according to snapshot generation instruction corresponding fast According to, and snapshot is sent to coordinator's node, wherein snapshot is business corresponding with business operation request in target participant's node The snapshot of data, target participant's node are coordinator's node in the business operation request that acquisition request method, apparatus is sent, root According to business operation request in the operation mark of business operation that carries determine;
When receiving the business operating instructions of coordinator's node transmission, corresponding business is executed according to business operating instructions Operation, and implementing result is sent to coordinator's node;
When receiving the snapshot that coordinator's node is sent, corresponding business datum is restored corresponding to executing according to snapshot State before business operation, wherein snapshot is that there are a targets to participate in the implementing result received for coordinator's node The implementing result of person's node is sent when executing failure.
In a kind of alternative embodiment mode of second aspect, fail if generating instruction according to snapshot and generating corresponding snapshot, This method further include:
Snapshot failed regeneration prompt information is sent to coordinator's node, so that coordinator's node is receiving prompt information When, prompt information is returned operation failure to request method, apparatus.
The third aspect of the application provides a kind of distributing real time system device, which is applied to distributed system In, include: including coordinator's node and at least two participant's nodes, the device in distributed system
Transceiver module carries industry in business operation request for the business operation request that acquisition request method, apparatus is sent The operation mark of business operation;
Destination node determining module, for being determined for executing business from all participant's nodes according to operation mark At least two target participant's nodes of operation;
Transceiver module is also used to obtain the snapshot of each target participant node and preservation, wherein snapshot is that target participates in The snapshot of corresponding business datum is requested in person's node with business operation;
Destination node calling module, for calling each target participant node to execute the son behaviour of corresponding business operation respectively Make, and obtains the implementing result of each target participant node;
Transceiver module is also used in each target participant node there are the implementing result of a node be to execute failure, Snapshot corresponding to each node is then sent respectively to each target participant node, so that each target participant node will according to snapshot Corresponding business datum is restored to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of the third aspect, destination node calling module is calling each target participant section When point executes the sub-operation of corresponding business operation respectively, it is specifically used for:
If getting the snapshot of each target participant node, each target participant node is called to execute respectively corresponding Sub-operation;
Transceiver module is also used to:
If in each target participant node, there are the snapshots of a node to have not been obtained, and returns to operation to request method, apparatus Failure prompt information.
In a kind of alternative embodiment mode of the third aspect, transceiver module is sent respectively to each target participant node Snapshot corresponding to each node, so that each target participant node restores corresponding business datum to executing correspondence according to snapshot Sub-operation before state when, be specifically used for:
According to the implementing result of each target participant node, participating in implementing result in node to each target is successful target It participates in node and sends corresponding snapshot, so that implementing result is that successfully each target participates in node according to snapshot for corresponding business Data are restored to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of the third aspect, if the son behaviour of the corresponding business operation of target participant's node As at least two, business datum corresponding with business operation in target participant's node, in target participant's node with institute There is the corresponding business datum of sub-operation;
Target participant node restores corresponding business datum to the shape executed before corresponding sub-operation according to snapshot State, refer to target participant node according to snapshot by business datum corresponding with all sub-operations in the node disposably restore to State before all sub-operations.
In a kind of alternative embodiment mode of the third aspect, if business operation request includes at least two, and at least two Different business operations requests to include identical node in corresponding target participant node in a business operation request, then simultaneously Corresponding to the snapshot for target participant's node that different business operations is requested, including corresponding to different business operations in node The snapshot of the business datum of request;
If implementing result is the mesh for executing the business operation request of failure and being while requesting corresponding to different business operations Operation requests corresponding to participant's node are marked, then transceiver module is to send each node institute respectively to each target participant node right The snapshot answered, is specifically used for:
To the target participant's node for corresponding to different business operation requests simultaneously, holding for target participant node is sent Row result is the corresponding snapshot of business operation request for executing failure.
In a kind of alternative embodiment mode of the third aspect, destination node determining module is determined according to operation mark When for executing at least two target participant's node of business operation, it is specifically used for:
According to the service mapping relations of operation mark and pre-configuration, at least two targets for executing business operation are determined Participant's node;
Wherein, service mapping relations be each operation mark be used for execute each of business operation corresponding to each operation mark The corresponding relationship of the node related information of participant's node.
In a kind of alternative embodiment mode of the third aspect, node related information includes the business operation of participant's node Interface call address, snapshot generate interface call address and rollback interface call address.
In a kind of alternative embodiment mode of the third aspect, if the son behaviour of the corresponding business operation of target participant's node As at least two, snapshot generates at least one of interface call address and rollback interface call address satisfaction or less:
It is same that the corresponding snapshot of all sub-operations, which generates interface call address,;
The corresponding rollback interface call address of all sub-operations is same.
In a kind of alternative embodiment mode of the third aspect, if business operation request includes at least two, and at least two Different business operations requests to include identical node in corresponding target participant node in a business operation request, then simultaneously Snapshot generation interface call address and rollback interface calling corresponding to target participant's node that different business operations is requested Address meets at least one of following:
It is same that target participant's node, which corresponds to the snapshot that different business operations is requested to generate interface call address,;
It is same that target participant's node, which corresponds to the rollback interface call address that different business operations is requested,.
In a kind of alternative embodiment mode of the third aspect, destination node calling module calls each target participant node When executing the sub-operation of corresponding business operation respectively, it is specifically used for:
By calling business operation interface corresponding to the business operation interface call address of each target participant node, to Each target participant node sends the business operating instructions of corresponding sub-operation, so that each target participates in node and is based on business operation The corresponding sub-operation of instruction execution;
Transceiver module is specifically used for when obtaining the snapshot of each target participant node:
For each target participant node, by calling the snapshot of each target participant node to generate interface call address institute Corresponding interface sends snapshot to each target participant node and generates instruction, and receives each target participant node according to snapshot Generate the snapshot that instruction returns;
Transceiver module is also used to:
By calling rollback interface corresponding to the rollback interface call address of each target participant node, join to each target Rollback instruction is sent with person's node, so that each target participant node is extensive by corresponding business datum according to rollback instruction and snapshot It is multiple to the state executed before corresponding sub-operation.
In a kind of alternative embodiment mode of the third aspect, participant's node in distributed system includes block chain link Point.
The application fourth aspect provides a kind of distributing real time system device, which is applied in distributed system, Distributed system includes coordinator's node and at least two participant's nodes;The device includes:
Snapshot generation module generates when for generating instruction in the snapshot for receiving the transmission of coordinator's node according to snapshot Instruction generates corresponding snapshot, and sends snapshot to coordinator's node, wherein snapshot is to grasp in target participant's node with business Make the snapshot of the corresponding business datum of request, target participant's node is what coordinator's node was sent in acquisition request method, apparatus When business operation is requested, according to business operation request in the operation mark of business operation that carries determine;
Business operation execution module, for when receive coordinator's node transmission business operating instructions when, according to business Operational order executes corresponding business operation, and implementing result is sent to coordinator's node;
Business operation recovery module, for when receiving the snapshot that coordinator's node is sent, according to snapshot by corresponding industry Business data are restored to the state executed before corresponding business operation, wherein snapshot is coordinator's node in the execution received As a result there are send when the implementing result of target participant's node executes failure in.
In a kind of alternative embodiment mode of fourth aspect, which further includes transceiver module, if being generated according to snapshot Instruction generates corresponding snapshot failure, and transceiver module is also used to:
Snapshot failed regeneration prompt information is sent to coordinator's node, so that coordinator's node is receiving prompt information When, prompt information is returned operation failure to request method, apparatus.
5th aspect of the embodiment of the present application, provides a kind of electronic equipment, which includes memory and processing Device;Computer program is stored in memory;Processor for executing first aspect and its optional when running a computer program Embodiment and any one of second aspect and its optional embodiment shown in method.
6th aspect of the embodiment of the present application, provides a kind of computer readable storage medium, the computer-readable storage Computer program is stored on medium, realized when which is executed by processor first aspect and its optional implementation and Method shown in any one of second aspect and its optional implementation.
Scheme provided by the embodiment of the present application has the advantages that
Scheme provided by the embodiment of the present application, coordinator's node are controlling the corresponding business behaviour of each target participant node Before work, the snapshot of each target participant node and preservation can be got in advance, to exist in each target participant node The implementing result of one node is to execute failure, and each target participant node is allow to distinguish rollback according to corresponding snapshot Corresponding business operation ensure that the ACID characteristic of distributed transaction.The program of the embodiment of the present application, by distributed thing All sub-operations of each target participant node of business generate associated snapshot, i.e., arrive target participant's node One or more sub-operations are bound on a corresponding snapshot, can benefit when the transaction operation of participant's node executes failure A rolling back action, the recovery of finishing service data are executed with snapshot, the scheme of the embodiment of the present application can make target participant The transaction-capable not only provided independent of database is realized in the transaction rollback operation of node, but also is made even if in target participant When node needs to complete multiple sub-operations, also a rollback can be executed based on snapshot and just complete the corresponding data of all sub-operations Recovery, the intrusion to service code can be significantly reduced, better met practical application request.
Detailed description of the invention
In order to more clearly explain the technical solutions in the embodiments of the present application, institute in being described below to the embodiment of the present application Attached drawing to be used is needed to be briefly described.
Fig. 1 is a kind of flow diagram of distributed transaction processing method provided by the embodiments of the present application;
Fig. 2 is the schematic diagram of bank transfer process provided by the embodiments of the present application;
Fig. 3 is the schematic diagram of account freezing process provided by the embodiments of the present application;
Fig. 4 is a kind of flow diagram of distributed transaction processing method provided by the embodiments of the present application;
Fig. 5 is the schematic diagram of user's online shopping process provided by the embodiments of the present application;
Fig. 6 is the basic framework schematic diagram of the distributed system in one example of the application;
Fig. 7 is the schematic diagram of the service mapping relations in one example of the application;
Fig. 8 is a kind of flow diagram of the distributed transaction processing method provided in the application example;
Fig. 9 is a kind of structural schematic diagram of distributing real time system device provided by the embodiments of the present application;
Figure 10 is another structural schematic diagram of distributing real time system device provided by the embodiments of the present application;
Figure 11 is the structural schematic diagram of a kind of electronic equipment provided by the embodiments of the present application.
Specific embodiment
Embodiments herein is described below in detail, the example of embodiment is shown in the accompanying drawings, wherein identical from beginning to end Or similar label indicates same or similar element or element with the same or similar functions.It is retouched below with reference to attached drawing The embodiment stated is exemplary, and is only used for explaining the application, and is not construed as limiting the claims.
Those skilled in the art of the present technique are appreciated that unless expressly stated, singular " one " used herein, " one It is a ", " its " and "the" may also comprise plural form.It is to be further understood that wording used in the description of the present application " comprising " refers to existing characteristics, step, operation, element and/or component, but it is not excluded that in the presence of or addition it is one or more its His feature, step, operation, element, component and/or their group.It should be understood that when we claim element to be " connected " or " coupling " When to another element, it can be directly connected or coupled to other elements, or there may also be intermediary elements.In addition, here " connection " or " coupling " used may include being wirelessly connected or wirelessly coupling.Wording "and/or" used herein includes one Or more the associated whole for listing item or any cell and all combinations.
Several nouns involved in the embodiment of the present application are introduced and are explained first:
Affairs: by a series of pairs of system datas access and update an executable unit of operative combination, there is atom Four spies such as property (Atomicity), consistency (Consistency), isolation (Isolation) and persistence (Duration) Property, this four characteristics can be abbreviated as ACID.Atomicity refers to the operation or all success or all mistake of composition affairs It loses, it is not possible to have intermediate state;Consistency refers to that the execution of affairs cannot destroy the complete and consistency of database, and affairs are held The row front and back each component part state of distributed system must be complete consistent;Isolation refers to concurrently executing affairs Under scene, each affairs must be independently execute it is non-interfering;Persistence refers to transaction operation once after success, executing As a result must be got off by persistence.
Distributed transaction: each operation for forming affairs executes on the different nodes of distributed system, i.e., practical to execute The operation of affairs is likely to occur on different equipment (such as server/server cluster), it is also possible to which generation is set same In standby different application, that is to say, that participant's node of each operation of affairs is executed, can be different equipment, it can also Think calculation processing unit corresponding to the different application of same equipment.The person that can be related to transaction coordination in a distributed system (coordinator's node in the embodiment of the present application) and affairs participant node (participant's node in the embodiment of the present application), distribution Formula affairs are participated in completing jointly by coordinator and participant's node.
Participant's node: for handling the node of distributed transaction.
Coordinator's node: for coordinating and managing multiple affairs participant node processing distributed transactions.
It is described in detail below with specifically embodiment and in conjunction with technical solution of the attached drawing to the application.Below these Specific embodiment can be combined with each other, may be no longer superfluous in certain embodiments for the same or similar concept or process It states.
Fig. 1 shows the flow diagram that the embodiment of the present application provides a kind of processing method of distributed transaction, the party Method is applied in distributed system, and distributed system includes coordinator's node and at least two participant's nodes, coordinator Node and each participant's node communicate to connect.Distributed transaction processing method shown in FIG. 1 is executed by coordinator's node, this method It can specifically include:
Step S101: the business operation that acquisition request method, apparatus is sent is requested, and business behaviour is carried in business operation request The operation mark of work;
Step S102: according to operation mark, at least two for executing business operation are determined from all participant's nodes A target participant node;
Wherein, request method, apparatus is the equipment for initiating business operation request, i.e. distributed transaction (business operation request) The actual operator of promoter, that is, client, the client can be ordinary user, be also possible to the pipe of distributed system Reason person etc..In practical applications, for coordinator, the number of business operation request can be one or more, industry It is a kind of distributed transaction (or being distributed task scheduling) that business operation requests, which request the business of processing,.
The operation mark of business operation is carried in business operation request, the operation mark of business operation can uniquely indicate this Business corresponding to business operation be which kind of business, such as the business be purchase commodity business or transferred account service or its His business etc..The concrete form of the operation mark of business operation can configure according to actual needs, as operation mark specifically may be used To be the title of operation.
In practical applications, online in distributed system is the administrative staff or technology people of system before coming into operation Member can configure each business operation request and need to participate in executing business operation request jointly according to the practical business demand of system Each participant's node mapping relations, and the mapping relations are stored into coordinator's node, behind specific configuration process It will be illustrated, each business operation will be requested, coordinator's node is when receiving business operation request, it can base The participant's node i.e. target participant node for executing the request is determined in the mapping relations.Certainly, optional as one Mode, above-mentioned mapping relations also can store into other equipment, and coordinator's node is by communicating with the other equipment come basis Operation mark determines target participant's node, and operation mark is such as sent to other equipment, receives the target that other equipment return The relevant information of participant's node, or the mapping relations are obtained according to communicating with other equipment, it is true further according to the mapping relations Set the goal the relevant information of participant's node.It is understood that when there are the request of two or more business operations, no The target participant node determined with business operation requests may be identical, can also be entirely different, it is also possible to part Identical, this is determined by actual business configuration.
Wherein, target participant node needs to cooperate with and completes the corresponding business operation of a certain business operation request Participant's node.Each target participant node can execute the operation (son hereinafter of the partial service in the business operation Operation), it is to be understood which partial sub operation that each target participant node specifically executes business operation is according to reality Business demand it is configured, coordinator's node get business operation request after, it can according to the behaviour in request Make a check mark the sub-operation for determining that target participant node and each target participant node need to be implemented.
Step S103: the snapshot of each target participant node and preservation are obtained, wherein snapshot is target participant's node In business datum corresponding with business operation snapshot;
Coordinator's node can generate instruction by sending snapshot respectively to each target participant node, to obtain each target The snapshot of participant's node and preservation, as the snapshot spatial cache of coordinator's node can be stored in (i.e. for storing snapshot Spatial cache) in.
It is understood that it is specifically that target participant node needs are held that snapshot, which generates instruction, for a business operation The snapshot of business datum involved by capable business operation generates instruction.Target participant node generates instruction life according to snapshot At the snapshot of target participant's node, the snapshot be specially target participant node (such as server) storage data in The snapshot of the corresponding business datum of sub-operation of target participant's node business operation to be executed, it is to be understood that such as Fruit target participant node only needs to be implemented the sub-operation of a business operation, then the sub-operation for generating the business operation is corresponding The snapshot of business datum, if target participant's node needs to be implemented at least two business operations, for each business operation, mesh Mark participant's node generates corresponding snapshot respectively, such as target participant's node needs to be implemented business operation A and business operation B generates the snapshot in the snapshot of participant's node including the corresponding business datum of business operation A for business operation A, for industry Business operation B generates the snapshot in the snapshot of participant's node including the corresponding business datum of business operation B.
Target participant node produces corresponding fast after the snapshot for receiving the transmission of coordinator's node generates instruction According to and return to coordinator's node.
As an example, as shown in Figure 2, the scene of transferred account service is handled for the application, it is assumed that distributed system is One banking system, the banking system have independent account service in each province, it is assumed that account A and account B is located at different Province is located in different account servers, be exactly one typical distributed when needing to transfer accounts from account A to account B Affairs scene, the transferred account service require the remaining sum variation of account A and account B while success.Specifically, the coordinator in this example Node (coordinator shown in figure) is the node for coordinating and managing each province's account server, and the account server of each province is The target participant for this i.e. transferred account service of account server that participant's node in this example, account A and account B are located at Node.Coordinator's node specifically carries operation mark in transfer operation request when receiving transfer operation request, this When, coordinator's node can determine that the participant's node for executing the operation is according to the mark and the mapping relations of configuration Participant node b corresponding to participant's node a and account B corresponding to account A, then coordinator's node can to node a and Node b sends snapshot corresponding with the transfer operation and generates instruction, after node a and node b receive snapshot generation instruction, node A generates the balance data snapshot of account A, and node b generates the balance data snapshot of account B, node a and node b and completes snapshot After generation, snapshot is sent to coordinator's node.In order to subsequent in transferred account service failure, node a and/or node b can The recovery operation of corresponding account balance is carried out according to the snapshot.
Step S104: calling each target participant node to execute the sub-operation of corresponding business operation respectively, and obtains each The implementing result of target participant's node;
Step S105: if there are the implementing result of a node being to execute failure in each target participant node, to each Target participant node sends snapshot corresponding to each node respectively, so that each target participant node will be corresponding according to snapshot Business datum is restored to the state executed before corresponding sub-operation.
Coordinator's node calls each target participant node to execute corresponding son at least one above-mentioned business operation respectively Operation, each target participant node require to hold when having executed or having executed failure or can not execute corresponding sub-operation Row result is sent to coordinator's node, after coordinator's node gets the implementing result of each target participant node, it can know Know whether each target participant node runs succeeded, if coordinator's node finds to have in each target participant node one or more The implementing result of a target participant node is to execute failure, then there are business operation requests to execute failure for explanation, at this point, for The business operation request of failure is executed, coordinator's node requests corresponding target complete participant node or portion to the business operation Partial objectives for participant's node sends the business operation request pair that each node got in step s 103 respectively fails with execution The snapshot answered.
Due to including before business operation executes, being executed in target participant's node with target participant's node in snapshot The corresponding business datum of sub-operation snapshot, for the target participant's node for receiving snapshot, target participant's node Rollback can be carried out to the sub-operation of business operation performed by target participant's node, i.e. target is joined according to corresponding snapshot Its business datum is restored to executing the state before corresponding sub-operation with person's node.
In the present embodiment, rollback is carried out to the sub-operation of business operation performed by target participant's node, referred specifically to :
If the number of distributed transaction in above-mentioned the application can be at least one, the number of business operation request can also be with It is at least one.If target participant node only needs to be implemented the sub-operation of a business operation, a target participant The number of sub-operation can be at least one in the corresponding business operation of node, i.e., a target participant node can execute one The snapshot of a or more than one sub-operation, target participant's node can the one or more sub- behaviour of rollback Make, is equivalent to and multiple sub-operations are tied on same snapshot, all sub- behaviour of target participant's node can be completed using snapshot The disposable rollback made, without individually carrying out rollback for each operation.
As it can be seen that the scheme of the embodiment of the present application, raw to the operation of subsystem each in distributed transaction by introducing snapshot At associated snapshot (automatically generating snapshot before target participant's node executes business operation), when affairs execute failure When, participant's node can use snapshot and execute rolling back action, can will be performed according to the snapshot that coordinator's node is sent The business datum of all operations reverts to the state before executing.The scheme of the embodiment of the present application, by by target participant's node One or more operations be tied on the same snapshot, participant's node utilizes snapshot rolling back action, can disposable rollback All operations performed by participant's node, without individually carrying out rollback for each operation, to make rolling back action Realization, transaction-capable can be provided independent of database, and compared with existing TCC scheme, and can be significantly reduced Intrusion to service code, reduces additional development amount.
In the alternative embodiment of the application, each target participant node is called to execute the son behaviour of corresponding business operation respectively Make, comprising:
If getting the snapshot of each target participant node, each target participant node is called to execute respectively corresponding Sub-operation;
This method further include:
If in each target participant node, there are the snapshots of a node to have not been obtained, and returns to operation to request method, apparatus Failure prompt information.
By taking coordinator handles the request of a distributed transaction corresponding business operation as an example, coordinator's node is called Each target participant node generates the snapshot of target participant's node respectively, if each target participant node generates target ginseng With the snapshot success of person's node, the available snapshot to each target participant node of coordinator's node, coordinator is saved later Point executes the step of each target participant node of subsequent calls executes corresponding business operation respectively, if each target participant saves The snapshot for having one or more target participant node to generate target participant node in point fails, that is, there are The snapshot of one or more target participant node have not been obtained to the case where, at this time coordinator's node then can directly to Request method, apparatus returns operation failure prompt information, and no longer executes subsequent calls target participant's node and execute corresponding business The step of operation.
In practical applications, since the implementing result in one or more target participant nodes is when executing failure, to need Each target participant node is wanted to restore business datum to the state executed before operating, if deposited according to corresponding snapshot Failure is obtained in the snapshot of one or more target participant nodes, if then illustrating the one or more target participant node Implementing result be failure, then can according to snapshot carry out business datum recovery, then can guarantee entire business operation at this time ACID characteristic therefore when the snapshot that there are one or more target participant's nodes obtains failure, then may not need and hold again The subsequent operation of row, to avoid there is the above problem.
In the alternative embodiment of the application, snapshot corresponding to each node is sent respectively to each target participant node, with Restore each target participant node corresponding business datum to the state executed before corresponding sub-operation, packet according to snapshot It includes:
According to the implementing result of each target participant node, participating in implementing result in node to each target is successful target It participates in node and sends corresponding snapshot, so that implementing result is that successfully each target participates in node according to snapshot for corresponding business Data are restored to the state executed before corresponding sub-operation.
In practical applications, as an optinal plan, a business operation is requested, if business operation request Implementing result is to execute failure, and coordinator's node can request corresponding target complete participant node difference to the business operation The corresponding snapshot of each node is sent, each node can be decided in its sole discretion after receiving snapshot and whether execute rolling back action, such as node It is not carried out corresponding business operation or business operation executes failure but the transaction operation of node meets atomicity characteristic, then may be used Not execute rolling back action, if node executes corresponding business operation success, need to execute phase according to the snapshot received The rolling back action answered.
As another alternative, if each participant's node when executing affairs, hold by affairs in distributed system Row is all satisfied atomicity characteristic, then participant's node is when executing transaction operation, if executing failure, corresponding business datum It can be rolled back to automatically and execute preoperative state, at this point, coordinator's node then can be only to the target participant section to run succeeded Point sends corresponding snapshot, and the target participant node to be run succeeded by these restores its business datum.If target The affairs execution of participant's node is unsatisfactory for atomicity characteristic, when the implementing result of target participant's node is to execute failure, It then there may be the case where operation performs part, the node is also required to carry out the recovery of business datum, coordinator's section at this time Point is also required to send corresponding snapshot to these nodes.
That is, in practical applications, each target participant node that coordinator's node can be known according to it Relevant information can also send corresponding snapshot to whole target participant nodes to decide whether to be sent to it snapshot, Determined whether to execute rolling back action according to the information of itself by target participant node.
In the alternative embodiment of the application, if the sub-operation of the corresponding business operation of target participant's node is at least two It is a, business datum corresponding with business operation in target participant's node, be target participant node in all sub-operations pair The business datum answered;
Above-mentioned target participant node restores corresponding business datum to before executing corresponding sub-operation according to snapshot State, refer to that target participant node is disposably extensive by business datum corresponding with all sub-operations in the node according to snapshot The multiple state to before all sub-operations.
In practical applications, for a business operation in distributed system, for executing each mesh of the business operation It marks in participant's node, these nodes can only need to be implemented a sub-operation of the business operation, can also need to be implemented this Multiple sub-operations in business operation.The program provided by the embodiments of the present application arrives each mesh since coordinator's node is available The snapshot of all business datums corresponding with the business operation in participant's node is marked, therefore, even if target participant's node needs Multiple sub-operations are executed, it can also be disposably extensive by business datum corresponding with this multiple sub-operation in node based on the snapshot The multiple rollback for completing multiple sub-operations to the state before these sub-operations, i.e. a rolling back action.With existing each sub-operation The scheme for requiring to be individually performed a rollback is compared, and the intrusion to service code can be greatly reduced, and reduces development amount.
As it can be seen that the program provided by the embodiments of the present application is substantially for each target participant's node The rolling back action that target participant's node is corresponded to a business operation, with the business operation in target participant's node In the snapshots of involved all business datums bound, no matter target participant's node needs to be implemented the business operation Several sub-operations, target participant node only need according to snapshot execute a rollback to complete involved by all sub-operations And the recovery of the business datum arrived.
In the alternative embodiment of the application, if business operation request includes at least two, and at least two business operations Different business operations requests to include identical node in corresponding target participant node in request, then corresponds to difference simultaneously Business operation request target participant's node snapshot, the business requested including corresponding to different business operation in node The snapshot of data;
If implementing result is the mesh for executing the business operation request of failure and being while requesting corresponding to different business operations Operation requests corresponding to participant's node are marked, then send snapshot corresponding to each node respectively to each target participant node, Include:
To the target participant's node for corresponding to different business operation requests simultaneously, holding for target participant node is sent Row result is the corresponding snapshot of business operation request for executing failure.
In the present embodiment, if the number of the distributed transaction of coordinator's node processing is at least two, at least two The corresponding at least two business operations request of distributed transaction, different business operations request corresponding target participant node may It is identical, it is also possible to be different.In practical applications, coordinator's node is when handling the request of multiple business operations, then very It there may be the same target participant node and simultaneously participate in two or more industry corresponding in multiple business operation requests The case where sub-operation of business operation, if the two or more business operations requests corresponding simultaneously of a certain target participant node, It needs to generate the corresponding snapshot of each business operation request respectively, and requests corresponding snapshot to send each business operation Give coordinator's node, so as to it is subsequent occur business operation execute failure (business operation request one or more targets participate in Person's node subtasking failure) the case where when, the corresponding snapshot of the business operation can be sent the target by coordinator's node Participant's node, so that target participant node is based on the recovery for receiving snapshot progress business datum.
For example, a certain target participant node a performs the sub-operation of business operation A and the son behaviour of business operation B Make, if business operation A runs succeeded in the treatment process of subsequent each business operation, business operation B execution is had failed, Then target participant node only needs to correspond to snapshot progress data recovery based on its business operation B.Certainly, it is grasped in business When making B execution failure, caused by executing corresponding sub-operation failure node A, and behaviour handled by node B The characteristics of work meets transaction atomicity, node B can not then execute the recovery of data.
In the present embodiment, for being performed simultaneously the node of the sub-operation of multiple business operations, if what the node executed The implementing result of multiple subservice operations is failure, which can also be based on its corresponding multiple snapshot finishing service data Disposable recovery.
In the alternative embodiment of the application, according to operation mark, determine from all participant's nodes for executing business At least two target participant's nodes of operation, comprising:
According to the service mapping relations of operation mark and pre-configuration, at least two targets for executing business operation are determined Participant's node;
Wherein, service mapping relations be each operation mark be used for execute each of business operation corresponding to each operation mark The corresponding relationship of the node related information of participant's node.
It wherein, may include the node identification of participant's node in node related information, which can indicate this Participant's node is specially which participant's node in distributed system, which can be with the number of participant's node, can also To be the title etc. of participant's node.Coordinator's node can determine that current business behaviour according to above-mentioned service mapping relations The node identification for making each target participant node corresponding to the operation mark requested, that is, determine each target participant node.
It is understood that service mapping relations are each operation mark and are used to execute business corresponding to each operation mark The corresponding relationship of the node related information of each participant's node of operation.As a simple examples, it is assumed that compartment system Business operation has operation A, operation B and operation C, and participant's node for executing operation A is node a and node b, for executing The node for operating B is node b, node c and node d, and the node for executing operation C is node a and node c, the then exemplary mapping What is stored in relationship is the corresponding relationship, operation B and node b, node of the node related information of operation A and node a and node b The corresponding relationship and operation C of the node related information of c and node d are corresponding with the node related information of node a and node c Relationship.
In the alternative embodiment of the application, node related information includes that the business operation interface of participant's node calls ground Location, snapshot generate interface call address and rollback interface call address.
Specifically, business operation interface call address is to be used to complete the application program of the computing unit of corresponding service operation The call address of interface is based on the address, and coordinator's node can be by calling the corresponding interface in the address to target participant The corresponding data processing unit of node sends business operating instructions.Likewise, generating interface call address, coordinator based on snapshot Node can generate interface by the corresponding snapshot in the address and send fastly to the corresponding data processing unit of target participant's node It is instructed according to generating, is based on rollback interface call address, coordinator's node can be by the corresponding rollback interface in the address to target The corresponding data processing unit of participant's node sends rollback instruction.
Correspondingly, above-mentioned each target participant node of calling executes the sub-operation of corresponding business operation respectively, specifically may be used To include:
By calling business operation interface corresponding to the business operation interface call address of each target participant node, to Each target participant node sends the business operating instructions of corresponding sub-operation, so that each target participates in node and is based on business operation The corresponding sub-operation of instruction execution.
The snapshot of the above-mentioned each target participant node of acquisition, can specifically include:
For each target participant node, by calling the snapshot of each target participant node to generate interface call address institute Corresponding interface sends snapshot to each target participant node and generates instruction, and receives each target participant node according to snapshot Generate the snapshot that instruction returns.
That is, can also include each correlation function interface of each target participant node in service mapping relations Call address information, coordinator's node is when determining each target participant node, it can according to the calling of each functional interface Address calls the corresponding interface of each target participant node to complete corresponding operation.Such as above by business operation interface to Target participant's node sends the business operating instructions of corresponding sub-operation, generates interface to target participant's node by snapshot It sends snapshot and generates instruction, each target participant node is after receiving each instruction, it can execute corresponding operation.
In the alternative embodiment of the application, this method further include:
By calling rollback interface corresponding to the rollback interface call address of each target participant node, join to each target Rollback instruction is sent with person's node, so that each target participant node is extensive by corresponding business datum according to rollback instruction and snapshot It is multiple to the state executed before corresponding sub-operation.
Specifically, coordinator's node is receiving each target participant section for the business operation of a distributed transaction After the implementing result that point returns, execute failing as a result, each target participant is needed to save if at this time if existed in implementing result Node carries out the recovery of business datum some or all of in point, at this point, coordinator's node can then be mapped based on above-mentioned service The rollback interface that relationship is determined sends rollback instruction to target participant's node.Target participant node refers to receiving rollback After order and corresponding snapshot, it can the rolling back action for being executed business datum based on the data in snapshot is restored business datum To preoperative state.
In practical applications, coordinator's node sends snapshot corresponding to each node to each target participant node respectively When, can be through above-mentioned rollback interface, rollback instruction and snapshot sent jointly into target participant's node, be also possible to by Rollback instruction and snapshot are sent respectively to target participant's node, and rollback instruction is such as sent to target by rollback interface and is participated in Person's node sends snapshot by other interfaces and gives target participant's node;It can also be that rollback instruction, which is sent to target, to be participated in After person's node, if participant's node determines that it needs to be implemented rolling back action, snapshot acquisition is sent to coordinator's node and is asked It asks, snapshot is sent to corresponding target participant node again by coordinator's node.
In the alternative embodiment of the application, if the sub-operation of the corresponding business operation of target participant's node is at least two A, snapshot generates at least one of interface call address and rollback interface call address satisfaction or less: all sub-operations are corresponding fast It is same according to interface call address is generated;
The corresponding rollback interface call address of all sub-operations is same.
In the scheme of the embodiment of the present application, for either objective participant's node, when executing a business operation, no Quantity by its sub-operation to be executed is one or multiple, the recovery of business datum be the execution of rolling back action be all according to According to it before the operation is performed, the snapshot of corresponding with these sub-operations business datum carries out, that is to say, that node All associated traffic datas involved by all sub-operations to be executed all are bundled on same snapshot, therefore, section Point is when needing to be implemented rolling back action, it is only necessary to which executing a rolling back action according to the snapshot can be completed involved by all sub-operations And business datum recovery.Based on this, in the program of the embodiment of the present application, to be completed one of target participant's node The snapshot of all sub-operations in business operation generates interface and/or rollback interface call address can be using same, coordination Person's node need to obtain the snapshot of all sub-operations of the business operation corresponding to target participant's node or need to When the node sends rollback instruction, interface can be generated by the snapshot that all sub-operations share and/or rollback interface calls Address calls the corresponding interface in the address to initiate snapshot and generates instruction and/or rollback instruction.
By this way, for a business operation, the involved current business behaviour of target participant's node All sub-operations made all only need to correspond to a unified snapshot and generate on interface and/or rollback interface, with existing one The mode of the corresponding rollback interface of a sub-operation is compared, and the intrusion to service code greatly reduced greatly reduces additional Development amount.
In the alternative embodiment of the application, if business operation request includes at least two, and at least two business operations Different business operations requests to include identical node in corresponding target participant node in request, then corresponds to difference simultaneously Business operation request target participant's node snapshot generate interface call address and rollback interface call address meet with It is at least one of lower:
It is same that target participant's node, which corresponds to the snapshot that different business operations is requested to generate interface call address,;
It is same that target participant's node, which corresponds to the rollback interface call address that different business operations is requested,.
In the embodiment of the present application, distributed transaction, that is, business operation request number can be multiple, for a mesh For marking participant's node, the generation of snapshot corresponding to all business operations which can be performed and (need to participate in) is connect Mouth call address all can be same, likewise, the rollback interface for all business operations that the node can be performed calls Address all can be same, i.e. the multiplexing of the corresponding snapshot generation interface of realization multi-service operation and/or rollback interface.Nothing Business operation by execution required for participant's node be which or which, coordinator's node can pass through the interface of the multiplexing Snapshot, which is sent, to participant's node generates instruction and/or rollback instruction.
In the embodiment of the present application, coordinator's node generates interface by a snapshot of invocation target participant node, real The now generation of the snapshot corresponding to multiple business operations of the node, likewise, can be same by calling the node to arrive Rollback interface sends rollback instruction to the node.The side of a corresponding interface is needed with a sub-operation of an existing node Case is compared, and the intrusion to service code greatly reduced greatly reduces additional development amount.
The scheme of the embodiment of the present application is illustrated below with reference to a specific application scenarios.
Application scenarios in this example are for the personnel P that breaks one's promise, and bank needs to freeze its all account under one's name, before operation Frozen Account may be had existed in the account of personnel P, therefore it is expected that this operation is also atom, i.e., after operation failure, all accounts Family keeps state before operating.As shown in Figure 3, the coordinator in figure is coordinator's node, and participant's node is target ginseng With person's node, target participant's node in the example is the account server where each account of personnel P, success institute in figure The state of participant's node in the left side of the arrow shown is the state of each account of personnel P before executing freeze operation, You Tuzhong As can be seen that its account B is frozen state before operation, the state of other each accounts is normal condition, arrow shown in success Right side be each account after successful execution freeze operation state, i.e., the state of whole accounts becomes frozen state.
For application scenarios shown in this example, if using tradition TCC scheme, freeze shape for adjusting accounts The operation of state, each participant's node (account server where account A, account B, account C ... and account N) just have to There is corresponding rollback state to operate.It is understood that here only for a example, in practical business there is also cancellation, borrow Money etc. is many, and there are the scenes of distributed transaction, in traditional TCC scheme, in each distributed transaction scene, and Mei Gecao Work will have corresponding rolling back action, there is larger additional development amount.
And based on scheme provided by the embodiment of the present application, for each account, actually the remaining sum of account, freeze shape State etc. can be seen as the attribute of account, before being related to the operation of account, all save the snapshot of a account, snapshot includes remaining The all properties relevant to account such as volume, frozen state, if operation failure, so that it may restore data using this part of snapshot. In this way, which the operation of related to account, all only needs to correspond to a unified rollback interface, utilizes the snapshot one of account All operations of secondary property rollback account, to greatly reduce additional development amount.Such as an account, simultaneously There are the business operation of account balance produced and freeze two distributed transactions, remaining sum, account status are that operation is corresponding Business datum, the scheme based on the embodiment of the present application produce this distributed transaction for account balance, need to obtain and save The snapshot of the remaining sum of the account freezes this distributed transaction for account, needs to obtain and save the snapshot of account status, such as Fruit needs to carry out rollback business operation after having executed the two business operations, and account server is only needed based on preservation Above-mentioned two snapshot can complete the recovery of remaining sum and account status.If the business operation of certain any distributed transaction at Function, such as account are freezed successfully, then only needing the snapshot for account status to carry out data recovery to account balance, i.e., Coordinator's node only needs to produce the corresponding target participant node of this distributed transaction to account balance and sends more than account The snapshot of volume.
Based on principle identical with method shown in Fig. 1, the embodiment of the present application also provides a kind of distributed transactions Processing method, this method are applied in distributed system, and distributed system includes that coordinator's node and at least two participate in Person's node, coordinator's node and each participant's node communicate to connect, and this method is executed by target participant's node;In Fig. 4 Shown, this method mainly may include following steps:
Step S401: when the snapshot for receiving the transmission of coordinator's node generates instruction, instruction is generated according to snapshot and is generated Corresponding snapshot, and snapshot is sent to coordinator's node;Wherein, snapshot be in target participant's node with business operation request pair The snapshot for the business datum answered, target participant's node are that coordinator's node is asked in the business operation that acquisition request method, apparatus is sent When asking, according to business operation request in the operation mark of business operation that carries determine;
Step S402: it when receiving the business operating instructions of coordinator's node transmission, is executed according to business operating instructions Corresponding business operation, and implementing result is sent to coordinator's node;
Step S403: receive coordinator's node send snapshot when, according to snapshot by corresponding business datum restore to Execute the state before corresponding business operation.
Wherein, snapshot is that there are the execution of target participant's node in the implementing result received for coordinator's node It is sent when as a result executing failure.
It will be apparent to those skilled in the art that this method shown in Fig. 4 is substantially and shown in Fig. 1 Method is system, and method shown in Fig. 1 is the description carried out from the angle of coordinator's node of distributed system, Fig. 4 Shown in method be from the angle of participant's node of distributed system carry out description, therefore, method shown in Fig. 4 And its detailed description of effect may refer to hereinbefore to describing accordingly in method shown in Fig. 1 and its alternative embodiment, Details are not described herein.
In the alternative embodiment of the application, fail if generating instruction according to snapshot and generating corresponding snapshot, this method may be used also To include:
Snapshot failed regeneration prompt information is sent to coordinator's node, so that coordinator's node is receiving prompt information When, prompt information is returned operation failure to request method, apparatus.
For a business operation, since the recovery of business datum needs to complete according to snapshot, if target is joined Obtain and fail with the snapshot of person's node, then the subsequent recovery for being unable to complete corresponding business datum, then may not need at this time into Operation after row, the prompt information directly returned operation failure from coordinator's node to operation requests side, entire business behaviour The process of work terminates.
By description above it is found that being requested for the business operation initiated of request method, apparatus, for the business operation, If target participant's node needs to be implemented multiple sub-operations in the business operation, the scheme based on the embodiment of the present application, Multiple sub-operations of target participant's node can correspond to the same snapshot and generate interface and/or rolling back action interface, i.e., For a business operation, no matter target participant's node needs to be implemented several sub-operations of the business operation, which is participated in The snapshot that person's node corresponds to a business operation generates interface and/or rolling back action interface can be same.
Likewise, for multiple business operations, no matter target participant's node needs to be implemented the son behaviour of several business operations Make, the snapshot that target participant's node corresponds to multiple business operations generates interface and/or rolling back action interface can be same One.
In addition, in the present embodiment, for a business operation, if distributed transaction performed by target participant's node Operation meets atomicity characteristic, then needing to be implemented the target participant section of rolling back action (i.e. execution business datum recovery operation) Point can be to execute the successful target participant node of sub-operation, if the son of distributed transaction performed by target participant's node Operation is unsatisfactory for atomicity, then target participant's node is any in all target participant nodes of above-mentioned business operation One target participant's node.
Distributed transaction widely exists in various internet systems, and common such as payment, transaction, order etc. are strong by one Cause property system.Above-mentioned each scheme provided by the embodiment of the present application, is theoretically adapted to that all there are the applications of distributed transaction Scene.
Distributed transaction control logic is complete unaware for users, but which ensure that each behaviour of user Work meets 4 fundamental characteristics of ACID.For example, as shown in Figure 5, user pays the bill in electric business system buys commodity, practical On in electric business system comprising subtracting inventory, payment, logistics place an order etc., and several operations, distributed transaction control guarantee these operations Together succeed or fail together, be reduced in front of the user one purchase commodity operation or buy successfully or Purchase failure.
In electric business system each participant's node execute respectively subtract inventory, several operations such as payment, logistics place an order, execute business Before operation, the participant's node for subtracting inventory operations is executed for the business datum progress snapshot for subtracting inventory operations, executes payment behaviour Participant's node of work carries out snapshot for the business datum of payment operation, and the participant's node for executing single operation under logistics is directed to The business datum of single operation under logistics carries out snapshot, if purchase failure, executes and subtracts participant's node of inventory operations, executes and pay The node or whole nodes to run succeeded in participant's node of single operation under the participant's node and execution logistics of money operation It then needs to carry out rollback using respective object snapshot, for example, executing participant's node of single operation under logistics can use fastly According to all operations involved in single operation under disposable rollback logistics, so as to primary using the snapshot of participant's node All operations of property rollback participant's node, greatly reduce the intrusion to service code relative to TCC scheme, reduced More additional workloads.
Actually participant's node is in addition to executing payment purchase this distributed task scheduling of commodity in electric business system Operation is outer, it is also possible to execute the operation of other distributed task schedulings, the same node is directed to the operation of other distributed task schedulings It calls same snapshot to generate interface and generates corresponding snapshot, so that it may with the operation of other distributed task schedulings of the snapshot rollback, by Multiple distributed task schedulings that multiple snapshots carry out rollback target participant's node, phase are generated in same snapshot generation interface can be multiplexed Intrusion to service code is greatly reduced for TCC scheme, reduces excessive additional workload.
In order to better illustrate scheme provided by the embodiment of the present application, below with reference to some examples to the embodiment of the present application Related content be further described.
The basic framework schematic diagram of one of one example of the application distributed system is shown in Fig. 6.In the example Coordinator's node is server cluster, including multiple coordinators (coordinator 1, coordinator 2 and coordinator 3 shown in figure), figure Shown in participant's node serve 1, participant's node serve 2 and participant's node serve 3 be this example in participant The signal of node.Branch scape illustrates each section of the system accordingly below.
Service the configuration (mapping configuration service shown in figure) of mapping relations
It is configured before online implementing, or to the service mapping relations in online system.Configuration flow master May include:
1. the service mapping relations that system manager drafts business operation according to practical business scene and rule;
Specifically, administrative staff are that the operation of each distributed service drafts a reasonable action name (in this example Operation mark), and the relevant information of the corresponding all participant's nodes of each business operation is configured, specifically such as participant's node Business operation interface call address (for example purchase commodity need the calling for subtracting single 3 interfaces under inventory, payment, logistics for including Address), the snapshots corresponding with business operation of all participant's nodes generate interface call address and all participant's nodes Rollback interface call address corresponding with business operation.
2. the service mapping relations that system manager is drafted by console typing (compile by mapping relations shown in figure Volume);
After 3. mapping configuration service receives the service mapping relations of console typing, service mapping relations storage is carried out, Store mapping relations database;
After 4. mapping configuration service receives the service mapping relations of console typing, synchronous service mapping relations are to owning Coordinator, coordinator will service mapping relations deposit own cache in.
Wherein, in this example, it may include following four part in above-mentioned service mapping relations:
Action name (operation mark in this example) drafts a reasonable title for integrated operation;
The call address of the business operation interface for all participant's nodes being related to is operated, for example purchase commodity need to wrap Contain subtract inventory, payment, logistics place an order the call address of this 3 interfaces;
The snapshot corresponding with business operation of all participant's nodes generates interface call address;
The rollback interface call address corresponding with business operation of all participant's nodes.
The configuration of service mapping relations is illustrated below with reference to a specific example.
As shown in Figure 7, the signal of the service mapping relations in an Intelligent dialogue platform service is shown in the example Figure.As shown in the figure, it needs to include all participant's node serve (i.e. participant's nodes in the service registration information in the example The business service of offer) title and address (call address of business operation interface), all participant's nodes snapshot generate The rollback call address of address and all participant's nodes, that is, rollback interface call address.Specifically, all in the example Participant's node serve includes Metadata Service, A algorithm platform service and B algorithm platform service shown in figure, these services The node (robot in this example) at place is participant's node, and robot information (i.e. request by this example and business operation Relevant all business datums) it needs to be stored in Metadata Service, A algorithm platform service, B algorithm platform service tripartite simultaneously In (with business development, may will also save in more algorithm platforms).When needing to modify robot information, it is necessary to It modifies simultaneously and Metadata Service, A algorithm platform service and the robot of B algorithm platform service is provided.Therefore, for modification Robot information this operation, it is necessary to configure the call address of the modification robot information serviced at above-mentioned 3, i.e., as shown in the figure 3 at robot information modified address (i.e. business operation interface call address), each robot snapshot generate interface call Address (snapshot i.e. shown in figure generates address) and the rollback interface call address of each robot are (i.e. shown in figure Information rollback address), while it is entitled " UpdateRobot (modification robot information) " to draft integrated operation.
In Intelligent dialogue platform, actually essentially all of business operation is both for robot, that is to say, that base The corresponding snapshot of all business operations (such as tens business operations) generates interface in sheet and rollback interface can be Same, even subsequent to increase new business operation newly, maximum probability is also that can directly be multiplexed current snapshot to generate interface And rollback interface, after new interface exploitation is completed, it is only necessary to which the service mapping relations that console typing is drafted can enable point Cloth affairs realize snapshot generation and the multiplexing of rollback interface, reduce development amount.
It completes to postpone matching for service mapping relations, can carried out based on scheme provided by the embodiment of the present application distributed The processing of affairs is below illustrated the process flow of a distributed transaction, which mainly may include:
1, client request process
Since coordinator (i.e. coordinator's node) helps client to complete all participant's nodes (i.e. participant's node) Calling be equivalent to multiple operations for client and be merged for the operation of an atom, therefore client only need to be to association It adjusts device cluster (such as coordinator cluster i.e. coordinator's node that coordinator 1, coordinator 2 and coordinator 3 are constituted in Fig. 6) to send to adjust With request, but need additionally to be passed to action name (a kind of optional way of operation mark) in request body, coordinator It needs to obtain corresponding service mapping relations according to action name.
2, mediators handle requests process
As shown in Figure 8, the process of mediators handle request may include:
2.1, it after the business operation that coordinator receives request method, apparatus is requested, is obtained first according to the action name in request Corresponding service mapping relations are got, the corresponding industry of all target participant nodes is contained in the service mapping relations got Business operation interface call address, snapshot generate interface call address and rollback interface call address;
2.2, coordinator generates interface corresponding to interface call address by the snapshot of each target participant node, to Each target participant node sends snapshot and generates instruction so that each target participant node generates snapshot, each target The snapshot that oneself is generated is returned to coordinator by participant's node, and coordinator caches the snapshot of each target participant node (i.e. Coordinator invocation target participant's node generates the object snapshot of each target participant node in corresponding diagram, and it is slow to be saved in snapshot The process deposited);
2.3, when the preservation of all snapshots finishes, coordinator calls the corresponding business operation of all participant's nodes to connect simultaneously Mouthful, business operating instructions are sent to each participant's node, that is, each target participant node is called to execute the corresponding business of each node Operation;
2.4, when all target participant nodes execute business operation success, coordinator to request method, apparatus return call at Function information.
In above-mentioned process flow, during obtaining snapshot, if the snapshot of any one participant's node generates Failure, coordinator then directly can return operation failure prompt information to request method, apparatus, terminate entire operation process.
If snapshot corresponding to each target participant node obtains successfully, in follow-up processing flow, if there is appointing That is, there is the implementing result of target participant's node to execute in the business operation failure of one or more of anticipating target participant's nodes Failure, then coordinator calls all target participant nodes or implementing result is returning for the target participant's node to run succeeded Interface is rolled, rollback instruction is sent to each target participant node, and corresponding snapshot is sent to corresponding node, so that corresponding Target participant node according to respective snapshot execute a rolling back action, the recovery of finishing service data, due to business grasp Work executes failure, and coordinator needs to return operation failure information to request method, apparatus.
In a kind of alternative embodiment mode of the application, participant's node in distributed system includes block chain node.
The distributed system of the embodiment of the present application can be the sheet of block chain in the distributed system based on block chain technology Matter is the database of a decentralization, multiple tasks can be executed on different block chain nodes, in block catenary system A node can on one server, alternatively, multiple nodes are on the same server, at this point, in each block chain Node correspond to participant's node.In block chain task is being needed to be implemented every time (i.e. in block catenary system Business operation request) when, the block chain node for needing to participate in the task is target participant's node, in block catenary system In, some or all of target participant's node can be in block chain node can be right according to the difference of practical application request Answer different configurations.
It is understood that coordinator's node in the embodiment of the present application may be block chain node, at this time as association The block chain node of tune person's node is equivalent to the management node in block catenary system, the management and coordination for participant's node Deng.
Corresponding to method provided by the embodiment of the present application, the embodiment of the present application also provides a kind of distributing real time systems Device, the device are applied in distributed system, include coordinator's node and at least two participants in distributed system Node, as shown in Figure 9, the distributing real time system device 900 may include transceiver module 901, destination node determining module 902 and destination node calling module 903, in which:
Transceiver module 901 carries in business operation request for the business operation request that acquisition request method, apparatus is sent The operation mark of business operation;
Destination node determining module 902, for being determined for executing industry from all participant's nodes according to operation mark At least two target participant's nodes of business operation;
Transceiver module 901 is also used to obtain the snapshot of each target participant node and preservation, wherein snapshot is target The snapshot of corresponding business datum is requested in participant's node with business operation;
Destination node calling module 903, for calling each target participant node to execute corresponding business operation respectively Sub-operation, and obtain the implementing result of each target participant node;
Transceiver module 901 is also used in each target participant node there are the implementing result of a node be to execute mistake It loses, then sends snapshot corresponding to each node respectively to each target participant node, so that each target participant node is according to fast Restore according to by corresponding business datum to the state executed before corresponding sub-operation.
Optionally, destination node calling module 903 is calling each target participant node to execute corresponding business behaviour respectively When the sub-operation of work, it is specifically used for:
If getting the snapshot of each target participant node, each target participant node is called to execute respectively corresponding Sub-operation;
Transceiver module 901, is also used to:
If in each target participant node, there are the snapshots of a node to have not been obtained, and returns to operation to request method, apparatus Failure prompt information.
Optionally, transceiver module 901 is sending snapshot corresponding to each node to each target participant node respectively, so that Each target participant node restores corresponding business datum to when executing the state before corresponding sub-operation according to snapshot, tool Body is used for:
According to the implementing result of each target participant node, participating in implementing result in node to each target is successful target It participates in node and sends corresponding snapshot, so that implementing result is that successfully each target participates in node according to snapshot for corresponding business Data are restored to the state executed before corresponding sub-operation.
Optionally, if the sub-operation of the corresponding business operation of target participant's node is at least two, target participant section Business datum corresponding with business operation in point is business datum corresponding with all sub-operations in target participant node;Mesh Mark participant's node restores corresponding business datum to the state executed before corresponding sub-operation according to snapshot, refers to target Participant's node disposably restores business datum corresponding with all sub-operations in the node to all sub-operations according to snapshot State before.
Optionally, if business operation request includes at least two, and business different in the request of at least two business operations Include identical node in the corresponding target participant node of operation requests, then corresponds to what different business operations was requested simultaneously The snapshot of target participant's node, the snapshot including corresponding to the business datum that different business operations is requested in node;
If implementing result is the mesh for executing the business operation request of failure and being while requesting corresponding to different business operations Operation requests corresponding to participant's node are marked, then transceiver module is to send each node institute respectively to each target participant node right The snapshot answered, is specifically used for:
To the target participant's node for corresponding to different business operation requests simultaneously, holding for target participant node is sent Row result is the corresponding snapshot of business operation request for executing failure.
Optionally, destination node determining module 902 determines at least two for executing business operation according to operation mark When a target participant node, it is specifically used for:
According to the service mapping relations of operation mark and pre-configuration, at least two targets for executing business operation are determined Participant's node;
Wherein, service mapping relations be each operation mark be used for execute each of business operation corresponding to each operation mark The corresponding relationship of the node related information of participant's node.
Optionally, node related information includes the business operation interface call address of participant's node, snapshot generation interface Call address and rollback interface call address.
Optionally, if the sub-operation of the corresponding business operation of target participant's node is at least two, snapshot generates interface Call address and rollback interface call address meet at least one of following:
It is same that the corresponding snapshot of all sub-operations, which generates interface call address,;
The corresponding rollback interface call address of all sub-operations is same.
Optionally, if business operation request includes at least two, and business different in the request of at least two business operations Include identical node in the corresponding target participant node of operation requests, then corresponds to what different business operations was requested simultaneously The snapshot of target participant's node generates at least one of interface call address and rollback interface call address satisfaction or less:
It is same that target participant's node, which corresponds to the snapshot that different business operations is requested to generate interface call address,;
It is same that target participant's node, which corresponds to the rollback interface call address that different business operations is requested,.
Optionally, destination node calling module 903 is calling each target participant node to execute corresponding business behaviour respectively When the sub-operation of work, it is specifically used for:
By calling business operation interface corresponding to the business operation interface call address of each target participant node, to Each target participant node sends the business operating instructions of corresponding sub-operation, so that each target participates in node and is based on business operation The corresponding sub-operation of instruction execution;
Transceiver module 901 is specifically used for when obtaining the snapshot of each target participant node:
For each target participant node, by calling the snapshot of each target participant node to generate interface call address institute Corresponding interface sends snapshot to each target participant node and generates instruction, and receives each target participant node according to snapshot Generate the snapshot that instruction returns;
Transceiver module 901 is also used to: by calling corresponding to the rollback interface call address of each target participant node Rollback interface sends rollback instruction to each target participant node, so that each target participant node is according to rollback instruction and fastly Restore according to by corresponding business datum to the state executed before corresponding sub-operation.
Optionally, participant's node in distributed system includes block chain node.
Corresponding to method provided by the embodiment of the present application, the embodiment of the present application also provides a kind of distributing real time systems Device, the device are applied to distributed system, and distributed system further includes coordinator's node and at least two participants section Point;
As shown in Figure 10, which holds including snapshot generation module 1001, business operation Row module 1002 and business operation recovery module 1003:
Snapshot generation module 1001, when for generating instruction in the snapshot for receiving the transmission of coordinator's node, according to snapshot Generate instruction and generate corresponding snapshot, and send snapshot to coordinator's node, wherein snapshot be in target participant's node with industry The snapshot of the corresponding business datum of operation requests of being engaged in, target participant's node are that coordinator's node is sent in acquisition request method, apparatus Business operation request when, according to business operation request in the operation mark of business operation that carries determine;
Business operation execution module 1002, for when receive coordinator's node transmission business operating instructions when, according to Business operating instructions execute corresponding business operation, and implementing result is sent to coordinator's node;
Business operation recovery module 1003, for that will be corresponded to according to snapshot when receiving the snapshot that coordinator's node is sent Business datum restore to the state executed before corresponding business operation, wherein snapshot is that coordinator's node is receiving There are send when the implementing result of target participant's node executes failure in implementing result.
Optionally, which further includes prompt information sending module, which is used for:
When snapshot generation module 1001 generates instruction according to snapshot and generates the failure of corresponding snapshot, sent out to coordinator's node Snapshot failed regeneration prompt information is sent, so that coordinator's node returns to operation when receiving prompt information, to request method, apparatus Failure prompt information.
The device as provided by the embodiment of the present invention is the device that can execute corresponding method in the embodiment of the present invention, So those skilled in the art can understand the dress of the embodiment of the present invention based on method provided in the embodiment of the present invention The specific embodiment set and its various change form, so how to be realized in the embodiment of the present invention at this for the device Method is no longer discussed in detail.As long as those skilled in the art implement device used by the method in the embodiment of the present invention, Belong to the range to be protected of the application.
Based on principle identical with method provided by the embodiment of the present application, the embodiment of the present application also provides a kind of electronics Equipment, the electronic equipment include memory and processor;Computer program is stored in memory;Processor is based in operation Method provided in any alternative embodiment of the application is executed when calculation machine program.
The embodiment of the present application also provides a kind of computer readable storage medium, stored on the computer readable storage medium There is computer program, which may be implemented method provided in any alternative embodiment of the application when being executed by processor.
As an example, shown in Figure 11 this application can be applied to a kind of electronic equipment structural schematic diagram, should Electronic equipment specifically can be server, be also possible to other equipment, which includes memory 8003 and processing Device 8001 is stored with computer program in memory 8003, and processor 8001 is above-mentioned for executing when running a computer program Either method.Specifically, Figure 11 illustrates only a kind of optional schematic structure of electronic equipment.The electricity shown in Figure 11 The structure of sub- equipment 8000 does not constitute the restriction to the embodiment of the present application.
Wherein, processor 8001 is connected with memory 8003, is such as connected by bus 8002.Optionally, electronic equipment 8000 can also include transceiver 8004.It should be noted that transceiver 8004 is not limited to one in practical application, transceiver 8004 can be specifically used for the communication of the electronic equipment 8000 and other equipment.
Processor 8001 can be CPU (Central Processing Unit, central processing unit), general processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit, specific integrated circuit), (Field Programmable Gate Array, scene can compile FPGA Journey gate array) either other programmable logic device, transistor logic, hardware component or any combination thereof.It can be with It realizes or executes and combine various illustrative logic blocks, module and circuit described in present disclosure.Processor 8001 are also possible to realize the combination of computing function, such as combine comprising one or more microprocessors, DSP and microprocessor Combination etc..
Bus 8002 may include an access, and information is transmitted between said modules.Bus 8002 can be PCI (Peripheral Component Interconnect, Peripheral Component Interconnect standard) bus or EISA (Extended Industry Standard Architecture, expanding the industrial standard structure) bus etc..It is total that bus 8002 can be divided into address Line, data/address bus, control bus etc..Only to be indicated with a thick line in Figure 11 convenient for indicating, it is not intended that only one total Line or a type of bus.
Memory 8003 can be ROM (Read Only Memory, read-only memory) or can store static information and refer to The other kinds of static storage device enabled, RAM (Random Access Memory, random access memory) or can store The other kinds of dynamic memory of information and instruction is also possible to EEPROM (Electrically Erasable Programmable Read Only Memory, Electrically Erasable Programmable Read-Only Memory), CD-ROM (Compact Disc Read Only Memory, CD-ROM) or other optical disc storages, optical disc storage (including compression optical disc, laser disc, optical disc, number The general optical disc of word, Blu-ray Disc etc.), magnetic disk storage medium or other magnetic storage apparatus or can be used in carrying or store Desired program code with instruction or data structure form simultaneously can be but unlimited by any other medium of computer access In this.
Memory 8003 is used to store the application code for executing application scheme, and is held by processor 8001 to control Row.Processor 8001 is for executing the application code stored in memory 8003, to realize any of the above embodiment of the method Shown in content.
It should be understood that although each step in the flow chart of attached drawing is successively shown according to the instruction of arrow, These steps are not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps Execution there is no stringent sequences to limit, can execute in the other order.Moreover, at least one in the flow chart of attached drawing Part steps may include that perhaps these sub-steps of multiple stages or stage are not necessarily in synchronization to multiple sub-steps Completion is executed, but can be executed at different times, execution sequence, which is also not necessarily, successively to be carried out, but can be with other At least part of the sub-step or stage of step or other steps executes in turn or alternately.
The above is only some embodiments of the invention, it is noted that those skilled in the art are come It says, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications also should be regarded as Protection scope of the present invention.

Claims (15)

1. a kind of processing method of distributed transaction, which is characterized in that the method is applied in distributed system, the distribution Formula system includes coordinator's node and at least two participant's nodes, and coordinator's node and each participant save Point communication connection, which comprises
The business operation that acquisition request method, apparatus is sent is requested, and the operation mark of business operation is carried in the business operation request Know;
According to the operation mark, at least two targets for executing the business operation are determined from all participant's nodes Participant's node;
Obtain the snapshot of each target participant node and preservation, wherein the snapshot is the target participant node In business datum corresponding with the business operation snapshot;
It calls each target participant node to execute the sub-operation of the corresponding business operation respectively, and obtains each mesh Mark the implementing result of participant's node;
If there are the implementing results of a node in each target participant node to execute failure, join to each target Snapshot corresponding to each node is sent respectively with person's node, so that each target participant node is according to snapshot by corresponding industry Business data are restored to the state executed before corresponding sub-operation.
2. the method according to claim 1, wherein described call each target participant node to execute respectively The sub-operation of the corresponding business operation, comprising:
If getting the snapshot of each target participant node, each target participant node is called to execute respectively pair The sub-operation answered;
The method also includes:
If in each target participant node, there are the snapshots of a node to have not been obtained, and returns to the request method, apparatus Operation failure prompt information.
3. the method according to claim 1, wherein described send respectively respectively to each target participant node Snapshot corresponding to node, so that each target participant node restores corresponding business datum to execution pair according to snapshot State before the sub-operation answered, comprising:
According to the implementing result of each target participant node, it is successful for participating in implementing result in node to each target Target participates in node and sends corresponding snapshot, so that implementing result is that successfully each target participation node will be corresponding according to snapshot Business datum is restored to the state executed before corresponding sub-operation.
4. the method according to claim 1, wherein if the corresponding business behaviour of the target participant node The sub-operation of work is at least two, and business datum corresponding with the business operation in the target participant node, is described Business datum corresponding with all sub-operations in target participant's node;
The target participant node restores corresponding business datum to the shape executed before corresponding sub-operation according to snapshot State refers to that the target participant node is primary by business datum corresponding with all sub-operations in the node according to snapshot Property is restored to the state before all sub-operations.
5. the method according to claim 1, wherein if business operation request includes at least two, and institute It states business operation different in the request of at least two business operations and requests to include identical section in corresponding target participant node Point then corresponds to the snapshot for target participant's node that different business operations is requested simultaneously, including corresponds to difference in node Business operation request business datum snapshot;
If implementing result is the target ginseng for executing the business operation request of failure and being while requesting corresponding to different business operations With operation requests corresponding to person's node, then it is described sent respectively to each target participant node it is fast corresponding to each node According to, comprising:
To the target participant's node for corresponding to different business operation requests simultaneously, holding for the target participant node is sent Row result is the corresponding snapshot of business operation request for executing failure.
6. the method according to any one of claims 1 to 5, which is characterized in that it is described according to the operation mark, from institute There are at least two target participant's nodes determined in participant's node for executing the business operation, comprising:
According to the service mapping relations of the operation mark and pre-configuration, at least two for executing the business operation are determined Target participant's node;
Wherein, the service mapping relations be each operation mark be used for execute each of business operation corresponding to each operation mark The corresponding relationship of the node related information of participant's node.
7. according to the method described in claim 6, it is characterized in that, the node related information includes the business of participant's node Operation interface call address, snapshot generate interface call address and rollback interface call address.
8. the method according to the description of claim 7 is characterized in that if the corresponding business behaviour of the target participant node The sub-operation of work is at least two, the snapshot generates interface call address and the rollback interface call address meet with down toward One item missing:
It is same that the corresponding snapshot of all sub-operations, which generates interface call address,;
The corresponding rollback interface call address of all sub-operations is same.
9. the method according to the description of claim 7 is characterized in that if business operation request includes at least two, and institute It states business operation different in the request of at least two business operations and requests to include identical section in corresponding target participant node Point, the then snapshot for corresponding to target participant's node that different business operations is requested simultaneously generate interface call address and rollback Interface call address meets at least one of following:
It is same that target participant's node, which corresponds to the snapshot that different business operations is requested to generate interface call address,;
It is same that target participant's node, which corresponds to the rollback interface call address that different business operations is requested,.
10. the method according to any one of claims 1 to 5, which is characterized in that the participant in the distributed system Node includes block chain node.
11. a kind of processing method of distributed transaction, which is characterized in that the method is applied in distributed system, and described point Cloth system includes coordinator's node and at least two participant's nodes, coordinator's node and each participant Node communication connection;The described method includes:
When receiving the snapshot generation instruction that coordinator's node is sent, generated according to snapshot generation instruction corresponding Snapshot, and send the snapshot to coordinator's node, wherein the snapshot be in target participant's node with the business The snapshot of the corresponding business datum of operation requests, the target participant node are that coordinator's node is set in acquisition request side When the business operation request that preparation is sent, determined according to the operation mark of the business operation carried in business operation request 's;
When receiving the business operating instructions that coordinator's node is sent, executed according to the business operating instructions corresponding Business operation, and implementing result is sent to coordinator's node;
When receiving the snapshot that coordinator's node is sent, the corresponding business datum is restored according to the snapshot State to before the execution corresponding business operation, wherein the snapshot is that coordinator's node is held what is received There are send when the implementing result of target participant's node executes failure in row result.
12. a kind of processing unit of distributed transaction, which is characterized in that described device is applied in distributed system, and described point Include: including coordinator's node and at least two participant's nodes, described device in cloth system
Transceiver module carries industry in the business operation request for the business operation request that acquisition request method, apparatus is sent The operation mark of business operation;
Destination node determining module, it is described for executing for being determined from all participant's nodes according to the operation mark At least two target participant's nodes of business operation;
The transceiver module is also used to obtain the snapshot of each target participant node and preservation, wherein the snapshot is The snapshot of corresponding business datum is requested in the target participant node with the business operation;
Destination node calling module, for calling each target participant node to execute the son behaviour of corresponding business operation respectively Make, and obtains the implementing result of each target participant node;
The transceiver module is also used in each target participant node there are the implementing result of a node be to execute mistake It loses, then sends the snapshot corresponding to each node respectively to each target participant node, so that each target participates in Person's node restores the corresponding business datum to the state executed before corresponding sub-operation according to the snapshot.
13. a kind of distributing real time system device, which is characterized in that described device is applied in distributed system, the distribution Formula system includes coordinator's node and at least two participant's nodes;Described device includes:
Snapshot generation module, when for generating instruction in the snapshot for receiving coordinator's node transmission, according to the snapshot It generates instruction and generates corresponding snapshot, and send the snapshot to coordinator's node, wherein the snapshot is that target participates in The snapshot of corresponding business datum is requested in person's node with the business operation, the target participant node is the coordinator Node is in the business operation request that acquisition request method, apparatus is sent, according to the business carried in business operation request What the operation mark of operation determined;
Business operation execution module, for when receiving the business operating instructions that coordinator's node is sent, according to described Business operating instructions execute corresponding business operation, and implementing result is sent to coordinator's node;
Business operation recovery module, for being incited somebody to action according to the snapshot when receiving the snapshot that coordinator's node is sent The corresponding business datum is restored to the state executed before the corresponding business operation, wherein the snapshot is described Coordinator's node is hair when executing failure there are the implementing result of target participant's node in the implementing result received It send.
14. a kind of electronic equipment, which is characterized in that the electronic equipment includes memory and processor;
Computer program is stored in the memory;
The processor, for method described in any one of perform claim requirement 1-11 when running the computer program.
15. a kind of computer readable storage medium, which is characterized in that computer program is stored on the storage medium, it is described Method of any of claims 1-11 is realized when program is executed by processor.
CN201910786076.4A 2019-08-23 2019-08-23 Distributed transaction processing method and device, electronic equipment and storage medium Active CN110502319B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910786076.4A CN110502319B (en) 2019-08-23 2019-08-23 Distributed transaction processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910786076.4A CN110502319B (en) 2019-08-23 2019-08-23 Distributed transaction processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110502319A true CN110502319A (en) 2019-11-26
CN110502319B CN110502319B (en) 2021-10-12

Family

ID=68589149

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910786076.4A Active CN110502319B (en) 2019-08-23 2019-08-23 Distributed transaction processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110502319B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143040A (en) * 2019-12-30 2020-05-12 北京三快在线科技有限公司 Transaction processing method, device, system and storage medium
CN111210350A (en) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 Block chain transaction method and device, computer equipment and storage medium
CN111818305A (en) * 2020-07-09 2020-10-23 杭州海康威视数字技术股份有限公司 Distributed system, service control method and device
CN111984439A (en) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 Data processing method and device based on block chain and storage medium
CN112069258A (en) * 2020-09-08 2020-12-11 北京金山云网络技术有限公司 Management method and device of transaction progress and distributed database
CN112907276A (en) * 2021-01-22 2021-06-04 北京达佳互联信息技术有限公司 Task processing method and device and storage medium
CN113495872A (en) * 2020-04-08 2021-10-12 北京万里开源软件有限公司 Transaction processing method and system in distributed database

Citations (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101317160A (en) * 2005-12-30 2008-12-03 英特尔公司 Software assisted nested hardware transactions
US20090217274A1 (en) * 2008-02-26 2009-08-27 Goldengate Software, Inc. Apparatus and method for log based replication of distributed transactions using globally acknowledged commits
CN102103518A (en) * 2011-02-23 2011-06-22 运软网络科技(上海)有限公司 System for managing resources in virtual environment and implementation method thereof
US20110225586A1 (en) * 2010-03-11 2011-09-15 Avaya Inc. Intelligent Transaction Merging
CN103200147A (en) * 2012-01-04 2013-07-10 中兴通讯股份有限公司 Method and device of requesting third-party service
CN103345420A (en) * 2013-06-03 2013-10-09 百度在线网络技术(北京)有限公司 Method for massively calling API interfaces, system for massively calling API interfaces and device for massively calling API interfaces
CN105573828A (en) * 2015-12-17 2016-05-11 布比(北京)网络技术有限公司 Operation processing method and device
CN105684377A (en) * 2013-10-31 2016-06-15 华为技术有限公司 System and method for creating a distributed transaction manager supporting repeatable read isolation level in a mpp database
CN106155832A (en) * 2015-03-30 2016-11-23 Tcl集团股份有限公司 Method, device and the Android device that a kind of data are recovered
CN106302611A (en) * 2015-06-09 2017-01-04 深圳市腾讯计算机***有限公司 Service request distribution system, method and apparatus
CN106325978A (en) * 2015-06-19 2017-01-11 阿里巴巴集团控股有限公司 Distributed transaction processing method and apparatus
CN106502769A (en) * 2016-09-30 2017-03-15 华为技术有限公司 Distributed transaction processing method, apparatus and system
CN106790501A (en) * 2016-12-15 2017-05-31 咪咕音乐有限公司 A kind of method for processing business and device redirected based on interface
CN106775959A (en) * 2016-12-06 2017-05-31 上海亿账通互联网科技有限公司 Distributed transaction processing method and system
CN106998370A (en) * 2017-06-15 2017-08-01 北京微影时代科技有限公司 Access control method, device and system
CN108733457A (en) * 2018-04-12 2018-11-02 阿里巴巴集团控股有限公司 The implementation method and device of distributed transaction
US20180322156A1 (en) * 2017-05-08 2018-11-08 Sap Se Atomic processing of compound database transactions that modify a metadata entity
CN109491767A (en) * 2018-11-13 2019-03-19 上海联寓智能科技有限公司 The processing method and distributed system of distributed transaction
CN109542428A (en) * 2018-10-16 2019-03-29 平安普惠企业管理有限公司 Method for processing business, device, computer equipment and storage medium
CN109976881A (en) * 2017-12-28 2019-07-05 腾讯科技(深圳)有限公司 Transaction recognition method and apparatus, storage medium and electronic device

Patent Citations (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101317160A (en) * 2005-12-30 2008-12-03 英特尔公司 Software assisted nested hardware transactions
US20090217274A1 (en) * 2008-02-26 2009-08-27 Goldengate Software, Inc. Apparatus and method for log based replication of distributed transactions using globally acknowledged commits
US20110225586A1 (en) * 2010-03-11 2011-09-15 Avaya Inc. Intelligent Transaction Merging
CN102103518A (en) * 2011-02-23 2011-06-22 运软网络科技(上海)有限公司 System for managing resources in virtual environment and implementation method thereof
CN103200147A (en) * 2012-01-04 2013-07-10 中兴通讯股份有限公司 Method and device of requesting third-party service
CN103345420A (en) * 2013-06-03 2013-10-09 百度在线网络技术(北京)有限公司 Method for massively calling API interfaces, system for massively calling API interfaces and device for massively calling API interfaces
CN105684377A (en) * 2013-10-31 2016-06-15 华为技术有限公司 System and method for creating a distributed transaction manager supporting repeatable read isolation level in a mpp database
CN106155832A (en) * 2015-03-30 2016-11-23 Tcl集团股份有限公司 Method, device and the Android device that a kind of data are recovered
CN106302611A (en) * 2015-06-09 2017-01-04 深圳市腾讯计算机***有限公司 Service request distribution system, method and apparatus
CN106325978A (en) * 2015-06-19 2017-01-11 阿里巴巴集团控股有限公司 Distributed transaction processing method and apparatus
CN105573828A (en) * 2015-12-17 2016-05-11 布比(北京)网络技术有限公司 Operation processing method and device
CN106502769A (en) * 2016-09-30 2017-03-15 华为技术有限公司 Distributed transaction processing method, apparatus and system
CN106775959A (en) * 2016-12-06 2017-05-31 上海亿账通互联网科技有限公司 Distributed transaction processing method and system
CN106790501A (en) * 2016-12-15 2017-05-31 咪咕音乐有限公司 A kind of method for processing business and device redirected based on interface
US20180322156A1 (en) * 2017-05-08 2018-11-08 Sap Se Atomic processing of compound database transactions that modify a metadata entity
CN106998370A (en) * 2017-06-15 2017-08-01 北京微影时代科技有限公司 Access control method, device and system
CN109976881A (en) * 2017-12-28 2019-07-05 腾讯科技(深圳)有限公司 Transaction recognition method and apparatus, storage medium and electronic device
CN108733457A (en) * 2018-04-12 2018-11-02 阿里巴巴集团控股有限公司 The implementation method and device of distributed transaction
CN109542428A (en) * 2018-10-16 2019-03-29 平安普惠企业管理有限公司 Method for processing business, device, computer equipment and storage medium
CN109491767A (en) * 2018-11-13 2019-03-19 上海联寓智能科技有限公司 The processing method and distributed system of distributed transaction

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
AKON DEY 等: "Scalable distributed transactions across heterogeneous stores", 《2015 IEEE 31ST INTERNATIONAL CONFERENCE ON DATA ENGINEERING》 *
FRANCK BUTELLE 等: "Distributed snapshot for rollback-recovery with one-sided communications", 《2018 INTERNATIONAL CONFERENCE ON HIGH PERFORMANCE COMPUTING & SIMULATION (HPCS)》 *
刘朝辉 等: "面向内存数据网格的分布式事务保障机制", 《计算机科学与探索》 *
张剑 等: "《信息安全技术(第二版 上册)》", 31 May 2015, 电子科技大学出版社 *
李晓中 等: "《数据恢复原理与实践》", 31 May 2011, 国防工业出版社 *
陈康: "分布式应用中的事务复制", 《程序员》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143040A (en) * 2019-12-30 2020-05-12 北京三快在线科技有限公司 Transaction processing method, device, system and storage medium
CN111210350A (en) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 Block chain transaction method and device, computer equipment and storage medium
CN113495872A (en) * 2020-04-08 2021-10-12 北京万里开源软件有限公司 Transaction processing method and system in distributed database
CN111818305A (en) * 2020-07-09 2020-10-23 杭州海康威视数字技术股份有限公司 Distributed system, service control method and device
CN111818305B (en) * 2020-07-09 2021-12-10 杭州海康威视数字技术股份有限公司 Distributed system, service control method and device
CN111984439A (en) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 Data processing method and device based on block chain and storage medium
CN112069258A (en) * 2020-09-08 2020-12-11 北京金山云网络技术有限公司 Management method and device of transaction progress and distributed database
CN112069258B (en) * 2020-09-08 2024-04-19 北京金山云网络技术有限公司 Transaction progress management method and device and distributed database
CN112907276A (en) * 2021-01-22 2021-06-04 北京达佳互联信息技术有限公司 Task processing method and device and storage medium

Also Published As

Publication number Publication date
CN110502319B (en) 2021-10-12

Similar Documents

Publication Publication Date Title
CN110502319A (en) Processing method, device, electronic equipment and the storage medium of distributed transaction
CN106775959B (en) distributed transaction processing method and system
WO2018232494A1 (en) A network of blockchains capable of cross-chain transactions
JP6864330B2 (en) Room inventory management system based on blockchain
CN107085810A (en) Across the chain operating method and block chain management system of a kind of block chain
CN100359508C (en) Merge protocol for schooling computer system
CN103312549B (en) A kind of office management method and device and system
US5768587A (en) Operating a transaction manager with a non-compliant resource manager
US7925764B2 (en) Method, apparatus and computer program product for integrating heterogeneous systems
CN108876618A (en) A kind of exchange block catenary system and corresponding universal block chain mutual operation method and network
WO2018232493A1 (en) A network of doubly-chained blockchains capable of cross-chain transactions
CN110503558A (en) A kind of processing method and processing device based on block catenary system
JP2003526837A5 (en)
CN102413166B (en) Distributed transaction method and system thereof
CN108681963A (en) Multi-tiling chain integral traffic control method, system, electronic device and storage medium
CN108230089A (en) A kind of online order processing method, system and device
CN106648936A (en) Cooperative processing method and system based on microservices and server
CN110275766A (en) A kind of task processing method and device
CN108510315A (en) A kind of resource issuing method and relevant device
CN109255704A (en) Information processing method, device, server and computer readable storage medium
CN109672727A (en) Ebanking services data processing method and device
CN108765142A (en) Electronic device, multi-tiling chain integral traffic control method and computer readable storage medium
US7509426B2 (en) System for aborting web services automatically and method thereof
CN113297329A (en) Transaction processing method, device, equipment, storage medium and program product
CN109408201A (en) Office management method based on distributed data base

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40016255

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant