Task processing method and apparatus, electronic device, and medium

CN115617466BActive Publication Date: 2026-09-04TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110791802.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-13
Publication Date
2026-09-04
Estimated Expiration
2041-07-13

AI Technical Summary

Technical Problem

[0003]本申请旨在提供一种任务处理方法、装置、电子设备及介质,能够解决遗漏任务的问题

Benefits of technology

[0016]In some embodiments of this application, when the task processing time corresponding to the target processing carrier is reached, a set of task identifiers with a pending execution status is obtained from the set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier; the pending tasks corresponding to the set of task identifiers with a pending execution status are processed; after the pending tasks are processed, the set status of the set of task identifiers with a pending execution status is updated to an executed status, and a set of task identifiers with a pending execution status is obtained again from the set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier for processing, until the set status of all task identifier sets is an executed status, thereby avoiding omission of tasks. Compared with determining whether a single task needs to be processed at once, by obtaining the set status, it is possible to determine at once whether there are any tasks that need to be processed among multiple tasks corresponding to a set of task identifiers, which can improve the efficiency of task processing. At the same time, since the set of task identifiers being processed is obtained from the set of task identifiers that have not been occupied by other processing carriers, when using multiple processing carriers, including the target processing carrier and other processing carriers, to process tasks, mutual conflicts can be avoided while improving processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115617466B_ABST
    Figure CN115617466B_ABST
Patent Text Reader

Abstract

The application provides a task processing method and device, electronic equipment and medium. The method comprises: when a target processing carrier reaches a target processing time, obtaining a task identifier set in a state of a to-be-executed set from a task identifier set not occupied by other processing carriers except the target processing carrier; processing a to-be-executed task corresponding to the task identifier set in the state of the to-be-executed set; after the to-be-executed task is processed, updating the state of the task identifier set in the state of the to-be-executed set to a state of an executed set, and re-obtaining a task identifier set in the state of the to-be-executed set from a task identifier set not occupied by other processing carriers except the target processing carrier for processing until the states of all task identifier sets are in the state of the executed set, thereby avoiding missing tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer and communication technology, and in particular to a task processing method, apparatus, electronic device and medium. Background Technology

[0002] In existing technologies, when executing tasks, tasks are usually sorted according to factors such as generation time, and then executed one by one according to the sorting order. However, when multiple tasks to be executed have the same generation time and other factors, the sorting step is usually omitted, and tasks are randomly selected for execution, which can easily lead to missing tasks. Summary of the Invention

[0003] This application aims to provide a task processing method, apparatus, electronic device, and medium that can solve the problem of missed tasks.

[0004] According to one aspect of the embodiments of this application, a task processing method is provided, comprising: when the task processing time corresponding to the target processing carrier is reached, obtaining a set of task identifiers with a set state of pending execution from a set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier; processing the pending tasks corresponding to the set of task identifiers with a set state of pending execution; after the pending tasks are processed, updating the set state of the set of task identifiers with a set state of pending execution to an executed set state, and obtaining a set of task identifiers with a set state of pending execution from the set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier again for processing, until the set state of all task identifier sets is an executed set state.

[0005] According to one aspect of the embodiments of this application, a task processing apparatus is provided, comprising: an acquisition module configured to, when the task processing time corresponding to a target processing carrier is reached, acquire a set of task identifiers whose set state is a pending execution set from a set of task identifiers that have never been occupied by any processing carrier other than the target processing carrier; a processing module configured to process the pending tasks corresponding to the set of task identifiers whose set state is a pending execution set; and an update module configured to, after the processing of the pending tasks is completed, update the set state of the set of task identifiers whose set state is a pending execution set to an executed set, and re-acquire the set of task identifiers whose set state is a pending execution set from the set of task identifiers that have never been occupied by any processing carrier other than the target processing carrier for processing, until the set state of all task identifier sets is an executed set.

[0006] In one embodiment of this application, based on the foregoing scheme, the processing module is configured to: obtain the identifier corresponding to the task to be executed in the task identifier set; obtain the task file corresponding to the identifier of the task to be executed; and execute the task file to process the task to be executed.

[0007] In one embodiment of this application, based on the aforementioned scheme, before obtaining the identifier corresponding to the task to be executed, the acquisition module is configured to: acquire the task status, number of task executions, and most recent execution time of the identifier corresponding to the identifier in the task identifier set; if the task status is a task to be executed, the number of task executions is less than a set number, and the time between the most recent execution time of the task and the time of acquiring the task identifier set is greater than the retry time interval, then the identifier in the task identifier set is confirmed to be the identifier corresponding to the task to be executed.

[0008] In one embodiment of this application, based on the foregoing scheme, after processing the tasks to be executed corresponding to the task identifier set, the update module is configured to: obtain the processing result obtained from processing the tasks to be executed; if the processing result is successful, update the task status corresponding to the task to be executed to the executed task status; if the processing result is unsuccessful, keep the task status corresponding to the task to be executed as the task to be executed status.

[0009] In one embodiment of this application, based on the foregoing scheme, before obtaining the task file corresponding to the identifier, the update module is configured to: increment the task execution count corresponding to the task to be executed by one.

[0010] In one embodiment of this application, based on the aforementioned scheme, after processing the task to be executed, the update module is configured to update the most recent execution time of the task to be executed to the time when the task to be executed was processed.

[0011] In one embodiment of this application, based on the foregoing scheme, before obtaining the set of task identifiers in the set state of pending execution, the acquisition module is configured to: acquire the set of task identifiers not occupied by any processing carrier other than the target processing carrier, and acquire the set state of the set of task identifiers not occupied by any processing carrier other than the target processing carrier; if there are pending tasks among the tasks corresponding to the task identifiers in the set of task identifiers not occupied by any processing carrier other than the target processing carrier, and the time for acquiring the set of task identifiers not occupied by any processing carrier other than the target processing carrier has reached the earliest retry time, then the set state corresponding to the set of task identifiers is determined to be a pending execution set state; if there are no pending tasks among the tasks corresponding to the identifiers in the set of task identifiers, or the time for acquiring the set of task identifiers has not reached the earliest retry time, then the set state corresponding to the set of task identifiers not occupied by any processing carrier other than the target processing carrier is determined to be an executed set state.

[0012] According to one aspect of the embodiments of this application, a computer-readable program medium is provided, which stores computer program instructions that, when executed by a computer, cause the computer to perform any of the methods described above.

[0013] According to one aspect of the embodiments of this application, an electronic device is provided, including: a processor; and a memory storing computer-readable instructions, which, when executed by the processor, implement the method as described in any of the preceding claims.

[0014] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative embodiments described above.

[0015] The technical solutions provided by the embodiments of this application may include the following beneficial effects:

[0016] In some embodiments of this application, when the task processing time corresponding to the target processing carrier is reached, a set of task identifiers with a pending execution status is obtained from the set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier; the pending tasks corresponding to the set of task identifiers with a pending execution status are processed; after the pending tasks are processed, the set status of the set of task identifiers with a pending execution status is updated to an executed status, and a set of task identifiers with a pending execution status is obtained again from the set of task identifiers that have never been occupied by any other processing carrier besides the target processing carrier for processing, until the set status of all task identifier sets is an executed status, thereby avoiding omission of tasks. Compared with determining whether a single task needs to be processed at once, by obtaining the set status, it is possible to determine at once whether there are any tasks that need to be processed among multiple tasks corresponding to a set of task identifiers, which can improve the efficiency of task processing. At the same time, since the set of task identifiers being processed is obtained from the set of task identifiers that have not been occupied by other processing carriers, when using multiple processing carriers, including the target processing carrier and other processing carriers, to process tasks, mutual conflicts can be avoided while improving processing efficiency.

[0017] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the principles of this application.

[0019] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solutions of the embodiments of this application can be applied is shown; Figure 2 A flowchart illustrating a task processing method according to an embodiment of this application is shown schematically; Figure 3 This diagram illustrates an overall architecture for implementing the task processing method of this application. Figure 4 The diagram illustrates an architecture for implementing the enterprise task filtering of this application. Figure 5 The diagram illustrates an architecture for implementing the number segment task filtering of this application. Figure 6 A schematic diagram illustrating a task processing method for implementing this application is shown. Figure 7 A block diagram of a task processing apparatus according to one embodiment of the present application is shown schematically; Figure 8 This is a hardware diagram of an electronic device according to an exemplary embodiment. Detailed Implementation

[0020] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.

[0021] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.

[0022] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0023] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0024] Figure 1 A schematic diagram of an exemplary system architecture 100 to which the technical solutions of the embodiments of this application can be applied is shown.

[0025] like Figure 1 As shown, system architecture 100 may include client 101, network 102, and server 103. Network 102 is used as a medium to provide a communication link between client 101 and server 103. Network 102 may include various connection types, such as wired communication links, wireless communication links, etc., which are not limited herein.

[0026] It should be understood that Figure 1The number of clients 101, networks 102, and servers 103 shown is merely illustrative. Depending on implementation needs, there can be any number of clients 101, networks 102, and servers 103. For example, server 103 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Client 101 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these.

[0027] In one embodiment of this application, when the task execution time arrives, the server 103 obtains a set of task identifiers with a pending execution status from the task identifier set that has never been occupied by any other processing carrier besides the target processing carrier when the task processing time corresponding to the target processing carrier arrives; processes the pending tasks corresponding to the task identifier set with a pending execution status; after the pending tasks are processed, the set status of the task identifier set with a pending execution status is updated to an executed set status, and the server obtains a set of task identifiers with a pending execution status from the task identifier set that has never been occupied by any other processing carrier besides the target processing carrier again for processing, until the set status of all task identifier sets is an executed set status, thereby avoiding missing tasks. Compared to determining whether a single task needs to be processed at a time, by obtaining the set status, it is possible to determine at a time whether there are any tasks that need to be processed among multiple tasks corresponding to a task identifier set, which can improve the efficiency of task processing. At the same time, since the task identifier set being processed is obtained from the task identifier set that has not been occupied by other processing carriers, when using multiple processing carriers, including the target processing carrier and other processing carriers, to process tasks, it can improve processing efficiency while avoiding mutual conflicts.

[0028] It should be noted that the task processing method provided in this application embodiment is generally executed by server 103, and correspondingly, the task processing device is generally located in server 103. However, in other embodiments of this application, client 101 may also have similar functions to server 103, thereby executing the task processing method provided in this application embodiment.

[0029] The implementation details of the technical solutions in the embodiments of this application are described in detail below: Figure 2The flowchart illustrating a task processing method according to an embodiment of this application is shown in the schematic diagram. The execution entity of the task processing method may be a server, for example, a... Figure 1 Server 103 is shown in the image.

[0030] Reference Figure 2 As shown, this task processing method includes at least steps S210 to S230, which are described in detail below: In step S210, when the task processing time corresponding to the target processing carrier is reached, the set of task identifiers with the set status of pending execution is obtained from the set of task identifiers that have never been occupied by other processing carriers besides the target processing carrier.

[0031] In one embodiment of this application, there may be multiple processing carriers (workers) for processing tasks. Each processing carrier may have its corresponding task processing time. When the task processing time of a certain processing carrier is reached, that processing carrier obtains a set of task identifiers in the pending execution state from the task identifier set that has not been occupied by other processing carriers besides itself. Multiple carriers can simultaneously obtain task identifier sets to process tasks, thereby achieving concurrent task processing and improving task processing efficiency.

[0032] In one embodiment of this application, the task identifier set may include task identifiers, which may be task numbers. The task identifier set may be a number range composed of task numbers. There may be multiple task identifier sets. When the task identifier set is a task number range, the tasks in multiple task number ranges can be consecutively numbered to obtain the number corresponding to the number of task processing quantities for the carrier, which is used as the task number range for that carrier. Alternatively, a task number can be randomly selected as the starting point of the number range, and the number of task processing quantities before or after the starting point can be obtained as the task number range for that carrier.

[0033] In one embodiment of this application, when the task type is uniquely determined, the task identifier can be the task source number. For example, when the task is to calculate the settlement of enterprise attendance data, the task identifier can correspond to the enterprise. Different task identifiers correspond to the attendance data settlement of different enterprises. Multiple enterprises can be numbered according to enterprise name, number of employees, etc., and the number of enterprise numbers corresponding to the task processing quantity of the carrier can be used as the task identifier set.

[0034] In other embodiments of this application, the task identifier may be an abbreviation of the task name, an abbreviation of the company name, etc.

[0035] In one embodiment of this application, a set of task identifiers not occupied by any processing carrier other than the target processing carrier can be obtained, and the set state of the set of task identifiers not occupied by any processing carrier other than the target processing carrier can be obtained. If there are tasks to be executed among the tasks corresponding to the task identifiers in the set of task identifiers not occupied by any processing carrier other than the target processing carrier, and the time of obtaining the set of task identifiers not occupied by any processing carrier other than the target processing carrier has reached the earliest retry time, then the set state corresponding to the set of task identifiers is determined to be a set state to be executed. If there are no tasks to be executed among the tasks corresponding to the identifiers in the set of task identifiers not occupied by any processing carrier other than the target processing carrier, or the time of obtaining the set of task identifiers not occupied by any processing carrier other than the target processing carrier has not reached the earliest retry time, then the set state corresponding to the set of task identifiers not occupied by any processing carrier other than the target processing carrier is determined to be a set state to be executed.

[0036] In one embodiment of this application, the task status, number of times the task is executed, and the most recent execution time of the identifier corresponding to the identifier in the task identifier set that is not occupied by any other processing carrier besides the target processing carrier can be obtained. If the task status is a pending task status, the number of times the task is executed is less than a set number, and the time between the most recent execution time of the task and the time between obtaining the task identifier set that is not occupied by any other processing carrier besides the target processing carrier is greater than the retry time interval, then the task corresponding to the identifier in the task identifier set is confirmed as a pending task.

[0037] In one embodiment of this application, if there are tasks to be executed among the tasks corresponding to task identifiers in a set of task identifiers not occupied by any processing carrier other than the target processing carrier, and the time of acquiring the task identifiers reaches the earliest retry time, then the tasks to be executed corresponding to the set of task identifiers are processed. The earliest retry time corresponding to the set of task identifiers can be the closest time among the earliest executable times of the multiple tasks to be executed corresponding to the set of task identifiers to the time when the set of task identifiers not occupied by any processing carrier other than the target processing carrier was acquired. The earliest executable time of the tasks to be executed can be obtained based on the most recent execution time of the task and the retry interval. The retry interval can be set empirically; it can be a fixed value or determined based on the size of the task file corresponding to the task.

[0038] Continue to refer to Figure 2 In step S220, the tasks to be executed corresponding to the task identifier set whose set state is to be executed are processed.

[0039] In one embodiment of this application, the task status, number of task executions, and most recent execution time of the identifiers in the task identifier set whose set status is pending execution can be obtained. If the task status is pending execution, the number of task executions is less than a set number, and the time between the most recent execution time of the task and the time between obtaining the task identifier set that is not occupied by any other processing carrier besides the target processing carrier is greater than the retry time interval, then the identifiers in the task identifier set whose set status is pending execution are confirmed to be the identifiers corresponding to the pending task.

[0040] In one embodiment of this application, the identifier corresponding to the task to be executed can be obtained from the task identifier set in the set state of the task to be executed; the task file corresponding to the identifier of the task to be executed can be obtained; the task file can be executed to process the task to be executed. Only the task file corresponding to the identifier of the task to be executed needs to be obtained. The task file can be offline, reducing the time to obtain the task file. In addition, tasks can be filtered by identifier. The task file is only obtained according to the identifier when the task is executed.

[0041] In one embodiment of this application, when obtaining a set of task identifiers that are not occupied by other processing carriers besides the target processing carrier, task files corresponding to multiple identifiers in the set of task identifiers that are not occupied by other processing carriers besides the target processing carrier can be obtained. After determining that the task status of the set of task identifiers that are not occupied by other processing carriers besides the target processing carrier is a set to be executed, the task file corresponding to the identifier of the task to be executed can be selected from the tasks corresponding to multiple identifiers in the set of task identifiers. This can reduce the time spent waiting to obtain the task file corresponding to the identifier of the task to be executed.

[0042] In one embodiment of this application, before obtaining the task file corresponding to the identifier, the task execution count corresponding to the task to be executed can be incremented by one. Incrementing the task execution count before executing the task file is better than incrementing it after the task is completed. This avoids the situation where a process exits due to an abnormality of a certain enterprise, and the retry count cannot be updated, which may lead to infinite re-entry and the task cannot be skipped.

[0043] In one embodiment of this application, the task file and the task identifier set may be stored on a blockchain.

[0044] In one embodiment of this application, when the task identifier is an enterprise number, the task can be determined by the file corresponding to the enterprise number. The file identifier may contain a type identifier indicating the task type. By obtaining the file corresponding to the enterprise number, the method of executing the file is determined according to the file identifier, so as to execute the file corresponding to the enterprise number and perform task processing.

[0045] In step S230, after the task to be executed is processed, the set state of the task identifier set whose set state is pending execution is updated to executed set state. Then, the task identifier set whose set state is pending execution is obtained from the task identifier set that has never been occupied by any other processing carrier besides the target processing carrier and processed again, until the set state of all task identifier sets is executed set state.

[0046] In one embodiment of this application, after processing the tasks to be executed corresponding to the task identifier set whose set state is pending execution, the processing result obtained from processing the tasks to be executed can be obtained; if the processing result is successful, the task state corresponding to the task to be executed is updated to the executed task state; if the processing result is unsuccessful, the task state corresponding to the task to be executed is kept as pending task state.

[0047] In one embodiment of this application, after processing the tasks to be executed corresponding to the task identifier set whose set state is pending execution, the most recent execution time of the task to be executed can be updated to the time when the task to be executed was processed.

[0048] In one embodiment of this application, the set state can be determined based on the set execution result and the earliest retry time. The set execution result can be determined based on the task execution result, which may include execution failure, execution success, and eventual failure. If the set execution result is execution failure, and the time for obtaining the task identifier set not occupied by any processing carrier other than the target processing carrier reaches the earliest retry time, the set state can be determined as a pending execution set state. If the set execution result is execution success or eventual failure, or the time for obtaining the task identifier set not occupied by any processing carrier other than the target processing carrier has not reached the earliest retry time, the set state can be determined as an executed set state. After processing the tasks corresponding to the task identifiers in the set of task identifiers in the "pending execution" state, the execution result and the earliest retry time of the set can be updated. The execution result of the set can be determined based on the task execution results. If there are failed execution results in the task execution results corresponding to the identifiers in the set of task identifiers in the "pending execution" state, and there are no pending tasks in the failed tasks, then the execution result of the set is determined to be a final failure. If there are failed execution results in the task execution results corresponding to the identifiers in the set of task identifiers in the "pending execution" state, and the failed tasks are pending tasks, then the execution result of the set is determined to be an execution failure. If all the task execution results corresponding to the identifiers in the set of task identifiers in the "pending execution" state are successful, then the execution result of the set is determined to be a successful execution.

[0049] exist Figure 2 In this embodiment, when the task processing time corresponding to the target processing carrier is reached, a set of task identifiers with a set state of "pending execution" is obtained from the set of task identifiers that have never been occupied by any processing carrier other than the target processing carrier. The tasks to be executed corresponding to the set of task identifiers with a set state of "pending execution" are processed. After the tasks to be executed are processed, the set state of the set of task identifiers with a set state of "pending execution" is updated to "executed", and the set of task identifiers with a set state of "pending execution" is obtained again from the set of task identifiers that have never been occupied by any processing carrier other than the target processing carrier, and processed, until the set state of all task identifier sets is "executed". This avoids missing tasks. Compared with determining whether a single task needs to be processed at a time, by obtaining the set state, it is possible to determine at a time whether there are any tasks that need to be processed among multiple tasks corresponding to a set of task identifiers, which can improve the efficiency of task processing. At the same time, since the set of task identifiers to be processed is obtained from the set of task identifiers that have not been occupied by other processing carriers, when using multiple processing carriers, including the target processing carrier and other processing carriers, to process tasks, mutual conflicts can be avoided while improving processing efficiency.

[0050] In one embodiment of this application, such as Figure 3 As shown, Figure 3 This diagram illustrates an overall architecture for implementing the task processing method of this application. Figure 3 The overall architecture diagram uses enterprise IDs as task identifiers. Its logical description includes: The service starts N processing vehicles (workers). For each worker, a task processing time is allocated to a specific computational segment. Each worker, upon acquiring a segment, retrieves the corresponding set state from the segment's task results and randomly selects a segment with a pending execution state for processing. This segment becomes the enterprise task queue and enters the enterprise task worker pool. When processing a task for a single segment, the system retrieves the task status, execution count, and most recent task information for each ID (e.g., at the individual enterprise level) from the enterprise task results. The execution time is used to filter enterprise tasks, sequentially identify tasks to be executed, and execute enterprise task logic to obtain task processing results. This also prevents a single enterprise from being executed too many times or taking too long, thus delaying the processing. The results of the number segment tasks and enterprise tasks are updated based on the task processing results to update the set status corresponding to the number segment and the task status, number of task executions, and the most recent execution time of the task corresponding to the number. The worker polls within the task processing time range until all number segment tasks are in the executed set status. For example, if there are 100 number segments to be executed and there are 10 workers, each worker will immediately execute the remaining unprocessed number segments after executing one number segment.

[0051] In one embodiment of this application, such as Figure 4 As shown, Figure 4 The schematic diagram illustrates an architecture for implementing the enterprise task filtering of this application. During the filtering phase, tasks with an executed task status, a task execution count exceeding the maximum execution count, or a task's most recent execution time being less than or equal to the retry interval from the time the task identifier set was obtained are filtered. Tasks with an executed task status, a task execution count exceeding the maximum execution count, and a task's most recent execution time being greater than the retry interval from the time the task identifier set was obtained undergo pre-update. The pre-update steps include incrementing the task's execution count and updating the task's most recent execution time to the pre-update time. Enterprise task logic is then executed on the pre-updated task, i.e., the task is processed to obtain a processing result. Based on the processing result, the task status and most recent execution time stored in the Expires Kubernetes (Pkv) are updated. The Expires Kubernetes provides storage for automatically cleaned up expired data and stores failed tasks. The Expires Kubernetes can also store segment task results and enterprise task results. During filtering, enterprise task results are retrieved from the Expires Kubernetes to obtain the task status, task execution count, and most recent execution time. The pre-updated task execution count and most recent execution time can also be stored in the Expires Kubernetes. In Pkv, the most recent execution time of the task updated during the pre-update can be the time of the last task processed before the pre-update, and the most recent execution time of the task updated during the update step can be the time of executing the enterprise task logic.

[0052] In one embodiment of this application, such as Figure 5 As shown, Figure 5 The diagram illustrates an architecture for implementing the number segment task filtering method of this application. In the filtering phase, number segments with a task status of "executed set" are filtered, and number segments with a corresponding set status of "pending execution set" are processed. The set status of the processed number segments is updated. The set status can include both "executed set" and "pending execution set" states. If the set execution result is successful or ultimately fails, the time to obtain the task identifier set has not reached the earliest retry time, and the number segment execution duration is less than a set duration, the set status can be updated to "executed set". If the set execution result is failed, and the time to obtain the task identifier set has reached the earliest retry time, the set status can be updated to "pending execution set". The earliest retry time of the set can be the earliest retry time of the pending tasks included in the set. When updating the set status, the execution result, earliest retry time, last execution time, total number of enterprises, number of failed enterprises, and number segment execution duration can also be updated.

[0053] Figure 5 In the architecture diagram, execution results, earliest retry time, last execution time, total number of enterprises, number of failed enterprises, and execution duration of number segments can be obtained from the data storage unit (Chubby). Chubby can be used to implement remote concurrency control and customize the directory structure of concurrent files.

[0054] In one embodiment of this application, such as Figure 6 As shown, Figure 6 This schematic diagram illustrates a flowchart of a task processing method for implementing this application. Figure 6In step 0, the current environment is determined; if the environment is illegal, the task thread will not be started. In step 1, it is determined whether the daily report calculation task is within the time range. If the condition is not met, proceed to step 5 for processing; if the condition is met, proceed to step 2 for processing. In step 2, all number segment files under chubby are read and traversed. In step 3, a number segment is randomly selected as the starting point. In step 4, for each number segment, the "number segment processing flow" is entered. In step 5, wait for 5 minutes, and then enter step 1 to process and re-acquire number segments. In the "Number Segment Processing Flow," in step 6, an attempt is made to acquire the number segment chubby lock under non-blocking conditions. In step 7, it is determined whether the lock acquisition was successful. If the lock acquisition fails, an error is returned, the number segment is skipped, and it will be scheduled again next time. At the same time, errors of non-occupied (eErrOtherAcquire) are logged and alarms are set. If the lock is successfully acquired, the process proceeds to step 8 to read the chubby number segment metadata. In step 9, it is determined whether the number segment needs to be processed. If the set status corresponding to the number segment is an executed set status or less than 5 minutes since the last execution, the number segment is skipped. If the set status corresponding to the number segment is a pending set status, the process continues to step 10 to check the number segment. All enterprises under the segment enter the "Enterprise Processing Flow"; in step 11, the execution results of the segment are statistically analyzed, including the total number of tasks in the segment, the number of failed tasks, and the most recent execution time of the set, and the set status corresponding to the segment is confirmed. If all tasks are successful, the set status is "executed set status". If some tasks fail, but there are still tasks that meet the retry conditions (step 15), the set status is determined to be "pending execution set status". If some tasks fail and there are no tasks that meet the retry conditions (step 15), the set status is determined to be "executed set status". In step 12, the chubby segment meta information is written back. In step 13, the segment chubby lock is released. In the "Enterprise Processing Flow", in step 14, the "Enterprise Task Status" is read; in step 15, it is determined whether the enterprise needs to be processed. If the task status is empty (first execution), or if the following retry conditions are met, execution continues; otherwise, it exits: a) not in a successful state (including execution failure or exiting midway, resulting in an empty status); b) the time interval since the last execution exceeds the retry interval; c) the number of executions is less than the maximum number of executions; in step 16, the execution count and execution time of the "Enterprise Execution Status" are updated by one to prevent the process from exiting due to an enterprise exception, which would prevent the retry count from being updated and could lead to infinite re-entry, making it impossible to skip; in step 17, the daily report calculation logic is executed to execute the enterprise task and obtain the return code; in step 18, the result status is determined to update the task status and the most recent execution time of the task. If the task is executed successfully, 0 or an ignorable error code is returned; if the task fails, a non-zero and non-ignorable error code is returned; in step 19, the "Enterprise Task Status" is updated.

[0055] This application has been approved. Figure 6The flowchart illustrates a complete offline daily attendance report calculation system. In terms of disaster recovery, it achieves independent processing for each calculation unit, with the ability to arbitrarily schedule concurrency and calculation time. It possesses comprehensive fault tolerance capabilities in terms of enterprise computing reliability, scheduling overhead, retry overhead, concurrency capabilities, and result detection and alarms, meeting enterprises' needs for timely statistical accounting, error correction capabilities, and stability of daily attendance reports.

[0056] The following describes an embodiment of the apparatus described in this application, which can be used to execute the task processing method described above in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the task processing method described above in this application.

[0057] Figure 7 A block diagram of a task processing apparatus according to one embodiment of the present application is shown schematically.

[0058] Reference Figure 7 As shown, a task processing apparatus 700 according to an embodiment of this application includes an acquisition module 701, a processing module 702, and an update module 703.

[0059] According to one aspect of the embodiments of this application, based on the foregoing scheme, the acquisition module 701 is configured to acquire a set of task identifiers with a set state of pending execution when the task processing time corresponding to the target processing carrier is reached; the processing module is configured to process the pending tasks corresponding to the set of task identifiers with a set state of pending execution; the update module is configured to update the set state of the set of task identifiers with a set state of pending execution to executed state after the processing of the pending tasks is completed, and re-acquire the set of task identifiers with a set state of pending execution from the set of task identifiers not occupied by other processing carriers besides the target processing carrier for processing, until the set state of all task identifier sets is executed.

[0060] In one embodiment of this application, based on the aforementioned scheme, the processing module 702 is configured to: obtain the identifier corresponding to the task to be executed in the task identifier set; obtain the task file corresponding to the identifier of the task to be executed; and execute the task file to process the task to be executed.

[0061] In one embodiment of this application, based on the aforementioned scheme, before obtaining the identifier corresponding to the task to be executed, the acquisition module 701 is configured to: obtain the task status, the number of times the task is executed, and the most recent execution time of the task corresponding to the identifier in the task identifier set; if the task status is the task to be executed status, the number of times the task is executed is less than the set number of times, and the time between the most recent execution time of the task and the time of obtaining the task identifier set is greater than the retry time interval, then the identifier in the task identifier set is confirmed to be the identifier corresponding to the task to be executed.

[0062] In one embodiment of this application, based on the aforementioned scheme, after processing the tasks to be executed corresponding to the task identifier set, the update module 703 is configured to: obtain the processing result obtained from processing the tasks to be executed; if the processing result is successful, update the task status corresponding to the task to be executed to the executed task status; if the processing result is unsuccessful, keep the task status corresponding to the task to be executed as the task to be executed status.

[0063] In one embodiment of this application, based on the aforementioned scheme, before obtaining the task file corresponding to the identifier, the update module 703 is configured to: increment the task execution count corresponding to the task to be executed by one.

[0064] In one embodiment of this application, based on the aforementioned scheme, after the task to be executed is processed, the update module 703 is configured to update the most recent execution time of the task to be executed to the time when the task to be executed is processed.

[0065] In one embodiment of this application, based on the aforementioned scheme, before obtaining the set of task identifiers whose set state is a pending execution set state, the acquisition module 701 is configured to: acquire the set of task identifiers not occupied by any processing carrier other than the target processing carrier, and acquire the set state of the set of task identifiers not occupied by any processing carrier other than the target processing carrier; if there are pending tasks among the tasks corresponding to the task identifiers in the set of task identifiers not occupied by any processing carrier other than the target processing carrier, and the time for acquiring the set of task identifiers not occupied by any processing carrier other than the target processing carrier has reached the earliest retry time, then the set state corresponding to the set of task identifiers is determined to be a pending execution set state; if there are no pending tasks among the tasks corresponding to the identifiers in the set of task identifiers, or the time for acquiring the set of task identifiers not occupied by any processing carrier other than the target processing carrier has not reached the earliest retry time, then the set state corresponding to the set of task identifiers not occupied by any processing carrier other than the target processing carrier is determined to be an executed set state.

[0066] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0067] The following reference Figure 8 To describe an electronic device 80 according to this embodiment of the present application. Figure 8The electronic device 80 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0068] like Figure 8 As shown, the electronic device 80 is presented in the form of a general-purpose computing device. The components of the electronic device 80 may include, but are not limited to: at least one processing unit 81, at least one storage unit 82, a bus 83 connecting different system components (including storage unit 82 and processing unit 81), and a display unit 84.

[0069] The storage unit stores program code that can be executed by the processing unit 81, causing the processing unit 81 to perform the steps described in the "Embodiment Methods" section above according to various exemplary embodiments of this application.

[0070] Storage unit 82 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 821 and / or a cache memory unit 822, and may further include a read-only memory unit (ROM) 823.

[0071] Storage unit 82 may also include a program / utility 824 having a set (at least one) of program modules 825, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0072] Bus 83 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0073] Electronic device 80 can also communicate with one or more external devices (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 80, and / or with any device that enables electronic device 80 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 85. Furthermore, electronic device 80 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 86. As shown, network adapter 86 communicates with other modules of electronic device 80 via bus 83. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 80, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0074] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.

[0075] According to one embodiment of this application, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above in this specification is stored. In some possible implementations, various aspects of this application may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of this application described in the "Exemplary Methods" section of this specification.

[0076] According to one embodiment of this application, the program product for implementing the above method can be a portable compact disc read-only memory (CD-ROM) and include program code, and can run on a terminal device, such as a personal computer. However, the program product of this application is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0077] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0078] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0079] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0080] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0081] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this application, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0082] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A task processing method, characterized in that, include: When the task processing time corresponding to the target processing carrier is reached, obtain the set of task identifiers that are not occupied by other processing carriers besides the target processing carrier, and obtain the set status of the set of task identifiers that are not occupied by other processing carriers besides the target processing carrier. If there is a task to be executed in the task identifier corresponding to the task identifier in the task identifier set that is not occupied by other processing carriers besides the target processing carrier, and the time of obtaining the task identifier set that is not occupied by other processing carriers besides the target processing carrier reaches the earliest retry time, then the set state corresponding to the task identifier set that is not occupied by other processing carriers besides the target processing carrier is determined to be the set state to be executed. From the set of task identifiers that have never been occupied by any processing carrier other than the target processing carrier, a set of task identifiers with a set status of pending execution is obtained based on the number segment acquired by the target processing carrier. The set of task identifiers includes task identifiers, where the task identifier is a task number, and the set of task identifiers is a number segment composed of task numbers. Process the tasks to be executed corresponding to the set of task identifiers whose set state is "to be executed"; After the task to be executed is processed, the set status of the task identifier set whose set status is pending execution is updated to executed. Then, the task identifier set whose set status is pending execution is retrieved from the task identifier set that is not occupied by any other processing carrier besides the target processing carrier and processed again, until the set status of all task identifier sets is executed.

2. The task processing method according to claim 1, characterized in that, The processing of the tasks to be executed corresponding to the set of task identifiers whose set state is "to be executed" includes: Obtain the identifier corresponding to the task to be executed from the set of task identifiers; Obtain the task file corresponding to the identifier of the task to be executed; The task file is executed to process the task to be performed.

3. The task processing method according to claim 2, characterized in that, Before obtaining the identifier corresponding to the task to be executed, the method includes: Obtain the task status, number of times the task was executed, and the most recent execution time of the task corresponding to the identifier in the task identifier set; If the task status is pending execution, the number of times the task has been executed is less than a set number, and the time between the most recent execution time of the task and the time between obtaining the task identifier set is greater than the retry time interval, then the identifier in the task identifier set is confirmed to be the identifier corresponding to the pending execution task.

4. The task processing method according to claim 3, characterized in that, After processing the tasks to be executed corresponding to the set of task identifiers, the method includes: Obtain the processing result obtained from processing the task to be executed; If the processing result is successful, the task status corresponding to the task to be executed will be updated to the executed task status. If the processing result is an execution failure, the task status corresponding to the task to be executed will be maintained as the task to be executed status.

5. The task processing method according to claim 3, characterized in that, Before obtaining the task file corresponding to the identifier, the method includes: Increment the number of times the task to be executed is corresponding to the task to be executed.

6. The task processing method according to claim 3, characterized in that, After processing the task to be executed, the method includes: Update the most recent execution time of the task corresponding to the task to be executed to the time when the task to be executed was processed.

7. The task processing method according to any one of claims 1 to 6, characterized in that, Before obtaining the set of task identifiers whose set status is "to be executed", the method includes: If there is no task to be executed in the task corresponding to the task identifier set that is not occupied by any other processing carrier besides the target processing carrier, or if the time for obtaining the task identifier set that is not occupied by any other processing carrier besides the target processing carrier has not reached the earliest retry time, then the set state corresponding to the task identifier set that is not occupied by any other processing carrier besides the target processing carrier is determined to be the executed set state.

8. A task processing device, characterized in that, include: The acquisition module is configured to, when the task processing time corresponding to the target processing carrier is reached, acquire a set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier, and acquire the set status of the set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier; if there are tasks to be executed among the tasks corresponding to the task identifiers in the set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier, and the time for acquiring the set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier has reached the earliest retry time, then the set status corresponding to the set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier is determined to be a set status to be executed; from the set of task identifiers that are not occupied by any other processing carrier besides the target processing carrier, based on the number segment acquired by the target processing carrier, acquire a set of task identifiers with a set status to be executed, wherein the set of task identifiers includes task identifiers, the task identifiers are task numbers, and the set of task identifiers is a number segment composed of task numbers; The processing module is configured to process the tasks to be executed corresponding to the set of task identifiers whose set state is a set state to be executed; The update module is configured to, after the task to be executed is completed, update the set status of the task identifier set whose set status is pending execution to executed set status, and re-obtain the task identifier set whose set status is pending execution from the task identifier set that is not occupied by any other processing carrier besides the target processing carrier, until the set status of all task identifier sets is executed.

9. An electronic device, characterized in that, include: Memory, which stores computer-readable instructions; A processor reads computer-readable instructions stored in memory to perform the method described in any one of claims 1-7.

10. A computer program medium having stored computer-readable instructions thereon, which, when executed by a processor of a computer, cause the computer to perform the method of any one of claims 1-7.

11. A computer program product, characterized in that, Includes computer instructions that, when executed by a processor, implement the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Task processing system, method and apparatus

    CN109144744A