CN117311930A - Task scheduling method, device, equipment, storage medium and program product - Google Patents

Task scheduling method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN117311930A
CN117311930A CN202311140354.1A CN202311140354A CN117311930A CN 117311930 A CN117311930 A CN 117311930A CN 202311140354 A CN202311140354 A CN 202311140354A CN 117311930 A CN117311930 A CN 117311930A
Authority
CN
China
Prior art keywords
task
execution
target
failure
shared resource
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
CN202311140354.1A
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202311140354.1A priority Critical patent/CN117311930A/en
Publication of CN117311930A publication Critical patent/CN117311930A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a task scheduling method, a task scheduling device, a task scheduling storage medium and a task scheduling program product. The method comprises the following steps: based on the created timing scheduling task, periodically triggering to acquire the distributed lock; the distributed lock is used for locking the target shared resource; reading a task execution record table from a database under the condition that the distributed lock is successfully acquired; task execution information of executed tasks is recorded in the task execution record table; determining a target task which fails to be executed from executed tasks according to task execution information; and calling the target shared resource to re-execute the target task. By adopting the method, the automatic processing of re-executing the failed task can be realized, and the execution efficiency of the task is further improved.

Description

Task scheduling method, device, equipment, storage medium and program product
Technical Field
The present invention relates to the field of computer technology, and in particular, to a task scheduling method, apparatus, device, storage medium, and program product.
Background
In various scenarios, tasks need to be performed, for example in banking scenarios, including: the method comprises the steps of sending marketing information to clients, generating reports at regular time, sending repayment reminding information at regular time, issuing payroll at regular time and the like. However, task execution fails because of the occurrence of certain disturbing factors, such as network jitter, device failure, data abnormality, and the like.
In the conventional task scheduling method, when a task fails, the failed task can be re-executed only by manually modifying the related information of the task. It is apparent that the conventional task scheduling method has a problem of low execution efficiency.
Therefore, a task scheduling method capable of improving the execution efficiency of a task is needed.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a task scheduling method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the execution efficiency of tasks.
In a first aspect, the present application provides a task scheduling method, where the method includes:
based on the created timing scheduling task, periodically triggering to acquire the distributed lock; the distributed lock is used for locking the target shared resource;
reading a task execution record table from a database under the condition that the distributed lock is successfully acquired; task execution information of executed tasks is recorded in the task execution record table;
determining a target task which fails to be executed from executed tasks according to task execution information;
and calling the target shared resource to re-execute the target task.
In some embodiments, periodically triggering acquisition of a distributed lock based on the created timed scheduled task includes:
based on the created timing scheduling task, performing data writing processing in the distributed lock table;
in the event that data is successfully written to the distributed lock table, a successful acquisition of the distributed lock is determined.
In some embodiments, invoking the target shared resource to re-execute the target task includes:
acquiring the latest execution time and execution failure times of a task corresponding to a target task;
and if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, calling the target shared resource to re-execute the target task.
In some embodiments, if the current time is earlier than the latest execution time of the task and the number of execution failures is less than the preset number, invoking the target shared resource to re-execute the target task includes:
if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, carrying out availability detection on the task data of the target task;
and after the availability detection is passed, calling the target shared resource to re-execute the target task.
In some embodiments, a failure reason field is set in the task execution record table;
if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, the availability detection of the task data of the target task comprises the following steps:
if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, reading the failure reason of the target task from the failure reason field in the task execution record table;
analyzing items to be verified of the target task based on failure reasons;
and detecting the availability of task data of the target task according to the item to be checked.
In some embodiments, the method further comprises: the task execution information comprises a first task execution result; determining a target task with execution failure from executed tasks according to task execution information, wherein the target task comprises the following steps:
if the first task execution result corresponding to the executed task is failure, determining the executed task as a target task of which the execution fails;
the method further comprises the steps of:
calling the target shared resource to re-execute the target task to obtain a second task execution result;
writing a second task execution result into the task execution record table;
and under the condition that the execution result of the second task is failure, updating the execution failure times corresponding to the target task.
In some embodiments, the method further comprises:
and deleting the data written into the distributed lock table under the condition that the target shared resource is called to re-execute the target task, so as to release the target shared resource.
In a second aspect, the present application further provides a task scheduling device, where the device includes:
the acquisition module is used for regularly triggering acquisition of the distributed lock based on the established timing scheduling task; the distributed lock is used for locking the target shared resource;
the reading module is used for reading the task execution record table from the database under the condition that the distributed lock is successfully acquired; task execution information of executed tasks is recorded in the task execution record table;
the determining module is used for determining a target task which fails to be executed from executed tasks according to the task execution information;
and the calling module is used for calling the target shared resource to re-execute the target task.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory in which a computer program is stored and a processor which, when executing the computer program, carries out the steps of the method described above.
In a fourth aspect, the present application also provides a computer-readable storage medium. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method described above.
In a fifth aspect, the present application also provides a computer program product. Computer program product comprising a computer program which, when executed by a processor, implements the steps of the method described above.
According to the task scheduling method, the device, the computer equipment, the storage medium and the computer program product, a failed task re-executing mechanism is provided, specifically, based on the established timing scheduling task, the acquisition of the distributed lock is triggered regularly, under the condition that the distributed lock is successfully acquired, a task execution record table is read from a database, a target task which is failed to execute is determined from executed tasks according to task execution information in the task execution record table, and the target shared resource locked by the distributed lock is called to re-execute the target task, so that the automatic processing of re-executing the failed task is realized, and the execution efficiency of the task is improved. In addition, under the condition that the distributed lock is successfully acquired, the target shared resource locked by the distributed lock is called to re-execute the target task, so that a plurality of tasks cannot access the same shared resource at the same time, the mutual exclusivity of different tasks on the access of the shared resource can be ensured, and the problem of resource conflict is avoided.
Drawings
FIG. 1 is a flow diagram of a task scheduling method in some embodiments;
FIG. 2 is a flow chart of a task scheduling method according to other embodiments;
FIG. 3 is a block diagram of a task scheduler in some embodiments;
FIG. 4 is a block diagram of the structure of a calling module in some embodiments;
FIG. 5 is an internal block diagram of a computer device in some embodiments;
fig. 6 is an internal structural view of the computer device in other embodiments.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
In some embodiments, as shown in fig. 1, a task scheduling method is provided, and this embodiment is applied to a terminal for illustration by using the method. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like.
It will be appreciated that the method may also be applied to a server, and may also be applied to a system comprising a terminal and a server, and implemented by interaction of the terminal and the server. In this embodiment, the method includes the steps of:
step 101, based on the created timing scheduling task, periodically triggering to acquire the distributed lock; the distributed lock is used to lock the target shared resource.
The timing scheduling task refers to a task which is automatically executed according to a certain time interval or a specific time point. It can be understood that, because the task execution process is inevitably affected by network jitter, equipment failure, data abnormality and other interference factors, a special timing scheduling task is set to trigger the failed task to re-execute.
Optionally, the terminal creates a timing task and triggers acquisition of the distributed lock periodically based on the created timing task, i.e. triggers the operation of acquiring the distributed lock at a certain time interval or at a specific time point.
The target shared resource is a resource that is commonly available for use by multiple tasks. The target shared resource may be a physical resource or a software resource.
Alternatively, the target shared resource may be a server resource.
102, under the condition that the distributed lock is successfully acquired, reading a task execution record table from a database; the task execution record table records task execution information of executed tasks.
It can be understood that the task execution information of the executed task is recorded through a special task execution record table, and the task execution condition and performance index can be known through statistics and analysis of the task execution record table.
The task execution information is used for representing the execution condition of the task. The task execution information includes at least one of a task name, a task latest execution time, a task execution result, a number of execution failures, or a failure cause. The task execution results include failure or success. It will be appreciated that each task is executed once, and the task execution information during task execution is recorded in the task execution record table.
In some embodiments, the task name and task latest execution time are recorded in a task base information table. The task execution result, the failed times or the failure reasons are recorded in a task execution record table.
Optionally, in the case that the terminal successfully acquires the distributed lock, that is, the terminal can freely access and operate the protected target shared resource, while other terminals will be blocked or wait during the period, and cannot acquire the same distributed lock, the task execution record table is read from the database based on the acquired target shared resource.
And step 103, determining a target task which fails to be executed from the executed tasks according to the task execution information.
Optionally, when the task execution information includes a task execution result, if the first task execution result corresponding to the executed task is failure, the executed task is determined to be the target task of the failure.
Optionally, when the task execution information includes a failure cause, it is determined whether the executed task has a corresponding failure cause. If the executed task has a corresponding failure reason, the executed task is determined to be the target task of the failure. It can be understood that only the failed task has the failure cause recorded, so that whether the executed task fails to execute can be judged according to whether the executed task has the corresponding failure cause.
Optionally, a failure reason field is set in the task execution record table, and determining, according to the task execution information, a target task with execution failure from the executed tasks includes: extracting a failure reason field in a task execution record table; and determining the failure reason of the executed task according to the corresponding relation between the failure reason field and the failure reason. And determining the executed task corresponding to the field with the failure reason as a target task with the failure.
For example, the failure cause field may be set to 001, and the corresponding failure cause is incomplete data; the failure reason field is set to 002, and the corresponding failure reason is that the data is invalid; the failure reason field is set to 003, and the corresponding failure reason is network connection failure. It should be noted that the present embodiment is only for illustration and is not intended to limit the present application.
Optionally, if it is determined that there is no task with execution failure from the executed tasks according to the task execution information, step 101 is executed again at a certain time interval or at a specific time point without processing.
Step 104, calling the target shared resource to re-execute the target task.
Optionally, before invoking the target shared resource to re-execute the target task, it is determined whether the target task satisfies an executable condition. And calling the target shared resource to re-execute the target task under the condition that the target task meets the executable condition.
Optionally, the executable condition includes at least one of a current time being earlier than a latest execution time of the task, a number of execution failures of the target task being less than a preset number of times, or availability of task data of the target task.
According to the task scheduling method, a failed task re-executing mechanism is provided, specifically, based on the established timing task scheduling, the distributed lock is triggered and acquired in a timing mode, under the condition that the distributed lock is successfully acquired, a task execution record table is read from a database, a target task which is failed to execute is determined from executed tasks according to task execution information in the task execution record table, and the target shared resource locked by the distributed lock is called to re-execute the target task, so that automatic re-execution processing of the failed task is realized, and further the execution efficiency of the task is improved.
In addition, under the condition that the distributed lock is successfully acquired, the target shared resource locked by the distributed lock is called to re-execute the target task, so that a plurality of tasks cannot access the same shared resource at the same time, the mutual exclusivity of different tasks on the access of the shared resource can be ensured, and the problem of resource conflict is avoided.
In some embodiments, periodically triggering acquisition of a distributed lock based on the created timed scheduled task includes: based on the created timing scheduling task, performing data writing processing in the distributed lock table; in the event that data is successfully written to the distributed lock table, a successful acquisition of the distributed lock is determined.
The distributed lock table is a table structure used in a distributed system and is used for managing and controlling a lock mechanism for concurrently accessing shared resources. The distributed lock table stores lock records for a plurality of distributed locks. The lock record includes the name of the lock, the time of locking, etc.
Optionally, based on the created timing scheduling task, performing write data processing into the distributed lock table, including: writing a lock record into the distributed lock table based on the created timing scheduling task; after the data is successfully written into the distributed lock table, the lock record is queried again, and whether the lock record is successfully written is judged. And under the condition that the writing lock record in the distributed lock table is inquired, confirming that the data is successfully written in the distributed lock table.
In the above embodiment, whether the distributed lock is acquired is determined by writing data into the distributed lock table, and only one task can acquire the lock by a mechanism of the distributed lock, so that the condition that the same shared resource is accessed by a plurality of tasks can be avoided, and the problem of resource conflict is avoided.
In some embodiments, invoking the target shared resource to re-execute the target task includes: acquiring the latest execution time and execution failure times of a task corresponding to a target task; and if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, calling the target shared resource to re-execute the target task.
The current time is the time when the distributed lock is successfully acquired.
The latest execution time of a task is the deadline by which the task must be executed. It will be appreciated that the latest execution time is determined based on business requirements or constraints. If the current time is equal to or later than the latest execution time of the task, the obtained execution result is meaningless and the waste of shared resources is caused.
The execution failure times are times when the execution result of the target task is failed before the current time.
Optionally, the target task is not re-executed when any of the following conditions is met:
if the current time is later than or equal to the latest execution time of the task;
if the execution failure times are greater than or equal to the preset times.
It can be appreciated that, because the shared resources are limited, when the number of execution failures of the target task is greater than or equal to the preset number of times, the target task is not re-executed, so as to save the shared resources.
In the above embodiment, when the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, the target shared resource is called to re-execute the target task, so that the shared resource can be saved.
In some embodiments, if the current time is earlier than the latest execution time of the task and the number of execution failures is less than the preset number, invoking the target shared resource to re-execute the target task includes: if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, carrying out availability detection on the task data of the target task; and after the availability detection is passed, calling the target shared resource to re-execute the target task.
It will be appreciated that the failure cause of the failure of the execution of the target task includes the unavailability of the task data of the target task. Therefore, before the target shared resource is called to re-execute the target task, the availability detection is required to be carried out on the task data of the target task, and after the availability detection is passed, the target shared resource is called to re-execute the target task, so that the waste of the shared resource is avoided.
In some embodiments, if the current time is earlier than the latest execution time of the task and the number of execution failures is less than a preset number of times, the performing the availability detection on the task data of the target task includes: if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, analyzing a to-be-checked item of the target task from a failure reason field in a task execution record table; and detecting the availability of task data of the target task according to the item to be checked.
In some embodiments, a failure reason field is set in the task execution record table; if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, the availability detection of the task data of the target task comprises the following steps: if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, reading the failure reason of the target task from the failure reason field in the task execution record table; analyzing items to be verified of the target task based on failure reasons; and detecting the availability of task data of the target task according to the item to be checked.
The item to be checked is a matter for checking whether task data of the target task has availability. The item to be verified includes at least one of data integrity or data validity.
Optionally, reading the failure reason of the target task from the failure reason field in the task execution record table includes: and determining the failure reason of the executed task according to the corresponding relation between the failure reason field and the failure reason in the task execution record table.
To facilitate understanding, the process of obtaining the items to be verified for the target task is illustrated. The failure reason field is set to 001, and the corresponding failure reason is incomplete data; and setting the failure reason field to 002, wherein the corresponding failure reason is invalid, and analyzing the data integrity and the data validity of the items to be checked of the target task based on the failure reason. That is, the task data of the target task is subjected to data integrity detection and data validity detection.
In the above embodiment, the failure reason of the target task is read from the failure reason field in the task execution record table, the item to be checked of the target task is analyzed based on the failure reason, and the availability detection is performed on the task data of the target task according to the item to be checked, so that the occurrence of the situation that the target task fails to execute again due to the availability problem can be avoided.
In some embodiments, the method further comprises: the task execution information comprises a first task execution result; determining a target task with execution failure from executed tasks according to task execution information, wherein the target task comprises the following steps: if the first task corresponding to the executed task fails in execution result, the executed task is determined to be the target task of the execution failure. Calling the target shared resource to re-execute the target task to obtain a second task execution result; writing a second task execution result into the task execution record table; and under the condition that the execution result of the second task is failure, updating the execution failure times corresponding to the target task.
The first task execution result is a task execution result recorded in a task execution record table before the target task is re-executed. The second task execution result is a task execution result obtained after re-executing the task. It will be appreciated that the first task execution result and the second task execution result are merely used to distinguish between task execution results obtained before re-executing the target task and after re-executing the task.
Optionally, updating the execution failure times corresponding to the target task includes: and adding 1 to the execution failure times corresponding to the target task in the task execution record table.
Optionally, if the second task execution result is failure, writing a failure reason corresponding to the second task execution result into the task execution record table.
Optionally, writing the second task execution result in the task execution record table includes: if the second task execution result is successful, the task execution result corresponding to the target task is updated to be successful.
In the above embodiment, the second task execution result is written into the task execution record table, and if the second task execution result is failure, the execution failure number corresponding to the target task is updated, so that the execution condition of the target task can be updated in time.
In some embodiments, the method further comprises: and deleting the data written into the distributed lock table under the condition that the target shared resource is called to re-execute the target task, so as to release the target shared resource.
It can be understood that under the condition that the target shared resource is called to re-execute the target task, the target shared resource can be ensured to be normally released by deleting the data in the distributed lock table, and long-time occupation and waste of the target shared resource are avoided, so that the utilization efficiency of the resource is improved.
In some embodiments, as shown in fig. 2, a flow chart of another task scheduling method is provided, and the method is applied to a terminal or a server for illustration, and includes the following steps:
step 201, based on the created timing scheduling task, periodically triggering to acquire the distributed lock; the distributed lock is used to lock the target shared resource.
Optionally, a timed scheduling task is created based on quatertz.
The quatertz is an open source task scheduling framework written by Java, and is mainly used for executing timing scheduling tasks by setting task execution rules through triggers and controlling the operation time of the jobs.
Optionally, based on the created timed scheduled task, periodically triggering acquisition of the distributed lock, including: based on the created timing scheduling task, performing data writing processing in the distributed lock table; under the condition that data is successfully written into the distributed lock table, determining that the distributed lock is successfully acquired; in the event that the data is not successfully written to the distributed lock table, a failure to acquire the distributed lock is determined.
Step 202, judging whether the distributed lock is successfully acquired. If yes, go to step 203; if not, step 213 is performed.
Step 203, reading a task execution record table from a database; the task execution record table records task execution information of executed tasks.
Optionally, reading the task execution record table from the database includes: and reading each record in the task execution record table in turn to obtain the task execution information of the executed task.
The task execution information comprises at least one of task name, task latest execution time, task execution result, execution failure times or failure reasons
Step 204, determining whether a target task with execution failure exists in the executed tasks according to the task execution information. If yes, go to step 205. If not, go to step 212.
Optionally, the task execution information includes a first task execution result; determining a target task with execution failure from executed tasks according to task execution information, wherein the target task comprises the following steps: if the first task corresponding to the executed task fails in execution result, the executed task is determined to be the target task of the execution failure.
It should be noted that, when there are multiple executed tasks in the task execution record table, for each executed task, a step of determining whether the executed task is a target task of execution failure according to the task execution information is executed.
Step 205, judging whether the current time is earlier than the latest execution time of the target task. If yes, go to step 206; if not, go to step 212.
Step 206, judging whether the execution failure times of the target task are smaller than the preset times. If yes, go to step 207; otherwise, step 212 is performed.
Step 207, judging whether the task data of the target task passes the availability detection. If yes, go to step 208; if not, go to step 212.
Optionally, the availability detection of the task data of the target task includes: reading the failure reason of the target task from the failure reason field in the task execution record table; analyzing items to be verified of the target task based on failure reasons; and detecting the availability of task data of the target task according to the item to be checked.
And step 208, calling the target shared resource to re-execute the target task to obtain a second task execution result.
Step 209, determining whether the second task execution result is successful. If yes, go to step 210; if not, go to step 211.
Step 210, updating the task execution result corresponding to the target task to be successful.
Step 211, updating the execution failure times and the failure reasons corresponding to the target task.
In the event that the target shared resource is called to re-execute the target task, step 212 is performed.
Step 212, deleting the data written into the distributed lock table to release the target shared resource.
Step 213, end.
According to the task scheduling method, a failed task re-executing mechanism is provided, specifically, based on the established timing task scheduling, the distributed lock is triggered and acquired in a timing mode, under the condition that the distributed lock is successfully acquired, a task execution record table is read from a database, a target task which is failed to execute is determined from executed tasks according to task execution information in the task execution record table, and the target shared resource locked by the distributed lock is called to re-execute the target task, so that automatic re-execution processing of the failed task is realized, and further the execution efficiency of the task is improved. In addition, under the condition that the distributed lock is successfully acquired, the target shared resource locked by the distributed lock is called to re-execute the target task, so that a plurality of tasks cannot access the same shared resource at the same time, the mutual exclusivity of different tasks on the access of the shared resource can be ensured, and the problem of resource conflict is avoided.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a task scheduling device for realizing the task scheduling method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of one or more task scheduling devices provided below may refer to the limitation of the task scheduling method hereinabove, and will not be repeated herein.
In some embodiments, as shown in fig. 3, there is provided a task scheduling device, including: an acquisition module 301, a reading module 302, a determination module 303 and a calling module 304, wherein:
an acquisition module 301, configured to periodically trigger acquisition of a distributed lock based on the created timing scheduling task; the distributed lock is used to lock the target shared resource.
A reading module 302, configured to read a task execution record table from a database in case of successfully acquiring the distributed lock; the task execution record table records task execution information of executed tasks.
And the determining module 303 is used for determining a target task which fails to be executed from the executed tasks according to the task execution information.
And the calling module 304 is used for calling the target shared resource to re-execute the target task.
In some embodiments, the obtaining module 301 is configured to perform write data processing into the distributed lock table based on the created timing scheduling task; in the event that data is successfully written to the distributed lock table, a successful acquisition of the distributed lock is determined.
In some embodiments, the calling module 304 is configured to obtain a latest execution time and execution failure times of a task corresponding to the target task; and if the current time is earlier than the latest execution time of the task and the execution failure times are less than the preset times, calling the target shared resource to re-execute the target task.
In some embodiments, the calling module 304 is specifically configured to perform availability detection on task data of the target task if the current time is earlier than the latest execution time of the task and the execution failure number is less than a preset number; and after the availability detection is passed, calling the target shared resource to re-execute the target task.
In some embodiments, a failure reason field is set in the task execution record table; as shown in fig. 4, there is provided a block diagram of the call module 304, which includes a reading unit 304a, an analyzing unit 304b, and a detecting unit 304c, wherein:
and a reading unit 304a, configured to read the failure reason of the target task from the failure reason field in the task execution record table if the current time is earlier than the latest execution time of the task and the number of execution failures is less than the preset number.
And an analysis unit 304b, configured to analyze the item to be verified of the target task based on the failure cause.
And the detecting unit 304c is configured to perform availability detection on task data of the target task according to the item to be verified.
In some embodiments, the task execution information includes a first task execution result; the determining module 303 is configured to determine the executed task as a target task for executing the failure if the first task corresponding to the executed task fails.
In some embodiments, the calling module 304 is further configured to call the target shared resource to re-execute the target task to obtain a second task execution result; writing a second task execution result into the task execution record table; and under the condition that the execution result of the second task is failure, updating the execution failure times corresponding to the target task.
In some embodiments, the calling module 304 is further configured to delete the data written to the distributed lock table to release the target shared resource if the target shared resource is called to re-execute the target task.
The respective modules in the task scheduling device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In some embodiments, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing relevant data required for implementing the task scheduling method. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a task scheduling method.
In some embodiments, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a task scheduling method. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structures shown in fig. 5 or 6 are merely block diagrams of portions of structures related to the aspects of the present application and are not intended to limit the computer devices to which the aspects of the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or may have a different arrangement of components.
In some embodiments, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, implements the steps of the method embodiments described above.
In some embodiments, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to comply with the related laws and regulations and standards of the related countries and regions.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A method of task scheduling, the method comprising:
based on the created timing scheduling task, periodically triggering to acquire the distributed lock; the distributed lock is used for locking the target shared resource;
reading a task execution record table from a database under the condition that the distributed lock is successfully acquired; task execution information of executed tasks is recorded in the task execution record table;
determining a target task which fails to be executed from the executed tasks according to the task execution information;
and calling the target shared resource to re-execute the target task.
2. The method of claim 1, wherein the periodically triggering acquisition of the distributed lock based on the created timed scheduled task comprises:
based on the created timing scheduling task, performing data writing processing in the distributed lock table;
and under the condition that the data is successfully written into the distributed lock table, determining that the distributed lock is successfully acquired.
3. The method of claim 1, wherein the invoking the target shared resource to re-execute the target task comprises:
acquiring the latest execution time and execution failure times of the task corresponding to the target task;
and if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, calling the target shared resource to re-execute the target task.
4. The method of claim 3, wherein invoking the target shared resource to re-execute the target task if the current time is earlier than the latest execution time of the task and the execution failure number is less than a preset number of times comprises:
if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, carrying out availability detection on the task data of the target task;
and after the availability detection is passed, calling the target shared resource to re-execute the target task.
5. The method according to claim 4, wherein a failure cause field is set in the task execution record table;
and if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, performing availability detection on the task data of the target task, including:
if the current time is earlier than the latest execution time of the task and the execution failure times are smaller than the preset times, reading the failure reason of the target task from the failure reason field in the task execution record table;
analyzing a to-be-verified item of the target task based on the failure reason;
and detecting the availability of the task data of the target task according to the item to be checked.
6. A method according to claim 3, characterized in that the method further comprises: the task execution information comprises a first task execution result; the determining the target task with the execution failure from the executed tasks according to the task execution information comprises the following steps:
if the first task execution result corresponding to the executed task is failure, determining the executed task as a target task with failed execution;
the method further comprises the steps of:
calling the target shared resource to re-execute the target task to obtain a second task execution result;
writing a second task execution result into the task execution record table;
and under the condition that the execution result of the second task is failure, updating the execution failure times corresponding to the target task.
7. The method according to any one of claims 1 to 6, further comprising:
and deleting the data written into the distributed lock table under the condition that the target shared resource is called to re-execute the target task, so as to release the target shared resource.
8. A task scheduling device, the device comprising:
the acquisition module is used for regularly triggering acquisition of the distributed lock based on the established timing scheduling task; the distributed lock is used for locking the target shared resource;
the reading module is used for reading the task execution record table from the database under the condition that the distributed lock is successfully acquired; task execution information of executed tasks is recorded in the task execution record table;
the determining module is used for determining a target task which fails to be executed from the executed tasks according to the task execution information;
and the calling module is used for calling the target shared resource to re-execute the target task.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202311140354.1A 2023-09-05 2023-09-05 Task scheduling method, device, equipment, storage medium and program product Pending CN117311930A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311140354.1A CN117311930A (en) 2023-09-05 2023-09-05 Task scheduling method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311140354.1A CN117311930A (en) 2023-09-05 2023-09-05 Task scheduling method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN117311930A true CN117311930A (en) 2023-12-29

Family

ID=89245353

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311140354.1A Pending CN117311930A (en) 2023-09-05 2023-09-05 Task scheduling method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN117311930A (en)

Similar Documents

Publication Publication Date Title
CN109997126B (en) Event driven extraction, transformation, and loading (ETL) processing
CN102541661B (en) Realize the method and apparatus of wait on address synchronization interface
WO2019037617A1 (en) Data transaction processing method, device, and electronic device
CN114925084B (en) Distributed transaction processing method, system, equipment and readable storage medium
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
CN109614270A (en) Data read-write method, device, equipment and storage medium based on Hbase
CN116561137A (en) Transaction processing method, device, computer equipment and storage medium
US8539512B2 (en) Transactional environments for event and data binding handlers
CN114780497B (en) Batch file processing method, apparatus, computer device, medium, and program product
CN117311930A (en) Task scheduling method, device, equipment, storage medium and program product
CN114924911B (en) Method, device, equipment and storage medium for backing up effective data of Windows operating system
CN116339626A (en) Data processing method, device, computer equipment and storage medium
CN114036564A (en) Construction method of private data derivative graph
US20080222321A1 (en) Method and system for tracking device driver requests
CN114756293A (en) Service processing method, device, computer equipment and storage medium
CN117667421A (en) Method, device, computer equipment and storage medium for realizing distributed lock
CN116432229A (en) Browser screen capture prevention method, device, computer equipment, medium and program product
CN116204291A (en) Task processing method, device, computer equipment and storage medium
US20230054774A1 (en) User constrained process mining
CN117591260A (en) Task execution method, device, equipment, storage medium and program product
CN117370948A (en) Information display method, information display device, terminal and computer readable storage medium
CN117891794A (en) Log generation method and device, terminal equipment and storage medium
CN118069700A (en) Data verification method, device, computer equipment and storage medium
CN114138196A (en) Power system data storage method and device, computer equipment and storage medium
CN117635290A (en) Payment resource business data inventory processing method and device and computer equipment

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