CN110737514A - method, device and medium for ensuring consistency of final data of distributed transaction - Google Patents

method, device and medium for ensuring consistency of final data of distributed transaction Download PDF

Info

Publication number
CN110737514A
CN110737514A CN201910915138.7A CN201910915138A CN110737514A CN 110737514 A CN110737514 A CN 110737514A CN 201910915138 A CN201910915138 A CN 201910915138A CN 110737514 A CN110737514 A CN 110737514A
Authority
CN
China
Prior art keywords
state
idempotent
distributed transaction
task
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910915138.7A
Other languages
Chinese (zh)
Inventor
卓达城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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 CN201910915138.7A priority Critical patent/CN110737514A/en
Publication of CN110737514A publication Critical patent/CN110737514A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • 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/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • 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/465Distributed object oriented systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses methods, devices and media for ensuring consistence of distributed transaction final data, wherein the method comprises the steps of obtaining a service request, obtaining a service set formed by services related to the service request, wherein the server set at least comprises two services, obtaining parameters related to the service request of each service to obtain a parameter subset corresponding to the service, obtaining a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set, generating an idempotent task according to the parameter set, wherein the idempotent task is used for performing idempotent operation on each parameter in the parameter set, executing the idempotent task and returning an execution result of the idempotent task.

Description

method, device and medium for ensuring consistency of final data of distributed transaction
Technical Field
The invention relates to the field of distributed transactions, in particular to methods, devices and media for ensuring consistency of final data of distributed transactions.
Background
However, the transaction execution conditions of other nodes cannot be accurately known between the nodes which are independent of each other, so that it is difficult to ensure the consistency of the final data between the nodes, where the consistency of the final data means that corresponding data on different nodes always change in a converging direction along with the migration of time, so as to reach a final consistency state, and the scheme for ensuring the consistency of the final data between the nodes in the prior art mainly includes:
(1) the two-phase submission protocol can be summarized as that the participants inform the coordinator of success or failure of the operation, and then the coordinator determines whether each participant needs to submit the operation or suspend the operation according to feedback information of all the participants.
(2) Final data consistency is ensured based on reconciliation limited by the effect of reconciliation frequency, the period for achieving final data consistency is longer, thereby reducing user experience.
Disclosure of Invention
In order to solve the technical problem that a scheme of ensuring consistency of final distributed transaction data with low time lag and high success rate cannot be provided in the prior art, embodiments of the present invention provide methods, apparatuses, and media for ensuring consistency of final distributed transaction data.
, the present invention provides methods of ensuring distributed transaction end data consistency, the method comprising:
acquiring a service request, and acquiring a service set formed by each service associated with the service request, wherein the server set at least comprises two services;
acquiring parameters related to the service request of each service to obtain a parameter subset corresponding to the service, and obtaining a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
generating an idempotent task according to the parameter set, wherein the idempotent task is used for performing idempotent operation on each parameter in the parameter set;
and generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction, and returning an execution result of the idempotent task.
In another aspect, the present invention provides apparatus for ensuring distributed transaction end data consistency, the apparatus comprising:
the service set acquisition module is used for acquiring a service request and acquiring a service set formed by services related to the service request, and the server set at least comprises two services;
a parameter set obtaining module, configured to obtain a parameter related to the service request for each service to obtain a parameter subset corresponding to the service, and obtain a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
the idempotent task generating module is used for generating an idempotent task according to the parameter set, and the idempotent task is used for performing idempotent operation on each parameter in the parameter set;
and the idempotent task execution module is used for generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction and returning an execution result of the idempotent task.
In another aspect, the present invention provides apparatus for ensuring distributed transaction end data consistency, the apparatus comprising a processor and a memory, the memory having stored therein at least instructions, at least programs, sets of codes, or sets of instructions, the at least instructions, the at least programs, sets of codes, or sets of instructions, loaded into and executed by the processor to implement methods for ensuring distributed transaction end data consistency.
In another aspect, the present invention provides computer storage media, wherein the storage media has stored therein at least instructions, at least programs, code sets, or instruction sets, wherein the at least instructions, at least programs, code sets, or instruction sets are loaded by a processor and execute methods to ensure consistency of distributed transaction end data.
The invention provides methods, devices and media for ensuring consistency of final data of distributed transactions, and the invention enables each item of relevant data participating in the distributed transactions to have the consistency of the final data without performing account checking processing after the idempotent tasks are executed by acquiring various parameters required by the implementation of the distributed transactions and generating and executing idempotent tasks based on the parameters, thereby significantly reducing the time required for reaching the consistency state of the final data , reducing time lag while ensuring that the distributed transactions are executed with high success rate, and significantly improving the viscosity of users.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic diagram of an implementation environment of methods for ensuring consistency of distributed transaction final data provided by the invention;
FIG. 2 is a schematic diagram of alternative structures of the blockchain system provided by the present invention;
FIG. 3 is an alternative Block Structure (Block Structure) diagram provided by the present invention;
FIG. 4 is a flow chart of methods for ensuring consistency of distributed transaction final data provided by the present invention;
FIG. 5 is a flow diagram for generating a distributed transaction for processing the business request, in which the idempotent tasks are executed, as provided by the present invention;
FIG. 6 is a flow diagram of the present invention providing for executing the idempotent tasks in the distributed transaction according to an th execution policy;
FIG. 7 is a flow diagram of the present invention providing for continuing execution of the idempotent tasks based on the state of the distributed transaction;
FIG. 8 is a flow diagram of the present invention providing for executing the idempotent tasks in the distributed transaction according to a second execution policy;
FIG. 9 is a flow diagram provided by the present invention for continuing execution of the idempotent tasks based on the state of the distributed transaction;
FIG. 10 is a flow diagram of the present invention providing for executing the idempotent tasks in the distributed transaction according to a second execution policy;
FIG. 11 is a logical schematic diagram of methods of ensuring consistency of distributed transaction end data provided by the present invention;
FIG. 12 is a block diagram of devices for ensuring consistency of final data of distributed transactions provided by the present invention;
fig. 13 is a hardware structural diagram of apparatuses for implementing the method provided by the embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only partial embodiments of of the present invention, rather than all embodiments.
Furthermore, the terms "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a series of steps or elements of is not necessarily limited to the expressly listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For purposes of clarity and understanding of the objects, technical solutions and advantages disclosed in the embodiments of the present invention, the embodiments of the present invention will be further described in detail with reference to the drawings and the embodiments.
In the following description, the terms "", "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated, whereby the features defined as "", "second" may or may not include or more of such features.
The final data consistency is that corresponding data on different nodes always change in a convergent direction as time goes on, so that after hours, corresponding data between nodes will finally reach a consistency state.
If the user successfully purchases movie tickets, the data in the payment system and the corresponding data in the movie ticketing system are both directed to the same distributed transaction, that is, the movie tickets are successfully purchased, the distributed transaction conforms to the data consistency principle, and if the data in the payment system and the corresponding data in the movie ticketing system are required to be directed to the same distributed transaction after a preset time, that is, the movie tickets are successfully purchased, the distributed transaction conforms to the final data consistency principle.
In the prior art, in order to ensure that the distributed transaction conforms to the final data consistency principle, a technical scheme of a two-stage commit protocol is provided, but the scheme can perform final implementation on the distributed transaction only after the voting result of each node related to the distributed transaction on the distributed transaction is determined, and any node rejecting the distributed transaction can cause the implementation failure of the distributed transaction, so that the success rate is low, and the fault tolerance rate is poor.
In other prior arts, the principle of using reconciliation to ensure that the distributed transaction conforms to the consistency of the final data is also proposed, the reconciliation, namely the reconciliation of the account is long, the reconciliation operation is long, therefore, the reconciliation frequency is low, reconciliation operations are performed only in days of many business systems, and it is seen that the time lag generated by ensuring the consistency of the final data based on the reconciliation is long, and the user requirements are difficult to meet.
In order to solve the technical problem that a scheme of ensuring consistency of final distributed transaction data with low time lag and high success rate cannot be provided in the prior art, embodiments of the present invention provide methods of ensuring consistency of final distributed transaction data.
First, the embodiment of the present invention discloses an implementation environment of the methods for ensuring consistency of distributed transaction final data in possible embodiments.
Referring to fig. 1, the implementation environment includes at least clients 01 and a server 03.
The client 01 may include: the physical devices may also include software running in the physical devices, such as applications with payment functions. The Client 01 may be communicatively connected to the Server 03 based on a Browser/Server mode (Browser/Server, B/S) or a Client/Server mode (Client/Server, C/S).
The server 03 can receive a service request related to a payment function sent by the client 01, implement a distributed transaction based on the service request, and ensure the final consistency of the distributed transaction, the server 03 can also feed back a service processing result generated by the service request to the client 01, and the server 03 can comprise servers which independently run, or distributed servers, or a server cluster consisting of a plurality of servers.
The related data generated by the distributed transaction implemented in the server 03 can be stored in or more nodes of the distributed system, the distributed system can be specifically a block chain structure, and any nodes in the block chain structure can store the related data generated by the distributed transaction.
Referring To fig. 2, fig. 2 is a optional structural schematic diagram of the blockchain system provided in the embodiment of the present invention, a point-To-point (P2P, Peer To Peer) network is formed among a plurality of nodes, and P2P is application layer protocols operating on a Transmission Control Protocol (TCP).
Referring to the functions of each node in the blockchain system shown in fig. 2, the functions involved include:
1) routing, a basic function that a node has, is used to support communication between nodes.
Besides the routing function, the node may also have the following functions:
2) the application is used for being deployed in a block chain, realizing specific services according to actual service requirements, recording data related to the realization functions to form recording data, carrying a digital signature in the recording data to represent a source of task data, and sending the recording data to other nodes in the block chain system, so that the other nodes add the recording data to a temporary block when the source and integrity of the recording data are verified successfully.
3) The Block chain comprises series of blocks (blocks) which are connected with each other according to the generated chronological order, a new Block cannot be removed again once being added into the Block chain, and recorded data submitted by nodes in the Block chain system are recorded in the blocks.
Referring to fig. 3, fig. 3 is a Block Structure (Block Structure) optional diagrams provided by the embodiment of the present invention, each Block includes a hash value of the Block storing a transaction record (hash value of the Block) and hash values of first blocks, the blocks are connected by the hash values to form a Block chain, and the Block chain (Block chain) may further include information such as a timestamp when the Block is generated.
Referring to FIG. 4, there is shown a flow chart of methods for ensuring consistency of distributed transaction final data , which can be implemented by a server in the implementation environment of FIG. 1 as an execution subject, and which can include:
s101, acquiring a service request, and acquiring a service set formed by services related to the service request, wherein the server set at least comprises two services.
Since the service set includes at least two services, each service in the service set needs to rely on cooperation to be able to successfully respond to the service request, and the cooperation process corresponds to execution process of the distributed transaction, and the related service is the service associated with the service request.
Taking the business request as an example of purchasing the movie tickets, if the payment service provided by the payment system and the ticketing service provided by the movie ticket ticketing system are required to cooperate for successfully purchasing the movie tickets, the payment service and the ticketing service are services related to the business request, and the service set is { payment service, ticketing service }.
S103, obtaining parameters related to the service request of each service to obtain a parameter subset corresponding to the service, and obtaining a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set.
Taking the service request as AN example of purchasing movie tickets, the payment service related parameters are { a1, a2, … …, AN }, then { a1, a2, … …, AN } is the parameter subset corresponding to the payment service, the ticketing service related parameters are { B1, B2, … …, BM }, then { B1, B2, … …, BM } is the parameter subset corresponding to the ticketing service. Accordingly, { payment service { a1, a2, … …, AN }, and ticketing service { B1, B2, … …, BM } } are parameter sets corresponding to the service sets.
And S105, generating an idempotent task according to the parameter set, wherein the idempotent task is used for performing idempotent operation on each parameter in the parameter set.
For steps, if the influence of the execution of the steps in any number of times is the same as that of times, the steps are idempotent steps.
Taking the consumption parameter a1 as an example, the consumption parameter a1 for any number of times produces only two results, results are consumption failures, results are that the consumption parameter a1 is successfully consumed times.
The process that the idempotent task consumes each parameter needs to call the service associated with the parameter, so the execution process of the idempotent task embodies the cooperation process of each service.
And S107, generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction, and returning an execution result of the idempotent task.
In possible embodiments, the parameters are classified into a limited use parameter and an unlimited use parameter, wherein the limited use parameter corresponds to a limited resource parameter, such as the number of accounts in a user account is a limited resource parameter, which can only be deducted a limited number of times, and the resource corresponding to the unlimited use parameter can be considered unlimited.
Accordingly, the executing the idempotent task in the distributed transaction, as shown in fig. 5, includes:
s1071, judging whether infinite use parameters exist in the idempotent task or not.
S1073, if the unlimited use parameter does not exist, executing the idempotent task in the distributed transaction according to an th execution strategy.
Since each parameter in the idempotent task is a limited use parameter, a consumption failure may occur, and therefore, pre-deducting resources pointed by the limited use parameter is required (referred to as pre-deducting parameters in the embodiment of the present invention), after the idempotent task starts, each limited use resource is pre-deducted first, if successful, the limited use resource corresponding to the limited use parameter is used really (referred to as consumption parameter in the embodiment of the present invention), and if failure occurs, the pre-deducted limited use resource (referred to as release parameter in the embodiment of the present invention) is released.
According to the embodiment of the invention, pre-deduction, consumption and release of each parameter can be realized by calling the service pointed by the parameter.
During execution of idempotent tasks, the consumption and release of limited-use parameters may cause changes in the data corresponding to their corresponding services. Taking idempotent consumption as an example of deducting 500 yuan of the user, the data of the user account corresponding to the payment service is reduced by 500 yuan, the data of the user account corresponding to the payment service is not changed when the idempotent is released, and the deduction only causes the payment service to freeze 500 yuan of the user account and does not cause the change of the account data. For payment services, the actions corresponding to withholding, consuming and releasing are freezing account funds, deducting account funds and restoring frozen account funds.
Specifically, the executing the idempotent task in the distributed transaction according to the th execution policy, as shown in fig. 6, includes:
s10731, the state of the distributed transaction is marked as an execution state by a transaction management process, and the distributed transaction is created by the transaction management process.
S10733, the idempotent task is pushed into an idempotent task execution manager.
In preferred embodiments, results of idempotent tasks pushed to the task execution manager may also be fed back to the transaction management process.
If business requests are acquired in a centralized manner, then the embodiment of the invention also generates an idempotent task aiming at each business request in a centralized manner, and each idempotent task is pressed into the idempotent task execution manager so as to be executed according to the preset management strategy.
In possible embodiments, the idempotent task execution manager may be a queue, push a newly generated idempotent task to the tail of the queue, and sequentially extract the idempotent tasks at the head of the queue according to a queue first-in first-out principle to execute, so as to achieve the purpose of executing the idempotent tasks according to a preset management policy.
S10735, the transaction management process starts to execute the distributed transaction to trigger execution of the idempotent task, pre-deducts all parameters in the idempotent task, and modifies the state of the distributed transaction according to pre-deducted results.
Specifically, if all the parameters are successfully deducted, the state of the distributed transaction is modified to be a normal execution state, and if at least parameters in all the parameters are unsuccessfully deducted, the state of the distributed transaction is modified to be an abnormal execution state.
S10737, continuing to execute the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
After the idempotent task is executed, the idempotent task execution manager is cleared.
Specifically, the continuing to execute the idempotent task according to the state of the distributed transaction, as shown in fig. 7, includes:
s107371, if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is consumed successfully, and modifying the state of the distributed task into an end state.
S107373, if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each parameter in the idempotent task until each parameter is released, and modifying the state of the distributed task into an end state.
S1075, if the unlimited use parameter exists, executing the idempotent task in the distributed transaction according to a second execution strategy.
Because the infinite use parameter exists, and the infinite use parameter does not cause consumption failure, only the finite use parameter in the idempotent task can be deducted.
Specifically, the executing the idempotent task in the distributed transaction according to the second execution policy, as shown in fig. 8, includes:
s10751, the state of the distributed transaction is marked as an execution state by the transaction management process, and the distributed transaction is created by the transaction management process.
S10753, the idempotent task is pushed into an idempotent task execution manager.
In preferred embodiments, results of idempotent tasks pushed to the task execution manager may also be fed back to the transaction management process.
S10755, the transaction management process starts to execute the distributed transaction to trigger the execution of the idempotent task, pre-deducts each limited use parameter in the idempotent task, and modifies the state of the distributed transaction according to a pre-deduction result.
Specifically, if all the limited use parameters are successfully deducted, the state of the distributed transaction is modified to be a normal execution state, and if at least deductions in all the limited use parameters fail, the state of the distributed transaction is modified to be an abnormal execution state.
S10757, the idempotent task is continuously executed according to the state of the distributed transaction, and when the state of the distributed transaction is modified into an end state, the execution result of the idempotent task is returned.
After the idempotent task is executed, the idempotent task execution manager is cleared.
Specifically, the continuing to execute the idempotent task according to the state of the distributed transaction, as shown in fig. 9, includes:
s107571, if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is successfully consumed, and modifying the state of the distributed task into an end state.
S107573, if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each limited use parameter in the idempotent task until each limited use parameter is released, and modifying the state of the distributed task into an end state.
In another possible embodiments, the pre-deducting of the limited-use resource may not be performed, and specifically, the performing the idempotent task in the distributed transaction according to the second execution policy, as shown in fig. 10, includes:
s10752, marking the state of the distributed transaction as an execution state by a transaction management process, wherein the distributed transaction is created by the transaction management process.
S10754, pushing the idempotent task into an idempotent task execution manager.
S10756, consuming each limited use parameter in the idempotent task, if the consumption of each limited use parameter is successful, modifying the distributed transaction state into a normal state, and if at least consumption of each limited use parameter are failed, modifying the distributed transaction state into an abnormal state.
S10758, continuing to execute the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
After the idempotent task is executed, the idempotent task execution manager is cleared.
Specifically, the executing the idempotent task according to the state of the distributed transaction includes:
s107581, if the state of the said distributed affair is the normal execution state, circulate each infinite use parameter in the said task of power and consume power, until each parameter is consumed successfully, modify the state of the said distributed task into the end state.
S107583, if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent rollback on each limited use parameter in the idempotent task until each limited use parameter is rolled back, and modifying the state of the distributed task into an end state.
Rollback may be considered the inverse of consumption, taking the payment system as an example, if 500 dollars are consumed, the user account funds are reduced by 500 dollars, if 500 dollars are rolled back, the user account funds are increased by 500 dollars, if rollback and consumption are performed for the same limited-use parameters, the limited-use resources to which the limited-use parameters point may be considered to eventually be unchanged.
According to the method for ensuring the consistency of the final data of the distributed transaction disclosed by the embodiment of the invention, various parameters required for implementing the distributed transaction are obtained, and the idempotent task is generated and executed based on the parameters, so that after the idempotent task is executed, all relevant data participating in the distributed transaction have the consistency of the final data , and account checking is not required, so that the time required for reaching the consistency state of the final data is obviously reduced, the distributed transaction is executed with high success rate, the time lag is reduced, and the viscosity of a user is obviously improved.
As shown in fig. 11, which is a logic diagram illustrating a method for ensuring consistency of distributed transaction final data according to an embodiment of the present invention, since each action in the process of executing an idempotent task is idempotent, it can be ensured that each parameter participating in the idempotent task finally points to the same result, that is, if a fails to use, B also fails to use, and if a succeeds to use, B also succeeds to use, so that it can be known that, after the idempotent task finishes executing, each item of data participating in the distributed transaction is finally consistent.
The embodiment of the present invention further provides apparatuses for ensuring consistency of distributed transaction final data , as shown in fig. 12, the apparatuses include:
a service set obtaining module 201, configured to obtain a service request, and obtain a service set formed by services associated with the service request, where the server set includes at least two services;
a parameter set obtaining module 203, configured to obtain parameters related to the service request for each service to obtain a parameter subset corresponding to the service, and obtain a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
an idempotent task generating module 205, configured to generate an idempotent task according to the parameter set, where the idempotent task is used to perform idempotent operation on each parameter in the parameter set;
and the idempotent task execution module 207 is configured to generate a distributed transaction for processing the service request, execute the idempotent task in the distributed transaction, and return an execution result of the idempotent task.
Specifically, the apparatuses and method embodiments for ensuring consistency of the distributed transaction final data according to the embodiments of the present invention are all based on the same inventive concept.
The instructions can be suitable for being loaded by a processor and executing methods for ensuring consistency of distributed transaction final data , the methods at least include the following steps:
, a method of ensuring consistency of distributed transaction end data, the method comprising:
acquiring a service request, and acquiring a service set formed by each service associated with the service request, wherein the server set at least comprises two services;
acquiring parameters related to the service request of each service to obtain a parameter subset corresponding to the service, and obtaining a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
generating an idempotent task according to the parameter set, wherein the idempotent task is used for performing idempotent operation on each parameter in the parameter set;
and generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction, and returning an execution result of the idempotent task.
In preferred embodiments, the executing the idempotent task in the distributed transaction includes:
judging whether infinite use parameters exist in the idempotent tasks or not;
if no infinite use parameter exists, executing the idempotent task in the distributed transaction according to an execution strategy;
and if the unlimited use parameter exists, executing the idempotent task in the distributed transaction according to a second execution strategy.
preferred embodiments, the executing the idempotent task in the distributed transaction according to the execution policy includes:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
starting to execute the distributed transaction by a transaction management process to trigger execution of an idempotent task, pre-deducting each parameter in the idempotent task, and modifying the state of the distributed transaction according to a pre-deduction result;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
preferred embodiments, the continuing execution of the idempotent task according to the state of the distributed transaction includes:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is successfully consumed, and modifying the state of the distributed task into an end state;
and if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each parameter in the idempotent task until each parameter is released, and modifying the state of the distributed task into an end state.
preferred embodiments, the executing the idempotent task in the distributed transaction according to the second execution policy includes:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
starting to execute the distributed transaction by a transaction management process to trigger the execution of the idempotent task, pre-deducting each limited use parameter in the idempotent task, and modifying the state of the distributed transaction according to a pre-deduction result;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
preferred embodiments, the continuing execution of the idempotent task according to the state of the distributed transaction includes:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is successfully consumed, and modifying the state of the distributed task into an end state;
and if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each limited use parameter in the idempotent task until each limited use parameter is released, and modifying the state of the distributed task into an end state.
preferred embodiments, the executing the idempotent task in the distributed transaction according to the second execution policy includes:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
consuming each limited use parameter in the idempotent tasks, modifying the distributed transaction state to be a normal state if the consumption of each limited use parameter is successful, and modifying the distributed transaction state to be an abnormal state if at least consumption of each limited use parameter are failed;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
preferred embodiments, the continuing execution of the idempotent task according to the state of the distributed transaction includes:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each infinite use parameter in the idempotent task until each parameter is consumed successfully, and modifying the state of the distributed task into an end state;
if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent rollback on each limited use parameter in the idempotent task until each limited use parameter is rolled back, and modifying the state of the distributed task into an end state.
Further , FIG. 13 illustrates a hardware block diagram of devices for implementing the methods provided by embodiments of the present invention, which may participate in forming or incorporating the apparatus or system provided by embodiments of the present invention, as shown in FIG. 13, the device 10 may include or more (illustrated in the figures as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a microprocessor MCU or a programmable logic device FPGA or the like), a memory 104 for storing data, and a transmission device 106 for communication functions, in addition to which a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as of the I/O interface ports), a network interface, a power supply, and/or a camera may be included, as will be appreciated by those of ordinary skill in the art, the structure shown in FIG. 13 is merely illustrative and is not intended to limit the structure of the above-described electronic devices.
It should be noted that or more of the processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry" which may be embodied in whole or in part in software, hardware, firmware, or any combination thereof.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the methods described in the embodiments of the present invention, and the processor 102 may execute various functional applications and data processing by executing the software programs and modules stored in the memory 104, so as to implement the methods for ensuring the distributed transaction final data consistency described above.
The transmission device 106 is configured to receive or transmit data via networks, where the aforementioned specific examples of networks may include a wireless network provided by a communication provider of the device 10. in examples, the transmission device 106 includes network adapters (NICs) that may be connected to other network devices via a base station so as to communicate with the internet.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the device 10 (or mobile device).
It should be noted that the foregoing descriptions of embodiments of the present invention are provided for illustrative purposes only and do not represent advantages or disadvantages of the embodiments, and that the description of the specific embodiments is provided above other embodiments are within the scope of the appended claims.in cases, acts or steps recited in the claims may be performed in an order different than the illustrated embodiments and still achieve desirable results.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in computer readable storage media, which may be read only memory, magnetic or optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1, A method for ensuring consistency of distributed transaction end data, the method comprising:
acquiring a service request, and acquiring a service set formed by each service associated with the service request, wherein the server set at least comprises two services;
acquiring parameters related to the service request of each service to obtain a parameter subset corresponding to the service, and obtaining a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
generating an idempotent task according to the parameter set, wherein the idempotent task is used for performing idempotent operation on each parameter in the parameter set;
and generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction, and returning an execution result of the idempotent task.
2. The method of claim 1, wherein the executing the idempotent task in the distributed transaction comprises:
judging whether infinite use parameters exist in the idempotent tasks or not;
if no infinite use parameter exists, executing the idempotent task in the distributed transaction according to an execution strategy;
and if the unlimited use parameter exists, executing the idempotent task in the distributed transaction according to a second execution strategy.
3. The method of claim 2, wherein executing the idempotent task in the distributed transaction according to an th execution policy comprises:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
starting to execute the distributed transaction by a transaction management process to trigger execution of an idempotent task, pre-deducting each parameter in the idempotent task, and modifying the state of the distributed transaction according to a pre-deduction result;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
4. The method of claim 3, wherein continuing to execute the idempotent task according to the state of the distributed transaction comprises:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is successfully consumed, and modifying the state of the distributed task into an end state;
and if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each parameter in the idempotent task until each parameter is released, and modifying the state of the distributed task into an end state.
5. The method of claim 2, wherein executing the idempotent task in the distributed transaction in accordance with a second execution policy comprises:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
starting to execute the distributed transaction by a transaction management process to trigger the execution of the idempotent task, pre-deducting each limited use parameter in the idempotent task, and modifying the state of the distributed transaction according to a pre-deduction result;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
6. The method of claim 5, wherein continuing to execute the idempotent task according to the state of the distributed transaction comprises:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each parameter in the idempotent task until each parameter is successfully consumed, and modifying the state of the distributed task into an end state;
and if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent release on each limited use parameter in the idempotent task until each limited use parameter is released, and modifying the state of the distributed task into an end state.
7. The method of claim 2, wherein executing the idempotent task in the distributed transaction in accordance with a second execution policy comprises:
marking, by a transaction management process, a state of the distributed transaction as an execution state, the distributed transaction created by the transaction management process;
consuming each limited use parameter in the idempotent tasks, modifying the distributed transaction state to be a normal state if the consumption of each limited use parameter is successful, and modifying the distributed transaction state to be an abnormal state if at least consumption of each limited use parameter are failed;
and continuously executing the idempotent task according to the state of the distributed transaction, and returning the execution result of the idempotent task after the state of the distributed transaction is modified into an end state.
8. The method of claim 7, wherein continuing to execute the idempotent task according to the state of the distributed transaction comprises:
if the state of the distributed transaction is a normal execution state, circularly performing idempotent consumption on each infinite use parameter in the idempotent task until each parameter is consumed successfully, and modifying the state of the distributed task into an end state;
if the state of the distributed transaction is an abnormal execution state, circularly performing idempotent rollback on each limited use parameter in the idempotent task until each limited use parameter is rolled back, and modifying the state of the distributed task into an end state.
An apparatus of for ensuring consistency of distributed transaction end data , the apparatus comprising:
the service set acquisition module is used for acquiring a service request and acquiring a service set formed by services related to the service request, and the server set at least comprises two services;
a parameter set obtaining module, configured to obtain a parameter related to the service request for each service to obtain a parameter subset corresponding to the service, and obtain a parameter set corresponding to the service set based on the parameter subset corresponding to each service in the service set;
the idempotent task generating module is used for generating an idempotent task according to the parameter set, and the idempotent task is used for performing idempotent operation on each parameter in the parameter set;
and the idempotent task execution module is used for generating a distributed transaction for processing the service request, executing the idempotent task in the distributed transaction and returning an execution result of the idempotent task.
10, computer storage media having stored therein at least instructions, at least programs, code sets, or instruction sets, the at least instructions, at least programs, code sets, or instruction sets being loaded and executed by a processor to implement the method of ensuring consistency of distributed transaction end data as recited in any of claims 1-8 .
CN201910915138.7A 2019-09-26 2019-09-26 method, device and medium for ensuring consistency of final data of distributed transaction Pending CN110737514A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910915138.7A CN110737514A (en) 2019-09-26 2019-09-26 method, device and medium for ensuring consistency of final data of distributed transaction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910915138.7A CN110737514A (en) 2019-09-26 2019-09-26 method, device and medium for ensuring consistency of final data of distributed transaction

Publications (1)

Publication Number Publication Date
CN110737514A true CN110737514A (en) 2020-01-31

Family

ID=69269629

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910915138.7A Pending CN110737514A (en) 2019-09-26 2019-09-26 method, device and medium for ensuring consistency of final data of distributed transaction

Country Status (1)

Country Link
CN (1) CN110737514A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111427542A (en) * 2020-03-19 2020-07-17 武汉慧联无限科技有限公司 Information processing method, device and computer readable storage medium
CN112769712A (en) * 2020-12-23 2021-05-07 中移(杭州)信息技术有限公司 Compensation method and device, electronic equipment and storage medium
CN114217734A (en) * 2021-04-30 2022-03-22 无锡江南计算技术研究所 Data management method for distributed storage system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111427542A (en) * 2020-03-19 2020-07-17 武汉慧联无限科技有限公司 Information processing method, device and computer readable storage medium
CN111427542B (en) * 2020-03-19 2023-07-04 武汉慧联无限科技有限公司 Information processing method, apparatus and computer readable storage medium
CN112769712A (en) * 2020-12-23 2021-05-07 中移(杭州)信息技术有限公司 Compensation method and device, electronic equipment and storage medium
CN114217734A (en) * 2021-04-30 2022-03-22 无锡江南计算技术研究所 Data management method for distributed storage system
CN114217734B (en) * 2021-04-30 2023-10-27 无锡江南计算技术研究所 Data management method for distributed storage system

Similar Documents

Publication Publication Date Title
CN110199302B (en) Event-driven blockchain workflow processing
CN108449410B (en) Message management method, system and related device in cloud platform
JP7422856B2 (en) Node data synchronization method and device, system, electronic equipment, storage medium and computer program
US8938510B2 (en) On-demand mailbox synchronization and migration system
CN110737514A (en) method, device and medium for ensuring consistency of final data of distributed transaction
CN108681777B (en) Method and device for running machine learning program based on distributed system
US11706106B2 (en) Resource lifecycle automation
CN109067841B (en) Service current limiting method, system, server and storage medium based on ZooKeeper
CN111277639B (en) Method and device for maintaining data consistency
JP2020525876A (en) Implementation of parallel execution of transactions in distributed ledger system
CN111338773A (en) Distributed timed task scheduling method, scheduling system and server cluster
US20120224482A1 (en) Credit feedback system for parallel data flow control
CN105302676A (en) Method and apparatus for transmitting host and backup mechanism data of distributed file system
CN110221927A (en) Asynchronous message processing method and device
CN109462650A (en) Data file downloading method, device, computer equipment and storage medium
CN111796946A (en) Data processing method, device, equipment and storage medium
CN113179301A (en) File downloading method and device, storage medium and electronic device
CN114610504A (en) Message processing method and device, electronic equipment and storage medium
CN108733515A (en) Dispatching method, file backup method, device and the storage medium of file backup
CN107908481A (en) A kind of method of data synchronization, device and system
CN112825525B (en) Method and apparatus for processing transactions
CN112819638A (en) Transaction weight judging method, device, equipment and computer readable medium
CN113791876A (en) System, method and apparatus for processing tasks
CN110807058B (en) Method and system for exporting data
CN112241332B (en) Interface compensation method and device

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: 40020134

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination