Task batch triggering method, device and triggering system based on database
By creating batches in the triggering system and combining batch locks and global locks, the performance degradation caused by resource lock conflicts in the triggering system is resolved, achieving high concurrency and efficient task execution.
Patent Information
- Application Number
- CN202511177949.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-10-28
AI Technical Summary
In existing technologies, the performance and concurrency of triggering systems are limited due to resource lock conflicts during large-scale concurrent task scheduling, which fails to meet the system's performance and concurrency requirements.
By creating multiple empty batches in the triggering system, dividing the batches according to the creation time of the call record, and using a combination of batch locks and global locks, the parallel processing of the nodes is controlled, the locking range is reduced, and parallel processing between call records with different lifecycles is achieved.
It improves the concurrency of data processing, solves the performance degradation problem caused by resource lock conflicts, and ensures accurate triggering and efficient execution of tasks.
Smart Images

Figure CN120849148A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of task triggering technology, and more specifically, to a database-based method, apparatus, computer-readable storage medium, and triggering system for batch task triggering. Background Technology
[0002] The triggering system is used to initiate a scheduled task after the timed triggering conditions are met. It is usually deployed in a distributed cluster, where multiple nodes in the cluster need to compete for the right to trigger the task at a timed time (i.e., lock contention) during data operations.
[0003] Traditional triggering systems typically employ the Quartz framework. The core design principle of this framework is to use global locks to control task concurrency and consistency, ensuring that tasks are triggered accurately as planned in a multi-node cluster environment, avoiding duplicate execution or conflicts. However, this approach, which relies excessively on global locks to guarantee accurate task triggering, severely restricts the performance and efficiency of the triggering system when dealing with large-scale concurrent task scheduling, as only one node in the cluster can perform task operations at a time.
[0004] In existing technologies, segmented locking is used to improve the global lock of the Quartz framework. This is achieved by dividing resource access requests into multiple segments and setting a lock for each segment, or by differentiating read and write operations to reduce resource access conflicts, thereby improving concurrent processing capabilities.
[0005] However, segmented locks require a pre-determined number of segments, which directly limits the system's concurrency. In systems with large data throughput, resource lock contention still exists, failing to meet the system's performance and concurrency requirements. Summary of the Invention
[0006] The main objective of this application is to provide a database-based task batch triggering method, apparatus, computer-readable storage medium, and triggering system, so as to at least solve the problem of performance degradation caused by resource lock conflicts between different nodes in the prior art triggering system.
[0007] To achieve the above objectives, according to one aspect of this application, a database-based task batch triggering method is provided, comprising: creating multiple empty batches in a triggering system and adding call records to the corresponding empty batches to obtain multiple creation batches; synchronously locking the call records of each creation batch by calling multiple creation batch locks to obtain multiple first objects; controlling multiple nodes to synchronously update the status of the first objects locked by each creation batch lock to "in effect" and release all creation batch locks; locking all first objects in effect by calling a global lock to obtain second objects; controlling multiple nodes to compete for the global lock; controlling the target node that has successfully competed for the lock to bind the second objects that have reached a predetermined execution time to the same execution batch, changing the status of the second objects in the execution batch to "bound" and releasing the global lock; synchronously locking the second objects in different execution batches with the status of "bound" by calling multiple execution batch locks to obtain third objects; controlling multiple target nodes to synchronously perform task calculations on the third objects in the corresponding execution batches and changing the status of the third objects to "in call"; when the status of all third objects in the execution batch is "in call", changing the status of each third object to "call completed" and releasing the execution batch lock to complete the triggering.
[0008] Optionally, multiple empty batches are created in the triggering system, and call records are added to the corresponding empty batches to obtain multiple creation batches, including: when a batch creation instruction is received, at least one empty batch is created in the triggering system; call records carrying the same creation batch code are traversed and assigned to the same empty batch to obtain creation batches.
[0009] Optionally, controlling the target node that passes the lock acquisition process to bind the second object that has reached the predetermined execution time to the same execution batch includes: if the second object that has reached the predetermined execution time is greater than or equal to a second threshold, dividing the second object that has reached the predetermined execution time into multiple lockable record groups, wherein the number of call records in each lockable record group is less than or equal to the second threshold; if the number of second objects that have reached the predetermined execution time is less than the second threshold, adding the second object that has reached the predetermined execution time to the same lockable record group; and binding the call records in each lockable record group to the same execution batch code to obtain the execution batch.
[0010] Optionally, after changing the state of each third object to "call completed" and releasing the execution batch lock, the method further includes: if the time interval between the scheduled execution time of the call record and the current time is greater than a second preset duration and the state is "binding", locking the call record by submitting a global lock twice to obtain a fourth object; changing the state of the fourth object to "execution exception", modifying the scheduled execution time to the current time and releasing the global lock; calling multiple execution batch locks to synchronously lock the fourth objects of different execution batches with the state of "execution exception" to obtain a fifth object; controlling multiple target nodes to synchronously perform task calculations on the fifth objects of the corresponding execution batches and changing the state of the fifth objects to "calling"; if the state of all fifth objects in the execution batch is "calling", changing the state of each fifth object to "call completed" and releasing the execution batch lock.
[0011] Optionally, after changing the status of each third object to "call completed" and releasing the execution batch lock, the method further includes: traversing all call records; if the time interval between the creation time of the call record and the current time is greater than a third preset time interval and the status is "initialized", locking the call record with a timeout global lock to obtain the sixth object; the control node changes the status of the sixth object to "uncommitted" and releases the timeout global lock; if the creation time of the call record is greater than a fourth preset time interval and the status is "effective", the control target node locks the call record with an exception global lock to obtain the seventh object; changing the status of the seventh object to "binding exception" and releasing the exception global lock; every fifth preset time interval, transferring the call records with the corresponding statuses of "call completed", "execution exception", "uncommitted", and "binding exception" to a preset location in the database.
[0012] Optionally, controlling the target node to bind the second object that has reached the predetermined execution time to the same execution batch includes: controlling the target node to traverse the second object, and adding the second object to the record group to be bound when the second object reaches the predetermined execution time; controlling the target node to randomly generate an execution batch code; and controlling the target node to bind the second object in the record group to be bound to the execution batch code.
[0013] Optionally, controlling multiple target nodes to synchronously perform task computation on the third objects of the corresponding execution batch and change the status of the third objects to "in progress" includes: obtaining the execution batch code, adding the call records carrying the same execution batch code to the same set to obtain multiple call record sets; sending call requests to the target nodes corresponding to each call record set, the call requests being used to request the execution ID of the target nodes; receiving the execution IDs sent by each target node and binding the execution IDs with all the third objects in the corresponding call record sets; controlling multiple target nodes to capture the third objects carrying the corresponding execution IDs and change the status of the third objects to "in progress"; and controlling each target node to perform task computation based on the corresponding third object.
[0014] According to another aspect of this application, a database-based task batch triggering device is provided. The device includes: a first execution unit, configured to divide the call records into batches according to their creation time to obtain multiple creation batches, and synchronously lock the call records of each creation batch by calling multiple creation batch locks to obtain multiple first objects; a second execution unit, configured to control multiple nodes to synchronously update the status of the first objects locked by each creation batch lock to "in effect" and release all creation batch locks; a third execution unit, configured to lock all the first objects in effect by calling a global lock to obtain second objects, and control multiple nodes to compete for the global lock; and a fourth execution unit, configured to control the lock competition. The target node binds the second object that has reached the predetermined execution time to the same execution batch, changes the state of the second object in the execution batch to "binding", and releases the global lock. The fifth execution unit calls multiple execution batch locks to simultaneously lock the second objects in different execution batches that are in the "binding" state, thus obtaining the third object. The sixth execution unit controls multiple target nodes to synchronously perform task calculations on the third objects in the corresponding execution batches and changes the state of the third objects to "in call". The seventh execution unit changes the state of each third object to "call completed" and releases the execution batch lock when all third objects in the execution batch are in the "in call" state, thus completing the triggering.
[0015] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0016] According to another aspect of this application, a triggering system is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a method for performing any one of them.
[0017] Applying the technical solution of this application, in the above-mentioned database-based batch task triggering method, firstly, batches are divided according to the creation time of the call records to obtain multiple creation batches. Multiple creation batch locks are invoked synchronously to lock the call records of each creation batch, resulting in multiple first objects. Then, multiple nodes are controlled to synchronously update the status of the first objects locked by each creation batch lock to "in effect" and release all creation batch locks. Afterwards, a global lock is invoked to lock all the first objects in effect, resulting in second objects. Multiple nodes are controlled to compete for the global lock. Then, the target node that has successfully competed for the lock binds the second objects that have reached the predetermined execution time to the same execution batch, changes the status of the second objects in the execution batch to "bound," and releases the global lock. Afterwards, multiple execution batch locks are invoked synchronously to lock the second objects in different execution batches that are in the "bound" state, resulting in third objects. Then, multiple target nodes are controlled to synchronously perform task calculations on the third objects in the corresponding execution batches and change the status of the third objects to "in effect." Finally, when the status of all third objects in the execution batch is "in effect," the status of each third object is changed to "call completed," and the execution batch lock is released, completing the triggering. To address the issue that existing technologies use global locks to lock all call records at different lifecycle stages, resulting in only one node processing data at a time, this application divides different row locks according to the lifecycle of the call record (e.g., in effect, in binding, and in call). Even with a global lock, only call records in effect are locked, while other nodes can still perform parallel processing of call record creation and task computation. By reducing the locking scope of row locks, the concurrency of data processing is improved. Furthermore, for call records at the same lifecycle, this application uses batch locks for locking, locking in batches of creation or execution, enabling parallel processing of different nodes among call records at the same lifecycle, further improving the concurrency of data processing and solving the performance degradation problem caused by resource lock conflicts between different nodes in the existing technology. Attached Figure Description
[0018] Figure 1 A hardware structure block diagram of a mobile terminal for a database-based task batch triggering method provided in an embodiment of this application is shown.
[0019] Figure 2 A flowchart illustrating a database-based batch task triggering method according to an embodiment of this application is shown.
[0020] Figure 3 A flowchart illustrating a specific database-based task batch triggering method according to an embodiment of this application is shown.
[0021] Figure 4A schematic diagram of a call record creation process according to an embodiment of this application is shown;
[0022] Figure 5 A structural block diagram of a database-based task batch triggering device is shown according to an embodiment of this application.
[0023] The above figures include the following reference numerals:
[0024] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] As described in the background section, existing locking mechanisms suffer from resource lock contention when facing high-data-throughput concurrent scenarios, which limits the concurrency and triggering efficiency of the triggering system. To address the performance degradation caused by resource lock conflicts between different nodes in the existing triggering system, embodiments of this application provide a database-based task batch triggering method, apparatus, computer-readable storage medium, and triggering system.
[0029] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0030] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a database-based task batch triggering method according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0031] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the database-based task batch triggering method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0032] This embodiment provides a database-based task batch triggering method that runs on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0033] Figure 2 This is a flowchart of a database-based task batch triggering method according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0034] Step S201: Create multiple empty batches in the triggering system and add the call records to the corresponding empty batches to obtain multiple creation batches. Simultaneously lock the call records of each creation batch by calling multiple creation batch locks to obtain multiple first objects.
[0035] Specifically, if Figure 3 As shown, the aforementioned call records are records left by the external system when initiating a task in the triggering system. These call records include basic information about the computation task, such as creation time and scheduled execution time. Furthermore, an empty batch is created in the triggering system, and the call records are added to the corresponding empty batch, thus obtaining the aforementioned creation batch. To avoid lock contention for the global lock, this application sets up a batch lock for each batch, used to lock all call records within a specific batch, facilitating subsequent batch processing of the call records.
[0036] Step S202: Control multiple nodes to synchronously update the status of the first object locked by each creation batch lock to "in effect" and release all creation batch locks;
[0037] Specifically, if Figure 3 As shown, the distributed triggering system controls each worker node to commit the first object mentioned above, thus enabling the initialized call record to enter the processing flow. After batch processing is complete, the batch creation lock is released to allow subsequent process-related nodes to access the data.
[0038] Step S203: Lock all first objects in effect by calling the global lock to obtain the second object, and control multiple nodes to compete for the lock when calling the global lock;
[0039] Specifically, if Figure 3 As shown, to ensure that the execution batch does not cause chaos, this application sets up a global lock to lock all first objects in effect, so as to ensure that only one node can operate on the first object at the same time, thus avoiding concurrency problems across batches.
[0040] Understandably, even with a global lock, it only involves one low-time database operation to call record binding execution batch, while one initialization can bind multiple call records. Therefore, the global lock has little impact on the entire lifecycle process.
[0041] Step S204: Control the target node that has passed the lock snatching to bind the second object that has reached the predetermined execution time to the execution batch, change the state of the second object in the execution batch to "binding", and release the global lock.
[0042] Specifically, if Figure 3 As shown, the second object that has reached the expected start time of the task is grouped, and the grouped second object is updated to be bound, indicating that the task has been assigned to the node that has acquired the lock.
[0043] Step S205: Simultaneously lock the second object of different execution batches in the binding state by calling multiple execution batch locks to obtain the third object;
[0044] Specifically, if Figure 3 As shown, the call records after binding are locked according to the execution batch using execution batch locks. While only one node processes the same data group, different data groups can be executed synchronously by different nodes.
[0045] Step S206: Control multiple target nodes to synchronously perform task calculations on the third object of the corresponding execution batch, and change the status of the third object to "in progress";
[0046] Specifically, if Figure 3 As shown, due to the existence of batch locks, the third object of each execution batch can only be executed by one node at a time. This application divides the batches into multiple batches, which can ensure that, in the presence of the current execution batch, other nodes can also start other execution batches that have arrived at the execution application, thus achieving parallel execution.
[0047] Step S207: If all third objects in the execution batch are in the state of "in call", change the state of each third object to "call completed" and release the execution batch lock to complete the triggering.
[0048] Specifically, if Figure 3 As shown, after all the third objects in the current batch have been invoked, it means that all tasks have been executed. At this time, the status of the call record is changed to call completed, and the batch lock is released to allow subsequent nodes to perform verification and exception handling.
[0049] In this embodiment, firstly, the creation time of the call records is used to divide the data into batches, resulting in multiple creation batches. Multiple creation batch locks are then used to simultaneously lock the call records of each creation batch, resulting in multiple first objects. Next, multiple nodes are controlled to simultaneously update the status of the first objects locked by each creation batch lock to "in effect" and release all creation batch locks. Then, a global lock is used to lock all the first objects in effect, resulting in second objects. Multiple nodes are controlled to compete for the global lock. Next, the target node that successfully competes for the lock binds the second objects that have reached their predetermined execution time to the same execution batch, changes the status of the second objects in the execution batch to "bound," and releases the global lock. Then, multiple execution batch locks are used to simultaneously lock the second objects in different execution batches that are in the "bound" state, resulting in third objects. Next, multiple target nodes are controlled to simultaneously perform task calculations on the third objects in the corresponding execution batches and change the status of the third objects to "in effect." Finally, when the status of all third objects in the execution batch is "in effect," the status of each third object is changed to "call completed," and the execution batch lock is released, completing the triggering process. To address the issue that existing technologies use global locks to lock all call records at different lifecycle stages, resulting in only one node processing data at a time, this application divides different row locks according to the lifecycle of the call record (e.g., in effect, in binding, and in call). Even with a global lock, only call records in effect are locked, while other nodes can still perform parallel processing of call record creation and task computation. By reducing the locking scope of row locks, the concurrency of data processing is improved. Furthermore, for call records at the same lifecycle, this application uses batch locks for locking, locking in batches of creation or execution, enabling parallel processing of different nodes among call records at the same lifecycle, further improving the concurrency of data processing and solving the performance degradation problem caused by resource lock conflicts between different nodes in the existing technology.
[0050] In order to divide the creation batches, in one optional implementation, step S201 above includes:
[0051] Step S2011: Upon receiving a batch creation instruction, create at least one empty batch in the triggering system;
[0052] Specifically, multiple batches are initialized in the trigger system based on the creation instructions input from the outside.
[0053] Step S2012: Traverse the call records and group call records carrying the same creation batch code into the same empty batch to obtain the creation batch.
[0054] Specifically, the batch code is a unique code randomly generated by the external system during the process of triggering system initialization call records to distinguish different batches. By traversing all call records, call records with the same batch code are grouped into the corresponding empty batches, forming multiple batches.
[0055] In one embodiment, before obtaining the batch code, such as Figure 4 As shown, the above method also includes:
[0056] Step S301: Receive a creation request sent by an external system. The creation request is used to instruct the system to generate a creation batch code. The creation batch code is the identity identifier of the calling record.
[0057] Step S302: Parse the creation request to obtain at least one call template code and the scheduled execution time of the call template code. The call template code is used to define the IP address, port number and name of the method to be executed of the node.
[0058] Specifically, the template configuration receives the IP address, port number, and method name to be executed from the external system, and randomly generates a call template code based on the triggering system, storing it in the database. Batch initialization is created, specifying the call template code and the scheduled execution time through the batch initialization interface.
[0059] Step S303: Write the call template code and the scheduled execution time into the database, and generate a batch code;
[0060] Furthermore, based on the template code and the scheduled execution time, a batch code randomly generated by the triggering system is stored in the database.
[0061] Step S304: Create a batch code and send it to an external system and receive a scheduling request from the external system. The scheduling request is used to create a call record in the triggering system.
[0062] Specifically, the batch creation code is sent to the external system through the batch initialization interface mentioned above, and the scheduling request input from the task receiving interface of the external system is received, specifying the batch creation code and the list of custom parameters in the request.
[0063] Step S305: Parse the scheduling request to obtain the batch code and execution parameters. The execution parameters are the parameters that the node needs to call to perform task operations.
[0064] Specifically, the scheduling request is parsed to extract the batch creation code and the list of custom parameters (execution parameters).
[0065] Step S306: Write the execution parameters into the database, and bind the execution parameters with the call template code, the scheduled execution time and the creation batch code according to the creation batch code to obtain the call record and change the status of the call record to initialization.
[0066] Specifically, the triggering system generates a call record for each execution parameter, binds the call record to a batch code and a scheduled execution time, and marks the status as initialized.
[0067] Understandably, before the batch is submitted, an external system can use the batch code to create the batch and add a call record to it within the batch.
[0068] It is understood that, in another embodiment, in order to verify the validity of the request, after receiving the above-mentioned creation request or scheduling request, the method further includes:
[0069] Step S401: Upon receiving a creation request, extract the token from the creation request to obtain the first target token;
[0070] Step S402: Compare the first target token with the second target token in the preset token list in sequence;
[0071] Step S403: If a second target token that matches the first target token exists, determine that the creation request is valid;
[0072] Step S404: If there is no second target token that matches the first target token, determine that the creation request is invalid.
[0073] To enable concurrent execution of the commit operation, in one optional implementation, step S204 further includes:
[0074] Step S2041: If the second object that has reached the predetermined execution time is greater than or equal to the second threshold, the second object that has reached the predetermined execution time is divided into multiple lockable record groups, and the number of call records in each lockable record group is less than or equal to the second threshold.
[0075] Specifically, the second threshold is the number of times the number of called records will cause a decrease in the efficiency of node batch processing. Therefore, this application sets that when the number of called records exceeds the second threshold, the execution batch will be further subdivided into multiple groups of records to be locked, thereby reducing lock contention.
[0076] Step S2042: If the second object that has reached the predetermined execution time is less than the second threshold, add the second object that has reached the predetermined execution time to the same lockable record group.
[0077] Specifically, if the number of call records within an execution batch is small, it can be directly treated as a group of records to be locked without further subdivision.
[0078] Step S2043: Bind the call record in each group of records to be locked to the same execution batch code to obtain the execution batch.
[0079] Through the above embodiments, the granularity of the lock is intelligently adjusted, effectively balancing the relationship between lock contention and lock overhead, achieving high concurrency and high efficiency in task processing. Too many call records being locked simultaneously can lead to performance degradation, as each node needs to wait for the lock to be released before continuing processing. By setting a reasonable "second threshold," this solution can minimize the scope of lock usage while ensuring task correctness, thereby reducing lock holding time and improving the overall system throughput.
[0080] To handle abnormal call logs, in one alternative implementation, after changing the state of each third object to call complete and releasing the execution batch lock, the method further includes:
[0081] Step S501: If the time interval between the scheduled execution time of the call record and the current time is greater than the second preset duration and the status is "binding", the call record is locked by submitting the global lock twice to obtain the fourth object.
[0082] Specifically, the second-commit global lock is a mechanism for handling tasks that have not been executed for a long time, and is used to help trigger the system to identify and reallocate call records that have failed to be executed in a timely manner due to network or other reasons.
[0083] Step S502: Change the state of the fourth object to execution exception, modify the scheduled execution time to the current time, and release the global lock for the second commit.
[0084] Specifically, an execution anomaly indicates that a task failed to start execution within the scheduled time and its execution plan needs to be reassessed.
[0085] Step S503: Invoke multiple execution batch locks to lock the fourth object of different execution batches with the synchronization state of execution exception, and obtain the fifth object;
[0086] Specifically, by executing a batch lock to relock the call record whose status is execution exception, it is ensured that the above call record can be reassigned to the appropriate node for execution.
[0087] Step S504: Control multiple target nodes to synchronously perform task calculations on the fifth object of the corresponding execution batch, and change the status of the fifth object to "in progress";
[0088] Specifically, the reassigned tasks will be marked "in progress," indicating that they are preparing to execute or have already begun.
[0089] Step S505: If the state of all fifth objects in the execution batch is in the process of calling, change the state of each fifth object to the process of calling completed and release the execution batch lock.
[0090] Specifically, once all tasks in an execution batch have restarted execution, its status changes to "call complete".
[0091] The above embodiments enhance the robustness and fault tolerance of the system by introducing a "secondary commit global lock" and an "execution exception" state. In distributed systems, due to factors such as network latency and node failures, tasks may fail to start execution within the scheduled time, leading to task backlog and impacting overall system performance. By periodically checking task status, the system can promptly identify and take remedial measures for tasks that have been "bound" for an extended period without starting execution, such as reallocating nodes and adjusting execution priorities, ensuring that all tasks are effectively processed within a reasonable timeframe.
[0092] In another embodiment, controlling multiple target nodes to synchronously perform task computation on the fifth object corresponding to the execution batch, and changing the state of the fifth object to "in progress," further includes:
[0093] Get the number of resubmissions and increment the number of resubmissions;
[0094] If the number of resubmissions after incrementing is less than the preset value, multiple target nodes will be controlled to synchronously perform task calculations on the fifth object of the corresponding execution batch, and the status of the fifth object will be changed to "in progress".
[0095] If the number of resubmissions after incrementing is greater than or equal to a preset value, the state of the fifth object will be locked as an execution exception.
[0096] To mitigate the database performance overhead caused by abnormally halted call records, in an optional implementation, after changing the state of each third object to "call complete" and releasing the execution batch lock, the method further includes:
[0097] Step S601: Traverse all call records. If the time interval between the creation time of a call record and the current time is greater than the third preset time and the state is initialized, lock the call record with a timeout global lock to obtain the sixth object.
[0098] Specifically, the timeout global lock is used to handle tasks that have been in the initialization state for a long time without being processed, ensuring that the system does not miss any call records.
[0099] In step S602, the control node changes the state of the sixth object to uncommitted and releases the timed-out global lock;
[0100] Specifically, the "not submitted" status indicates that the task has not yet started execution and its execution plan needs to be reconsidered.
[0101] Step S603: If the creation time of the call record is greater than the fourth preset time and the status is active, the control target node locks the call record through an exception global lock to obtain the seventh object;
[0102] Specifically, the exception global lock is used to handle call records that have been in an "active" state for a long time but have not been bound to the execution batch (which may be due to system failure or other abnormal conditions).
[0103] Step S604: Change the state of the seventh object to bound exception and release the exception global lock;
[0104] Specifically, the "binding error" status indicates that the task encountered a problem during the preparation phase and requires further diagnosis and repair.
[0105] Step S605: Every five preset time intervals, the call records with corresponding statuses of call completion, execution exception, uncommitted, and binding exception are transferred to a preset location in the database.
[0106] Specifically, regularly cleaning up and archiving completed or abnormal task records helps maintain the health of the database and reduces the space occupied by invalid data.
[0107] Through the above embodiments, by introducing timeout global locks and exception global locks, effective monitoring and management of task states are achieved, ensuring task integrity and system stability. In distributed systems, task state changes may be affected by various factors, such as network fluctuations, hardware failures, and software errors. This may cause some tasks to remain in a certain state for an extended period, affecting the overall efficiency of the system. By periodically checking task states, for tasks that have not started execution after a preset time or have encountered abnormal situations, the system can take timely measures, such as reallocating nodes, adjusting the execution order, and recording exception logs, to ensure that all tasks are properly handled.
[0108] To achieve the binding of call records with execution batches, in an optional implementation, step S204 above includes:
[0109] Step S2041: Control the target node to traverse the second object. If the second object reaches the predetermined execution time, add the second object to the record group to be bound.
[0110] Specifically, the record group to be bound is the set of tasks that will be bound to the same execution batch.
[0111] Step S2042: Control the target node to randomly generate execution batch codes;
[0112] Specifically, the batch execution code is a unique identifier generated for each execution batch, used to distinguish and track tasks in different batches.
[0113] Step S2043: Control the target node to bind the second object in the record group to be bound to the execution batch code.
[0114] Specifically, by binding tasks to execution batch codes, the system can ensure that tasks within the same execution batch are executed by the same node, thus avoiding concurrency conflicts.
[0115] Through the above embodiments, a unique "execution batch code" is generated for each task that reaches its scheduled execution time, and these codes are bound to the same execution batch. This solution achieves orderly and efficient task execution. This method avoids the problems that may arise from directly using timestamps as batch identifiers, such as timestamp collisions and uncertainties in sorting, thus ensuring accurate task scheduling.
[0116] In order to submit the aforementioned call record, in an optional implementation, step S206 includes:
[0117] Step S2061: Obtain the execution batch code, add the call records carrying the same execution batch code to the same set, and obtain multiple call record sets;
[0118] Specifically, a call record set is a group of tasks belonging to the same execution batch that will be processed by the same node.
[0119] Step S2062: Send a call request to the target node corresponding to each call record set. The call request is used to request the execution ID of the target node.
[0120] Specifically, the execution ID is a unique identifier for the target node when executing a task, used to track and manage the task execution process.
[0121] In practice, the triggering system sends a call request to the task executor of the external system, determines the corresponding method body by the name of the method to be executed, and then asynchronously triggers the execution of the call record of this method through the thread pool.
[0122] Step S2063: Receive the execution ID sent by each target node, and bind the execution ID with all third objects in the corresponding call record set;
[0123] Specifically, by binding tasks to execution IDs, the system can ensure that the results of task execution can be correctly tracked and verified.
[0124] Step S2064: Control multiple target nodes to capture the third object carrying the corresponding execution ID, and change the status of the third object to "in call";
[0125] Specifically, the in-call status indicates that the task is being executed, and the system can begin to monitor its execution progress and results.
[0126] Step S2065: Control each target node to perform task calculations based on the corresponding third object.
[0127] Specifically, task operation refers to executing corresponding business logic, such as data processing, calculation, and querying, based on the type and requirements of the task.
[0128] Through the above embodiments, by binding tasks to the execution IDs of target nodes, this solution achieves transparency and controllability in task execution, improving system scheduling efficiency and task processing accuracy. In distributed systems, tasks may be assigned to multiple nodes for execution. Without an effective binding mechanism, it is difficult to track the execution status of each task and ensure the correctness of task results. By generating a unique "execution ID" for each execution batch and binding it to the task, the system can not only accurately know which tasks are executed by which node, but also collect and summarize the task execution results based on the execution ID for subsequent data analysis and business processing.
[0129] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0130] This application also provides a database-based task batch triggering device. It should be noted that this database-based task batch triggering device can be used to execute the database-based task batch triggering method provided in this application. This device is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0131] The following describes the database-based task batch triggering device provided in the embodiments of this application.
[0132] Figure 5 This is a structural block diagram of a database-based task batch triggering device according to an embodiment of this application. Figure 5 As shown, the device includes:
[0133] The first execution unit 10 is used to create multiple empty batches in the triggering system, add the call records to the corresponding empty batches to obtain multiple creation batches, and call multiple creation batch locks to lock the call records of each creation batch synchronously to obtain multiple first objects;
[0134] The second execution unit 20 is used to control multiple nodes to synchronously update the status of the first object locked by each creation batch lock to "in effect" and release all creation batch locks.
[0135] The third execution unit 30 is used to lock all first objects in effect by calling the global lock, obtain the second object, and control multiple nodes to compete for the lock when calling the global lock.
[0136] The fourth execution unit 40 is used to control the target node that has passed the lock snatching to bind the second object that has reached the predetermined execution time to the same execution batch, change the state of the second object in the execution batch to "bound", and release the global lock.
[0137] The fifth execution unit 50 is used to call multiple execution batch locks to synchronously lock the second objects of different execution batches that are in the binding state, and obtain the third object;
[0138] The sixth execution unit 60 is used to control multiple target nodes to synchronously perform task calculations on the third object of the corresponding execution batch, and change the status of the third object to "in call";
[0139] The seventh execution unit 70 is used to change the state of each third object to "call completed" and release the execution batch lock when all third objects in the execution batch are in the "calling" state, thus completing the trigger.
[0140] In this embodiment, the first execution unit divides the call records into batches based on their creation time, obtaining multiple creation batches. It then calls multiple creation batch locks to simultaneously lock the call records of each creation batch, resulting in multiple first objects. The second execution unit controls multiple nodes to simultaneously update the status of the first objects locked by each creation batch lock to "in effect" and releases all creation batch locks. The third execution unit calls a global lock to lock all effective first objects, obtaining second objects, and controls multiple nodes to compete for the global lock. The fourth execution unit controls the target node that successfully competes for the lock to bind the second objects that have reached their predetermined execution time to the same execution batch, changes the status of the second objects in the execution batch to "bound," and releases the global lock. The fifth execution unit calls multiple execution batch locks to simultaneously lock second objects in different execution batches that are in the "bound" state, obtaining third objects. The sixth execution unit controls multiple target nodes to simultaneously perform task calculations on the third objects in the corresponding execution batches and changes the status of the third objects to "in call." The seventh execution unit, when all third objects in the execution batch are in the "in call" state, changes the status of each third object to "call completed" and releases the execution batch lock, thus completing the triggering process. To address the issue that existing technologies use global locks to lock all call records at different lifecycle stages, resulting in only one node processing data at a time, this application divides different row locks according to the lifecycle of the call record (e.g., in effect, in binding, and in call). Even with a global lock, only call records in effect are locked, while other nodes can still perform parallel processing of call record creation and task computation. By reducing the locking scope of row locks, the concurrency of data processing is improved. Furthermore, for call records at the same lifecycle, this application uses batch locks for locking, locking in batches of creation or execution, enabling parallel processing of different nodes among call records at the same lifecycle, further improving the concurrency of data processing and solving the performance degradation problem caused by resource lock conflicts between different nodes in the existing technology.
[0141] In order to divide the creation batches, in one optional implementation, the first execution unit mentioned above includes:
[0142] The first processing module is used to create at least one empty batch in the triggering system upon receiving a batch creation instruction.
[0143] The second processing module is used to traverse the call records and group call records carrying the same creation batch code into the same empty batch to obtain the creation batch.
[0144] In one embodiment, the above-described apparatus further includes:
[0145] The first acquisition unit is used to receive a creation request sent by an external system before acquiring the creation batch code. The creation request is used to instruct the system to generate a creation batch code, and the creation batch code is the identity identifier of the call record.
[0146] The first processing unit is used to parse the creation request and obtain at least one calling template code and the scheduled execution time of the calling template code. The calling template code is used to define the IP address, port number and name of the method to be executed of the node.
[0147] The generation unit is used to write the call template code and the scheduled execution time into the database and generate the batch code for creation;
[0148] The sending unit is used to send the batch creation code to the external system and receive the scheduling request sent by the external system. The scheduling request is used to create a call record in the triggering system.
[0149] The second processing unit is used to parse the scheduling request to obtain the batch code and execution parameters. The execution parameters are the parameters that the node needs to call to perform task operations.
[0150] The storage unit is used to write execution parameters into the database, and bind the execution parameters with the call template code, the scheduled execution time and the creation batch code according to the creation batch code to obtain the call record and change the status of the call record to initialization.
[0151] In another embodiment, to verify the validity of the request, the above-described apparatus further includes:
[0152] The third processing unit is used to extract the token in the creation request after receiving the above-mentioned creation request or scheduling request, and to obtain the first target token in the case of receiving the creation request.
[0153] The comparison unit is used to compare the first target token with the second target token in the preset token list in sequence;
[0154] The first determining unit is used to determine that the creation request is valid if a second target token that matches the first target token exists.
[0155] The second determining unit is used to determine that the creation request is invalid if there is no second target token that matches the first target token.
[0156] To enable concurrent execution of the submit operation, in one optional implementation, the fourth execution unit further includes:
[0157] The third processing module is used to divide the second object that has reached the predetermined execution time into multiple lockable record groups when the second object that has reached the predetermined execution time is greater than or equal to the second threshold. The number of call records in each lockable record group is less than or equal to the second threshold.
[0158] The first determining module is used to add the second object that has reached the predetermined execution time to the same lockable record group if the second object that has reached the predetermined execution time is less than the second threshold.
[0159] The fourth processing module is used to bind the call records in each group of records to be locked to the same execution batch code to obtain the execution batch.
[0160] To handle abnormal call logs, in one optional implementation, the above-mentioned apparatus further includes:
[0161] The fourth processing unit is used to lock the call record by submitting the global lock a second time after changing the status of each third object to call completion and releasing the execution batch lock, and if the time interval between the scheduled execution time of the call record and the current time is greater than the second preset duration and the status is in binding, to obtain the fourth object.
[0162] The fifth processing unit is used to change the state of the fourth object to execution exception, modify the scheduled execution time to the current time, and release the global lock for the second commit.
[0163] The sixth processing unit is used to call multiple execution batch locks to lock the fourth object of different execution batches with the synchronization state of execution exception, and obtain the fifth object;
[0164] The seventh processing unit is used to control multiple target nodes to synchronously perform task calculations on the fifth object of the corresponding execution batch, and change the status of the fifth object to "in progress";
[0165] The eighth processing unit is used to change the state of each fifth object to "call completed" and release the execution batch lock when all fifth objects in the execution batch are in the "calling" state.
[0166] In another embodiment, the seventh processing unit further includes:
[0167] The second acquisition module is used to acquire the number of resubmissions and increment the number of resubmissions.
[0168] The fifth processing module is used to control multiple target nodes to synchronously perform task calculations on the fifth object of the corresponding execution batch when the number of resubmissions after incrementing is less than a preset value, and to change the status of the fifth object to "in progress".
[0169] The sixth processing module is used to lock the state of the fifth object as an execution exception if the number of resubmissions after incrementing is greater than or equal to a preset value.
[0170] To mitigate the database performance overhead caused by abnormal pauses in data access records, in one optional implementation, the aforementioned apparatus further includes:
[0171] The ninth processing unit is used to, after changing the state of each third object to call completion and releasing the execution batch lock, traverse all call records. If the interval between the creation time of the call record and the current time is greater than the third preset time and the state is initialized, the call record is locked by a timeout global lock to obtain the sixth object.
[0172] The tenth processing unit is used to control the node to change the state of the sixth object to uncommitted and release the timed-out global lock;
[0173] The eleventh processing unit is used to control the target node to lock the call record through an abnormal global lock when the creation time of the call record is greater than the fourth preset time and the status is active, so as to obtain the seventh object.
[0174] The twelfth processing unit is used to change the state of the seventh object to a bound exception and release the exception global lock;
[0175] The thirteenth processing unit is used to transfer call records with corresponding statuses of call completion, execution exception, uncommitted, and binding exception to a preset location in the database every five preset time intervals.
[0176] To achieve the binding of call records and execution batches, in one optional implementation, the fourth execution unit includes:
[0177] The seventh processing module is used to control the target node to traverse the second object, and add the second object to the record group to be bound when the second object reaches the predetermined execution time;
[0178] The eighth processing module is used to control the target node to randomly generate execution batch codes;
[0179] The ninth processing module is used to control the target node to bind the second object in the record group to be bound to the execution batch code.
[0180] In order to submit the aforementioned call records, in one optional implementation, the sixth execution unit includes:
[0181] The third acquisition module is used to acquire the execution batch code, add the call records carrying the same execution batch code to the same set, and obtain multiple call record sets;
[0182] The sending module is used to send call requests to the target nodes corresponding to each call record set. The call request is used to request the execution ID of the target node.
[0183] The fourth acquisition module is used to receive the execution ID sent by each target node and bind the execution ID with all third objects in the corresponding call record set;
[0184] The tenth processing module is used to control multiple target nodes to capture the third object carrying the corresponding execution ID and change the status of the third object to "in call";
[0185] The eleventh processing module is used to control each target node to perform task calculations based on the corresponding third object.
[0186] The aforementioned database-based task batch triggering device includes a processor and a memory. All the aforementioned units are stored as program units in the memory, and the processor executes these program units to achieve the corresponding functions. All the aforementioned modules reside in the same processor; alternatively, the modules may be located in different processors in any combination.
[0187] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can improve the system's task processing efficiency.
[0188] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0189] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the database-based task batch triggering method.
[0190] This invention provides a processor for running a program, wherein the program executes the database-based task batch triggering method during runtime.
[0191] This invention provides a triggering system, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements at least the steps of the database-based task batch triggering method described above.
[0192] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform the steps of initializing a database-based task batch triggering method as described above.
[0193] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0194] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0195] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0196] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0197] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0198] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0199] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0200] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0201] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0202] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0203] 1) The database-based batch task triggering method of this application first divides the task into batches according to the creation time of the call records, resulting in multiple creation batches. Multiple creation batch locks are then used to synchronously lock the call records of each creation batch, resulting in multiple first objects. Next, multiple nodes are controlled to synchronously update the status of the first objects locked by each creation batch lock to "in effect" and release all creation batch locks. Then, a global lock is used to lock all the first objects in effect, resulting in second objects. Multiple nodes are controlled to compete for the global lock. Next, the target node that successfully competes for the lock binds the second objects that have reached their predetermined execution time to the same execution batch, changes the status of the second objects in the execution batch to "bound," and releases the global lock. Then, multiple execution batch locks are used to synchronously lock the second objects in different execution batches that are in the "bound" state, resulting in third objects. Next, multiple target nodes are controlled to synchronously perform task calculations on the third objects in the corresponding execution batches and change the status of the third objects to "in effect." Finally, when the status of all third objects in the execution batch is "in effect," the status of each third object is changed to "call completed," and the execution batch lock is released, completing the triggering process. To address the issue that existing technologies use global locks to lock all call records at different lifecycle stages, resulting in only one node processing data at a time, this application divides different row locks according to the lifecycle of the call record (e.g., in effect, in binding, and in call). Even with a global lock, only call records in effect are locked, while other nodes can still perform parallel processing of call record creation and task computation. By reducing the locking scope of row locks, the concurrency of data processing is improved. Furthermore, for call records at the same lifecycle, this application uses batch locks for locking, locking in batches of creation or execution, enabling parallel processing of different nodes among call records at the same lifecycle, further improving the concurrency of data processing and solving the performance degradation problem caused by resource lock conflicts between different nodes in the existing technology.
[0204] 2) The database-based task batch triggering device of this application comprises: a first execution unit dividing the call records into batches based on their creation time to obtain multiple creation batches, and synchronously locking the call records of each creation batch by calling multiple creation batch locks to obtain multiple first objects; a second execution unit controlling multiple nodes to synchronously update the status of the first objects locked by each creation batch lock to "in effect" and releasing all creation batch locks; a third execution unit locking all the first objects in effect by calling a global lock to obtain second objects, and controlling multiple nodes to compete for the global lock; a fourth execution unit controlling the target node that has successfully competed for the lock to bind the second objects that have reached the predetermined execution time to the same execution batch, changing the status of the second objects in the execution batch to "bound" and releasing the global lock; a fifth execution unit synchronously locking the second objects in different execution batches with the status of "bound" by calling multiple execution batch locks to obtain third objects; a sixth execution unit controlling multiple target nodes to synchronously perform task calculations on the third objects in the corresponding execution batches and changing the status of the third objects to "in call"; and a seventh execution unit changing the status of each third object to "call completed" and releasing the execution batch lock when all the third objects in the execution batch are in "in call" and completing the triggering. To address the issue that existing technologies use global locks to lock all call records at different lifecycle stages, resulting in only one node processing data at a time, this application divides different row locks according to the lifecycle of the call record (e.g., in effect, in binding, and in call). Even with a global lock, only call records in effect are locked, while other nodes can still perform parallel processing of call record creation and task computation. By reducing the locking scope of row locks, the concurrency of data processing is improved. Furthermore, for call records at the same lifecycle, this application uses batch locks for locking, locking in batches of creation or execution, enabling parallel processing of different nodes among call records at the same lifecycle, further improving the concurrency of data processing and solving the performance degradation problem caused by resource lock conflicts between different nodes in the existing technology.
[0205] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A database-based method for batch triggering of tasks, characterized in that, include: Multiple empty batches are created in the triggering system, and call records are added to the corresponding empty batches to obtain multiple creation batches. Multiple creation batch locks are called to synchronously lock the call records of each creation batch to obtain multiple first objects. Control multiple nodes to synchronously update the status of the first object locked by each creation batch lock to "in effect" and release all creation batch locks; By invoking a global lock to lock all the first objects in effect, the second object is obtained, and multiple nodes are controlled to compete for the lock by invoking the global lock; The target node that controls the lock acquisition will bind the second object that has reached the predetermined execution time to the execution batch, change the state of the second object in the execution batch to "binding", and release the global lock. Multiple execution batch locks are invoked synchronously to lock the second object in different execution batches that are in a bound state, thus obtaining the third object; Control multiple target nodes to synchronously perform task calculations on the third object corresponding to the execution batch, and change the status of the third object to "in call"; If all the third objects in the execution batch are in a state of invocation, change the state of each third object to invocation completed and release the execution batch lock to complete the triggering.
2. The method according to claim 1, characterized in that, Multiple empty batches are created in the triggering system, and call records are added to the corresponding empty batches to obtain multiple creation batches, including: Upon receiving a batch creation instruction, at least one empty batch is created in the triggering system; The call records are traversed, and call records carrying the same creation batch code are grouped into the same empty batch to obtain the creation batch.
3. The method according to claim 1, characterized in that, The target node controlling the lock acquisition will bind the second object that reaches the predetermined execution time to the same execution batch, including: If the second object that has reached the predetermined execution time is greater than or equal to the second threshold, the second object that has reached the predetermined execution time is divided into multiple lockable record groups, and the number of the call records in each lockable record group is less than or equal to the second threshold. If the second object that has reached the predetermined execution time is less than the second threshold, the second object that has reached the predetermined execution time will be added to the same group of records to be locked. The call record in each group of records to be locked is bound to the same execution batch code to obtain the execution batch.
4. The method according to claim 1, characterized in that, After changing the state of each of the third objects to call complete and releasing the execution batch lock, the method further includes: If the time interval between the scheduled execution time of the call record and the current time is greater than the second preset duration and the status is "bound", the call record is locked by submitting a global lock twice to obtain the fourth object; Change the state of the fourth object to execution exception, modify the scheduled execution time to the current time, and release the second commit global lock; Multiple execution batch locks are invoked to lock the fourth object of different execution batches that are in the state of execution exception, thereby obtaining the fifth object; Control multiple target nodes to synchronously perform task calculations on the fifth object corresponding to the execution batch, and change the status of the fifth object to "in call"; If all the fifth objects in the execution batch are in a state of invocation, change the state of each fifth object to invocation completed and release the execution batch lock.
5. The method according to claim 4, characterized in that, After changing the state of each of the third objects to call complete and releasing the execution batch lock, the method further includes: Traverse all the aforementioned call records. If the time interval between the creation time of the call record and the current time is greater than the third preset time and the state is initialized, lock the call record through a timeout global lock to obtain the sixth object. The node is controlled to change the state of the sixth object to uncommitted and release the timeout global lock; If the creation time of the call record is greater than the fourth preset time and the status is active, the target node is controlled to lock the call record through an abnormal global lock to obtain the seventh object; Change the state of the seventh object to a bound exception and release the exception global lock; Every five preset time intervals, the call records with corresponding statuses of call completion, execution exception, uncommitted, and binding exception are transferred to a preset location in the database.
6. The method according to claim 1, characterized in that, The target node controlling the lock acquisition will bind the second object that reaches the predetermined execution time to the same execution batch, including: The target node is controlled to traverse the second object, and when the second object reaches the predetermined execution time, the second object is added to the record group to be bound. The target node is controlled to randomly generate execution batch codes; The target node is controlled to bind the second object in the record group to be bound to the execution batch code.
7. The method according to claim 6, characterized in that, Controlling multiple target nodes to synchronously perform task computation on the third object corresponding to the execution batch, and changing the status of the third object to "in progress", includes: Obtain the execution batch code, and add the call records carrying the same execution batch code to the same set to obtain multiple call record sets; A call request is sent to the target node corresponding to each of the call record sets, and the call request is used to request the execution ID of the target node; Receive the execution ID sent by each of the target nodes, and bind the execution ID with all the third objects in the corresponding call record set; Control multiple target nodes to capture the third object carrying the corresponding execution ID, and change the status of the third object to "in call"; Each target node is controlled to perform task calculations based on the corresponding third object.
8. A database-based task batch triggering device, characterized in that, The device includes: The first execution unit is used to create multiple empty batches in the triggering system, add call records to the corresponding empty batches to obtain multiple creation batches, and call multiple creation batch locks to synchronously lock the call records of each creation batch to obtain multiple first objects; The second execution unit is used to control multiple nodes to synchronously update the status of the first object locked by each creation batch lock to "in effect" and release all the creation batch locks. The third execution unit is used to lock all the first objects in effect by calling the global lock, obtain the second object, and control multiple nodes to compete for the lock by calling the global lock; The fourth execution unit is used to control the target node that has passed the lock snatching to bind the second object that has reached the predetermined execution time to the execution batch, change the state of the second object in the execution batch to "binding", and release the global lock. The fifth execution unit is used to call multiple execution batch locks to synchronously lock the second object in different execution batches that are in a bound state, thereby obtaining the third object; The sixth execution unit is used to control multiple target nodes to synchronously perform task calculations on the third object corresponding to the execution batch, and change the status of the third object to "in call"; The seventh execution unit is used to change the state of each of the third objects in the execution batch to "call completed" and release the execution batch lock when all the third objects in the execution batch are in the "calling" state, thus completing the triggering.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.
10. A triggering system, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising methods for performing any one of claims 1 to 7.