A distributed transaction processing method and related devices

In the distributed transaction processing system, the business application calls the attempted interface of each subserver and judges the interface call result. If it fails, a transaction rollback request is sent to realize rollback and synchronization of distributed transactions, which solves the problem of inconsistency in information in distributed transactions and ensures the integrity and consistency of transactions.

CN115599504BActive Publication Date: 2025-07-01国家电网有限公司客户服务中心
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210953382.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2025-07-01
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

During the personnel management process, due to network timeout and other reasons, personnel information management in distributed transactions is inconsistent, and various transactions are not synchronized. How to ensure the synchronization of distributed transactions has become an urgent problem.

Method used

A distributed transaction processing method is proposed. Through business applications, the personnel account subserver, personnel state subserver and to-do transaction subserver are called to determine the interface of the interface call. If any interface call fails, a transaction rollback request is sent to the transaction coordinator, and the rollback interface of each subserver is called in turn to realize the rollback and synchronization of transaction processing.

Benefits of technology

Through this method, the integrity and synchronization of distributed transactions are achieved, information inconsistency caused by network timeouts and other reasons is avoided, and the correctness and consistency of transactions during personnel management is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115599504B_ABST
    Figure CN115599504B_ABST
Patent Text Reader

Abstract

The present disclosure provides a distributed transaction processing method and related devices. A business application starts a distributed transaction; the business application calls the attempt interfaces of a personnel account sub-server, a personnel status sub-server, and a to-do transaction sub-server; the business application sequentially determines the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server; in response to determining that the call of the attempt interface of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, it is determined that any one of the distributed transaction processing fails, and the business application sends a transaction rollback request to the transaction coordinator; in response to determining that the transaction coordinator receives the transaction rollback request, the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are sequentially called.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data processing, and in particular, to a distributed transaction processing method and related devices. Background Art

[0002] In the process of personnel management, due to different management requirements and the differentiation and complexity of personnel information, there will be a situation where the personnel information management in multiple databases is inconsistent due to network timeouts, resulting in the problem of different transaction out-of-sync.

[0003] In view of this, how to ensure the synchronization of each distributed transaction in the process of personnel management has become an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the purpose of the present disclosure is to propose a distributed transaction processing method and related devices to solve or partially solve the above technical problems.

[0005] Based on the above purpose, a first aspect of the present disclosure proposes a distributed transaction processing method, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a business application, a transaction coordinator, and a server. Among them, the server includes: a personnel account sub-server, a personnel status sub-server, and a to-do transaction sub-server. There are corresponding databases for the servers respectively, and distributed transactions are set in the databases. The method includes:

[0006] The business application starts the distributed transaction, where the distributed transaction includes: a query account information sub-transaction, a query personnel status sub-transaction, and a query to-do transaction sub-transaction;

[0007] The business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. The personnel account sub-server performs an attempt operation process on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs an attempt operation process on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server;

[0008] The business application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server;

[0009] In response to determining that the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, it is determined that the attempt operation processing of any distributed transaction fails, and the business application sends a transaction rollback request to the transaction coordinator;

[0010] In response to determining that the transaction coordinator receives the transaction rollback request, the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are called in sequence.

[0011] In some embodiments, the personnel account sub-server performs an attempt operation processing on the query account information sub-transaction according to the attempt interface of the personnel account sub-server, the personnel status sub-server performs an attempt operation processing on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server, and the to-do transaction sub-server performs an attempt operation processing on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server, including:

[0012] The personnel account sub-server performs an attempt operation processing on the query account information sub-transaction according to the attempt interface of the personnel account sub-server, which is used to query personnel account information and monitor and manage personnel accounts;

[0013] The personnel status sub-server performs an attempt operation processing on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server, which is used to query personnel status information and monitor and manage personnel status;

[0014] The to-do transaction sub-server performs an attempt operation processing on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server, which is used to query personnel to-do transaction information and monitor and manage personnel to-do transactions;

[0015] Among them, the query account information sub-transaction and the query personnel status sub-transaction are executed in sequence according to the processing logic.

[0016] In some embodiments, it further includes:

[0017] The business application returns to re-call the attempt ports of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, and re-performs the attempt operation processing on the query account information sub-transaction, the query personnel status sub-transaction, and the query to-do transaction sub-transaction.

[0018] In some embodiments, after the business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, it further includes:

[0019] In response to determining that the business application network times out, the business application fails to call the attempt interface, the transaction coordinator calls the rollback interface, and the business application determines that the rollback interface called by the transaction coordinator is an empty rollback, and sets the state of the distributed transaction to the transaction empty rollback state.

[0020] In some embodiments, it further includes:

[0021] In response to determining that the business application network resumes, the business application re - calls the attempt interface of the server and re - sends the corresponding transaction request to the transaction coordinator;

[0022] The transaction coordinator judges the call status of the rollback interface;

[0023] In response to determining that the call of the rollback interface is successful, the transaction coordinator ignores the re - sent transaction request.

[0024] In some embodiments, it further includes:

[0025] In response to determining that the transaction coordinator network times out and the call of the rollback interface fails, the transaction coordinator re - calls the rollback interface;

[0026] In response to determining that the transaction coordinator network times out and the call of the confirmation interface fails, the transaction coordinator re - calls the confirmation interface.

[0027] In some embodiments, it further includes:

[0028] The business application and the transaction coordinator respectively set processing states for the distributed transaction;

[0029] Among them, after the business application sends a start - transaction request to the transaction coordinator, it sets the state of the distributed transaction to the transaction start state; after the business application calls all the attempt interfaces of the server, it sets the state of the distributed transaction to the transaction in - progress state; after the business application determines that the call of any attempt interface of the server fails, it sets the state of the distributed transaction to the transaction failure state; after the business application determines that the calls of all the attempt interfaces of the server are successful, it sets the state of the distributed transaction to the transaction success state; after the transaction coordinator calls the rollback interface of the server, it sets the state of the distributed transaction to the transaction rollback - completed state; after the transaction coordinator calls the confirmation interface of the server, it sets the state of the distributed transaction to the transaction confirmation - completed state.

[0030] Based on the same inventive concept, a second aspect of the present disclosure proposes a distributed transaction processing device, including:

[0031] An opening module, configured to enable the business application to start the distributed transaction, where the distributed transaction includes: a query account information sub-transaction, a query personnel status sub-transaction, and a query pending transaction sub-transaction;

[0032] A try interface call module, configured to enable the business application to call the try interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server. The personnel account sub-server performs a try operation process on the query account information sub-transaction according to the try interface of the personnel account sub-server. The personnel status sub-server performs a try operation process on the query personnel status sub-transaction according to the try interface of the personnel status sub-server. The pending transaction sub-server performs a try operation process on the query pending transaction sub-transaction according to the try interface of the pending transaction sub-server;

[0033] A try interface determination module, configured to enable the business application to sequentially judge the try interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server;

[0034] A rollback request sending module, configured to, in response to determining that the try interface call of any one of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server fails, determine that any one of the distributed transaction processes fails, and the business application sends a transaction rollback request to the transaction coordinator;

[0035] A rollback interface call module, configured to, in response to determining that the transaction coordinator receives the transaction rollback request, sequentially call the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server.

[0036] Based on the same inventive concept, a third aspect of the present disclosure provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable by the processor. When the processor executes the computer program, the above-described method is implemented.

[0037] Based on the same inventive concept, a fourth aspect of the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the above-described method.

[0038] As can be seen from the above, the distributed transaction processing method and related devices provided by the present disclosure enable the business application to initiate the distributed transaction, where the distributed transaction includes: a sub-transaction for querying account information, a sub-transaction for querying personnel status, and a sub-transaction for querying pending transactions; the business application invokes the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server. The personnel account sub-server performs an attempt operation process on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The pending transaction sub-server performs an attempt operation process on the query pending transaction sub-transaction according to the attempt interface of the pending transaction sub-server, and processes the corresponding sub-transactions by invoking the corresponding attempt interfaces of each sub-server; the business application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server, and determines whether the attempt operation of the distributed transaction is successful by judging the attempt ports; when the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server fails, it can be determined that there is a failure in the attempt operation process of the distributed transaction, and the business application sends a transaction rollback request to the transaction coordinator to achieve the integrity of the transaction processing; when the transaction coordinator receives the transaction rollback request, it sequentially invokes the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server to achieve the rollback of the transaction processing, and the transaction processing status returns to the attempt state. As long as one of the distributed transactions fails, it will be rolled back to achieve the synchronization of the transaction processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the following will briefly introduce the drawings required for use in the embodiments or related technology descriptions. Obviously, the drawings in the following description are only embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0040] Figure 1A It is a flowchart of the distributed transaction processing method according to an embodiment of the present disclosure;

[0041] Figure 1B It is a schematic diagram of the personnel management distributed transaction processing model according to an embodiment of the present disclosure;

[0042] Figure 2 It is a flowchart of the distributed transaction processing device according to an embodiment of the present disclosure;

[0043] Figure 3Schematic diagram of the structure of the electronic device according to an embodiment of the present disclosure. Detailed implementation manners

[0044] To make the objectives, technical solutions, and advantages of the present disclosure more clear and understandable, the following further describes the present disclosure in detail with reference to specific embodiments and the accompanying drawings.

[0045] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should have the ordinary meanings understood by those of ordinary skill in the art to which the present disclosure belongs. The "first", "second", and similar terms used in the embodiments of the present disclosure do not denote any order, quantity, or importance, but are only used to distinguish different components. The terms such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. The terms such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms such as "upper", "lower", "left", and "right" are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0046] As described above, how to ensure the synchronization of each distributed transaction in the personnel management process has become an important research issue.

[0047] Based on the above description, as Figure 1A shown, a distributed transaction processing method proposed in this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a business application, a transaction coordinator, and a server. Among them, the server includes: a personnel account sub-server, a personnel status sub-server, and a to-do transaction sub-server. There are corresponding databases for the server respectively, and distributed transactions are set in the databases. The method includes:

[0048] Step 101, the business application starts the distributed transaction, where the distributed transaction includes: a sub-transaction for querying account information, a sub-transaction for querying personnel status, and a sub-transaction for querying to-do transactions.

[0049] Specifically, when implemented, the business application serves as the entry point for starting the transaction and starts the distributed transaction. The distributed transaction includes: a sub-transaction for querying account information, a sub-transaction for querying personnel status, and a sub-transaction for querying to-do transactions. Each sub-transaction is processed by the corresponding sub-server. For example, when the personnel account sub-server queries the personnel account information, the business application starts a distributed transaction including two sub-transactions: querying personnel status and querying to-do transactions.

[0050] Step 102, the business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. The personnel account sub-server performs an attempt operation on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs an attempt operation on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server.

[0051] In specific implementation, the business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. Among them, the call of the attempt interface may include information such as the transaction identifier of the sub-transaction. For example, the personnel account sub-server sends attempt requests to the personnel status sub-server and the to-do transaction sub-server respectively. The attempt request sent to the personnel status sub-server includes the transaction identifier identifying the sub-transaction of "querying personnel status information", and the attempt request sent to the to-do transaction sub-server includes the transaction identifier identifying the sub-transaction of "querying personnel to-do transaction information".

[0052] Among them, calling the attempt interface means attempting to execute the sub-transaction, including completing all business checks required for executing the sub-transaction and reserving the necessary business resources. After the attempt interface of each sub-server is called, it performs an attempt operation on its own sub-transaction. The attempt operation does not actually execute the sub-transaction. It is equivalent to a "dress rehearsal" and "preview" of executing the sub-transaction, and does not actually change the data in the database.

[0053] Step 103, the business application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server.

[0054] In specific implementation, the call result of the attempt interface includes call success and call failure. When the call result is successful, it means that when the corresponding sub-server performs the attempt operation, it can complete the operation according to the predetermined requirements. When the call result is failure, it means that when the corresponding sub-server performs the attempt operation, it cannot complete the operation according to the predetermined requirements. The predetermined requirements include execution time, execution logic, etc. For example, when the personnel status sub-server calls the attempt interface and fails, if the query of personnel status information fails, then when calling the attempt interface of the to-do transaction sub-server, continue to query the personnel to-do transaction, which does not meet the execution logic and the execution result is failure.

[0055] Step 104, in response to determining that the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, it is determined that the attempt operation processing of any distributed transaction fails, and the business application sends a transaction rollback request to the transaction coordinator.

[0056] In specific implementation, when the business application receives the failure of the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, it indicates that there is a sub-transaction in the distributed transaction that cannot be executed normally. To ensure the consistency of the transaction, a transaction rollback request is sent to the transaction coordinator. For example, when the attempt interface call of the personnel status sub-server fails, it indicates that the sub-transaction of "querying personnel status information" cannot be executed normally, and the business application sends a transaction rollback request to the transaction coordinator.

[0057] Step 105, in response to determining that the transaction coordinator receives the transaction rollback request, the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are called in sequence.

[0058] In specific implementation, after the transaction coordinator receives the transaction rollback request, the transaction coordinator calls the rollback interfaces of each sub-server, performs a rollback operation, rolls back the attempt operation, and all sub-servers return to the initial state.

[0059] In the above embodiments, the business application initiates the distributed transaction, where the distributed transaction includes: a sub-transaction for querying account information, a sub-transaction for querying personnel status, and a sub-transaction for querying pending transactions; the business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server. The personnel account sub-server performs an attempt operation process on the sub-transaction for querying account information according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the sub-transaction for querying personnel status according to the attempt interface of the personnel status sub-server. The pending transaction sub-server performs an attempt operation process on the sub-transaction for querying pending transactions according to the attempt interface of the pending transaction sub-server. By calling the corresponding attempt interfaces of each sub-server to process the corresponding sub-transactions; the business application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server, and determines whether the attempt operation of the distributed transaction is successful by judging the attempt port; when the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server fails, it can be determined that there is a failure in the attempt operation process of the distributed transaction. The business application sends a transaction rollback request to the transaction coordinator to achieve the integrity of transaction processing; when the transaction coordinator receives the transaction rollback request, it sequentially calls the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server to achieve the rollback of transaction processing. The transaction processing status returns to the attempt state. As long as one of the processes in the distributed transaction fails, a rollback will be performed to achieve the synchronization of transaction processing.

[0060] In some embodiments, step 102 includes:

[0061] Step 1021, the personnel account sub-server performs an attempt operation process on the sub-transaction for querying account information according to the attempt interface of the personnel account sub-server, which is used to query personnel account information and monitor and manage personnel accounts.

[0062] Step 1022, the personnel status sub-server performs an attempt operation process on the sub-transaction for querying personnel status according to the attempt interface of the personnel status sub-server, which is used to query personnel status information and monitor and manage personnel status.

[0063] Step 1023, the pending transaction sub-server performs an attempt operation process on the sub-transaction for querying pending transactions according to the attempt interface of the pending transaction sub-server, which is used to query personnel pending transaction information and monitor and manage personnel pending transactions.

[0064] Among them, the query account information sub-transaction and the query personnel status sub-transaction are executed successively according to the processing logic.

[0065] During specific implementation, by calling the attempt interfaces of each sub-server, transmission operation processing can be performed on the corresponding sub-transactions. Calling the attempt interface means attempting to execute the sub-transaction, including completing all business checks required for executing the sub-transaction and reserving necessary business resources. After the attempt interface of each sub-server is called, an attempt operation is performed on its own sub-transaction. The attempt operation does not actually execute the sub-transaction, which is equivalent to a "dress rehearsal" and "preview" of executing the sub-transaction, and does not actually change the data in the database.

[0066] Among them, the various sub-transactions included in the distributed transaction are executed successively according to the processing logic. For example, only after the personnel account information is queried can the personnel status information and the personnel pending transaction information be queried. Therefore, after the query account information sub-transaction is completed, the query personnel status sub-transaction and the query pending transaction sub-transaction can be executed.

[0067] In some embodiments, after step 105, it further includes:

[0068] Step 105A, the business application returns to re-call the attempt ports of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server, and re-performs attempt operation processing on the query account information sub-transaction, the query personnel status sub-transaction, and the query pending transaction sub-transaction.

[0069] During specific implementation, when the transaction coordinator calls the rollback interfaces of each sub-server, the attempt operation is rolled back, all sub-servers return to the initial state, the attempt ports of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server are re-called, and attempt operation processing is re-performed on each sub-transaction.

[0070] In some embodiments, after step 102, it further includes:

[0071] Step 1030, in response to determining that the business application network times out, the business application fails to call the attempt interface, the transaction coordinator calls the rollback interface, the business application determines that the rollback interface called by the transaction coordinator is an empty rollback, and sets the status of the distributed transaction to the transaction empty rollback state.

[0072] In specific implementation, when a network timeout occurs in the service application, in the case where the attempt interface is not called but the rollback interface is successfully called, the service application identifies that this is an empty rollback and directly returns to the initial state. For example, when a network timeout occurs in the service application, the attempt ports of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are not called. Therefore, no attempt operation processing is performed on the query account information sub-transaction, the query personnel status sub-transaction, and the query to-do transaction sub-transaction. However, if the transaction coordinator calls the rollback interfaces of each sub-server, then this rollback is an empty rollback.

[0073] In some embodiments, after step 1030, the following steps are further included:

[0074] Step 1030A, in response to determining that the network of the service application has recovered, the service application re-calls the attempt interface of the server and re-sends the corresponding transaction request to the transaction coordinator.

[0075] Step 1030B, the transaction coordinator determines the call status of the rollback interface.

[0076] Step 1030C, in response to determining that the call of the rollback interface is successful, the transaction coordinator ignores the re-sent transaction request.

[0077] In specific implementation, after the network of the service application recovers, the service application re-calls the attempt ports of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. After the attempt interface call is completed, the service application sends a commit request or a rollback request to the transaction coordinator. However, due to the empty rollback, the transaction coordinator has already completed the call of the rollback interface. Therefore, the transaction coordinator ignores this commit request or rollback request.

[0078] In some embodiments, after step 105, the following steps are further included:

[0079] Step 105B, in response to determining that the network of the transaction coordinator times out and the call of the rollback interface fails, the transaction coordinator re-calls the rollback interface.

[0080] Step 105C, in response to determining that the network of the transaction coordinator times out and the call of the confirmation interface fails, the transaction coordinator re-calls the confirmation interface.

[0081] During specific implementation, when the transaction coordinator times out, the rollback interface and / or the confirmation interface of the sub-server will fail to be called. At this time, the transaction coordinator needs to re-call the corresponding interface. To ensure data consistency, the try interface, the confirmation interface, and the rollback interface must be idempotent. When the rollback interface call fails, the rollback interface will be re-called, and there will be no problem that the rollback interface call fails and another interface is called when it is called again. In this way, data consistency is ensured, and resources are not reused or released repeatedly.

[0082] In some embodiments, after step 105, it further includes:

[0083] Step 105D, the business application and the transaction coordinator respectively set the processing status of the distributed transaction.

[0084] Among them, after the business application sends a start transaction request to the transaction coordinator, it sets the status of the distributed transaction to the transaction start status; after the business application calls the try interfaces of all servers, it sets the status of the distributed transaction to the transaction in progress status; after the business application determines that the try interface of any server fails to be called, it sets the status of the distributed transaction to the transaction attempt failed status; after the business application determines that the try interfaces of all servers are called successfully, it sets the status of the distributed transaction to the transaction attempt successful status; after the transaction coordinator calls the rollback interface of the server, it sets the status of the distributed transaction to the transaction rollback completed status; after the transaction coordinator calls the confirmation interface of the server, it sets the status of the distributed transaction to the transaction confirmation completed status.

[0085] During specific implementation, while the business application and the transaction coordinator are making interface calls, they also need to set the processing status of the distributed transaction, and judge the processing progress of the distributed transaction based on the processing status, which is convenient for the next operation.

[0086] In the above embodiment, the service application starts the distributed transaction, where the distributed transaction includes: an account information query sub-transaction, a personnel status query sub-transaction, and a to-do transaction query sub-transaction; the service application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. The personnel account sub-server performs an attempt operation process on the account information query sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the personnel status query sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs an attempt operation process on the to-do transaction query sub-transaction according to the attempt interface of the to-do transaction sub-server, and processes the corresponding sub-transactions by calling the corresponding attempt interfaces of each sub-server; the service application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, and determines whether the attempt operation of the distributed transaction is successful by judging the attempt ports; when the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, it can be determined that there is a failure in the attempt operation process of the distributed transaction, and the service application sends a transaction rollback request to the transaction coordinator to achieve the integrity of transaction processing; when the transaction coordinator receives the transaction rollback request, it sequentially calls the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server to achieve the rollback of transaction processing, and the transaction processing status returns to the attempt state. As long as one of the distributed transactions fails, it will be rolled back to achieve the synchronization of transaction processing.

[0087] It should be noted that the embodiments of the present disclosure can also be further described in the following manner:

[0088] As Figure 1B shown, Figure 1B is a schematic diagram of a distributed transaction processing model for personnel management, including: a service application, a transaction coordinator, a personnel account sub-server, a personnel status sub-server, a to-do transaction sub-server, an account information query sub-transaction, a personnel status query sub-transaction, and a to-do transaction query sub-transaction.

[0089] Step 1: The service application sends a request to start a transaction to the transaction coordinator, and the service application and the transaction coordinator start to process the distributed transaction.

[0090] Step 2: The business application respectively invokes the corresponding Try interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server to process the query account information sub-transaction, the query personnel status sub-transaction, and the query to-do transaction sub-transaction corresponding to the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server respectively.

[0091] Step 3: The business application sends a request for transaction submission or rollback to the transaction coordinator.

[0092] Step 4: The transaction coordinator respectively invokes the corresponding Confirm interface or Cancel interface of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. When any one of the Try interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server in Step 2 fails to be invoked, the transaction coordinator invokes the Cancel interface for rollback. When all the Try interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are successfully invoked, the transaction coordinator invokes the Confirm interface for confirmation.

[0093] It should be noted that the method of the embodiments of the present disclosure can be executed by a single device, such as a computer or a server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In such a distributed scenario, one of the multiple devices can only execute one or more steps of the method of the embodiments of the present disclosure, and these multiple devices will interact with each other to complete the described method.

[0094] It should be noted that some embodiments of the present disclosure have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be executed in a different order from that in the above embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0095] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present disclosure also provides a distributed transaction processing device.

[0096] Refer to Figure 2 , the distributed transaction processing device includes:

[0097] An opening module 201, configured to enable the business application to start the distributed transaction, where the distributed transaction includes: a query account information sub-transaction, a query personnel status sub-transaction, and a query pending transaction sub-transaction;

[0098] A try interface call module 202, configured to enable the business application to call the try interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server. The personnel account sub-server performs a try operation process on the query account information sub-transaction according to the try interface of the personnel account sub-server. The personnel status sub-server performs a try operation process on the query personnel status sub-transaction according to the try interface of the personnel status sub-server. The pending transaction sub-server performs a try operation process on the query pending transaction sub-transaction according to the try interface of the pending transaction sub-server;

[0099] A try interface determination module 203, configured to enable the business application to sequentially judge the try interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server;

[0100] A rollback request sending module 204, configured to, in response to determining that the try interface call of any one of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server fails, determine that the try operation process of any one of the distributed transactions fails, and the business application sends a transaction rollback request to the transaction coordinator;

[0101] A rollback interface call module 205, configured to, in response to determining that the transaction coordinator receives the transaction rollback request, sequentially call the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the pending transaction sub-server.

[0102] In some embodiments, the try interface call module 202 specifically includes:

[0103] An account query unit, configured to enable the personnel account sub-server to perform a try operation process on the query account information sub-transaction according to the try interface of the personnel account sub-server, for querying personnel account information and monitoring and managing personnel accounts;

[0104] A status query unit, configured to enable the personnel status sub-server to perform a try operation process on the query personnel status sub-transaction according to the try interface of the personnel status sub-server, for querying personnel status information and monitoring and managing personnel status;

[0105] A to-do transaction query unit, configured to enable the to-do transaction sub-server to perform a trial operation process on the query to-do transaction sub-transaction according to the trial interface of the to-do transaction sub-server, for querying personnel to-do transaction information and monitoring and managing personnel to-do transactions;

[0106] Among them, the query account information sub-transaction and the query personnel status sub-transaction are executed successively according to the processing logic.

[0107] In some embodiments, after the rollback interface call module 205, the following is further included:

[0108] A trial port return unit, configured to enable the business application to return the trial ports for re-calling the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, and re-perform the trial operation process on the query account information sub-transaction, the query personnel status sub-transaction, and the query to-do transaction sub-transaction.

[0109] In some embodiments, after the trial interface call module 202, the following is further included:

[0110] An empty rollback unit, configured to, in response to determining that the business application network times out, the business application fails to call the trial interface, the transaction coordinator calls the rollback interface, the business application determines that the rollback interface called by the transaction coordinator is an empty rollback, and sets the status of the distributed transaction to the transaction empty rollback status.

[0111] In some embodiments, after the rollback interface call module 205, the following is further included:

[0112] A trial interface re-call unit, configured to, in response to determining that the business application network resumes, the business application re-calls the trial interface of the server and re-sends the corresponding transaction request to the transaction coordinator;

[0113] A determination unit, configured to enable the transaction coordinator to judge the rollback interface call status;

[0114] A request ignoring unit, configured to, in response to determining that the rollback interface call is successful, the transaction coordinator ignores the re-sent transaction request.

[0115] In some embodiments, after the rollback interface call module 205, the following is further included:

[0116] A rollback interface re-call unit, configured to, in response to determining that the transaction coordinator network times out, the rollback interface call fails, the transaction coordinator re-calls the rollback interface;

[0117] The confirmation interface re - call unit is configured to, in response to determining that the transaction coordinator network times out and the confirmation interface call fails, the transaction coordinator re - calls the confirmation interface.

[0118] In some embodiments, after the rollback interface call module 205, it further includes:

[0119] The status setting unit is configured to set the processing status of the distributed transaction for the service application and the transaction coordinator respectively;

[0120] Among them, after the service application sends a start - transaction request to the transaction coordinator, it sets the status of the distributed transaction to the transaction - starting state; after the service application calls the try interfaces of all servers, it sets the status of the distributed transaction to the transaction - trying state; after the service application determines that the try interface call of any server fails, it sets the status of the distributed transaction to the transaction - try - failed state; after the service application determines that the try interface calls of all servers are successful, it sets the status of the distributed transaction to the transaction - try - successful state; after the transaction coordinator calls the rollback interface of the server, it sets the status of the distributed transaction to the transaction - rollback - completed state; after the transaction coordinator calls the confirmation interface of the server, it sets the status of the distributed transaction to the transaction - confirmation - completed state.

[0121] For the convenience of description, when describing the above - mentioned device, it is divided into various modules according to functions for separate description. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0122] The device of the above - mentioned embodiment is used to implement the corresponding distributed transaction processing method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0123] Based on the same inventive concept, corresponding to the method in any of the above - mentioned embodiments, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the distributed transaction processing method described in any of the above - mentioned embodiments.

[0124] Figure 3 FIG. shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 310, a memory 320, an input / output interface 330, a communication interface 340, and a bus 350. Among them, the processor 310, the memory 320, the input / output interface 330, and the communication interface 340 are communicatively connected to each other inside the device through the bus 350.

[0125] The processor 310 can be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0126] The memory 320 can be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 320 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 320 and are called and executed by the processor 310.

[0127] The input / output interface 330 is used to connect to the input / output module to achieve information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Among them, the input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0128] The communication interface 340 is used to connect to a communication module (not shown in the figure) to achieve communication interaction between this device and other devices. Among them, the communication module can achieve communication through a wired method (such as USB, network cable, etc.) or can also achieve communication through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.).

[0129] The bus 350 includes a path for transmitting information between various components of the device (such as the processor 310, the memory 320, the input / output interface 330, and the communication interface 340).

[0130] It should be noted that although the above device only shows the processor 310, the memory 320, the input / output interface 330, the communication interface 340, and the bus 350, in the specific implementation process, this device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solutions of the embodiments of this specification, and do not have to include all the components shown in the figure.

[0131] The electronic device in the above embodiment is used to implement the corresponding distributed transaction processing method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0132] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the distributed transaction processing method as described in any one of the above embodiments.

[0133] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0134] The computer instructions stored in the storage medium of the above embodiment are used to cause the computer to execute the distributed transaction processing method as described in any one of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0135] Those of ordinary skill in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples; under the concept of the present disclosure, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present disclosure as described above, which are not provided in detail for the sake of brevity.

[0136] In addition, for simplicity of explanation and discussion, and so as not to render the embodiments of the present disclosure difficult to understand, well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Further, the devices may be shown in block diagram form in order to avoid rendering the embodiments of the present disclosure difficult to understand, and this also takes into account the fact that details of the implementation of such block diagram devices are highly dependent on the platform on which the embodiments of the present disclosure are to be implemented (i.e., these details should be fully within the understanding of those skilled in the art). In cases where specific details (such as circuits) are set forth to describe exemplary embodiments of the present disclosure, it will be apparent to those skilled in the art that the embodiments of the present disclosure may be practiced without these specific details or with variations of these specific details. Accordingly, these descriptions should be regarded as illustrative rather than restrictive.

[0137] Although the present disclosure has been described in connection with specific embodiments thereof, many alternatives, modifications, and variations thereof will be apparent to those of ordinary skill in the art based on the foregoing description. For example, other memory architectures (such as dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0138] Embodiments of the present disclosure are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Accordingly, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of the present disclosure shall be included within the protection scope of the present disclosure.

Claims

1. A distributed transaction processing method, characterized in that, The method is applied to a distributed transaction processing system, which includes a business application, a transaction coordinator, and a personnel management server. Among them, the personnel management server includes: a personnel account sub-server, a personnel status sub-server, and a to-do transaction sub-server. There are corresponding databases for each of the servers, and distributed transactions are set in the databases. The method includes: The business application starts the distributed transaction, where the distributed transaction includes: a query account information sub-transaction, a query personnel status sub-transaction, and a query to-do transaction sub-transaction; The business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. The personnel account sub-server performs an attempt operation process on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs an attempt operation process on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server; The business application sequentially judges the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server; In response to determining that the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, it is determined that the attempt operation process of any one of the distributed transactions fails, and the business application sends a transaction rollback request to the transaction coordinator; In response to determining that the transaction coordinator receives the transaction rollback request, the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server are called sequentially; After the business application calls the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server, it further includes: In response to determining that the business application has a network timeout and the business application fails to call the attempt interface, the transaction coordinator calls the rollback interface, and the business application determines that the rollback interface called by the transaction coordinator is an empty rollback, and sets the status of the distributed transaction to the transaction empty rollback status.

2. The method according to claim 1, characterized in that, The personnel account sub-server performs an attempt operation process on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs an attempt operation process on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs an attempt operation process on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server, including: The personnel account sub-server performs an attempt operation process on the query account information sub-transaction according to the attempt interface of the personnel account sub-server, which is used to query personnel account information and monitor and manage personnel accounts; The personnel status sub-server performs a try operation on the query personnel status sub-transaction according to the try interface of the personnel status sub-server, which is used to query personnel status information and monitor and manage the personnel status; The to-do transaction sub-server performs a try operation on the query to-do transaction sub-transaction according to the try interface of the to-do transaction sub-server, which is used to query personnel to-do transaction information and monitor and manage the personnel to-do transactions; Among them, the query account information sub-transaction and the query personnel status sub-transaction are executed successively according to the processing logic.

3. The method according to claim 1, characterized in that, It also includes: The business application returns and re-calls the try ports of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server to re-perform try operations on the query account information sub-transaction, the query personnel status sub-transaction, and the query to-do transaction sub-transaction.

4. The method according to claim 1, wherein It also includes: In response to determining that the business application network is restored, the business application re-calls the try interface of the server and re-sends the corresponding transaction request to the transaction coordinator; The transaction coordinator judges the call status of the rollback interface; In response to determining that the rollback interface call is successful, the transaction coordinator ignores the re-sent transaction request.

5. The method according to claim 1, characterized in that, The sub-server includes a rollback interface and / or a confirmation interface; it also includes: In response to determining that the transaction coordinator network times out and the rollback interface call fails, the transaction coordinator re-calls the rollback interface; In response to determining that the transaction coordinator network times out and the confirmation interface call fails, the transaction coordinator re-calls the confirmation interface.

6. The method according to claim 1, characterized in that, It also includes: The business application and the transaction coordinator respectively set the processing status of the distributed transaction; Among them, after the business application sends a start transaction request to the transaction coordinator, it sets the status of the distributed transaction to the transaction start state; after the business application calls the try interfaces of all servers, it sets the status of the distributed transaction to the transaction in progress state; after the business application determines that the try interface call of any server fails, it sets the status of the distributed transaction to the transaction failed state; after the business application determines that the try interface calls of all servers are successful, it sets the status of the distributed transaction to the transaction successful state; after the transaction coordinator calls the rollback interface of the server, it sets the status of the distributed transaction to the transaction rollback completed state; The transaction coordinator calls the confirmation interface of the server and sets the status of the distributed transaction to the transaction confirmed completed state.

7. A distributed transaction processing device, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a business application, a transaction coordinator, and a personnel management server, where, The personnel management server includes: a personnel account sub-server, a personnel status sub-server, and a to-do transaction sub-server. There are corresponding databases for each server, and distributed transactions are set in the databases, including: An opening module, configured to open the distributed transaction by the business application, where the distributed transaction includes: a query account information sub-transaction, a query personnel status sub-transaction, and a query to-do transaction sub-transaction; The attempt interface call module is configured for the business application to call the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server. The personnel account sub-server performs attempt operation processing on the query account information sub-transaction according to the attempt interface of the personnel account sub-server. The personnel status sub-server performs attempt operation processing on the query personnel status sub-transaction according to the attempt interface of the personnel status sub-server. The to-do transaction sub-server performs attempt operation processing on the query to-do transaction sub-transaction according to the attempt interface of the to-do transaction sub-server; The attempt interface determination module is configured for the business application to sequentially judge the attempt interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server; The rollback request sending module is configured to, in response to determining that the attempt interface call of any one of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server fails, determine that the attempt operation processing of any distributed transaction fails, and the business application sends a transaction rollback request to the transaction coordinator; The rollback interface call module is configured to, in response to determining that the transaction coordinator receives the transaction rollback request, sequentially call the rollback interfaces of the personnel account sub-server, the personnel status sub-server, and the to-do transaction sub-server; After the attempt interface call module, there is further included: The null rollback unit is configured to, in response to determining that the business application network times out, the business application fails to call the attempt interface, the transaction coordinator calls the rollback interface, the business application determines that the rollback interface called by the transaction coordinator is a null rollback, and sets the status of the distributed transaction to the transaction null rollback status.

8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Distributed affair submitting method and device thereof

    CN102073540A

  • Highly available transaction failure detection and recovery for electronic commerce transactions

    US20020103663A1