Database lease driven exclusive task anti-duplication method

By dynamically adjusting lease allocation weights, durations, and heartbeat frequencies, combined with multi-level anti-duplicate verification strategies, the problem of insufficient dynamic correlation between database leases and exclusive tasks in distributed systems is solved, enabling efficient and secure execution of exclusive tasks and improving the system's adaptability and resource utilization efficiency.

CN121501771BActive Publication Date: 2026-05-29BEIJING CTJ SOFTWARE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING CTJ SOFTWARE
Filing Date
2026-01-13
Publication Date
2026-05-29

Smart Images

  • Figure CN121501771B_ABST
    Figure CN121501771B_ABST
Patent Text Reader

Abstract

The application provides a database lease driven exclusive task anti-repetition execution method, through introducing a dynamic evaluation and update mechanism of the effectiveness of the association strategy, effectively improving the intelligence and environmental adaptability of the exclusive task anti-repetition execution, and accurately evaluating the effectiveness of the historical strategy under the current system state, and generating an optimal anti-repetition verification strategy based on multi-objective optimization in real time, thereby significantly reducing the risk of task repetition execution or error interception. Compared with the static configuration scheme, the application realizes the collaborative adaptive adjustment of the key parameters of the system, so that the system can actively respond to dynamic environments such as load fluctuations and network changes. This dynamic correlation ensures the data consistency and system reliability in high-priority task processing such as electronic certificates, while optimizing resource utilization and reducing performance bottlenecks or resource waste caused by strategy lag, providing more efficient and reliable anti-repetition protection for distributed task scheduling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, specifically to a database lease-driven method for preventing duplicate execution of exclusive tasks. Background Technology

[0002] In distributed systems and multi-node task processing environments, effective management of exclusive tasks is crucial for ensuring data consistency and security in electronic voucher-based transactions (such as financial transactions, invoice generation, and settlement processing). Existing technologies typically employ the following methods to achieve task exclusivity:

[0003] 1. Data block-based pessimistic locking method: Locking task records by designing statements, but this method is prone to database connection exhaustion and performance bottlenecks in high-concurrency scenarios, and cannot effectively handle the lock release problem after node failure.

[0004] 2. Methods based on distributed locks such as Redis: Distributed locks are implemented using the SETNX command or the RedLock algorithm. However, this method has problems such as difficulty in setting the lock expiration time, clock drift that may cause the lock to be released prematurely, and the possibility of multiple clients holding the lock simultaneously during failover.

[0005] 3. ZooKeeper-based ephemeral node method: This method achieves exclusive locks by creating ephemeral nodes, but it has high system complexity and requires the maintenance of additional middleware.

[0006] The aforementioned existing technologies have the following common shortcomings when dealing with business scenarios that require extremely high data consistency, such as electronic voucher generation:

[0007] 1) Rigid lease mechanism. Traditional database leases are designed with fixed durations and cannot be dynamically adjusted according to system load and task complexity, resulting in leases expiring prematurely during high-load periods or being occupied for a long time during low-load periods.

[0008] 2) The anti-duplicate mechanism is too simple. It relies solely on simple status flags or locking mechanisms and lacks multi-level anti-duplicate verification, making it difficult to handle boundary situations such as network partitions and message duplication in complex distributed environments.

[0009] 3) The lack of detailed monitoring of lease lifecycle and task execution status makes it difficult for system maintenance personnel to quickly locate and resolve issues such as repeated task execution or task freezing.

[0010] Most importantly, existing technologies have significant shortcomings in the dynamic correlation between database leases and exclusive task anti-duplicate execution. They cannot intelligently adjust anti-duplicate strategies based on the actual operating status of the system, task characteristics, and historical data, resulting in a lack of necessary flexibility and adaptability when dealing with high-frequency, high-value electronic voucher-type transactions. Summary of the Invention

[0011] This application aims to establish a dynamically adjustable database lease mechanism by extracting the dynamic correlation characteristics between database leases and exclusive task anti-duplicate execution, and deeply integrate it with multi-level anti-duplicate verification strategies. In business scenarios with extremely high requirements for data consistency, such as electronic voucher generation, this method provides a database lease-driven exclusive task anti-duplicate execution method to achieve secure and efficient execution of exclusive tasks in a distributed environment.

[0012] To achieve this objective, the following technical solution is adopted in this application:

[0013] A database lease-driven method for preventing duplicate execution of exclusive tasks is provided, including the following steps:

[0014] S1, based on the time-sensitive weight decay model and system state drift analysis, evaluates... Historical association strategy generated at any time Application in the current Time validity,

[0015] If effective, proceed to step S2;

[0016] If ineffective, update the current algorithm using a multi-objective collaborative optimization algorithm. Time-based correlation strategy Then proceed to step S2;

[0017] The decision model adaptively adjusts the lease allocation weights, lease duration prediction parameters, and heartbeat frequency based on historical monitoring data to generate the historical association strategy. ;

[0018] S2, using the historical association strategy Or the updated association strategy As input, a model is generated through the anti-duplicate verification strategy, dynamically outputting the anti-duplicate verification strategy for the current task, and performing anti-duplicate verification on the current task based on this strategy.

[0019] Preferably, in step S1, the association strategy is updated. The method includes the following steps:

[0020] A1, based on the Q-learning reinforcement learning framework, uses lease allocation weights, duration prediction parameters, and heartbeat frequency as action sets, and system throughput and task repetition rate as reward signals to optimize policy parameters online.

[0021] A2, implement adaptive adjustment of lease allocation weights, and dynamically reconstruct weight allocation rules based on historical data of the sparsity of the task priority queue and node reliability;

[0022] A3, continuously predict and update the optimal lease duration parameter;

[0023] A4. Construct a negative feedback adjustment mechanism for heartbeat frequency and system load. Based on the current system load and the updated lease allocation weights and lease durations, adaptively adjust the heartbeat frequency. The optimization results of strategy parameters obtained in steps A1-A4, the adaptive adjustment results of lease allocation weights, the reconstructed weight allocation rules, the optimal lease duration parameters, and the adaptive adjustment results of heartbeat frequency together constitute the updated association strategy. .

[0024] Preferably, in step A1, the method for optimizing the strategy parameters in a linked manner includes the following steps:

[0025] A11, Define the state space This quantizes the system state into a multidimensional state vector.

[0026] A12, Define Action Set This includes adjustments to the weighting of lease allocations. Lease duration prediction parameter adjustment action Heart rate adjustment actions ;

[0027] A13, Constructing a multi-objective weighted reward function ,in, Indicates the current system throughput reward, This indicates the current task's anti-duplication reward. Indicates current system overhead rewards, This indicates the load balancing degree among task nodes. , , They are respectively , , , In calculation The proportion and weight of time;

[0028] A14, Initialize the Q-value table;

[0029] A15, Dynamically Adjust Exploration Rate and according to Choose or explore actions to perform;

[0030] A16, collects real-time rewards and updates Q-value;

[0031] A17 extracts the optimal strategy from the updated Q-value table and transforms it into continuous system parameter adjustments;

[0032] A18. Based on the parameters adjusted in step A17, perform iterative training of the strategy.

[0033] Preferably, in step A2, the method for adaptively adjusting lease allocation weights and dynamically reconstructing weight allocation rules includes the following steps:

[0034] A21, Define the fuzzy set and membership function of the input variables for adaptively adjusting lease allocation weights;

[0035] A22, Construct a fuzzy rule base;

[0036] A23, perform fuzzy inference and output aggregation to form a fuzzy set of weight adjustment suggestions;

[0037] A24, Defuzzify the fuzzy set of the weight adjustment suggestions;

[0038] A25, dynamically update fuzzy rules and parameters.

[0039] Preferably, the method for rolling prediction and updating the optimal lease duration parameter in step A3 includes the following steps:

[0040] A31, collects and serializes historical execution data;

[0041] A32, preprocess and calculate the moving average of the data collected in step A31;

[0042] A33, based on the preprocessed time series data, fit a rolling prediction model for lease duration;

[0043] A34, Apply the lease duration rolling prediction model fitted in step A33 to the current... The moving average sequence generated at each time step predicts the expected execution time of the next similar task.

[0044] A35 dynamically calculates the safety margin and combines it with the predicted lease duration to form the optimal lease duration parameter.

[0045] Preferably, the lease duration rolling prediction model fitted in step A33 includes the ARIMA model, and the fitting method includes the following steps:

[0046] A331, test the stationarity of the preprocessed time series data Y and determine the difference order d;

[0047] A332, plot the autocorrelation function and partial autocorrelation function of the new stationary sequence ΔY, and determine the values ​​of the partial autoregression order p and the moving average order q by observing the "truncation" characteristic of the plots;

[0048] A333, based on the values ​​of the difference order d, partial autoregression order p, and moving average order q determined for the ARIMA model, the parameters of the ARIMA model are estimated and the model is fitted.

[0049] Preferably, in step A4, the method for adaptively adjusting the heart rate includes the following steps:

[0050] A41, construct a baseline frequency calculation model with load and lease strategy as the core to calculate the heartbeat baseline frequency. The model input includes the current system load, the task concentration determined by the current lease allocation weight strategy, and the current adaptively adjusted average lease duration.

[0051] A42, based on the node lease allocation weight and / or lease duration, and on the basis of the heartbeat baseline frequency calculated in step A41, perform differentiated heartbeat adjustments on each node.

[0052] Preferably, in step S1, the evaluation Historical association strategy generated at any time Application in the current The methods for ensuring the validity of time include the following steps:

[0053] B1, Introducing a time-sensitivity weight decay factor. To quantify the historical association strategy The timeliness value;

[0054] B2, Construct the system state drift vector To characterize the system state from Time's up Dynamic changes over time;

[0055] B3, the historical association strategy after attenuation in step B1. The timeliness value and the system state drift vector constructed in step B2 By performing weighted fusion, we can obtain the result. Apply historical association strategy at all times A composite score for effectiveness;

[0056] B4. Determine whether the composite score calculated in step B3 is greater than a preset composite score threshold.

[0057] If so, then it is determined that... Apply the historical association strategy at all times efficient;

[0058] If not, then determine in Apply the historical association strategy at all times invalid.

[0059] Preferably, step B1 specifically includes the following steps:

[0060] B11 defines and monitors the system environment change rate index;

[0061] B12, Calculate the rate of change of the multidimensional environment state vector. ;

[0062] B13, based on rate of change Design a nonlinear decay function ;

[0063] B14, Application Quantitative historical correlation strategy The timeliness value;

[0064] Step B2 specifically includes the following steps:

[0065] B21 defines and quantifies system state indicators;

[0066] B22, construction System state point at time 1 and current System state point at time 1 ;

[0067] B23, Calculation and 3D Euclidean distance ;

[0068] B24, according to and , The three-dimensional coordinate points are used to construct the system state drift vector. .

[0069] Preferably, in step S2, the method for performing anti-duplicate verification on the current task includes the following steps:

[0070] C1, parse the input association strategy. Or the historical association strategy Extract the decision logic of lease allocation weight, lease duration and heartbeat frequency carried in the strategy, and at the same time obtain the features of the current task to be executed. Then, merge the extracted strategy parameters and task features into a strategy and task context feature vector.

[0071] C2, the anti-duplicate verification strategy generation model takes the strategy and task context feature vector as input, dynamically selects and combines verification rules that are suitable for the current scenario from the verification rule base, and then generates an executable anti-duplicate verification strategy.

[0072] C3, execute the anti-duplicate verification strategy generated in step C2 and perform atomic anti-duplicate verification.

[0073] This application has the following beneficial effects:

[0074] 1. This application effectively improves the intelligence and environmental adaptability of exclusive task anti-duplicate execution by introducing a dynamic evaluation and update mechanism for the effectiveness of association strategies. It can accurately evaluate the effectiveness of historical strategies under the current system state and generate the optimal anti-duplicate verification strategy in real time based on multi-objective optimization, thereby significantly reducing the risk of task duplication or erroneous interception. Compared to static configuration schemes, this application achieves collaborative adaptive adjustment of key system parameters, enabling the system to proactively respond to dynamic environments such as load fluctuations and network changes. This dynamic association ensures data consistency and system reliability in high-priority tasks such as electronic vouchers, while optimizing resource utilization and reducing performance bottlenecks or resource waste caused by policy lag, providing a more efficient and reliable anti-duplicate guarantee for distributed task scheduling.

[0075] 2. When updating the association strategy, a parameter linkage adjustment mechanism is adopted. By coordinating the adjustment of lease allocation weight, duration prediction parameters and heartbeat frequency, the system imbalance that may be caused by adjusting a single parameter is avoided, and the overall integrity and coordination of strategy optimization are improved.

[0076] 3. Constructing a multi-objective weighted reward function Through multi-objective collaborative optimization design, a balance is struck between multiple performance metrics such as system throughput, task duplication prevention effectiveness, resource overhead, and load fairness, overcoming the system drift problem that may result from single-objective optimization. It is important to emphasize that... The deduplication prevention effect is represented by the result of repeated deduplication verification of each execution step S1-S3 at several historical moments, which makes the multi-objective weighted reward function... It has a better collaborative optimization effect on multiple objectives, and further improves the overall balance between system throughput, task anti-duplication effect, resource consumption and load fairness.

[0077] 4. By using an adaptive exploration decay mechanism, the action space is fully explored in the early stages of training, and the focus is on selecting the optimal strategy in the later stages of training. This balances the contradiction between exploration and selection, and improves the efficiency and accuracy of anti-repetitive execution.

[0078] 5. In step A2, the dynamic reconstruction of the weight allocation rule is based on the result of the "strategy effectiveness evaluation" in step S1, and is achieved by fine-tuning the parameters of the fuzzy logic system (such as the weight adjustment ratio under each rule). The dynamic reconstruction of the weight allocation rule has been verified by the anti-duplicate execution effect of exclusive tasks, so that each dynamic reconstruction of the weight allocation rule can more effectively promote the performance improvement of anti-duplicate execution of exclusive tasks.

[0079] 6. In step A3, when rolling the prediction and updating the optimal lease duration parameter, the collected serialized data is the data formed after the weight allocation rules are continuously dynamically reconstructed in step A2. The weight reconstruction process is based on the strategy effectiveness evaluation results, which verifies the promoting effect of the reconstruction process on the performance improvement of the anti-duplicate execution of exclusive tasks. This makes the lease duration rolling prediction model (preferably the ARIMA model) fitted in step A33 more accurate and effective, which is conducive to improving the rolling prediction accuracy of the optimal lease duration parameter.

[0080] 7. The dynamic safety margin used in this application is not simply calculated based on the standard deviation of the duration of the most recent 50 historical tasks, but rather is the result of collaborative optimization. Specifically, it is obtained by adaptively adjusting the lease allocation weights in step A2, verifying the effectiveness of the adjusted lease allocation weights on the association strategy, and verifying the effectiveness of the dynamically adjusted lease duration in improving the efficiency and accuracy of exclusive task anti-duplicate execution. This means that the standard deviation of the dynamic safety margin integrates the comprehensive characteristics of lease allocation weight adjustment, association strategy application and effectiveness, and improving the efficiency and accuracy of exclusive task anti-duplicate execution. This solves the problem of lease expiration (insufficient margin) or resource waste (excessive margin) caused by fixed safety margins when task execution time fluctuates greatly. This dynamic margin mechanism makes the system more resilient and accurate in the face of uncertainty, effectively balancing task completion assurance and resource utilization efficiency.

[0081] 8. In step A41, by introducing task concentration and average lease duration, the heartbeat reference frequency can reflect the system's true coordination capability, realizing cross-parameter system initialization and solving the problem of heartbeat frequency being disconnected from task scheduling and time planning.

[0082] 9. In step A4, during the adaptive adjustment of the heartbeat frequency, through the dynamic game among heartbeat frequency, load, lease duration, and lease allocation weight, the heartbeat frequency is upgraded from a static and isolated configuration item to a core variable that is dynamically adjusted under the collaborative optimization framework of load, weight, and duration. This deep integration ensures that the system can make globally optimal coordination decisions when facing complex and ever-changing operating environments, which not only guarantees strict anti-duplicate protection for exclusive tasks but also achieves efficient utilization of system resources.

[0083] 10. Step B13 achieves intelligent linkage between strategy value decay and system dynamism; step B14 utilizes... The quantitative analysis of the time-sensitive value of historical correlation strategies enables dynamic, context-aware, flexible, and accurate evaluation of strategy value. This allows for the full utilization of historical strategies to reduce decision-making overhead when the system is stable, and the decisive abandonment of old strategies and the seeking of new optimizations when the system is turbulent. This greatly enhances the adaptability and robustness of the entire method in real, dynamic, distributed environments, and solves the technical defect that fixed time window evaluation cannot adapt to dynamic environments.

[0084] 11. The activity level of a lease is related to the rationality of the lease allocation weight. The allocation of lease weight depends on the collaborative optimization results among lease duration and heartbeat frequency. Therefore, in this application, the lease activity level is not a fixed value, but a dynamically changing value after collaborative optimization, which makes the quantification of the system state indicator of resource competition more accurate and effective, thereby further improving the anti-duplicate execution effect of exclusive tasks.

[0085] 12. Drift vector carrying information about the change in system state and the direction of change. This provides richer contextual information for subsequent evaluation of the effectiveness of association strategies, and provides a reliable data foundation for the entire dynamic and adaptive evaluation system of association strategy effectiveness. Attached Figure Description

[0086] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments of this application will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0087] Figure 1 This is a diagram illustrating the implementation steps of the database lease-driven exclusive task anti-duplicate execution method provided in this application embodiment. Detailed Implementation

[0088] The technical solution of this application will be further described below with reference to the accompanying drawings and specific embodiments.

[0089] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual images. They should not be construed as limiting the scope of this application. To better illustrate the embodiments of this application, some components in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.

[0090] In the accompanying drawings of the embodiments of this application, the same or similar reference numerals correspond to the same or similar components. In the description of this application, it should be understood that if terms such as "upper," "lower," "left," "right," "inner," and "outer" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting this application. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.

[0091] In the description of this application, unless otherwise expressly specified and limited, the term "connection" or similar designation indicating a connection between components should be interpreted broadly. For example, it can refer to a fixed connection, a detachable connection, or an integral part; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can refer to the internal communication between two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.

[0092] The database lease-driven method for preventing duplicate execution of exclusive tasks provided in this application embodiment, such as... Figure 1 As shown, the steps include:

[0093] S1, based on the time-sensitive weight decay model and system state drift analysis, evaluates... Historical association strategy generated at any time Application in the current Time validity,

[0094] If effective, proceed to step S2;

[0095] If ineffective, update the current algorithm using a multi-objective collaborative optimization algorithm. Time-based correlation strategy Then proceed to step S2;

[0096] Decision model based on The historical correlation strategy is generated by adaptively adjusting lease allocation weights, lease duration prediction parameters, and heartbeat frequency based on real-time monitoring data. ;

[0097] S2, using historical association strategy Or updated association strategy As input, a model is generated through the anti-duplicate verification strategy, dynamically outputting the anti-duplicate verification strategy for the current task, and performing anti-duplicate verification on the current task based on this strategy.

[0098] In step S1, we evaluate the historical association strategy. Application in the current Before discussing specific methods for determining the validity of time points, we must first address the association strategy. The update method will be explained.

[0099] In this embodiment, the association strategy is updated. The method specifically includes the following steps:

[0100] A1, based on the Q-learning reinforcement learning framework, uses lease allocation weights, duration prediction parameters, and heartbeat frequency as the action set, and system throughput and task repetition rate as reward signals to optimize policy parameters online.

[0101] Specifically, the strategy parameter optimization method includes the following steps:

[0102] A11, Define the state space The system state is quantized into a multi-dimensional state vector; for example, this application defines the system load state. ={low, medium, high}, defines the task queue state. ={Idle, Normal, Congested}, defines the resource contention state. ={Relaxed, Moderate, Intense}, defines the network quality state. ={Stability, Fluctuation, Congestion}. By discretizing the key indicators of the system, the complex continuous state space is transformed into a finite state space that reinforcement learning can handle, laying the foundation for subsequent policy learning.

[0103] A12, Define Action Set This includes adjustments to the weighting of lease allocations. { ,Keep, }, Lease duration prediction parameter adjustment action { ,Keep, Heart rate adjustment actions { ,Keep, }; This indicates the adjustment amount for the lease allocation weight; This indicates the adjustment amount for the lease duration forecast parameter; This indicates the amount of adjustment to the heart rate.

[0104] It should be noted that this application adopts a parameter linkage adjustment mechanism, which avoids system imbalance that may be caused by adjusting a single parameter by coordinating the adjustment of lease allocation weight, duration prediction parameters and heartbeat frequency, thereby improving the integrity and coordination of strategy optimization.

[0105] A13, Constructing a multi-objective weighted reward function ;

[0106] In this embodiment, the multi-objective weighted reward function ,in, This represents the current system throughput reward. = (Current system throughput - Baseline throughput) / Baseline throughput; This indicates the current task's anti-duplication reward. = (Current task repetition rate × magnification factor); This indicates the current system overhead reward. (Current system overhead / Maximum allowed overhead); This indicates the load balancing degree among task nodes and represents a fair reward for the current system. , , They are respectively , , , In calculation The weighting of time. It should be noted here that... The calculation is a complex process. The calculation method is not within the scope of the claims made in this application, and does not affect the implementation of the database lease-driven exclusive task anti-duplicate execution method; therefore, it is not applicable to... The calculation process will not be explained in detail.

[0107] For example, assume the current throughput is 120 tasks / minute, the baseline throughput is 100 tasks / minute; the task duplication rate is 0.5%; the system overhead is 70% of the maximum allowable overhead; and the load balancing factor is 0.85. Take the weighting coefficients. , , , ,but:

[0108] Throughput Rewards : 0.5 × (120 - 100) / 100 = 0.1

[0109] Anti-repetition reward :0.3×(-log(0.005×10))≈0.3×3.9=1.17

[0110] Expenses Rewards 0.15 × (-0.7) = -0.105

[0111] Fair rewards 0.05 × 0.85 = 0.0425

[0112] Total reward value 0.1 + 1.17 - 0.105 + 0.0425 = 1.2075

[0113] The multi-objective weighted reward function constructed in this application Through multi-objective collaborative optimization design, a balance is struck between multiple performance metrics such as system throughput, task duplication prevention effectiveness, resource overhead, and load fairness, overcoming the system drift problem that may result from single-objective optimization. It is important to emphasize that... The deduplication prevention effect is represented by the result of repeated deduplication verification of each execution step S1-S3 at several historical moments, which makes the multi-objective weighted reward function... It has a better collaborative optimization effect on multiple objectives, and further improves the overall balance between system throughput, task anti-duplication effect, resource consumption and load fairness.

[0114] A14, Initialize the Q-value table; First, create a four-dimensional Q-value table, expressed as: Then, the Q value is initialized based on the historical best strategy. And set the initial exploration rate. For example, 0.3.

[0115] For example, given the state combination {load = medium, queue = normal, resource contention = moderate, network = stable}, historical data suggests the optimal action is {lease allocation weight = +0.1, lease duration = +5%, heartbeat = hold}, and the historical average reward for this action is... For example, a discount factor of 2.1. Set to 0.9, maximum Q value in the next state Assuming a Q-value of 1.8, the initial Q-value for the state combination {load = medium, queue = normal, resource contention = moderate, network = stable} is: 2.1 + 0.9 × 1.8 = 3.72. Other state-action pairs are initialized with Q-values ​​based on their respective historical performance using the same method.

[0116] Maximum Q value in the next state Calculated using the following method:

[0117] When in state And perform the action Afterwards, the environment will transition to a new state. . Indicates a new state Below, all possible actions to be taken. The maximum Q value corresponding to that state. For example, the system is currently in state [state name missing]. {Load = High, Queue = Congested, Competition = Intense, Network = Fluctuating}, assuming an action has been performed. {Lease allocation weight = +0.1, lease duration = hold, heartbeat frequency = +0.2}, after the system interacts with the environment based on this action, it enters a new state. {Load = Medium, Queue = Normal, Concurrency = Moderate, Network = Stable}. Then, query the status. All Q values ​​under the following conditions, i.e., query and state All actions associated with {Load=Medium, Queue=Normal, Concurrency=Moderate, Network=Stable} The corresponding Q value. Assumptions and state. The associated actions are: {Load = Medium, Queue = Normal, Concurrency = Moderate, Network = Stable} Including {Lease allocation weight = +0.1, lease duration = hold, heart rate = hold} and {Lease allocation weight = hold, lease duration = +5%, heart rate = -0.1}, the Q value for {Lease allocation weight = +0.1, lease duration = hold, heart rate = hold} is 3.2, and the Q value for {Lease allocation weight = hold, lease duration = +5%, heart rate = -0.1} is 2.9. Therefore, 3.2 is chosen. .

[0118] In this embodiment, the Q-value initialization strategy guided by historical experience significantly shortens the model convergence time and can greatly improve training efficiency compared with random initialization.

[0119] A15, Dynamically Adjust Exploration Rate and according to Choose or explore actions to perform;

[0120] In this embodiment, the exploration rate is used as the basis for the exploration rate. Randomly select actions (exploration process); with 1- Select the action with the largest current Q value (selection process). , , These represent the maximum exploration rate (initial exploration rate) and the minimum exploration rate, respectively. This represents the decay coefficient (a parameter characterizing the rate at which the exploration rate decays over time). This indicates the number of iterations in the reinforcement learning training.

[0121] For example, the current exploration rate The system is in a state of {high load, congestion, intense activity, and fluctuation}. Generate a random number of 0.15 to determine the current exploration rate. If the random number is greater than 0.15, the action exploration machine is triggered: for example, randomly selecting {lease allocation weight = -0.1, lease duration = -10%, heart rate +0.2} from 27 possible actions for testing. However, suppose the calculated random number is 0.25, which is greater than the current exploration rate. Then, using existing knowledge, select the action with the largest Q value in this state, such as {lease allocation weight = keep, lease duration = +5%, heart rate = keep}.

[0122] This application employs an adaptive exploration decay mechanism to fully explore the action space in the early stages of training and focus on selecting the optimal strategy in the later stages of training. This balances the contradiction between exploration and selection, and improves the efficiency and accuracy of anti-repetitive execution.

[0123] A16, collects real-time rewards and updates Q-value;

[0124] Perform step A15 to explore or select the action. Afterwards, observe the new state. and instant rewards (pass (Calculated by formula), let , where the left side of the equation For the updated Q value, the right side of the equation is... This is the Q value before the update. The learning rate is obtained through adaptive adjustment. The adaptive adjustment process is not within the scope of the rights claimed in this application, and therefore will not be specifically described.

[0125] For example, in state Next action After that, the system enters a new state. Receive instant rewards The original value was obtained by looking up the table. New state Lower maximum Q value Assuming a learning rate of 3.2, let's set the learning rate. Discount factor =0.9, then the updated Q value is: 2.8+0.1×[1.5+0.9×3.2-2.8]=2.8+0.1×1.58=2.958.

[0126] A17 extracts the optimal strategy from the updated Q-value table and transforms it into continuous system parameter adjustments;

[0127] For example, for state {Medium load, normal, relaxed, stable}, the updated Q-value table shows the following three optimal actions:

[0128] Action 1 {+0.05,+3%,Hold}: Q=4.2; Action 2 {Hold,+5%,-0.1}: Q=4.1; Action 3 {+0.1,Hold,Hold}: Q=3.9. Select Action 1 with the largest Q value and map it to the actual parameters: Lease allocation weight: 0.6+0.05=0.65; Lease duration parameter: 300 seconds × (1+3%)=309 seconds; Heart rate: 1.0Hz × (1+0%)=1.0Hz.

[0129] A18. Based on the parameters adjusted in step A17, perform iterative training of the strategy.

[0130] In this embodiment, the system maintains a sliding window with a capacity of 1000 to store the state transition records of the most recent 1000 times. After processing 100 new samples (i.e., time step K=100), the system automatically triggers policy evaluation: calculating the average reward of the current policy over the past 1000 samples. If the average reward drops from 2.1 to 1.7 (a decrease of more than 15%), it is determined to be an environmental change, triggering a policy reset mechanism: the state space structure is preserved, but the Q value is reinitialized to 80% of the current value and the exploration rate is reset to accelerate readaptation to the new environment.

[0131] After optimizing the parameter linkage of the action selection or exploration strategy through step A1, update the associated strategy. Method transition steps:

[0132] A2, implement adaptive adjustment of lease allocation weights, and dynamically reconstruct weight allocation rules based on historical data of the sparsity of the task priority queue and node reliability;

[0133] In this application, step A2 utilizes fuzzy logic to handle the "uncertainty" and "gradual change" in the system state. Specifically, it includes the following steps:

[0134] A21, Define the fuzzy set and membership function of the input variable;

[0135] In this application, the input variables for adaptively adjusting lease allocation weights include the task priority queue coefficient and node reliability. The fuzzy set of task priority queue sparsity is defined as {sparse, medium, crowded}, and a membership function is designed for each set, such as a trigonometric function or trapezoidal function. When there are few high-priority tasks to be processed, the membership degree of "sparse" is high; when the number of tasks is moderate, the membership degree of "medium" is the highest; and when there is a large backlog of tasks, the membership degree of "crowded" is high.

[0136] A fuzzy set of node reliability can be defined as {low, medium, high}. Reliability is calculated by weighted summation based on data such as the node's historical task success rate and mean time between failures. A new node or a node that fails frequently has a high membership degree for "low" reliability, while a node that operates stably has a high membership degree for "high" reliability.

[0137] For example, if there are 5 tasks in the current high-priority task queue, the membership function might determine that the task is "sparse" with a score of 0.7, "medium" with a score of 0.3, and "crowded" with a score of 0. The system state is thus described in a richer and more quantitative way, rather than simply as "crowded" or "not crowded".

[0138] A22, Construct a fuzzy rule base;

[0139] In this application, fuzzy rules for adaptive adjustment of lease allocation weights are established based on domain knowledge (such as operational experience and business objectives) or specific business scenarios. For example:

[0140] Rule 1: If the queue is sparse and the nodes are highly reliable, the lease allocation weight will be significantly increased, for example, by 50%.

[0141] Rule 2: If the queue is of medium size and the nodes are highly reliable, then slightly increase the lease allocation weight, for example, by 10%.

[0142] Rule 3: If the queue is of medium quality and the node reliability is medium, then the lease allocation weight remains unchanged;

[0143] Rule 4: If the queue is sparse and the node reliability is low, the weight will be significantly reduced, for example, by 30%.

[0144] For example, suppose a queue has a membership degree of 0.7 for "sparse" and 0.3 for "medium". Suppose a node has a membership degree of 0.9 for "high" reliability and 0.1 for "medium" reliability. Then the condition strength (activation) of rule 1 and rule 2 is min(0.7, 0.9) = 0.7; the condition strength of rule 2 is min(0.3, 0.9) = 0.3.

[0145] A23 performs fuzzy inference and output aggregation to form the final, comprehensive fuzzy set of "weight adjustment suggestions";

[0146] In this embodiment, the fuzzy reasoning process is as follows: the input membership degree obtained in step A21 is matched with the fuzzy rules constructed in step A22, and the strength of the conclusion of each rule is calculated.

[0147] For example, suppose a queue has a membership degree of 0.7 for "sparse" and 0.3 for "medium". Suppose a node has a membership degree of 0.9 for "high" reliability and 0.1 for "medium" reliability. Then the condition strength (activation) of rule 1 and rule 2 is min(0.7, 0.9) = 0.7; the condition strength of rule 2 is min(0.3, 0.9) = 0.3.

[0148] The output aggregation process is as follows: the output fuzzy sets of all activated rules (such as the output fuzzy sets corresponding to significantly increased weight and slightly increased weight) are superimposed according to their respective strengths and merged into a total output fuzzy set.

[0149] For example, rule 1 outputs "significantly increase weight" (intensity 0.7), and rule 2 outputs "slightly increase weight" (intensity 0.3). The system aggregates these two output fuzzy sets to form a final, comprehensive "weight adjustment suggestion" fuzzy set. For example, the range for increasing weight is [0.3, 0.7].

[0150] A24, Defuzzify the fuzzy set of weight adjustment suggestions;

[0151] The purpose of the defuzzification process in this step is to transform the aggregated "weight adjustment suggestion" fuzzy set back into a precise and executable lease allocation weight adjustment value. In this embodiment, it is preferable to calculate the horizontal axis coordinate value corresponding to the centroid of the entire "weight adjustment suggestion" fuzzy set as the precise weight adjustment value obtained after defuzzification. Assuming that the output universe of discourse of the "weight adjustment suggestion" fuzzy set aggregated in step A23 is [0.3, 0.7], and the horizontal axis coordinate value corresponding to the calculated centroid is 0.45, then the lease allocation weight of this node will be adjusted to increase by 0.45 on the base value, such as the weight during the previous adjustment. Solving for the centroid of the output universe of the fuzzy set using the centroid method is a complex process. Since the centroid solution method is not within the scope of the claims of this application, it will not be specifically described. In addition, to simplify the calculation, the mean of the upper and lower limits of the output universe can be solved as the weight adjustment value. For example, for the output universe of discourse [0.3, 0.7], (0.3 + 0.7) / 2 = -0.5 is the calculated weight adjustment value.

[0152] A25, dynamically update fuzzy rules and parameters.

[0153] Periodically (e.g., every 24 hours), the parameters of the fuzzy logic system are fine-tuned based on the results of the "strategy effectiveness evaluation" (the strategy effectiveness evaluation based on the timeliness weight decay model and system state drift analysis in step S1). If a rule is found to frequently cause performance degradation, its weight is automatically reduced or its conclusion is modified. Alternatively, by introducing a very small learning rate, the shape of the membership function and the rule results can be slowly adjusted based on the overall performance of historical tasks.

[0154] For example, system monitoring revealed that even a slight increase in the weight of "high-reliability" nodes failed to effectively alleviate congestion during periods of "queue congestion." Therefore, the system automatically changed the corresponding rule's conclusion from "slightly increase weight" to "moderately increase weight," thus enabling a more proactive scheduling strategy in similar situations in the future.

[0155] After completing the dynamic reconstruction of the weight allocation rules in step A2, the update association strategy provided in this embodiment... Method transition steps:

[0156] A3, rolling prediction and updating of the optimal lease duration parameter, specifically includes the following steps:

[0157] A31, collects and serializes historical execution data;

[0158] The system continuously captures and stores execution metadata for each completed task, including task type, task ID, start time, end time, actual execution duration, result status (success or failure), and the identifier of the execution node. This data is grouped by task type and indexed by time, forming multiple independent time series. For example: {Task type: Electronic voucher generation, Time series: [Task duration t1, Task duration t2, ...]}. For instance, for an "Electronic voucher generation" task, the system records the execution time for each task (e.g., [285 seconds, 292 seconds, 278 seconds, 305 seconds, ...]), which is then sorted by task submission time to form a historical execution duration sequence.

[0159] A32, preprocess and calculate the moving average of the data collected in step A31;

[0160] Specifically, the original time series generated in step A31 is cleaned to remove outliers caused by system failures (such as tasks with extremely long or short execution times). Then, a fixed-length sliding window (e.g., the most recent 50 data points) is used to calculate the moving average and standard deviation of the data within the window.

[0161] Assuming the original data fluctuates significantly between 250 and 350 seconds, a relatively smooth curve is obtained after calculating the moving average of 50 tasks, showing that the average duration stabilizes at around 300 seconds and exhibits a slow upward trend.

[0162] A33, based on the preprocessed time series data, fit a rolling prediction model for lease duration;

[0163] The fitting process of the lease duration rolling prediction model specifically includes the following steps:

[0164] A331, test the stationarity of the preprocessed time series data and determine the difference order d;

[0165] For example, the preprocessed time series data Y shows a clear upward trend (e.g., slowly increasing from 295 seconds to 311 seconds), indicating it is non-stationary. First, the difference between two adjacent data points in the sequence is calculated to obtain a new sequence ΔY. For example, ΔY = [298-295, 296-298, 302-296, ...] = [3, -2, 6, 3, 3, 2, 2, -3, 2, ...].

[0166] Examining the new sequence ΔY, we find that it fluctuates around zero without a clear trend, and can be considered stationary. Therefore, we determine that the difference order of Y is 1.

[0167] A332. Plot the autocorrelation function (ACF) and partial autocorrelation function (PACF) plots of the new stationary sequence ΔY. By observing the "truncation" characteristics of the plots, determine the values ​​of the partial autoregression order p and the moving average order q.

[0168] For example, by observing the PACF plot, we find that after a lag of 2 (lag=2), the coefficient suddenly truncates (falls into the confidence interval), indicating that the partial autoregression order p is 2. By observing the ACF plot, we find that after a lag of 2 (lag=2), the coefficient also suddenly truncates, indicating that the moving average order q is also 2.

[0169] At this point, the difference order d=1, the partial autoregression order p=2, and the moving average order q=2 are determined for the rolling forecast model of lease duration.

[0170] In this embodiment, the preferred model for rolling forecast of lease duration is the ARIMA model. The methods for plotting the autocorrelation function (ACF) plot and the partial autocorrelation function (PACF) plot are conventional methods, and the plotting process is not described in detail.

[0171] A333, Parameters of the estimated rental duration rolling forecast model.

[0172] In this embodiment, mathematical methods such as maximum likelihood estimation are used to calculate the parameters of the rolling forecast model for lease duration obtained in step A332. Taking the ARIMA model as an example, after step A332, it has been determined that the difference order d=1, the partial autoregressive order p is 2, and the moving average order q is 2. At this point, the coefficients of the two autoregressive terms (AR1, AR2) and the two moving average terms (MA1, MA2) of the ARIMA model can be calculated using methods such as maximum likelihood estimation.

[0173] A34, Apply the lease duration rolling prediction model fitted in step A33 to the current... The moving average sequence generated at each time step predicts the expected execution time of the next similar task.

[0174] Step A34 is a rolling prediction process, which means that after each new task is completed, new data is added to the sliding window, and the lease duration rolling prediction model is retrained or updated for the next round of prediction, ensuring that the prediction is always based on the latest data.

[0175] For example, based on the ARIMA (p=2, d=1, q=2) model determined in step A333 and the latest moving average, the system predicts that the average execution time of the next "electronic voucher generation" task will be 308 seconds. This value is no longer a simple historical average, but a forward-looking prediction derived by fuzzy integration of trends, cycles and noise.

[0176] It should be noted here that the ARIMA model uses the moving average as input, and the process of outputting predicted values ​​is not explained in detail. The prediction principle is similar to fitting calculations through higher-order equations. A brief explanation is as follows: using the historical moving average as the independent variable of the higher-order equation and the corresponding true value as the dependent variable, the coefficients of the higher-order equation are solved. These coefficients are equivalent to the parameters of the ARIMA model obtained through step A33.

[0177] A35 dynamically calculates the safety margin and combines it with the predicted lease duration to form the optimal lease duration parameter.

[0178] In this embodiment, the final lease duration is not directly based on the predicted value from the rolling lease duration prediction model, but rather a dynamically calculated safety margin is added to the predicted value. This safety margin is not a fixed value, but is positively correlated with the standard deviation of the data within the sliding window and / or the width of the prediction interval; the greater the volatility, the larger the safety margin.

[0179] For example, if the predicted duration is 308 seconds, the system calculates the standard deviation of the duration of the last 50 tasks to be 15 seconds. Based on preset margin calculation rules (e.g., safety margin = 2 × standard deviation), a safety margin of 30 seconds is dynamically added. Therefore, the recommended lease duration is 308 seconds + 30 seconds = 338 seconds.

[0180] It's important to note that the dynamic safety margin used in this application is not simply calculated based on the standard deviation of the durations of the last 50 historical tasks. Instead, it's the result of a collaborative optimization. Specifically, step A2 adaptively adjusts the lease allocation weights, verifies the effectiveness of the adjusted weights on the association strategy, and verifies the effectiveness of the dynamically adjusted lease duration in improving the efficiency and accuracy of exclusive task anti-duplicate execution. Only after these verifications are made can the dynamic safety margin for each adjustment be obtained. In other words, the standard deviation representing the dynamic safety margin integrates the comprehensive characteristics of lease allocation weight adjustment, association strategy application and effectiveness, and improving the efficiency and accuracy of exclusive task anti-duplicate execution. This solves the problem of fixed safety margins leading to lease expiration (insufficient margin) or resource waste (excessive margin) when task execution time fluctuates greatly. This dynamic margin mechanism makes the system more resilient and accurate in the face of uncertainty, effectively balancing task completion assurance and resource utilization efficiency.

[0181] After updating the optimal lease duration parameter in step A3, this embodiment updates the association strategy. Method transition steps:

[0182] A4. Construct a negative feedback adjustment mechanism for heartbeat frequency and system load. Based on the current system load and the updated lease allocation weights and lease durations, adaptively adjust the heartbeat frequency. The optimization results of strategy parameters obtained in steps A1-A4, the adaptive adjustment results of lease allocation weights, the reconstructed weight allocation rules, the optimal lease duration parameters, and the adaptive adjustment results of heartbeat frequency together constitute the updated association strategy. .

[0183] In this application, step A4 provides a dynamic and intelligent heartbeat management mechanism. The core technology lies in the fact that the heartbeat frequency is no longer an isolated parameter, but is dynamically linked with the lease allocation weight (which determines who will execute the task) and the lease duration (which determines the time budget for task execution), forming an adaptive collaborative optimization system, which specifically includes the following steps:

[0184] A41, construct a reference frequency calculation model based on load and lease strategies to calculate the heartbeat reference frequency;

[0185] In this embodiment, a function (baseline frequency calculation model) is designed to calculate the baseline heartbeat frequency. The input of this function includes not only the system average load, but also the task concentration determined by the current lease allocation weighting strategy, and the current adaptively adjusted average lease duration.

[0186] Task concentration measures the uneven distribution of exclusive tasks across a node cluster within a specific time period, reflecting the actual effectiveness of the current "lease allocation weight" strategy. For example, low concentration means tasks are evenly distributed across nodes, resulting in a dispersed system load and a small impact from the failure of a single node; high concentration means tasks are concentrated on a few nodes, which become the critical hubs of the system, where the reliability of their heartbeats is directly important, but they also face greater load and heartbeat pressure.

[0187] An example of how to calculate task concentration is as follows:

[0188] Assume the system has four nodes: A, B, C, and D. Node A performs 3 tasks, B performs 2 tasks, C performs 2 tasks, and D performs 3 tasks, for a total of 10 tasks. Nodes A and D each bear a task share of 3 / 10 (0.3), while nodes B and C each bear a task share of 0.2. The concentration is the square of the task share; therefore, the concentration of nodes A and D is 0.09, and the concentration of nodes B and C is 0.04. A weighted average of the concentrations of each node is then calculated to obtain the merged task concentration. In this embodiment, to simplify the calculation, the weight of the concentration of each node in the concentration fusion calculation is set to 1. Therefore, the task concentration of the four nodes in the example above is 0.09 × 2 + 0.04 × 2 = 0.26.

[0189] It's important to note that the concentration weights for each node in the concentration fusion calculation are not actually the same. The weights depend on the historical adjustments made to the lease allocation weight and lease duration for that node. Larger adjustments result in smaller weights, and vice versa. It's a highly complex process, a result of the coordinated optimization of lease allocation weight, lease duration, and heartbeat frequency adjustments. To simplify the calculation, this embodiment assigns a concentration fusion weight of 1 to each node.

[0190] The following is an example of how to calculate the average lease duration:

[0191] In this embodiment, the average lease duration is not a fixed configuration value, but a weighted average of all successfully allocated lease durations within a dynamically rolling time window. It reflects the system's overall expectation and planning for task execution time in the near future and is a key indicator for measuring the system's task execution rhythm.

[0192] Suppose that the system assigned the following three leases within the most recent statistical window:

[0193] Electronic voucher generation task A (high priority, high resource consumption core task): lease duration is 300 seconds, lease allocation weight is 2.0;

[0194] Data cache update task B (low priority, background task): lease duration is 600 seconds, lease allocation weight is 0.5;

[0195] Log archiving task C (low priority task): lease duration = 1200 seconds, lease allocation weight is 0.5;

[0196] First, calculate the weighted sum of the lease durations for the three tasks mentioned above:

[0197] (300 seconds × 2.0) + (600 seconds × 0.5) + (1200 seconds × 0.5) = 600 + 300 + 600 = 1500

[0198] Then, calculate the total weights: 2.0 + 0.5 + 0.5 = 3.0;

[0199] Then, the weighted average (weighted average lease duration) is calculated: 1500 / 3.0 = 500 seconds. This weighted average lease duration resolves the issue of the heartbeat frequency being disconnected from the system's task planning. As a dynamic indicator, the average lease duration accurately captures the system's current task execution rhythm.

[0200] Finally, the current system load, the current task concentration, and the current average lease duration are weighted and summed to obtain the heartbeat baseline frequency.

[0201] For example, the current system load is 75% (high load, tending to reduce heartbeat frequency), the task concentration is: 70% of the tasks are processed by 30% of the nodes, and the task concentration is quantified to 0.7 by calculation; the average lease duration is, for example, 250 seconds.

[0202] To simplify calculations, this application defines a baseline frequency calculation model that is linearly normalized to a range such as [0.5, 1.5]. This range represents the adjustment range of the heartbeat frequency. It is assumed that the weights of system load, task concentration, and average lease duration in calculating the heartbeat baseline frequency are 0.4, 0.35, and 0.25, respectively. For example, the system load conversion function is: 1.5 - current system load / 100. Substituting a load of 75%, the converted system load index value is 1.5 - 0.75 = 0.75. The task concentration conversion function is: 0.5 + concentration. Substituting a concentration of 0.7, the converted task concentration index value is 0.5 + 0.7 = 1.2. The average lease duration conversion function is: 1.8 - average lease duration / 500. Substituting an average lease duration of 250 seconds, the converted average lease duration index value is 1.8 - 250 / 500 = 1.3. Finally, the weighted average of the converted index values ​​(0.4×0.75)+(0.35×1.2)+(0.25×1.3)=1.045Hz was calculated as the heartbeat reference frequency.

[0203] In step A41 of this embodiment, by introducing task concentration and average lease duration, the heartbeat reference frequency can reflect the true coordination capability of the system, realizing cross-parameter system initialization and solving the problem of heartbeat frequency being disconnected from task scheduling and time planning.

[0204] A42, based on the node lease allocation weight and lease duration, and on the basis of the heartbeat baseline frequency calculated in step A41, perform differentiated heartbeat adjustments for each node;

[0205] Assume the system has 3 nodes and a database monitoring service, and the current baseline heartbeat frequency is 1.0Hz. Node A's lease allocation weight is assumed to be 0.9, and Node A is the hub node handling the "electronic voucher issuance" task. According to preset rules, for example, when the hub node's lease allocation weight reaches 0.9 or higher, the heartbeat frequency increases by 50% above the baseline value. Therefore, Node A's heartbeat frequency is adjusted to 1.0Hz × (1 + 0.5) = 1.5Hz. Node B's lease allocation weight is assumed to be 0.6, and Node B handles general "voucher format conversion" tasks. According to preset rules, its heartbeat frequency remains at the calculated baseline value, i.e., 1.0Hz. Node C's lease allocation weight is assumed to be 0.3, and it is a backup node or a node handling non-critical tasks. According to the rules, its heartbeat frequency is reduced by 30%, so the adjusted heartbeat frequency is 1.0Hz × (1 - 0.3) = 0.7Hz.

[0206] In this embodiment, the lease duration is also an important factor to consider when adjusting the heartbeat baseline frequency, as it reflects the urgency of adjusting the heartbeat baseline frequency. The shorter the lease duration, the tighter the time budget for task execution, the smaller the fault tolerance margin, and the higher the heartbeat frequency should be to prevent the lease from expiring during a brief node lag.

[0207] The process of adjusting the baseline heart rate based on the lease duration is illustrated below:

[0208] For example, node A is currently executing an emergency credential task with a lease duration of 200 seconds (the system average lease duration is 300 seconds). Because the lease duration is shorter than average, its heartbeat frequency needs to be further increased. Similarly, assuming an increase of 0.2Hz according to the rules, the final adjusted heartbeat frequency is 1.5Hz + 0.2Hz = 1.7Hz. Node C is executing a data backup task with a lease duration of 500 seconds (above average). Because the lease duration is above average, its heartbeat frequency can be further decreased. Assuming a decrease of 0.1Hz according to the rules, the final heartbeat frequency is 0.7Hz - 0.1Hz = 0.6Hz.

[0209] In step A4, during the adaptive adjustment of the heartbeat frequency, this application uses a dynamic game among heartbeat frequency, load, lease duration, and lease allocation weight to upgrade the heartbeat frequency from a static, isolated configuration item into a core variable that is dynamically adjusted within a collaborative optimization framework of load, weight, and duration. This deep integration ensures that the system can make globally optimal coordination decisions when facing complex and ever-changing operating environments, guaranteeing both strict anti-duplication of exclusive tasks and efficient utilization of system resources.

[0210] Historical association strategy The generation method is the same as the association strategy. The generation method is simply different depending on the data obtained at different times, so I will not go into details.

[0211] The following section evaluates step S1. Historical association strategy generated at any time Application in the current The method for ensuring the validity of time points will be explained in detail:

[0212] In this embodiment, the evaluation Historical association strategy generated at any time Application in the current The methods for ensuring the validity of time include the following steps:

[0213] B1, Introducing a time-sensitivity weight decay factor. To quantify the historical association strategy The timeliness value specifically includes the following steps:

[0214] B11 defines and monitors the rate of change of the system environment, including the average system load at each monitoring time. (e.g., CPU utilization), length of the task queue to be processed Intensity of resource competition (e.g., data lock wait time), network latency In each time slice A vector that records these metrics ;

[0215] For example, in Time's up During the monitoring period, the system detected that the average CPU utilization increased from 40% to 80%, the task queue length increased from 50 to 200, and the database lock wait time increased from 10ms to 50ms. These specific values ​​constituted the raw data for calculating the rate of change.

[0216] B12, Calculate the rate of change of the multidimensional environment state vector. , This represents the norm of the vector (e.g., L2 norm). To eliminate the influence of dimensions, it is preferable to normalize the index of each dimension before calculation.

[0217] For example, , Calculate the Euclidean distance between the two to obtain... .

[0218] B13, Design of Nonlinear Decay Function Based on Rate of Change ;

[0219] The calculations from step B12 Mapped to attenuation factor And satisfy Follow Increases and then decreases. Preferably, in this embodiment, , A sensitivity coefficient greater than 0 is used to control the rate of decay. When the rate of change is 0, The strategic value is fully preserved; when the rate of change increases, The sensitivity coefficient rapidly approaches zero, causing the strategy's value to depreciate quickly. For example, consider a sensitivity coefficient... Substituting the rate of change of 0.76 into... From the calculation formula, we get This indicates a drastic change in the system environment (the rate of change reached 0.76), and the historical correlation strategy... Its timeliness value has been significantly reduced to 22% of its original value.

[0220] B14, Application Quantitative historical correlation strategy Its timeliness value.

[0221] Specifically, in evaluating historical correlation strategies When considering the effectiveness, its inherent static value and attenuation factor are compared. Multiply to get its current value. The dynamic failure value at any given moment. Historical correlation strategy. static value Preferred The performance score recorded at the time of generation, or the average reward it achieved in the first few time windows. The performance score recorded at the time of generation is a complex process, and can be... The total reward received each time after being applied consecutively within the first few time windows. The average value can also be calculated using a completely new method. The performance score recorded during generation will not be discussed in detail here.

[0222] For example, Static performance score recorded at the time of generation The score is 90 out of 100, calculated in the previous step. Then in Time-based historical association strategy The dynamic timeliness value score is 90 × 0.22 = 19.8 points.

[0223] This application achieves intelligent linkage between strategy value decay and system dynamism through step B13, and in step B14, it applies... The quantitative analysis of the time-sensitive value of historical correlation strategies enables dynamic, context-aware, flexible, and accurate evaluation of strategy value. This allows for the full utilization of historical strategies to reduce decision-making overhead when the system is stable, and the decisive abandonment of old strategies and the seeking of new optimizations when the system is turbulent. This greatly enhances the adaptability and robustness of the entire method in real, dynamic, distributed environments, and solves the technical defect that fixed time window evaluation cannot adapt to dynamic environments.

[0224] B2, Construct the system state drift vector To characterize the system state from Time's up The dynamic changes over time specifically include the following steps:

[0225] B21 defines and quantifies system state indicators;

[0226] In this embodiment, the quantitative indicators for defining the system state include system load, task queue length, and resource contention level. System load... This is quantified as a weighted average of server CPU utilization, ranging from 0 to 1. For example, a node with 4 CPU cores has utilization rates of 80%, 70%, 90%, and 60%, respectively, indicating a high system load. Set the task queue length. This is quantified as the sum of all pending exclusive tasks. For example, if there are 15 records in the database task table with a status of "pending processing," then... Resource competition This is quantified as the ratio of the number of currently active database leases to the maximum allowed number of leases. For example, if the system currently has 8 active leases and the maximum allowed is 10, then... It is important to emphasize that the activity level of a lease is related to the rationality of the lease weight allocation, and the allocation of lease weight depends on the collaborative optimization results among lease duration and heartbeat frequency. Therefore, in this application, the lease activity level is not a fixed value, but a dynamically changing value after collaborative optimization.

[0227] B22, construct state space points;

[0228] Specifically, the three quantitative indicators obtained in step B21 are combined into a three-dimensional coordinate point, which represents the complete state of the system at a certain moment. For example, in At what moment, the system state point ,exist At what moment, the system state point As can be seen from the coordinates, the system has improved in all three dimensions.

[0229] B23, calculates three-dimensional Euclidean distance;

[0230] Calculate from state point to state point European distance The calculation method is as follows:

[0231]

[0232] Substituting the values ​​from the example above, we get

[0233] By setting To determine a reasonable threshold This indicates whether the system state has experienced a drastic drift. For example, if the threshold is set to 5, then 15.01 indicates that the system state has already experienced a drastic drift.

[0234] B24, Construct the system state drift vector .

[0235] Drift vector carrying information about the change in system state and the direction of change This provides richer contextual information for subsequent evaluation of the effectiveness of association strategies, and provides a reliable data foundation for the entire dynamic and adaptive evaluation system of association strategy effectiveness.

[0236] B3, the historical association strategy after attenuation in step B1. The timeliness value and the system state drift vector constructed in step B2 By performing weighted fusion, we can obtain the result. Apply historical association strategy at all times The validity composite score results;

[0237] Assuming that the weight of timeliness value and drift vector is 1 when calculating the composite score of validity, then continuing with the example above, the composite score result is 19.8 points calculated in step B1 - 15.01 points calculated in step B2 = 4.79 points.

[0238] B4. Determine whether the composite score calculated in step B3 is greater than the preset composite score threshold.

[0239] If so, then it is determined that... Apply the historical association strategy at all times efficient;

[0240] If not, then determine in Apply the historical association strategy at all times invalid.

[0241] It should be noted that in this application, the composite scoring threshold is actually a dynamically updated threshold. The sensitivity of the threshold is dynamically adjusted based on the policy failure frequency within the sliding time window to ensure that the evaluation criteria self-optimize over long-term system operation; this is a complex optimization process. To simplify the calculation, a fixed composite scoring threshold can also be used.

[0242] After executing step S1, step S2 specifically includes the following steps for performing anti-duplicate verification on the currently pending task:

[0243] C1, Analyzing the association strategy of the input or historical association strategy Extract the decision logic of lease allocation weight, lease duration and heartbeat frequency carried in the strategy, and at the same time obtain the features of the current task to be executed, including task type (such as "electronic voucher generation"), data scale, priority, submission source, etc., and fuse the extracted strategy parameters and task features into a strategy and task context feature vector.

[0244] For example, input association strategies The system prompts a message due to high load: Increase the heartbeat frequency to 2Hz. The current task to be executed is: "High priority, large-value electronic voucher issuance" task. In step C1, the system integrates the information of {increase heartbeat frequency to 2Hz, high priority, large-value voucher} into a strategy and task context feature vector, and passes it to the next stage of the generative model.

[0245] Step C1 links macro-level system-level strategies with micro-level task-level features, providing precise input for generating highly customized anti-duplicate verification strategies and solving the technical shortcomings of traditional unified anti-duplicate methods that cannot adapt to the differences in sensitivity of different tasks.

[0246] C2, the anti-duplicate verification strategy generation model takes the strategy and task context feature vector as input, dynamically selects and combines verification rules that are suitable for the current scenario from the verification rule base, and then generates an executable anti-duplicate verification strategy.

[0247] For example, the strategy and task context feature vector generated in step C1 are input into a pre-trained anti-duplicate verification strategy generation model. Based on the input vector, this model dynamically selects and combines verification rules from a predefined "verification rule base" to generate a specific and executable anti-duplicate verification strategy. The anti-duplicate verification strategy clearly defines the verification levels, order, and specific operations (e.g., first check the local cache, then verify the token, and finally perform database status verification). For instance, after receiving the feature vector {increase heartbeat frequency to 2Hz, high priority, large-value voucher}, the anti-duplicate verification strategy generation model determines that the current task is crucial and the system is unstable. Therefore, it selects the verification rule most suitable for the current scenario from the predefined "verification rule base," including: checking the local lease cache; forcibly verifying the global anti-duplicate token; and performing exclusive lock verification on the target record in the database transaction. Finally, according to the preset verification order rules, the process is as follows: first, check the local lease cache; then, forcibly verify the global anti-duplicate token; and finally, perform exclusive lock verification on the target record in the database transaction.

[0248] C3 executes the anti-duplicate verification strategy generated in step C2 and performs atomic anti-duplicate verification.

[0249] In this embodiment, the task execution node strictly follows the generated anti-duplicate verification strategy step by step. The entire process is encapsulated as an atomic operation. For example, the node strictly follows the steps of "querying task status - executing anti-duplicate verification strategy - updating task status to in progress" to perform atomic anti-duplicate verification. Specifically, the second step, "executing the anti-duplicate verification strategy," also strictly follows the steps of "first, checking the local lease cache, then forcibly verifying the global anti-duplicate token, and finally, performing exclusive lock verification on the target record in the database transaction." In the third step, executing the database transaction, an attempt is made to update the task status from "pending" to "in progress." Because this application sets the system's database transactions to have mutual isolation characteristics, at any given time, only one node's transaction can be successfully committed; transactions of other concurrent nodes will fail due to data version conflicts or unmet conditions, thus ensuring absolute anti-duplicate protection for the task.

[0250] In summary, this application effectively enhances the intelligence and environmental adaptability of exclusive task anti-duplicate execution by introducing a dynamic evaluation and update mechanism for the effectiveness of association strategies. It can accurately assess the effectiveness of historical strategies under the current system state and generate the optimal anti-duplicate verification strategy in real time based on multi-objective optimization, thereby significantly reducing the risk of task duplication or erroneous interception. Compared to static configuration schemes, this application achieves collaborative adaptive adjustment of key system parameters, enabling the system to proactively respond to dynamic environments such as load fluctuations and network changes. This dynamic association ensures data consistency and system reliability in high-priority tasks such as electronic vouchers, while optimizing resource utilization and reducing performance bottlenecks or resource waste caused by policy lag, providing a more efficient and reliable anti-duplicate guarantee for distributed task scheduling.

[0251] It should be stated that the above-described specific embodiments are merely preferred embodiments and technical principles applied in this application. Those skilled in the art should understand that various modifications, equivalent substitutions, and variations can be made to this application. However, such variations, as long as they do not depart from the spirit of this application, should be within the scope of protection of this application. Furthermore, some terminology used in this application's specification and claims is not limiting but merely for ease of description.

Claims

1. A database lease-driven method for preventing duplicate execution of exclusive tasks, characterized in that, Including the following steps: S1, based on the time-sensitive weight decay model and system state drift analysis, evaluates... Historical association strategy generated at any time Application in the current Time validity, If effective, proceed to step S2; If ineffective, update the current algorithm using a multi-objective collaborative optimization algorithm. Time-based correlation strategy Then proceed to step S2; The decision model adaptively adjusts the lease allocation weights, lease duration prediction parameters, and heartbeat frequency based on historical monitoring data to generate the historical association strategy. ; S2, using the historical association strategy Or the updated association strategy As input, a model is generated through the anti-duplicate verification strategy, dynamically outputting the anti-duplicate verification strategy for the current task, and performing anti-duplicate verification on the current task based on this strategy; In step S1, the association strategy is updated. The method includes the following steps: A1, based on the Q-learning reinforcement learning framework, uses lease allocation weights, duration prediction parameters, and heartbeat frequency as action sets, and system throughput and task repetition rate as reward signals to optimize policy parameters online. A2, implement adaptive adjustment of lease allocation weights, and dynamically reconstruct weight allocation rules based on historical data of the sparsity of the task priority queue and node reliability; A3, continuously predict and update the optimal lease duration parameter; A4. Construct a negative feedback adjustment mechanism for heartbeat frequency and system load. Based on the current system load and the updated lease allocation weights and lease durations, adaptively adjust the heartbeat frequency. The optimization results of strategy parameters obtained in steps A1-A4, the adaptive adjustment results of lease allocation weights, the reconstructed weight allocation rules, the optimal lease duration parameters, and the adaptive adjustment results of heartbeat frequency together constitute the updated association strategy. .

2. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 1, characterized in that, Step A1, the method for optimizing the strategy parameters in a linked manner, includes the following steps: A11, Define the state space The system state is quantized into a multi-dimensional state vector; where the system load state is defined as... Define the task queue state as Define resource competition state as Define network quality status as ; A12, Define Action Set This includes adjustments to the weighting of lease allocations. Lease duration prediction parameter adjustment action Heart rate adjustment actions ; A13, Constructing a multi-objective weighted reward function ,in, Indicates the current system throughput reward, This indicates the current task's anti-duplication reward. Indicates current system overhead rewards, This indicates the load balancing degree among task nodes. , , They are respectively , , , In calculation The proportion and weight of time; A14, Initialize the Q-value table; A15, Dynamically Adjust Exploration Rate and according to Choose or explore actions to perform; A16, collects real-time rewards and updates Q-value; A17 extracts the optimal strategy from the updated Q-value table and transforms it into continuous system parameter adjustments; A18. Based on the parameters adjusted in step A17, perform iterative training of the strategy.

3. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 1, characterized in that, In step A2, the method for adaptively adjusting lease allocation weights and dynamically reconstructing weight allocation rules includes the following steps: A21, Define the fuzzy set and membership function of the input variables for adaptively adjusting lease allocation weights; A22, Construct a fuzzy rule base; A23, perform fuzzy inference and output aggregation to form a fuzzy set of weight adjustment suggestions; A24, Defuzzify the fuzzy set of the weight adjustment suggestions; A25, dynamically update fuzzy rules and parameters.

4. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 1, characterized in that, Step A3, the method for rolling prediction and updating the optimal lease duration parameter, includes the following steps: A31, collects and serializes historical execution data; A32, preprocess and calculate the moving average of the data collected in step A31; A33, based on the preprocessed time series data, fit a rolling prediction model for lease duration; A34, Apply the lease duration rolling prediction model fitted in step A33 to the current... The moving average sequence generated at each time step predicts the expected execution time of the next similar task. A35 dynamically calculates the safety margin and combines it with the predicted lease duration to form the optimal lease duration parameter.

5. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 4, characterized in that, The lease duration rolling prediction model fitted in step A33 includes the ARIMA model, and the fitting method includes the following steps: A331, test the stationarity of the preprocessed time series data Y and determine the difference order d; A332, plot the autocorrelation function and partial autocorrelation function of the new stationary sequence ΔY, and determine the values ​​of the partial autoregression order p and the moving average order q by observing the "truncation" characteristic of the plots; A333, based on the values ​​of the difference order d, partial autoregression order p, and moving average order q determined for the ARIMA model, the parameters of the ARIMA model are estimated and the model is fitted.

6. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 1, characterized in that, In step A4, the method for adaptively adjusting heart rate includes the following steps: A41, construct a baseline frequency calculation model with load and lease strategy as the core to calculate the heartbeat baseline frequency. The model input includes the current system load, the task concentration determined by the current lease allocation weight strategy, and the current adaptively adjusted average lease duration. A42, based on the node lease allocation weight and / or lease duration, and on the basis of the heartbeat baseline frequency calculated in step A41, perform differentiated heartbeat adjustments on each node.

7. The database lease-driven method for preventing duplicate execution of exclusive tasks according to any one of claims 1-6, characterized in that, In step S1, the evaluation Historical association strategy generated at any time Application in the current The methods for ensuring the validity of time include the following steps: B1, Introducing a time-sensitivity weight decay factor. To quantify the historical association strategy The timeliness value; B2, Construct the system state drift vector To characterize the system state from Time's up Dynamic changes over time; B3, the historical association strategy after attenuation in step B1. The timeliness value and the system state drift vector constructed in step B2 By performing weighted fusion, we can obtain the result. Apply historical association strategy at all times A composite score for effectiveness; B4. Determine whether the composite score calculated in step B3 is greater than a preset composite score threshold. If so, then it is determined that... Apply the historical association strategy at all times efficient; If not, then determine in Apply the historical association strategy at all times invalid.

8. The database lease-driven method for preventing duplicate execution of exclusive tasks according to claim 7, characterized in that, Step B1 specifically includes the following steps: B11 defines and monitors the system environment change rate index; B12, Calculate the rate of change of the multidimensional environment state vector. ; B13, based on rate of change Design a nonlinear decay function ; B14, Application Quantitative historical correlation strategy The timeliness value; Step B2 specifically includes the following steps: B21 defines and quantifies system state indicators; B22, construction System state point at time 1 and current System state point at time 1 ; B23, Calculation and 3D Euclidean distance ; B24, according to and , The three-dimensional coordinate points are used to construct the system state drift vector. .

9. The database lease-driven method for preventing duplicate execution of exclusive tasks according to any one of claims 1-6, characterized in that, Step S2, the method for performing anti-duplicate verification on the current task includes the following steps: C1, parse the input association strategy. Or the historical association strategy Extract the decision logic of lease allocation weight, lease duration and heartbeat frequency carried in the strategy, and at the same time obtain the features of the current task to be executed. Then, merge the extracted strategy parameters and task features into a strategy and task context feature vector. C2, the anti-duplicate verification strategy generation model takes the strategy and task context feature vector as input, dynamically selects and combines verification rules that are suitable for the current scenario from the verification rule base, and then generates an executable anti-duplicate verification strategy. C3, execute the anti-duplicate verification strategy generated in step C2 and perform atomic anti-duplicate verification.