CN116680055A - Asynchronous task processing method and device, computer equipment and storage medium - Google Patents

Asynchronous task processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN116680055A
CN116680055A CN202310699683.3A CN202310699683A CN116680055A CN 116680055 A CN116680055 A CN 116680055A CN 202310699683 A CN202310699683 A CN 202310699683A CN 116680055 A CN116680055 A CN 116680055A
Authority
CN
China
Prior art keywords
task
asynchronous
target
queue
target task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310699683.3A
Other languages
Chinese (zh)
Inventor
王萍萍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ziroom Information Technology Co Ltd
Original Assignee
Beijing Ziroom Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ziroom Information Technology Co Ltd filed Critical Beijing Ziroom Information Technology Co Ltd
Priority to CN202310699683.3A priority Critical patent/CN116680055A/en
Publication of CN116680055A publication Critical patent/CN116680055A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention relates to the technical field of computers, and discloses an asynchronous task processing method, an asynchronous task processing device, computer equipment and a storage medium, wherein the method comprises the following steps: when an asynchronous task request is received, writing the asynchronous tasks into a task queue and a task data table respectively, and sequentially taking out and executing the asynchronous tasks in the task queue according to a predefined priority; taking out a target task to be executed currently from a task queue through a main thread, and distributing sub threads from a predefined thread pool to execute the target task; if the target task fails to be executed, extracting the target task from the task data table, and rewriting the target task into the task queue. The success rate of asynchronous task processing is improved.

Description

Asynchronous task processing method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an asynchronous task processing method, an asynchronous task processing device, a computer device, and a storage medium.
Background
At present, the more commonly used asynchronous task processing means in JAVA is @ Async annotation, namely @ Async annotation is added in front of a method or class code, which means that the method or the method in the method is an asynchronous method, the @ Async annotation defaults to use a thread pool SimpleAsyncTaskExutesor, and the thread pool defaults to newly add an asynchronous task to create a thread. For example, when the main code of the A task runs, if the main code runs to the B task position annotated by @ Async, a sub thread is newly added to run the B task by the default thread pool, the main thread continues to run the rest of the A task, if the main thread runs to the C task position annotated by @ Async next time, the sub thread is newly added to run the C task by the default thread pool, the main thread continues to run the rest of the A task, if the annotated asynchronous tasks in the A task are more, the default thread pool can always create a new sub thread, and as the system continuously creates a new thread, the system finally occupies too high memory, and out memory error is caused, so that normal service operation is affected. The current common means for solving this problem is to configure a custom thread pool, and process redundant tasks by using a corresponding rejection policy for the case of reaching the maximum thread number of the thread pool, where the thread pool has 4 common rejection policies:
ThreadPoolExuter. AbortPolicy discard the current task and throw exceptions.
Threadpolexechamtor. Discard policy: the current task is also discarded, but no exception is thrown.
ThreadPoolExecutor. DiscardOldestPolicy: the oldest task in the thread pool is discarded, one thread is released, and then the current task is retried (the process is repeated).
ThreadPoolExecutor.CallerusPolicy: the current task is submitted to the main thread for execution, which is equivalent to the situation that an asynchronous task is not started, and the main thread throws out an exception when the task fails.
It is apparent that the rejection policy of the related art brings about a risk of failure and irrecoverability of the execution of the asynchronous task, and thus a new method is required to improve the success rate of the asynchronous task processing.
Disclosure of Invention
In view of the above, the invention provides an asynchronous task processing method, an asynchronous task processing device, a computer device and a storage medium, which solve the problem of low success rate of asynchronous task processing.
In a first aspect, the present invention provides an asynchronous task processing method, the method including: when an asynchronous task request is received, writing the asynchronous task into a task queue and a task data table respectively, and sequentially taking out and executing the asynchronous tasks in the task queue according to a predefined priority; taking out a target task to be executed currently from the task queue through a main thread, and distributing sub threads from a predefined thread pool to execute the target task; and if the target task fails to be executed, extracting the target task from the task data table, and rewriting the target task into the task queue.
Optionally, the predefined priority is a time of execution of an asynchronous task, and extracting the target task from the task data table if the target task fails to execute includes: if the target task fails to be executed, marking the execution state of the target task as failure in the task data table, and marking the next execution time for the target task based on a preset time interval; and extracting the marked target task from the task data table according to the state of the target task.
Optionally, before the extracting the marked target task from the task data table, the method further includes: if the target task fails to execute, marking the failure times of the target task in the task data table plus 1.
Optionally, the extracting the marked target task from the task data table includes: judging whether the failure times of the target task are larger than a preset time threshold; when the failure times of the target task are smaller than a preset time threshold, extracting marked target tasks from the task data table; and when the failure times of the target task is larger than a preset time threshold, canceling rewriting the target task into the task queue, sending alarm information, and marking the alarm times for the target task by adding 1.
Optionally, the fetching, by the main thread, the target task to be executed currently from the task queue includes: judging whether an idle child thread exists in the thread pool or not through a main thread; when idle sub-threads exist in the thread pool, a target task to be executed currently is taken out of the task queue through a main thread; and when no idle sub-thread exists in the thread pool, keeping the main thread waiting.
Optionally, the asynchronous task is an asynchronous data storage task, and the method further comprises: determining the asynchronous task with highest abnormal frequency according to the failure times, the alarming times and the execution state of each asynchronous task record in the task data table; and positioning an abnormal data interface according to the asynchronous task with the highest abnormal frequency.
Optionally, the task queue is a mondab queue.
In a second aspect, the present invention provides an asynchronous task processing device, the device comprising: the asynchronous task writing module is used for writing the asynchronous tasks into a task queue and a task data table respectively when receiving an asynchronous task request, and the asynchronous tasks in the task queue are sequentially taken out and executed according to a predefined priority; the asynchronous task execution module is used for taking out a target task to be executed currently from the task queue through a main thread and distributing sub threads from a predefined thread pool to execute the target task; and the asynchronous task retry module extracts the target task from the task data table and rewrites the target task into the task queue if the target task fails to be executed.
In a third aspect, the present invention provides a computer device comprising: the memory and the processor are in communication connection, the memory stores computer instructions, and the processor executes the computer instructions to perform the method of the first aspect or any implementation manner corresponding to the first aspect.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of the first aspect or any of its corresponding embodiments.
The technical scheme provided by the invention has the following advantages:
when the operating system receives an asynchronous task request, the method provided by the embodiment of the invention writes the asynchronous task into the pre-created task queue and the task data table, wherein the task queue is used for temporarily storing the asynchronous task according to the predefined priority, the asynchronous tasks in the task queue are sequentially taken out and executed according to the predefined priority, and the task data table is used for backing up the asynchronous task so as to be convenient for recovering the asynchronous task when the task queue is abnormal or the execution of the asynchronous task fails. Then, the operating system takes out the target task to be executed currently from the task queue according to the priority through the main thread, and distributes the sub-threads from the predefined thread pool to execute the target task; if the execution of the target task fails, the operating system extracts the backup target task from the task data table and rewrites the target task into the task queue, so that the target task can be read and distributed again by the main thread, compared with 4 rejection strategies commonly used in the related art, whether the asynchronous task fails due to insufficient number of sub-threads of the thread pool or fails due to the execution of the asynchronous task, the task can be repeatedly and sequentially executed through the task queue and the task data table, and the task can not be directly abandoned after the failure and cannot be backtraced, and therefore, the success rate of the processing of the asynchronous task can be remarkably improved through the scheme provided by the embodiment of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow diagram of an asynchronous task processing method according to an embodiment of the present invention;
FIG. 2 is another flow diagram of an asynchronous task processing method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an asynchronous task processing device according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In accordance with an embodiment of the present invention, an asynchronous task processing method embodiment is provided, it being noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system, such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
In this embodiment, an asynchronous task processing method is provided, which may be used in the above-mentioned computer device, as shown in fig. 1 and fig. 2, and the asynchronous task processing method provided in this embodiment includes the following steps:
step S101, when an asynchronous task request is received, the asynchronous tasks are respectively written into a task queue and a task data table, and the asynchronous tasks in the task queue are sequentially taken out and executed according to a predefined priority.
Specifically, the asynchronous task processing method provided by the embodiment of the invention is applied to an operating system of computer equipment, wherein the computer equipment comprises, but is not limited to, a mobile phone, a personal computer and a tablet personal computer. The request of the asynchronous task can be realized through two means of custom annotation and buried point, wherein the custom annotation is similar to @ Async annotation and is used for matching the asynchronous task processing logic provided by the embodiment of the invention, for example, the method code or the class code is annotated through a custom symbol, so that when the main thread runs to the corresponding annotation position, the asynchronous task processing logic provided by the embodiment of the invention is executed. For example: it is assumed that this embodiment provides a housing service APP, where a function in the APP is to calculate a house cost for a user, send a short message to the user after calculating the house cost to inform the calculation result, perform a custom annotation by the method of sending a short message, and after calculating the house cost by a main thread, run to the method of sending a short message, and detect the custom annotation, so as to start executing the asynchronous task processing logic provided by the embodiment of the present invention, allocate a sub-thread to execute the task of sending a short message, and the main thread continues to execute other tasks. Buried points are asynchronous tasks by detecting a triggering event of a user, such as: the method is characterized in that an interface of a house service APP, through which a user browses house source information, is provided with a place ordering control, when the user browses house source information is satisfied, the user can trigger the place ordering control, so that one task is to collect the house source information of the current house and store the collected information into a database, the task is an asynchronous task, whether the user triggers the place ordering control to start execution is monitored by a buried point mode, and the main thread continues to execute other tasks. By the two modes, an asynchronous task request is generated, and when an operating system acquires the asynchronous task request from the front end (the task request comprises data to be processed), the embodiment of the invention performs double writing on the asynchronous task and writes a pre-deployed task queue and a task data table respectively. The task queue is used for temporarily storing asynchronous tasks according to a predefined priority, the asynchronous tasks in the task queue are sequentially taken out and executed according to the predefined priority, after the asynchronous tasks are taken out from the task queue, the taken out tasks are cleared from the task queue, and the task data table is used for backing up the asynchronous tasks so as to restore the asynchronous tasks when the asynchronous tasks fail to execute. It should be noted that the task queue belongs to a simulation queue, and the tasks in the queue are not executed first in advance, but executed first by a predefined priority, and the priority of which task is high, and the priorities of the asynchronous tasks in the task queue can be directly defined according to the urgency degree of the task request or defined according to a certain rule. The task queue can be a Redis queue, a kafka queue and the like, in an embodiment of the invention, the implementation is specifically realized by adopting a mongolib queue, and the situation that a plurality of sub-threads are simultaneously allocated to the same asynchronous task can not occur by adopting the mongolib queue in combination with the atomicity of mongolib operation, so that the reliability of asynchronous task processing is ensured. In addition, the task data table of the embodiment of the invention is realized by adopting a mysql database.
Step S102, the target task to be executed is taken out of the task queue through the main thread, and the sub-threads are allocated from the predefined thread pool to execute the target task.
Specifically, based on the task queue deployed in the above step, the task queue includes one or more asynchronous tasks, and in this embodiment, the target task to be executed currently is fetched from the task queue by the main thread according to the priority. The present embodiment also predefines a thread pool, e.g., a thread pool comprising 5 sub-threads, and then allocates the sub-threads from the predefined thread pool to perform the target task.
Step S103, if the target task fails to be executed, extracting the target task from the task data table, and rewriting the target task into the task queue.
Specifically, there are various reasons for failure of execution of the target task, for example: the sub-threads are all in a working state, and no redundant sub-threads execute target tasks; or in the process of executing the target task, the failure of calling the interface such as the third party for reading data/sending the short message and the like causes the failure of executing the target task. The scheme provided by the embodiment of the invention ensures that the operating system can extract the backup target task from the task data table and rewrite the target task into the task queue, so that the target task is repeatedly executed subsequently according to the preset priority, the successful execution of the target task is ensured, and the success rate of the execution of the target task can be obviously improved. In addition, the embodiment of the invention adopts a mode of double writing of the task queue and the task data table, and on one hand, the execution efficiency of the asynchronous task can be improved through the task queue. Because the task queue clears the task each time an asynchronous task is taken out of the task queue, the calculation amount involved in calculating the task priority is not too large every time the main thread extracts a target task in the task queue, and the task extraction time is reduced. If only the task data table is adopted, the task data in the task data table generally reaches tens of millions of units and hundreds of millions of units along with the time, the main thread directly calculates which task has the highest priority in the task data table, so that the comparison calculation of the main thread is very heavy, on the other hand, the task with the execution failure still can be restored to the task queue through the matching of the task data table with the task queue, and the main thread can still re-execute the task with the failure before being re-fetched from the task queue. Therefore, by the scheme provided by the embodiment of the invention, the success rate and the execution efficiency of asynchronous task execution are improved at the same time.
In some alternative embodiments, the step S103 includes:
step a1, if the target task fails to be executed, marking the execution state of the target task as failure in a task data table, and marking the next execution time of the target task based on a preset time interval;
and a2, extracting the marked target task from the task data table.
Specifically, in an embodiment of the present invention, the predefined priority is the time of asynchronous task execution, such as: the time for asynchronous task A to execute is set to be 12:00, and the time for asynchronous task B to execute is set to be 12:01. When the target task fails to execute, the operating system acquires the failure of executing the target task, so that the failed executing state is written into the target task in the task data table, and the next executing time is marked for the target task based on a preset time interval. For example: the current execution fails to be that of the asynchronous task A, the preset time interval is 2 minutes, so that the next execution time of the asynchronous task A is marked as 12:00 plus 2 minutes to obtain 12:02, then the marked target task is put into a task queue again, when the main thread searches the task needing to be executed currently from the task queue, the priority of the target task is reduced, and the sub-threads are allocated to the target task again after the interval is 2 minutes. By the method, the problem of code of the target task or the problem of calling an interface is avoided, so that the target task repeatedly tries without interruption, and limited sub-thread resources are occupied.
In some optional embodiments, before the step a2, further includes:
and b1, if the target task fails to execute, adding 1 to the failure times of the target task marked in the task data table.
Thus, in the embodiment of the present invention, the step a2 includes:
and step c1, judging whether the failure times of the target task are larger than a preset time threshold.
And c2, when the failure times of the target task are smaller than a preset time threshold, extracting the marked target task from the task data table.
And c3, when the failure times of the target task is larger than a preset time threshold, canceling rewriting the target task into the task queue, sending out alarm information, and simultaneously marking the alarm times of the target task by 1.
Specifically, when each asynchronous task fails to process, the operating system writes a mark of 1 plus the number of failures to the asynchronous task in the task data table. Therefore, before the failed task is replaced in the task queue, the operating system determines whether the failure frequency of the target task is greater than a preset frequency threshold, for example, the preset frequency threshold is set to 6 times, which is not limited to this. When the failure times of the target task do not exceed the preset times threshold, the target task is put back into the task queue again, when the failure times of the target task exceed the preset times threshold, the target task is not put back into the task queue any more, but alarm information is sent out through technologies such as short messages, enterprise WeChat, station information and the like, and background staff is prompted to perform manual intervention, so that whether the target task is re-executed is determined after manual processing. By the scheme provided by the embodiment of the invention, the preset frequency threshold is limited, the endless loop enqueue caused by the failure of the target task is avoided, and limited thread resources are preempted. Based on the time interval of adding 2 minutes to each failed retry, the retry is usually completed within 1 hour and 49 minutes for 6 times, so that the problem of task failure caused by temporary abnormality of a third party system or network jitter can be effectively solved.
In some optional embodiments, the step S102 includes:
step d1, judging whether an idle sub-thread exists in a thread pool or not through a main thread;
step d2, when idle sub-threads exist in the thread pool, the target task to be executed currently is taken out from the task queue through the main thread;
and d3, when no idle sub-thread exists in the thread pool, keeping the main thread waiting.
Specifically, when the main thread is set to fetch an asynchronous task from the task queue, the embodiment of the invention firstly judges whether the thread pool has idle sub threads, and when only has idle sub threads, the main thread fetches the target task to be executed currently from the task queue, otherwise, the main thread keeps waiting. By the method, failures of the asynchronous task caused by full sub-threads are further reduced, and the failure rate of the asynchronous task is reduced.
In some optional implementations, the asynchronous task in the embodiments of the present invention is an asynchronous data storage task, and the asynchronous task processing method further includes:
and e1, determining the asynchronous task with the highest abnormal frequency according to the failure times, the alarming times and the execution state of each asynchronous task record in the task data table.
And e2, positioning the abnormal data interface according to the asynchronous task with the highest abnormal frequency.
In particular, in practical application, the data pulling failure of the asynchronous task is often caused by the abnormal data interface of the third party, so that the asynchronous data storage task fails. Based on the above, according to the failure times, the alarm times and the execution state recorded in the task data table, the asynchronous task with the highest abnormal frequency can be accurately positioned, and then the data interface with the abnormal frequency can be determined. The data in the task data table is not deleted and is regularly archived, so that the data can be used for analyzing which tasks fail to retry for a higher frequency, thereby providing basis for relevant optimization.
By the scheme provided by the embodiment of the invention, the system performance problem caused by using the @ ASync annotation can be effectively solved; after the asynchronous task fails, data compensation retry with preset times can be performed, if the asynchronous task still fails, manual intervention can be performed by alarming, so that 100% of successful execution of the asynchronous task is ensured; the problem that tasks are lost under abnormal conditions such as downtime of a system can be effectively solved by adopting a mode of double writing of a mongasb queue and a mysql data table; in addition, the data storage is not deleted in the mysql table, and the asynchronous storage data failure condition can be used for data analysis.
In this embodiment, an asynchronous task processing device is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and will not be described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides an asynchronous task processing device, as shown in fig. 3, including:
the asynchronous task writing module 301 is configured to, when receiving an asynchronous task request, write the asynchronous tasks into a task queue and a task data table, respectively, where the asynchronous tasks in the task queue are sequentially fetched and executed according to a predefined priority. For details, refer to the related description of step S101 in the above method embodiment, and no further description is given here.
The asynchronous task execution module 302 is configured to take a target task to be executed currently from the task queue through the main thread, and allocate the sub-threads from the predefined thread pool to execute the target task. For details, refer to the related description of step S102 in the above method embodiment, and no further description is given here.
The asynchronous task retry module 303 extracts the target task from the task data table and rewrites the target task into the task queue if the target task fails to execute. For details, see the description of step S103 in the above method embodiment, and the details are not repeated here.
The asynchronous task processing means in this embodiment are presented in the form of functional units, here referred to as ASIC circuits, processors and memories executing one or more software or fixed programs, and/or other devices that can provide the functionality described above.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
Through the above components, when the operating system receives an asynchronous task request, the asynchronous task is written into a pre-created task queue and a task data table, the task queue is used for temporarily storing the asynchronous task according to a predefined priority, the asynchronous tasks in the task queue are sequentially taken out and executed according to the predefined priority, and the task data table is used for backing up the asynchronous task so as to restore the asynchronous task when the execution of the asynchronous task fails. Then, the operating system takes out the target task to be executed currently from the task queue according to the priority through the main thread, and distributes the sub-threads from the predefined thread pool to execute the target task; if the execution of the target task fails, the operating system extracts the backup target task from the task data table and rewrites the target task into the task queue, so that the target task can be read and distributed again by the main thread, compared with 4 rejection strategies commonly used in the related art, whether the asynchronous task fails due to insufficient number of sub-threads of the thread pool or fails due to the execution of the asynchronous task, the task can be repeatedly and sequentially executed through the task queue and the task data table, and the task can not be directly abandoned after the failure and cannot be backtraced, and therefore, the success rate of the processing of the asynchronous task can be remarkably improved through the scheme provided by the embodiment of the invention.
The embodiment of the invention also provides computer equipment, which is provided with the asynchronous task processing device shown in the figure 3.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, as shown in fig. 4, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 4.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform a method for implementing the embodiments described above.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created from the use of the computer device of the presentation of a sort of applet landing page, and the like. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.

Claims (10)

1. A method of asynchronous task processing, the method comprising:
when an asynchronous task request is received, writing the asynchronous task into a task queue and a task data table respectively, and sequentially taking out and executing the asynchronous tasks in the task queue according to a predefined priority;
taking out a target task to be executed currently from the task queue through a main thread, and distributing sub threads from a predefined thread pool to execute the target task;
and if the target task fails to be executed, extracting the target task from the task data table, and rewriting the target task into the task queue.
2. The method of claim 1, wherein the predefined priority is a time of execution of an asynchronous task, and wherein extracting the target task from the task data table if the target task fails to execute comprises:
if the target task fails to be executed, marking the execution state of the target task as failure in the task data table, and marking the next execution time for the target task based on a preset time interval;
and extracting the marked target task from the task data table.
3. The method of claim 2, wherein prior to said extracting the marked target task from the task data table, the method further comprises:
if the target task fails to execute, marking the failure times of the target task in the task data table plus 1.
4. A method according to claim 3, wherein said extracting the marked target task from the task data table comprises:
judging whether the failure times of the target task are larger than a preset time threshold;
when the failure times of the target task are smaller than a preset time threshold, extracting marked target tasks from the task data table;
and when the failure times of the target task is larger than a preset time threshold, canceling rewriting the target task into the task queue, sending alarm information, and marking the alarm times for the target task by adding 1.
5. The method of claim 1, wherein the fetching, by the main thread, the target task currently to be executed from the task queue comprises:
judging whether an idle child thread exists in the thread pool or not through a main thread;
when idle sub-threads exist in the thread pool, a target task to be executed currently is taken out of the task queue through a main thread;
and when no idle sub-thread exists in the thread pool, keeping the main thread waiting.
6. The method of claim 4, wherein the asynchronous task is an asynchronous data storage task, the method further comprising:
determining the asynchronous task with highest abnormal frequency according to the failure times, the alarming times and the execution state of each asynchronous task record in the task data table;
and positioning an abnormal data interface according to the asynchronous task with the highest abnormal frequency.
7. The method of claim 1, wherein the task queue is a monodb queue.
8. An asynchronous task processing device, the device comprising:
the asynchronous task writing module is used for writing the asynchronous tasks into a task queue and a task data table respectively when receiving an asynchronous task request, and the asynchronous tasks in the task queue are sequentially taken out and executed according to a predefined priority;
the asynchronous task execution module is used for taking out a target task to be executed currently from the task queue through a main thread and distributing sub threads from a predefined thread pool to execute the target task;
and the asynchronous task retry module extracts the target task from the task data table and rewrites the target task into the task queue if the target task fails to be executed.
9. A computer device, comprising:
a memory and a processor in communication with each other, the memory having stored therein computer instructions which, upon execution, cause the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of any one of claims 1 to 7.
CN202310699683.3A 2023-06-13 2023-06-13 Asynchronous task processing method and device, computer equipment and storage medium Pending CN116680055A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310699683.3A CN116680055A (en) 2023-06-13 2023-06-13 Asynchronous task processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310699683.3A CN116680055A (en) 2023-06-13 2023-06-13 Asynchronous task processing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116680055A true CN116680055A (en) 2023-09-01

Family

ID=87790589

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310699683.3A Pending CN116680055A (en) 2023-06-13 2023-06-13 Asynchronous task processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116680055A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117076158A (en) * 2023-09-28 2023-11-17 荣耀终端有限公司 Broadcast distribution processing method and related equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117076158A (en) * 2023-09-28 2023-11-17 荣耀终端有限公司 Broadcast distribution processing method and related equipment
CN117076158B (en) * 2023-09-28 2024-03-12 荣耀终端有限公司 Broadcast distribution processing method and related equipment

Similar Documents

Publication Publication Date Title
JP6333410B2 (en) Fault processing method, related apparatus, and computer
US8132043B2 (en) Multistage system recovery framework
US8468389B2 (en) Firmware recovery system and method of baseboard management controller of computing device
US8473783B2 (en) Fault tolerance in distributed systems
US10831741B2 (en) Log-shipping data replication with early log record fetching
US20180285216A1 (en) Virtual Machine Recovery Method and Virtual Machine Management Device
CN107016480B (en) Task scheduling method, device and system
US20150033072A1 (en) Monitoring hierarchical container-based software systems
US9535754B1 (en) Dynamic provisioning of computing resources
US8145944B2 (en) Business process error handling through process instance backup and recovery
CN110413432B (en) Information processing method, electronic equipment and storage medium
EP3147797B1 (en) Data management method, node and system for database cluster
CN116680055A (en) Asynchronous task processing method and device, computer equipment and storage medium
US10613922B2 (en) Synchronously generating diagnostic data
CN112637284A (en) Redo log storage method and device, electronic device and storage medium
CN108958965A (en) A kind of BMC monitoring can restore the method, device and equipment of ECC error
CN111782431A (en) Exception processing method, exception processing device, terminal and storage medium
CN113157426B (en) Task scheduling method, system, equipment and storage medium
TWI518680B (en) Method for maintaining file system of computer system
CN114138838A (en) Data processing method and device, equipment and medium
CN115952227A (en) Data acquisition system and method, electronic device and storage medium
CN115499493A (en) Asynchronous transaction processing method and device, storage medium and computer equipment
CN116391177A (en) Prioritized inactive memory device updates
CN110908644B (en) Configuration method and device of state node, computer equipment and storage medium
CN110188008B (en) Job scheduling master-slave switching method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination