Sub-logical task processing method, device, equipment and medium

By specifying the rollback process in advance in transaction processing and releasing the task process, the low concurrency and efficiency problems caused by long-term locking of task processes in the prior art are solved, and efficient transaction processing and data consistency are achieved.

CN114579259BActive Publication Date: 2025-03-28TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011380629.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-30
Publication Date
2025-03-28
Estimated Expiration
2040-11-30

AI Technical Summary

Technical Problem

In the prior art, in transaction processing, the task process requires long-term locking, resulting in low concurrency and low efficiency.

Method used

Multiple sub-logical tasks are generated through the transaction process, and each task process is assigned to the corresponding task process, specifying the rollback process used to perform data rollback in advance. If the sub-logical task fails to execute, the rollback process is notified to perform the data rollback operation.

Benefits of technology

Improves the concurrency and efficiency of transaction processing, avoids long-term locking of task processes, and ensures data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579259B_ABST
    Figure CN114579259B_ABST
Patent Text Reader

Abstract

The present application provides a processing method, device, equipment and medium for a sub-logical task, which relates to the field of computers. The processing method is used to improve transaction processing efficiency. The processing method includes: generating multiple sub-logical tasks in response to a transaction processing request through a transaction processing process, assigning corresponding task processes to the multiple sub-logical tasks, and determining a rollback process; sending a transaction message to a transaction message process through a transaction processing process; calling a task process through a transaction processing process to execute a corresponding sub-logical task; if a sub-logical task fails to execute, sending a data rollback notification to a transaction message process through a transaction processing process, and instructing a rollback process to execute a data rollback operation through a transaction message process. The processing method executes a data rollback operation through a specified rollback process, so that the task process can be released in a timely manner, thereby improving the efficiency of transaction processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for processing sub-logical tasks. Background Art

[0002] In software development, the transaction to be processed is usually divided into multiple sub-logical tasks, each of which needs to be implemented through a corresponding task process. When multiple sub-logical tasks are successfully executed, the transaction processing is completed.

[0003] The current transaction processing mechanism is: the task processes corresponding to multiple sub-logical tasks are executed in a serial mechanism. If any sub-logical task fails to execute, other already executed task processes are required to perform a rollback operation. This requires that each task process needs to be in a locked state during the transaction processing process so that each task process can perform a rollback operation in a timely manner. That is, each task process will be locked for a long time, resulting in low transaction processing efficiency. Summary of the invention

[0004] The embodiments of the present application provide a method, apparatus, device and medium for processing a sub-logical task, which are used to improve the efficiency of transaction processing.

[0005] On the one hand, a method for processing a sub-logic task is provided, comprising:

[0006] In response to a transaction processing request, a plurality of sub-logical tasks are generated through a transaction processing process, and corresponding task processes are assigned to the plurality of sub-logical tasks, and a rollback process for performing a data rollback operation is determined;

[0007] Sending a transaction message to a transaction message process through the transaction processing process, wherein the transaction message is used to notify the transaction message process of the rollback process for executing the data rollback operation;

[0008] Calling the task process through the transaction processing process to execute the corresponding sub-logical tasks;

[0009] If a sub-logical task fails to execute, a data rollback notification is sent to the transaction message process through the transaction processing process, and the data rollback notification is used to instruct the rollback process to perform a data rollback operation.

[0010] The present application provides a processing device for a sub-logical task, including:

[0011] A generating module, for generating a plurality of sub-logical tasks through a transaction processing process in response to a transaction processing request;

[0012] An allocation module, used for allocating corresponding task processes to the plurality of sub-logical tasks through a transaction processing process;

[0013] A determination module, used for determining a rollback process for performing a data rollback operation through a transaction processing process;

[0014] A transceiver module, used for sending a transaction message to a transaction message process through the transaction processing process, wherein the transaction message is used to notify the transaction message process of the rollback process for executing the data rollback operation;

[0015] An execution module, used to call the task process through the transaction processing process to execute the corresponding sub-logical tasks;

[0016] The transceiver module is used to send a data rollback notification to the transaction message process through the transaction processing process if a sub-logical task fails to execute, and the data rollback notification is used to instruct the rollback process to perform a data rollback operation.

[0017] In a possible embodiment, the execution module is further used for:

[0018] When the task process is called through the transaction processing process to execute the corresponding sub-logical tasks, the corresponding task process is released after each sub-logical task is completed.

[0019] In a possible embodiment, the transceiver module is further used for:

[0020] If the plurality of sub-logical tasks are all executed successfully, an execution success notification is sent to the transaction message process through the transaction processing process, and the execution success notification is used to instruct the transaction message process to delete the transaction message.

[0021] In a possible embodiment, the device further includes a deletion module, wherein:

[0022] The generating module is further configured to generate a message identifier of the transaction message through the transaction message process after the transaction message is sent to the transaction message process through the transaction processing process, and associate the transaction message with the message identifier and store it in a message queue;

[0023] The transceiver module is further used to feed back the message identifier to the transaction processing process;

[0024] The deletion module is used to, if the multiple sub-logical tasks are all executed successfully, send an execution success notification to the transaction message process through the transaction processing process, and then, through the transaction message process, find the transaction message from the message queue according to the message identifier in the execution success notification and delete the transaction message.

[0025] In a possible embodiment, the transaction message further includes dedicated interface information for checking the execution result, and the determination module is further used to:

[0026] If the preset check condition is met, obtaining the first execution results of the plurality of sub-logical tasks from the transaction processing process through the transaction message process based on the dedicated interface corresponding to the dedicated interface information;

[0027] If the first execution result indicates that the plurality of sub-logical tasks are all executed successfully, calling the transaction message process to delete the transaction message;

[0028] If the first execution result indicates that a sub-logical task among the multiple sub-logical tasks fails to execute, the transaction message process is called to instruct the rollback process to perform a data rollback operation.

[0029] In a possible embodiment, the determining module is specifically configured to:

[0030] If the number of failures in sending the second execution results of the multiple sub-logical tasks to the transaction message process through the transaction processing process reaches a preset number, the transaction message process obtains the first execution results of the multiple sub-logical tasks from the transaction processing process based on the dedicated interface corresponding to the dedicated interface information.

[0031] In a possible embodiment, the determining module is specifically configured to:

[0032] If the transaction message process does not receive the second execution results of the multiple sub-logical tasks within a preset time period, the transaction message process obtains the first execution results of the multiple sub-logical tasks from the transaction processing process based on the dedicated interface corresponding to the dedicated interface information.

[0033] An embodiment of the present application provides a computer device, including:

[0034] at least one processor, and

[0035] a memory communicatively coupled to the at least one processor;

[0036] The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements a processing method for a sub-logical task as discussed above by executing the instructions stored in the memory.

[0037] An embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes a processing method for a sub-logical task as discussed above.

[0038] Since the embodiment of the present application adopts the above technical solution, it has at least the following technical effects:

[0039] In the embodiment of the present application, a rollback process for performing a rollback will be specified first, and there is no need for the task process to perform a rollback subsequently. Therefore, when processing a transaction, once the sub-logical task has been completed, the task process corresponding to the sub-logical task can be released, that is, there is no need to synchronize and lock each task process, which can improve the concurrency of transaction processing and improve transaction processing efficiency. Moreover, when a sub-logical task fails to execute, the transaction message process can instruct the rollback process to roll back the data, thereby ensuring data consistency during the transaction processing. Moreover, there is no need to synchronize and lock the resource objects corresponding to each task process, so as to avoid the situation where the resource objects are locked for a long time by a task process. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1A An application scenario diagram of the method for processing sub-logical services provided in an embodiment of the present application;

[0041] Figure 1B Provided in the embodiments of this application Figure 1A A structural diagram of a server in FIG.

[0042] Figure 2 A flowchart of a method for processing a sub-logical task provided in an embodiment of the present application;

[0043] Figure 3 Provided in the embodiments of this application Figure 1B Schematic diagram of the interaction between various processes in 1;

[0044] Figure 4A An example diagram of a data modification interface displayed by a client provided in an embodiment of the present application;

[0045] Figure 4B An example diagram of a data modification result interface displayed by a client provided in an embodiment of the present application;

[0046] Figure 5 Provided in the embodiments of this application Figure 1B Interaction between various processes in Figure 2 ;

[0047] Figure 6 A schematic diagram of the structure of a processing device for a sub-logical task provided in an embodiment of the present application;

[0048] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to better understand the technical solution provided by the embodiments of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0050] In order to help those skilled in the art better understand the technical solution of the present application, the terms involved in the present application are introduced below.

[0051] Process: refers to a program that is already running in a computer. The process was once the basic operating unit of a time-sharing system. In a process-oriented system, a process is the basic execution entity of a program; in a thread-oriented system, the process itself is not a basic operating unit, but a container for threads. The program itself is only a description of instructions, data and their organizational form, and the process is the actual running instance of the program. The various processes involved in this application can be running on the same physical device or on different physical devices respectively, and this application does not make specific restrictions.

[0052] Sub-logical task: refers to when a device processes a transaction, it can divide the transaction into multiple sub-logical tasks. Each sub-logical task can be understood as a link required to complete the processing of a transaction. Specifically, the transaction can be divided into multiple sub-logical tasks based on the task process that needs to be called to process the transaction. For example, when an enterprise modifies employee information (such as adding or deleting employees, etc.), it is necessary to modify the employee account information and the enterprise organizational structure data at the same time. At this time, if the modification of employee information is regarded as a pending transaction, two sub-logical tasks can be divided based on the transaction, one of which is to modify the employee account information, and the other is to modify the enterprise organizational structure data.

[0053] Data rollback: Rollback refers to the act of restoring data to its previous state in case of data processing errors.

[0054] Transaction message process: In actual applications, it can also be called a transaction message center, which is used to manage transaction messages sent by various transaction processing processes. A transaction message process can create a message queue corresponding to the transaction message process. The transaction message process can add the received transaction message to the message queue, or delete the transaction message in the message queue after the transaction is processed.

[0055] The following related technologies are introduced:

[0056] In the related technology, when processing a transaction, if any sub-logical task fails to execute, other already executed task processes are required to perform a rollback operation. This requires that any task process and the resource objects it calls are in a locked state during the transaction processing, that is, adding a synchronization lock to each task process. This will result in low concurrency of the entire transaction processing and low transaction processing efficiency.

[0057] In view of this, the embodiment of the present application provides a sub-logical task processing solution. The design concept of the sub-logical task solution in the embodiment of the present application is introduced below:

[0058] In an embodiment of the present application, when processing a transaction, a rollback process for executing data rollback is executed, and the rollback process used to execute data rollback is notified to the transaction message process. If the sub-logical task is executed, the corresponding task process can be released. Once the sub-logical business fails to execute, the transaction message process is notified to instruct the rollback process to execute data rollback. In this scheme, since the rollback process is specified in advance, when an execution error occurs, the rollback process performs data rollback. On the one hand, data consistency in the transaction processing process can be guaranteed. On the other hand, there is no need for the task process to wait for other sub-logical businesses to be executed. Therefore, the waiting time of the task process can be reduced, and there is no need to add synchronization locks to each task process. The concurrency performance of transaction processing is relatively improved, and the transaction processing efficiency is improved.

[0059] Based on the above design ideas, the application scenarios of the processing method of the sub-logical tasks of the embodiment of the present application are introduced below.

[0060] Please refer to Figure 1A , which is an application scenario diagram of the processing method of the sub-logical business provided in an embodiment of the present application, and the application scenario diagram includes multiple terminals 110, a server 120 and a database 130. The terminal 110 and the server 120 can be directly or indirectly connected via wired or wireless communication, and the present application does not limit this. The terminal 110 corresponds to the user, and a client 111 is provided in the terminal 110. Among them, the client 111 can be a web version of the client, a client preinstalled in the terminal 110, or a client embedded in a third party. The client 111 generally refers to any type of client, such as a team instant messaging client. The server 120 can read and write data to the database 130. The database 130 can be set in the server 120, or independently implemented through other storage devices.

[0061] Combine the following Figure 1B The structural diagram of the server 120 shown in the figure introduces the structure of the server 120: multiple processes can be created in the server 120, a process in the embodiment of the present application can be equivalent to a service, and the server 120 in the embodiment of the present application includes a transaction processing process 121, a transaction message process 122, a rollback process 123 and a task process 124.

[0062] Figure 1B In the figure, it is taken as an example that the transaction processing process 121, the transaction message process 122, the rollback process 123 and the task process 124 are all one. In fact, the number of the transaction processing process 121, the transaction message process 122, the rollback process 123 and the task process 124 is not limited.

[0063] The following example Figure 1A to Figure 1B The functions of each device are introduced as follows:

[0064] When a user wants to implement a transaction through client 111, the user can perform transaction processing operations through client 111. Client 111 generates a transaction processing request in response to the transaction processing operation. Client 111 feeds back the transaction processing request to server 120, and server 120 calls transaction processing process 121 to process the transaction processing request.

[0065] The server 120 calls the transaction processing process 121 to receive the transaction processing request, generates various sub-logical tasks, and calls the task process 124 to process various sub-logical tasks, for example, calling the task process 124 to modify the user data in the database 140, and notifying the transaction message process 122 to perform the rollback process 123 for the data rollback operation.

[0066] When the server 120 calls the transaction processing process 121 to determine that a certain logical sub-task is completed, the corresponding task process 124 can be released. When the server 120 calls the transaction processing process 121 to determine that a logical sub-task fails to be processed, the transaction message process 122 is notified to instruct the rollback process 123 to roll back the data, thereby relatively reducing the waiting time of the task process and improving the transaction processing efficiency while ensuring data consistency.

[0067] The server 120 may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.

[0068] certainly, Figure 1A to Figure 1B The method for processing the sub-logical task in this solution using the server 120 is introduced as an example, but the device for executing the method for processing the sub-logical task is not actually limited. For example, the device for executing the method for processing the sub-logical task may also be the terminal 110 or other devices.

[0069] Based on the above application scenario, the following takes the processing method of the server executing the above sub-logical task as an example to illustrate a processing method of a sub-logical task involved in an embodiment of the present application.

[0070] Please refer to Figure 2 , is a flowchart of a method for processing a sub-logical task involved in an embodiment of the present application, combined with Figure 2 , the method comprising:

[0071] S201, the server generates a plurality of sub-logical tasks through a transaction processing process in response to a transaction processing request, allocates corresponding task processes to the plurality of sub-logical tasks, and determines a rollback process for performing a data rollback operation.

[0072] The transaction processing request may be generated locally by the server, or received from other servers or terminals, which is not limited in this embodiment.

[0073] In some implementations, the server may receive a transaction processing request from a terminal, determine the transaction to be processed according to the transaction processing request, generate multiple sub-logical tasks through the transaction processing process, and assign corresponding task processes to the multiple sub-logical tasks, one task process may correspond to one sub-logical task, so that the task process may be used to execute the corresponding sub-logical task later. In addition, the server determines one or more rollback processes through the transaction processing process, so that the rollback process can subsequently perform a data rollback operation.

[0074] S202, the server sends a transaction message to the transaction message process through the transaction processing process. The transaction message is used to notify the transaction message process of the rollback process used to perform the data rollback operation, that is, the transaction processing process notifies the transaction message process in advance of which rollback process is used to perform the data rollback operation, so that when the transaction message process needs to perform the data rollback operation later, it can directly determine the rollback process and instruct the rollback process to perform the data rollback operation.

[0075] S203, the server calls the task process through the transaction processing process to execute the corresponding sub-logical task.

[0076] When processing a transaction, the server can call the corresponding task process through the transaction processing process to execute the corresponding sub-logical tasks.

[0077] S204: If a sub-logical task fails to execute, the server sends a data rollback notification to the transaction message process through the transaction processing process. The data rollback notification is used to instruct the rollback process to perform a data rollback operation.

[0078] When the server determines that a sub-logical task fails to execute, it can send a data rollback notification to the transaction message process through the transaction processing process. Further, the transaction message process can execute a corresponding rollback process to perform a data rollback operation.

[0079] It should be noted that Figure 2The server, transaction processing process and transaction message process in can be respectively, for example Figure 1A to Figure 1B The server 120, transaction processing process 121 and transaction message process 122 shown in FIG.

[0080] In the above Figure 2 In the illustrated embodiment, the server can specify in advance a rollback process for performing data rollback operations when processing transactions. When a rollback is required, other task processes do not need to be locked for a long time, thereby improving the concurrency of each task process and improving transaction processing efficiency.

[0081] In order to more clearly illustrate the technical solution in the embodiment of the present application, Figure 3 The processing method of the sub-logical tasks in the embodiment of the present application is introduced. Figure 3 The embodiment of the present application provides Figure 1B The interaction diagram between the various processes in the figure can include:

[0082] S301, the server 120 responds to a transaction processing request through the transaction processing process 121, generates a sub-logical task, allocates a task process, and determines a rollback process.

[0083] The user may initiate a transaction processing operation through the client 111. The client 111 generates a transaction processing request in response to the transaction processing operation and sends the transaction processing request to the server 120. The server 120 performs transaction processing through the transaction processing process 121. For example, the server 120 may call the transaction processing process 121 to execute the corresponding transaction through the transaction processing process 121, or the transaction processing process 121 may execute the corresponding transaction by default according to the pre-code configuration of the server 120. The transaction processing request includes the target transaction for requesting processing and may also include transaction data for processing the target transaction.

[0084] For example, see Figure 4A , which is a data modification interface displayed by the client 111. After the user enters the modified information of employee Zhang San, click Figure 4A The modification button 400 shown in FIG. 1 is equivalent to performing a transaction processing operation. In response to the operation, the client 111 generates a transaction processing request. The transaction processing request is used to request to modify the information of employee Zhang San, and the modified information of Zhang San, specifically including: Figure 4A "Zhang San, 1XXXX8, Design Department" is shown.

[0085] After receiving a transaction processing request, the server 120 can generate multiple sub-logical tasks according to the target transaction to be processed through the transaction processing process 121. For example, the server 120 can pre-store the corresponding relationship between the execution of each transaction and the multiple sub-logical tasks of each transaction through the transaction processing process 121. The server 120 can determine the target transaction to be processed according to the transaction processing request through the transaction processing process 121, and determine the multiple sub-logical tasks of the target transaction according to the corresponding relationship and the target transaction, and then assign a corresponding task process to each sub-logical task. Among them, one sub-logical task can correspond to one task process.

[0086] Alternatively, after determining the target transaction to be processed through the transaction processing process 121, the server 120 determines the task process that needs to be called to process the target transaction, and the task to be processed by each task process is regarded as a sub-logical task, thereby generating a sub-logical task corresponding to each task process.

[0087] It should be noted that for ease of description, Figure 3 In the illustrated embodiment, a plurality of sub-logical tasks include a first sub-logical task and a second sub-logical task as an example, where the first sub-logical task corresponds to a first task process and the second sub-logical task corresponds to a second task process.

[0088] As an embodiment, the server 120 can also determine the execution order of the multiple sub-logical tasks when generating multiple sub-logical tasks through the transaction processing process 121. The server 120 can determine the execution order of the multiple sub-logical tasks through the transaction processing process 121 according to whether there is a dependency relationship between resource objects when executing each sub-logical task.

[0089] Specifically, if the resource object of a sub-logical task needs to depend on the resource object of another sub-logical task, such as the execution result or intermediate result of the sub-logical task, or the input data used by the sub-logical task, then it is determined that the other sub-logical task is executed first and the sub-logical task is executed later. If the resource object of a sub-logical task is irrelevant to the execution result of another sub-logical task, then the two sub-logical tasks can be executed in parallel. For example, the execution of sub-logical task b needs to depend on the execution result of sub-logical task a, then sub-logical task a needs to be executed before sub-logical task b. Alternatively, the server 120 pre-stores the execution order of each sub-logical task in the transaction processing process 121, and only needs to execute each sub-logical task in sequence according to the pre-stored execution order.

[0090] For example, continue to use Figure 4AIn the example shown, after obtaining the transaction processing request, the server 120 determines through the transaction processing process 121 that the target transaction is to modify the information of employee Zhang San. The modification of employee Zhang San's information can be divided into modifying the employee account information in the database 130 and modifying the enterprise organizational structure data of employee Zhang San A in the database 130, and assigning task process A to execute the modification of the employee account information, and assigning task process B to execute the modification of the enterprise structure data of the employee.

[0091] In addition, the server 120 can determine the rollback service for performing the data rollback operation from other processes through the transaction processing process 121, or the server 120 can create a rollback process through the transaction processing process 121 and obtain the rollback process identifier, or the server 120 can determine the first task process as the rollback process.

[0092] Further, the server 120 generates a transaction message according to the rollback process identifier through the transaction processing process 121, and the transaction message is used to indicate that the rollback process is used to perform the data rollback operation of the target transaction. The transaction message includes that the process used to perform the data rollback operation is the rollback process, and the transaction message may also include the data rollback operation that the rollback process needs to perform.

[0093] Continue to use Figure 4A For example, the server 120 can determine that process C is a rollback process through the transaction processing process 121, and generate a transaction message, which is used to instruct process C to restore the information of employee Zhang San to the initial data, that is, the information data of Zhang San before modification.

[0094] S302 , the server 120 sends a transaction message to the transaction message process 122 through the transaction processing process 121 .

[0095] S303 , the server 120 adds the transaction message to the message queue through the transaction message process 122 .

[0096] Since the transaction message process 122 may receive multiple transaction messages sent by the transaction processing process 121, or receive multiple transaction messages sent by different transaction processing processes 121, each transaction message may be added to the message queue in the embodiment of the present application. For example, the server 120 calls the transaction message process 122 and may add each transaction message to the message queue in the order in which the transaction messages are received, so as to process each transaction message in sequence in the order of the message queue.

[0097] As an embodiment, when adding a transaction message to a message queue, the server 120 can generate a message identifier for the transaction message through the transaction message process 122, and associate the message identifier with the transaction message and add it to the message queue. In this embodiment, a message identifier is generated for the transaction message to facilitate later retrieval of the transaction message from the message queue.

[0098] It should be noted that S303 is an optional step. For example, the transaction message process 122 can directly store the transaction message, and does not necessarily need to add the transaction message to the message queue.

[0099] S304 , the server 120 sends the message identifier to the transaction processing process 121 through the transaction message process 122 .

[0100] S305 , the server 120 calls the first task process through the transaction processing process 121 to execute the first sub-logical task.

[0101] When the server 120 determines to execute a sub-logical task through the transaction processing process 121, it can call the corresponding task process to execute the sub-logical task. For example, when the transaction processing process 121 determines to execute the first sub-logical task first, it can call the first task process to execute the first sub-logical task.

[0102] It should be noted that Figure 3 In the example, the first sub-logical task is executed first and then the second sub-logical task is executed. In fact, the execution order of multiple sub-logical tasks is not limited.

[0103] S306 , the server 120 releases the first task process through the transaction processing process 121 .

[0104] In the first case, if the first task process successfully executes the first sub-logical task, the transaction process 121 can release the first task process. Releasing the first task process can be understood as the first task process is no longer in a locked state. Since the resource object of the first task process may affect the execution of the next sub-logical task, the server 120 can obtain the resource object of the first task process through the transaction process 121 to provide it to the next task process. Alternatively, the server 120 can wait for the execution of the next task process to obtain the resource object from the first task process through the transaction process 121, and then release the first task process.

[0105] S307, the server 120 calls the second task process through the transaction processing process 121 to execute the second sub-logical task.

[0106] For example, continue to refer to Figure 4AIn the example shown, the server 120 calls the transaction processing process 121 to call the task process A to modify the employee account information of Zhang San. After the task process A is executed, the task process B is called to modify the enterprise organizational structure data of employee Zhang San A.

[0107] S308 , the server 120 sends a data rollback notification to the transaction message process through the transaction processing process 121 .

[0108] In the embodiment of the present application, transaction processing involves processing multiple data in the database 130. If a certain data is processed successfully, but other data processing fails, it may lead to data inconsistency, so data rollback is required. In the second case, for example, various reasons such as the unexpected crash of the second task process cause the second task process to fail to execute the second sub-logical task. At this time, in order to ensure the data consistency of the target transaction, the server 120 needs to perform a data rollback operation on the target transaction. In the embodiment of the present application, the server 120 sends a data rollback notification to the transaction message process through the transaction processing process 121, and the data rollback notification indicates that a sub-logical task in the target transaction has failed to execute.

[0109] As an embodiment, in order to facilitate the association of the transaction message process with the previous transaction message, a message identifier may be carried in the data rollback notification.

[0110] S309 , the server 120 updates the transaction message status to committable through the transaction message process 122 .

[0111] After receiving the data rollback notification through the transaction message process 122 , the server 120 determines that a rollback needs to be performed on the target transaction, and thus the status of the transaction message in the message queue may be updated to be committable.

[0112] It should be noted that S309 is an optional step, that is, when the transaction message process 122 does not add the transaction message to the message queue, it does not need to manage the state of the transaction message.

[0113] S310 , the server 120 sends a data rollback notification to the rollback process 123 through the transaction message process 122 .

[0114] The data rollback notification is used to instruct the rollback process 123 to perform a corresponding data rollback operation, that is, to instruct to restore the data involved in the target transaction to the initial data.

[0115] S311 , the server 120 performs a data rollback operation through the rollback process 123 .

[0116] After receiving the data rollback notification, the server 120 performs a data rollback operation through the rollback process 123 to restore the data involved in the target transaction to the initial data.

[0117] Continue to use Figure 4A In the example shown, task process A has modified Zhang San's employee account information, and rollback process 123 will restore Zhang San's employee account information to the content before the modification to ensure that Zhang San's employee account information is consistent with the data under Zhang San's enterprise organizational structure.

[0118] S312 , the server 120 releases the second task process through the transaction processing process 121 .

[0119] In the third case, the second task process successfully executes the second sub-logic process, and the server 120 calls the transaction processing process 121 to release the second task process.

[0120] S313, the server 120 sends an execution success notification to the transaction message process 122 through the transaction processing process 121.

[0121] After the server 120 determines through the transaction processing process 121 that all the sub-logical tasks involved in the target transaction are successfully executed, it is determined that the target transaction is successfully executed, and thus a successful execution notification can be sent to the transaction message process 122. The successful execution notification indicates that multiple sub-logical tasks in the target transaction are successfully executed. The successful execution notification may also carry a message identifier.

[0122] S314 , the server 120 deletes the transaction message in the message queue through the transaction message process 122 .

[0123] The server 120 determines through the transaction message process 122 that the target transaction has been basically processed, and then determines that there is no need to perform a rollback operation on the target transaction, so the transaction message in the message queue can be deleted.

[0124] It should be noted that S308-S311 and S312-S313 are two situations in the transaction processing process. In fact, only one of the situations will occur in the process of processing the target transaction.

[0125] Furthermore, after the target transaction is executed, the server 120 may feed back the transaction processing result to the client 111 through the transaction processing process 121, so that the client 111 updates and displays the transaction processing result.

[0126] In addition, when the client 111 needs to display relevant information of the transaction, the server 120 can also obtain the latest data of the transaction from the database 130 and feed the latest data back to the client 111, so that the client 111 can display the latest data. For example, in a team instant messaging client, transaction processing may not only involve the terminal 110 of the user, but also the terminals of other relevant team members. Therefore, the server 120 can also feed back the latest data to the terminals of other relevant team members, so that each terminal in the team can synchronize the latest data.

[0127] Continue to use Figure 4A For examples shown, please refer to Figure 4B , which is an example diagram of an interface for receiving transaction processing results displayed by the client 111, wherein a prompt message “Prompt: Modification successful” is displayed in the interface so that the user can know the transaction processing results.

[0128] In the above Figure 3 In the illustrated embodiment, the transaction processing process 121 determines in advance the rollback process used for the data rollback operation. If there is a sub-logical task processing failure, the data can be rolled back with the help of the rollback process, so that the task process does not need to wait for the transaction processing to be completed before being released, and there is also no need to lock the resource object corresponding to the task process for a long time, thereby improving the efficiency of transaction processing.

[0129] based on Figure 1A to Figure 1B The application scenarios discussed below are combined Figure 5 The processing method of the sub-logic tasks involved in the embodiment of the present application is introduced:

[0130] S501, the server 120 responds to a transaction processing request through the transaction processing process 121, generates a sub-logical task, allocates a task process, and determines a rollback process.

[0131] The contents of generating sub-logical tasks, assigning task processes and determining rollback processes can refer to the contents discussed above, and will not be repeated here. In the embodiment of the present application, the sub-logical tasks are the first sub-logical task and the second sub-logical task as an example for introduction.

[0132] After determining the rollback process, the server 120 may generate a transaction message according to the rollback process through the transaction processing process 121. The transaction message may refer to the content discussed above and will not be described again here.

[0133] Under normal circumstances, the server 120 will promptly feedback the execution results of multiple sub-logical tasks to the transaction message process 122 through the transaction processing process 121, but the transaction processing process 121 may crash or the network may be interrupted. In this case, the transaction message process 122 will not be able to receive the execution results of the sub-logical tasks for a long time. Therefore, in an embodiment of the present application, the transaction message may include the process identifier of the rollback process, and may also include special interface information for checking the execution results.

[0134] S502 , the server 120 sends a transaction message to the transaction message process 122 through the transaction processing process 121 .

[0135] S503 , the server 120 adds the transaction message to the message queue through the transaction message process 122 .

[0136] When adding a transaction message to a message queue, a message identifier of the transaction message may also be generated.

[0137] S504 , the server 120 sends the message identifier to the transaction processing process through the transaction message process 122 .

[0138] S505 , the server 120 calls the first task process through the transaction processing process 121 to execute the first sub-logical task.

[0139] S506 , the server 120 releases the first task process through the transaction processing process 121 .

[0140] When the first sub-logical task is executed successfully, the server 120 calls the transaction processing process 121 to release the first sub-logical task.

[0141] S507, the server 120 calls the second task process through the transaction processing process 121 to execute the second sub-logic process.

[0142] S508 , the server 120 returns the second execution result to the transaction processing process 121 through the transaction message process 122 .

[0143] During the processing of the transaction message process 122 , if the preset check-back condition is met, the server 120 , through the transaction message process 122 , can check the second execution result to the transaction processing process 121 through the dedicated interface corresponding to the dedicated interface information in the transaction message.

[0144] The preset check condition may be, for example, that the server 120 determines that the number of failures of the transaction processing process 121 to send the first execution result to the transaction message process 122 reaches a preset number. The first execution result refers to the execution results of multiple sub-logical tasks.

[0145] Specifically, the transaction processing process 121 may try to send the first execution result to the transaction message process 122. When the server 120 determines that the number of failed sendings by the transaction processing process 121 reaches a preset number, the transaction processing process 121 is called to check back to obtain the first execution result.

[0146] It should be noted that both the first execution result and the second execution result refer to the processing results of multiple subtasks, but the second execution result refers to the result actively sent by the transaction processing process 121 to the transaction message process 122, and the first execution result refers to the execution result checked back by the transaction message process 122, that is, the first execution result and the second execution result are only for distinguishing the processing results of multiple subtasks obtained in different ways, and the actual content is not different.

[0147] The preset checkback condition is, for example, that the transaction message process 122 does not receive the second execution results of the plurality of sub-logical tasks for a preset period of time.

[0148] Specifically, if the transaction message process 122 determines that the second execution result is not received within the preset time, it is determined that the communication between the transaction processing process 121 and the transaction message process 122 may fail, so the transaction message process 122 is called back to obtain the first execution result.

[0149] The first execution result and the second execution result specifically include two types: one is used to indicate that multiple sub-logical tasks are executed successfully, and the other is used to indicate that a sub-logical task fails to execute.

[0150] S509 , the server 120 updates the transaction message status to committable through the transaction message process 122 .

[0151] In one possible case, the transaction message process 122 obtains the execution result using a dedicated interface. If the execution result indicates that the sub-logic task is not executed successfully, it means that a rollback is required, and the transaction message process 122 can update the transaction message state to committable.

[0152] S510 , the server 120 sends a data rollback notification to the rollback process 123 through the transaction message process 122 .

[0153] S511 , the server 120 performs a data rollback operation through the rollback process 123 .

[0154] S512 , the server 120 releases the second task process through the transaction processing process 121 .

[0155] In another possible case, the server 120 calls the transaction processing process 121 to determine that the second task process is executed successfully, and then the second task process can be released. In this case, the server 120 calls the transaction message process 122 and queries through a dedicated interface the execution results of multiple sub-logical tasks being successfully executed. At this time, the transaction message process 122 can delete the transaction message in the message queue.

[0156] It should be noted that S508-S511 and S512-S514 are two situations that may occur in the process of processing a transaction. In fact, in the process of processing a transaction, only one of S508-S511 and S512-S514 will occur.

[0157] It should be noted that Figure 3 and Figure 5 The embodiments shown are two situations that may occur during the transaction process. Figure 3 The difference is, Figure 5 In the embodiment shown, the transaction message process does not directly receive the execution result of the sub-logic task fed back by the transaction processing process 121, but actively queries the execution result of the sub-logic task through a dedicated interface, and executes the corresponding process according to the execution result obtained by the query. Figure 5 In the illustrated embodiment, not only can data consistency in the transaction processing process be guaranteed and transaction processing efficiency be improved, but also the transaction processing process can be completed normally even when the transaction processing process 121 is abnormal, thereby improving the reliability of transaction processing.

[0158] Based on the same inventive concept, the present application embodiment provides a processing device for a sub-logical task, which can be used to implement the function of the transaction processing process 121 in the above text, please refer to Figure 6 , the device comprises:

[0159] A generating module 601 is used to generate a plurality of sub-logical tasks through a transaction processing process in response to a transaction processing request;

[0160] The allocation module 602 is used to allocate corresponding task processes to multiple sub-logical tasks through the transaction processing process;

[0161] A determination module 603, configured to determine a rollback process for performing a data rollback operation through a transaction processing process;

[0162] The transceiver module 604 is used to send a transaction message to the transaction message process through the transaction processing process, and the transaction message is used to notify the transaction message process of the rollback process for performing the data rollback operation;

[0163] An execution module 605 is used to call a task process through a transaction processing process to execute a corresponding sub-logical task;

[0164] The transceiver module 604 is used to send a data rollback notification to the transaction message process through the transaction processing process if a sub-logical task fails to execute. The data rollback notification is used to instruct the rollback process to perform a data rollback operation.

[0165] In a possible embodiment, the execution module 605 is further configured to:

[0166] When calling the task process through the transaction processing process and executing the corresponding sub-logical tasks, the corresponding task process is released after each sub-logical task is completed.

[0167] In a possible embodiment, the transceiver module 604 is further configured to:

[0168] If multiple sub-logical tasks are executed successfully, an execution success notification is sent to the transaction message process through the transaction processing process. The execution success notification is used to instruct the transaction message process to delete the transaction message.

[0169] In a possible embodiment, the apparatus further includes a deletion module 606, wherein:

[0170] The generating module 601 is further used to generate a message identifier of the transaction message through the transaction message process after the transaction message is sent to the transaction message process through the transaction processing process, and associate the transaction message with the message identifier and store it in the message queue;

[0171] The transceiver module 604 is also used to feed back the message identifier to the transaction processing process;

[0172] The deletion module 606 is used to find the transaction message from the message queue according to the message identifier in the execution success notification and delete the transaction message after sending the execution success notification to the transaction message process through the transaction processing process if multiple sub-logical tasks are executed successfully.

[0173] In a possible embodiment, the transaction message further includes dedicated interface information for checking the execution result, and the determination module 603 is further used to:

[0174] If the preset check-back condition is met, the first execution results of the plurality of sub-logical tasks are obtained from the transaction processing process through the dedicated interface corresponding to the dedicated interface information by the transaction message process;

[0175] If the first execution result indicates that the multiple sub-logical tasks are successfully executed, the transaction message process is called to delete the transaction message;

[0176] If the first execution result indicates that a sub-logical task among the multiple sub-logical tasks fails to execute, the transaction message process is called to instruct the rollback process to perform a data rollback operation.

[0177] In a possible embodiment, the determination module 603 is specifically configured to:

[0178] If the number of failures in sending the second execution results of multiple sub-logical tasks to the transaction message process through the transaction processing process reaches a preset number, the transaction message process obtains the first execution results of multiple sub-logical tasks from the transaction processing process through a dedicated interface corresponding to the dedicated interface information.

[0179] In a possible embodiment, the determination module 603 is specifically configured to:

[0180] If the transaction message process does not receive the second execution results of the multiple sub-logical tasks within a preset time period, the transaction message process obtains the first execution results of the multiple sub-logical tasks from the transaction processing process through a dedicated interface corresponding to the dedicated interface information.

[0181] Above Figure 6 The device can also be used to implement any of the sub-logical task processing devices discussed above, which will not be repeated here.

[0182] Based on the same inventive concept, the present application embodiment provides a computer device, please refer to Figure 7 , the computer device includes a processor 701 and a memory 702.

[0183] The processor 701 may be a central processing unit (CPU) or a digital processing unit, etc. The specific connection medium between the memory 702 and the processor 701 is not limited in the embodiment of the present application. Figure 7 In the embodiment, the memory 702 and the processor 701 are connected via a bus 703. The bus 703 is connected to the processor 701 via a bus 703. Figure 7 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 703 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0184] The memory 702 may be a volatile memory, such as a random-access memory (RAM); the memory 702 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 702 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 702 may be a combination of the above memories.

[0185] The processor 701 is used to execute the processing method of the sub-logical task as discussed above when calling the computer program stored in the memory 702, and can also be used to implement the functions of the server 120 mentioned above, for example, it can be used to implement the functions of the transaction processing process 121 and the transaction message process 122 mentioned above, or it can also be used to implement Figure 6 Functions of the device shown.

[0186] Based on the same inventive concept, an embodiment of the present application provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes a processing method for any of the sub-logical tasks discussed above.

[0187] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0188] Based on the same inventive concept, an embodiment of the present application provides a computer program product, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned sub-logical task processing method.

[0189] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.

[0190] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0191] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for processing a sub-logic task, characterized in that: include: In response to a transaction processing request, a plurality of sub-logical tasks are generated through a transaction processing process, and corresponding task processes are assigned to the plurality of sub-logical tasks, and a rollback process for performing a data rollback operation is determined, wherein the rollback process is determined from other processes through the transaction processing process, or is created through the transaction processing process; Sending a transaction message to a transaction message process through the transaction processing process, wherein the transaction message is used to notify the transaction message process of the rollback process for executing the data rollback operation; Calling the task process through the transaction processing process to execute the corresponding sub-logical tasks, and releasing the corresponding task process after each sub-logical task is completed; If a sub-logical task fails to execute, a data rollback notification is sent to the transaction message process through the transaction processing process, and the data rollback notification is used to instruct the rollback process to perform a data rollback operation.

2. The method according to claim 1, characterized in that The method further comprises: If the plurality of sub-logical tasks are all executed successfully, an execution success notification is sent to the transaction message process through the transaction processing process, and the execution success notification is used to instruct the transaction message process to delete the transaction message.

3. The method according to claim 2, characterized in that After sending the transaction message to the transaction message process through the transaction processing process, the method further includes: Generate a message identifier of the transaction message through the transaction message process, associate the transaction message with the message identifier and store it in a message queue, and feed back the message identifier to the transaction processing process; If the plurality of sub-logical tasks are all executed successfully, after sending an execution success notification to the transaction message process through the transaction processing process, the method further includes: The transaction message process searches for the transaction message from the message queue according to the message identifier in the execution success notification, and deletes the transaction message.

4. The method according to any one of claims 1 to 3, characterized in that: The transaction message also includes dedicated interface information for checking the execution result, and the method further includes: If the preset check condition is met, obtaining the first execution results of the plurality of sub-logical tasks from the transaction processing process through the transaction message process based on the dedicated interface corresponding to the dedicated interface information; If the first execution result indicates that the plurality of sub-logical tasks are all executed successfully, calling the transaction message process to delete the transaction message; If the first execution result indicates that a sub-logical task among the multiple sub-logical tasks fails to execute, the transaction message process is called to instruct the rollback process to perform a data rollback operation.

5. The method according to claim 4, characterized in that If the preset check condition is met, obtaining the first execution results of the plurality of sub-logical tasks from the transaction processing process through the transaction message process based on the dedicated interface corresponding to the dedicated interface information includes: If the number of failures in sending the second execution results of the multiple sub-logical tasks to the transaction message process through the transaction processing process reaches a preset number, the first execution results of the multiple sub-logical tasks are obtained from the transaction processing process through the transaction message process based on the dedicated interface corresponding to the dedicated interface information.

6. The method according to claim 4, characterized in that If the preset check condition is met, obtaining the first execution results of the plurality of sub-logical tasks from the transaction processing process through the transaction message process based on the dedicated interface corresponding to the dedicated interface information includes: If the transaction message process does not receive the second execution results of the multiple sub-logical tasks within a preset time period, the transaction message process obtains the first execution results of the multiple sub-logical tasks from the transaction processing process based on the dedicated interface corresponding to the dedicated interface information.

7. A processing device for a sub-logical task, characterized in that: include: A generating module, for generating a plurality of sub-logical tasks through a transaction processing process in response to a transaction processing request; An allocation module, used for allocating corresponding task processes to the plurality of sub-logical tasks through a transaction processing process; A determination module, used for determining a rollback process for performing a data rollback operation through a transaction processing process; a transceiver module, configured to send a transaction message to a transaction message process through the transaction processing process, wherein the transaction message is used to notify the transaction message process of the rollback process for executing the data rollback operation, wherein the rollback process is determined from other processes through the transaction processing process, or is created by the transaction processing process; An execution module is used to call the task process through the transaction processing process to execute the corresponding sub-logical tasks, and release the corresponding task process after each sub-logical task is executed; The transceiver module is used to send a data rollback notification to the transaction message process through the transaction processing process if a sub-logical task fails to execute, and the data rollback notification is used to instruct the rollback process to perform a data rollback operation.

8. The device according to claim 7, characterized in that The transceiver module is also used for: If the plurality of sub-logical tasks are all executed successfully, an execution success notification is sent to the transaction message process through the transaction processing process, and the execution success notification is used to instruct the transaction message process to delete the transaction message.

9. A computer device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the method according to any one of claims 1 to 6 by executing the instructions stored in the memory.

10. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • A cross-system distributed transaction processing method and a distributed transaction processing system

    CN109885382A