Hierarchical priority-based query asynchronous processing scheduling method and system

By adopting a query asynchronous processing scheduling method based on hierarchical priority, the problem of uneven resource allocation under the static priority strategy is solved, achieving efficient resource scheduling and improving the response speed and throughput of the industrial data processing system.

CN123137950APending Publication Date: 2026-11-20GUANGZHOU DORA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611644637.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-23
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In existing industrial data processing systems, static priority strategies cannot detect the actual resource consumption differences of query requests. This leads to high-priority queries waiting due to resource scarcity and low-priority queries occupying resources for extended periods, resulting in a decrease in system throughput and real-time response.

Method used

A query asynchronous processing scheduling method based on hierarchical priority is adopted. By classifying query requests through random forest, syntax tree parsing and resource usage statistics are performed to generate resource pressure signals. Clustering and hierarchical degradation are then carried out to achieve adaptive resource protection for high-priority queries and elastic resource reclamation for low-priority queries.

Benefits of technology

It enables precise resource allocation based on the actual business requirements and load characteristics of query requests, improving the response speed of high-priority queries, reducing the resource consumption of low-priority queries, and enhancing the system's throughput and real-time response.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123137950A_ABST
    Figure CN123137950A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of asynchronous processing scheduling, and discloses a query asynchronous processing scheduling method and system based on hierarchical priority, which comprises the following steps: acquiring a query request under a mixed load, classifying the query request by using a random forest and analyzing a syntax tree, generating a physical operator sequence, dividing the physical operator sequence into execution stages and counting resource occupation; if the resource occupation exceeds a threshold value, triggering a resource pressure signal, clustering and dividing requests in the execution stage into a guaranteed set and a to-be-recovered set; hierarchically degrading the to-be-recovered set, recovering idle resources, matching the guaranteed set, distributing resources to the guaranteed requests according to a resource matching degree, generating a scheduling decision instruction, issuing the instruction as request metadata to a local storage component and a cooperation module, independently executing priority scheduling on the local storage component and the cooperation module, and obtaining a final query request. The method can realize adaptive resource guarantee for high-priority query requests and elastic resource recovery for low-priority requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of asynchronous processing scheduling technology, and in particular to a query asynchronous processing scheduling method and system based on hierarchical priority. Background Technology

[0002] Currently, in the field of industrial data processing, distributed database systems serve as the core infrastructure supporting intelligent manufacturing, IoT data aggregation, and real-time analysis. Their query processing capabilities directly impact the response efficiency and service quality of industrial applications. With the increasing prevalence of mixed online transaction processing and online analytical processing workloads in industrial scenarios, competition for computing and I / O resources among different types of query requests is becoming increasingly fierce. How to achieve efficient scheduling of query requests under limited resources has become a key challenge for industrial data processing systems.

[0003] In existing technologies, query scheduling in industrial data processing systems often employs static partitioning strategies based on fixed priorities or simple first-come, first-served queuing mechanisms. Processing order is primarily determined by the submission time of query requests or preset user levels, with resource allocation ratios determined by pre-configured weight parameters. When the system faces sudden surges in concurrent query requests, the static priority strategy fails to recognize the actual resource consumption differences and blocking states of each query request during the execution phase. Low-priority, long queries may occupy processor threads and buffer pool resources for extended periods, causing high-priority, short transaction queries to wait continuously due to resource scarcity. This can trigger a chain reaction of lock contention and transaction rollbacks, severely weakening the throughput and real-time response of the industrial data processing system.

[0004] In summary, existing technologies struggle to achieve adaptive resource protection for high-priority query requests and elastic resource reclamation for low-priority requests in mixed load scenarios, resulting in insufficient service quality assurance capabilities for industrial data processing systems during peak resource contention periods. Summary of the Invention

[0005] This invention provides a query asynchronous processing scheduling method and system based on hierarchical priority to achieve adaptive resource protection for high-priority query requests and elastic resource reclamation for low-priority requests.

[0006] Firstly, to address the aforementioned technical problems, this invention provides a query asynchronous processing scheduling method based on hierarchical priority, comprising: Query requests under mixed load are obtained, and random forest is used to classify the query requests to obtain an initial level; The query request is parsed using a syntax tree based on the initial level to obtain a sequence of physical operators. The sequence of physical operators is then segmented to obtain an execution phase. Resource usage statistics are then performed on the execution phase to obtain the computational resource usage. If the computational resource usage exceeds a preset resource threshold, a resource pressure signal is generated. Based on the resource pressure signal, the query requests in the execution phase are clustered to obtain a protected set and a set to be reclaimed. The set to be recycled is hierarchically downgraded to obtain idle resources. The idle resources are matched with the protected set to obtain the resource matching degree. Resources are allocated to the protected set according to the resource matching degree to obtain scheduling decision instructions. The scheduling decision instruction is sent as request metadata to the storage component and the collaboration module, which then independently execute priority scheduling locally to obtain the final query request.

[0007] Secondly, the present invention provides a query asynchronous processing scheduling system based on hierarchical priority, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the query asynchronous processing scheduling method based on hierarchical priority as described above.

[0008] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the query asynchronous processing scheduling method based on hierarchical priority as described above.

[0009] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention obtains query requests under mixed load and classifies them using a random forest to obtain an initial level. The random forest takes multi-dimensional load features such as business SLA tags, tenant identifiers, query types, concurrent connections, and memory consumption as input, and maps query requests to five priority levels through an integrated voting mechanism of multiple decision trees. This makes the initial level division both resistant to noise samples and able to characterize the essential differences in business demands and resource requirements of different types of query requests, thus solving the problem that the static priority strategy in the prior art cannot perform flexible classification according to the actual business demands and load characteristics of the query requests.

[0010] (2) This invention parses the query request into a syntax tree based on the initial level to obtain a sequence of physical operators, divides it into execution stages according to the data redistribution boundary, and calculates the computational resource consumption by weighting the thread concurrency and memory allocation of the execution stage. By converting the structured query statement into a sequence of physical operators and dividing the execution stage by the data redistribution operator, the resource consumption statistics can accurately correspond to the specific execution intervals of the actual computational and memory resources consumed in the query plan, and directly trigger the resource pressure signal with an independent resource pressure threshold, thus achieving accurate triggering of the resource pressure signal and solving the problem of coarse resource monitoring granularity and inability to locate resource bottlenecks in specific execution stages in the prior art.

[0011] (3) In this invention, the priority tag and resource group identifier in the scheduling decision instruction are sent as request metadata to the storage component and the collaboration module. The storage component and the collaboration module independently execute priority scheduling in their respective local queues based on the unified metadata to obtain the final query request. Through the metadata-driven hierarchical scheduling mechanism, the extraction and in-situ rearrangement of the active queues inside the storage component or collaboration module are avoided. This ensures that the I / O service order of high-priority requests in the storage layer is consistent with the resource allocation priority of the computing layer. Furthermore, the collaboration module can switch its local scheduling strategy based on the unified metadata to form a unified priority response link with the computing layer and the storage layer. This effectively solves the problem of priority strategy failure caused by the separation of computing layer scheduling and storage layer service order in the prior art. Attached Figure Description

[0012] Figure 1 This is a schematic diagram of the query asynchronous processing scheduling method based on hierarchical priority provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of the resource occupation and execution phase segmentation of the physical operator sequence provided in the first embodiment of the present invention. Detailed Implementation

[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0014] Reference Figure 1 The first embodiment of the present invention provides a query asynchronous processing scheduling method based on hierarchical priority, including the following steps: Step S11: Obtain query requests under mixed load, and classify the query requests using random forest to obtain an initial level; Step S12: Parse the query request using a syntax tree based on the initial level to obtain a sequence of physical operators; perform data segmentation on the sequence of physical operators to obtain an execution phase; and perform resource usage statistics on the execution phase to obtain the computational resource usage. Step S13: If the computational resource usage is greater than a preset resource threshold, a resource pressure signal is generated. Based on the resource pressure signal, the query requests in the execution phase are clustered and divided to obtain a protected set and a set to be reclaimed. Step S14: Perform hierarchical degradation on the set to be recycled to obtain idle resources, match the idle resources with the protected set to obtain the resource matching degree, allocate resources to the protected set according to the resource matching degree, and obtain scheduling decision instructions; Step S15: The scheduling decision instruction is sent as request metadata to the storage component and the collaboration module, and the storage component and the collaboration module independently execute priority scheduling locally to obtain the final query request.

[0015] In step S11, query requests under mixed load are obtained, and random forest is used to classify the query requests to obtain an initial level, including: Extract the business SLA tag, tenant identifier, query type, number of concurrent connections and memory consumption of the query request as load features. After feature encoding and normalization, input the load features into the pre-trained random forest model and output the initial level.

[0016] The query request is a structured query statement received by the distributed database system in a mixed load scenario. Mixed load refers to the load pattern in which online transaction processing and online analytical processing are executed concurrently in the same database cluster. After the query request arrives, it is uniformly received by the database connection management module and assigned a globally unique transaction identifier. At the same time, the session management module reads three types of business dimension information, namely business SLA tag, tenant identifier and query type, from the session attributes carried during the connection establishment phase and writes them into the session context field.

[0017] Five basic metrics are extracted from the query request. The first is the business SLA tag, which is the response latency commitment level corresponding to the business process to which the query request belongs (the value ranges from L1 to L5, with L1 corresponding to the highest commitment and L5 corresponding to the lowest commitment. It is registered by the business system according to the service level agreement SLA when accessing the database and written into the session context by the session management module during the session establishment phase). The second is the tenant identifier, which is the unique identifier of the tenant or business process to which the query request belongs (assigned by the tenant management system when creating the tenant, and the value is a unique integer). The third is the query type, which is the OLTP or OLAP category of the query request determined by the statement type (OLTP is determined by the statement type being INSERT, UPDATE, DELETE, single-row SELECT, or primary key lookup; OLAP is determined by the statement type being GROUP). (For complex queries involving BY aggregation, multi-table JOIN, or scanned rows estimated to exceed 10,000 rows), the fourth category is the number of concurrent connections, which is the number of active concurrent connections within the database cluster belonging to the same tenant as the query request at the current moment. This is obtained in real-time by the connection management module through the query session status table, and the unit is individual connections. The fifth category is memory consumption, which is the amount of database buffer pool memory occupied by the query request during the parsing phase. This is obtained by the memory management module from the memory allocation log after the query parsing is completed, and the unit is MB. The first load feature is obtained by concatenating the above business SLA label, tenant identifier, query type, number of concurrent connections, and memory consumption into a five-dimensional array according to a preset field order. This first load feature provides a unified vector input for subsequent feature processing. In this embodiment, the business SLA label is L2, the tenant identifier is tenant number 17, the query type is OLAP, the number of concurrent connections is 500, and the memory consumption is 800MB.

[0018] Feature encoding and normalization rules are pre-trained offline and stored during the production commissioning and debugging phase. Under experimental cluster conditions, at least 5,000 sets of query request samples are collected from the same model database under typical mixed load conditions (OLTP short transactions as the main type, OLAP long queries as the main type, and OLTP and OLAP alternating, etc., for at least 3 types of conditions) running continuously for at least 30 days. Each set of samples records a 5-dimensional original feature vector (business SLA label, tenant identifier, query type, number of concurrent connections, and memory consumption). The encoding rules are as follows: tenant identifiers, whose values ​​do not have magnitude meaning, are mapped to integer codes from 1 to 5 according to the resource quota level to which the tenant belongs; query types are binary encoded as 0 for OLTP and 1 for OLAP; and business SLA labels are assigned numbers from 1 to 5 according to their level sequence. The normalization rule is to perform Z-score standardization on each column (i.e., subtract the mean of each column and then divide by the standard deviation of the column), thereby transforming the five load features with different dimensions to the same order of magnitude. The mean and standard deviation of each dimension are loaded into the database scheduling engine memory at once during the initialization phase. Only 5 subtractions and 5 divisions are required to obtain the 5-dimensional standardized feature vector during runtime, with minimal computational overhead.

[0019] It should be noted that this scheme inputs the above 5-dimensional standardized feature vectors into the random forest model as a whole. Random forest is an ensemble model composed of multiple decision trees. Its discriminative ability comes from the combination of split features selected by each decision tree on different feature dimensions. If the features are first reduced to 1-dimensional scalars before input, the splitting of decision trees on single-dimensional features will actually degenerate into several threshold segments, and the noise resistance advantage of ensemble voting over single decision trees will not be reflected. Retaining all 5-dimensional features allows each dimension to participate in node splitting independently, avoiding the loss of discriminative information caused by dimensionality reduction, and also allows the importance of each dimension feature to be directly given by the model based on the out-of-bag data evaluation.

[0020] The pre-defined random forest model contains 100 classification and regression CART decision trees, each with a maximum depth of 8. During training, each tree samples samples with replacement at a sampling ratio of 0.8 of the total number of samples. The hyperparameters mentioned above are determined by grid search based on the principle of maximizing classification accuracy using 5-fold cross-validation. The specific search range is the number of decision trees [50, 100, 200], maximum depth [4, 8, 12], and sample sampling ratio [0.6, 0.8, 1.0]. The final determined hyperparameter combination is 100 decision trees, 8 maximum depth, and 0.8 sample sampling ratio.

[0021] The pre-training process of the random forest model involves collecting at least 8,000 sets of query request samples from the same database under typical mixed load conditions for at least 60 days in an experimental cluster. Each set of samples consists of input features and manually labeled initial level labels (output). The input features are the first load features of the query request, processed according to the aforementioned feature encoding and normalization rules to obtain a 5-dimensional standardized feature vector. The initial level labels are divided into 5 levels (level 1 corresponds to the highest priority, and level 5 corresponds to the lowest priority). The labeling rules are as follows: three engineers with more than 5 years of experience in database performance tuning independently score the labels based on two criteria: business latency requirements and resource requirements. The composite criterion considers both the Service Level Agreement (SLA) response latency commitment of the query request (Level 1 corresponds to an SLA response latency commitment of less than 100ms, Level 2 to 100 to 300ms, Level 3 to 300 to 1000ms, Level 4 to 1000 to 3000ms, and Level 5 to more than 3000ms), the query type, and the resource requirements represented by the estimated execution cost under the optimizer cost model. After three engineers comprehensively evaluate the level according to the above composite criterion, the arithmetic mean of the scores is rounded to the nearest integer as the initial level label of the sample. If the range of the scores from the three engineers exceeds one level, the sample is removed and does not participate in the training.

[0022] It should be noted that since the initial level label is comprehensively evaluated by a combination of business latency requirements and resource needs, its value cannot be determined by any single input feature. It must be inferred from the random forest by integrating the 5-dimensional standardized feature vector.

[0023] To assess the consistency of the ratings from the three engineers, Cohen's Kappa coefficient was used to measure the pairwise consistency of the ratings from any two engineers. The arithmetic mean of these three Kappas was taken as the overall consistency index. Only when the average Kappa value was not lower than 0.7 was the labeling considered consistent, and the sample was removed and resampled. In this embodiment, the average Kappa value was 0.81. The training set consisting of all samples was divided into a training subset and a validation subset in a 4:1 ratio. The training subset was used for decision tree growth and out-of-bag (OOB) error estimation, while the validation subset was used for evaluating the overall classification accuracy and confusion matrix. The model was only accepted and embedded into the scheduling engine model library if the overall classification accuracy was not lower than 92% after training. During runtime, the first load feature of the query request is processed according to the above feature encoding and normalization rules to obtain a 5-dimensional standardized feature vector. The 5-dimensional standardized feature vector is input into the preset random forest model. Each decision tree independently outputs a level prediction value (an integer from 1 to 5). The prediction results of all decision trees are statistically analyzed according to the majority voting rule. The level with the most votes is taken as the initial level output. When there are two or more levels with the same number of votes, the level with the smallest value is taken as the initial level output.

[0024] In step S12, the query request is parsed using a syntax tree based on the initial level to obtain a sequence of physical operators. This sequence of physical operators is then segmented to obtain an execution phase. Resource usage statistics are then performed on the execution phase to obtain the computational resource usage, including: The structured query statement of the query request is parsed using a syntax tree to obtain a logical execution plan. The nodes of the logical execution plan are traversed and transformed to obtain a sequence of physical operators. The physical operator sequence is segmented according to the data redistribution boundary to obtain the execution stage; The computational resource usage is obtained by weighting the thread concurrency and memory allocation during the execution phase.

[0025] In one implementation, the step of segmenting the physical operator sequence according to the data redistribution boundary to obtain the execution stage includes: The physical operator sequence is segmented according to the data redistribution boundary to obtain a pre-execution stage and a post-execution stage. The pre-execution stage is the first execution stage before data redistribution. The scheduling actions of generating resource pressure signals, clustering query requests within the execution stage according to the resource pressure signals, hierarchically degrading the set to be recycled, and allocating resources to the protected set according to the resource matching degree are all implemented in the pre-execution stage.

[0026] The syntax tree parsing is implemented using the SQL parser built into the database kernel. The input is the structured query statement text corresponding to the query request, and the output is a logical execution plan composed of logical operator nodes (such as table scan, selection, projection, join, aggregation, etc.). The logical execution plan is a tree, with the leaves corresponding to the base table scan and the root corresponding to the final result output.

[0027] Subsequently, a depth-first traversal is used to iterate through the logical execution plan, starting from the root node and proceeding in left-subtree priority. For each logical operator node, a physical transformation is performed according to preset heuristic query optimization rules. For example, for logical join operators, one of nested loop joins, hash joins, or merge joins is selected as the physical operator based on its cost estimate; for logical aggregation operators, one of hash aggregation or sort aggregation is selected as the physical operator. The heuristic query optimization rules are cost-minimizing search strategies permanently implemented in the database kernel. After the traversal is complete, a sequence of physical operators arranged in chronological order is obtained.

[0028] Based on the data redistribution boundary, the sequence of physical operators is scanned from left to right. Whenever a data redistribution type operator is encountered, the sequence is cut off at that point, dividing the original sequence into multiple sub-sequences, each corresponding to an execution stage. In this embodiment, the 7th operator is used as the dividing boundary, representing a data redistribution type operator, i.e., the Exchange operator (indicating cross-node data exchange requirements). The original sequence of 15 physical operators is divided into two execution stages: the pre-execution stage includes physical operators 1 to 7 (mainly table scans, conditional filtering, and local aggregation), and the post-execution stage includes physical operators 8 to 15 (mainly cross-node joins and final aggregation). Subsequent resource scheduling and queue rearrangement processes in S13 to S15 are implemented for the pre-execution stage.

[0029] It should be noted that this invention anchors all scheduling actions—such as generating resource pressure signals, clustering query requests within the execution phase based on these signals, hierarchically downgrading the collection to be recycled, and allocating resources to the protected collection based on resource matching—to the pre-execution phase. This differs from existing technologies that uniformly schedule the entire query or the entire cluster resources. Since the pre-execution phase occurs before cross-node data exchange, its perception and recycling of computational resource pressure directly determine the waiting latency for subsequent data redistribution and cross-node exchange. Moving the scheduling anchor point to this phase avoids the irreversible waiting introduced by scheduling after cross-node data exchange, which is crucial for reducing end-to-end query latency.

[0030] Thread concurrency refers to the number of concurrent worker threads allocated in the execution engine during the execution phase (in units), which is automatically calculated by the query optimizer when generating the physical execution plan based on the ratio of data scan volume to CPU cores during the execution phase. Memory allocation refers to the pre-allocated memory quota (in MB) in the database buffer pool during the execution phase, which is estimated by the memory management module based on the size of the intermediate result sets involved in the execution phase. This embodiment uses a thread concurrency of 32 and a memory allocation of 4096 MB as an example.

[0031] The weighted statistics are achieved using a preset resource pressure index synthesis formula. Thread concurrency and memory allocation are normalized to dimensionless ratios according to their respective preset baseline values, and then summed according to their respective resource weights to obtain a dimensionless resource pressure index. Simultaneously, thread concurrency and memory allocation are compared with their respective fractal dimension thresholds. The normalization relationships are: thread concurrency normalized value Nnorm = Nthread / N0, memory allocation normalized value Mnorm = Mmem / M0, where N0 is the preset baseline number of threads (number of threads) and M0 is the preset baseline number of memory (MB). The synthesis relationship is: resource pressure index C = w1 × Nnorm + w2 × Mnorm, where w1 is the preset thread weight coefficient and w2 is the preset memory weight coefficient, and the sum of w1 and w2 is 1.

[0032] Since both types of resources have been normalized to dimensionless ratios according to their respective baseline values, the resource pressure index is a dimensionless quantity. This eliminates the incommensurability issue of converting two different types of resources to the same scalar, and also prevents a single dimension from exhausting the entire threshold budget. In this embodiment, the preset thread baseline N0 is 20, the preset memory baseline M0 is 2048MB, w1 is 0.6, and w2 is 0.4. The physical meanings of N0 and M0 are the typical levels of thread concurrency and memory allocation during the execution phase of the same database under typical mixed load conditions. These are taken as the median of at least 3000 execution phase samples running continuously for at least 30 days under experimental cluster conditions (20 samples and 2048MB in this embodiment). A resource pressure index of 1 indicates that the combined resource usage of the two types during the execution phase reaches the typical level. The values ​​of w1 and w2 are determined by collecting no fewer than 50 system operation samples of the same database under different resource occupancy conditions in the experimental cluster. The optimization objective is to maximize the correlation coefficient between the resource pressure index and whether system-level blocking occurs in the corresponding execution stage. Within the grid, three combinations of w1 and w2 are used: 0.5:0.5, 0.6:0.4, and 0.7:0.3. The highest correlation coefficient of 0.88 is found when the ratio is 0.6:0.4.

[0033] The fractal thresholds include a preset thread fractal threshold and a preset memory fractal threshold. Their physical meaning is the upper limit of the occupation of each type of resource. They are respectively taken as the 85th percentile of the thread concurrency and memory allocation in the sample of the same type of database under typical mixed load conditions during the execution phase (30th and 3600MB respectively in this embodiment). The two and the preset resource threshold constitute three parallel judgment conditions. If any one of them is true, it is determined that the resource occupation of the current execution phase exceeds the permitted range. Substituting the parameters of this embodiment, the normalized value of thread concurrency is 32 / 20=1.6, the normalized value of memory allocation is 4096 / 2048=2.0, and the resource pressure index C=0.6×1.6+0.4×2.0=1.76. This value is the amount of computing resources used during the execution phase. Since 1.76 is greater than the preset resource threshold of 1.0, and the thread concurrency of 32 is greater than the preset thread fractal threshold of 30, and the memory allocation of 4096MB is greater than the preset memory fractal threshold of 3600MB, all three judgment conditions are met, and a resource pressure signal is generated accordingly.

[0034] It should be noted that the preset thread baseline of 20, preset memory baseline of 2048MB, preset thread weight coefficient of 0.6, preset memory weight coefficient of 0.4, preset thread fractal threshold of 30, and preset memory fractal threshold of 3600MB are all engineering constants that were calibrated and fixed once for the same type of database cluster during the production and debugging phase. During runtime, only two divisions, two multiplications, and three comparisons are required, resulting in minimal computational overhead.

[0035] For example, Figure 2 This diagram illustrates the resource consumption and execution phase segmentation of the physical operator sequence. The resource consumption of the 15 physical operators is weighted and aggregated into a progressively accumulating resource pressure index. During the pre-execution phase, the index gradually increases but does not exceed the preset resource threshold of 1.0. At the first Exchange operator, the accumulated value reaches 1.76, exceeding the threshold and triggering a resource pressure signal. Accumulation continues in subsequent execution phases before entering the final stage. The curve preserves the progressively increasing process at each operator, demonstrating that segmenting the execution phase based on data redistribution boundaries and determining resource pressure based on the accumulated resource consumption at each phase can generate a resource pressure signal before cross-node data exchange execution. This provides a quantitative basis for clustering and hierarchical degradation scheduling in the pre-execution phase.

[0036] In step S13, if the computational resource consumption exceeds a preset resource threshold, a resource pressure signal is generated. Based on the resource pressure signal, the query requests within the execution phase are clustered to obtain a protected set and a set to be reclaimed, including: The execution cost and memory consumption of each query request during the execution phase are extracted, and after normalization, a two-dimensional request feature vector is obtained. The two-dimensional request feature vector is then processed by K-means clustering and divided into a high-resource-consumption cluster and a low-resource-consumption cluster, which correspond to the set to be reclaimed and the set to be guaranteed, respectively.

[0037] The preset resource threshold is 1.0 (dimensionless). At least 3000 execution phase samples of the same database model running continuously for at least 30 days under standard mixed load conditions were collected under experimental cluster conditions. The computational resource consumption of each sample was calculated using the S12 method described above. Simultaneously, the database kernel's blocking monitoring module recorded whether each sample actually caused system-level blocking (the blocking criterion was that the lock wait queue length exceeded 32 or the transaction rollback rate exceeded 5% during the corresponding execution phase). The 85th percentile of all computational resource consumption was sorted from smallest to largest and used as a candidate for the lower limit of the preset resource threshold. The 15th percentile of the computational resource consumption of the sample set that actually caused blocking was calculated as a candidate for the upper limit. The median of these two values ​​yielded the preset resource threshold of 1.0. This value was obtained statistically from a validation sample set independent of the aforementioned calibration samples. This approach can achieve a system-level blocking event recall rate of at least 80% while controlling the false positive rate of non-blocking samples to within 15%. If the computational resource usage is greater than the preset resource threshold of 1.0, it is determined that there is a resource pressure risk in the current execution stage, and the clustering partitioning step is directly triggered without using deadlock detection as a prerequisite. If the computational resource usage is less than or equal to the preset resource threshold of 1.0, it is determined that there is no resource pressure risk in the current execution stage, no resource pressure signal is generated, no clustering partitioning is required, and each query request directly executes the regular scheduling process at the initial level without triggering the hierarchical degradation and resource reclamation in S14.

[0038] It should be noted that in this embodiment, a preset resource threshold is used as a sufficient condition for triggering the S13 clustering partition, which operates independently of the database kernel's deadlock detection mechanism. Deadlock detection is implemented by the database kernel's lock manager using an independent wait graph loop detection algorithm, serving as a parallel mechanism in this embodiment rather than a prerequisite for S13. When deadlock detection triggers and outputs a deadlock loop, the lock manager selects the transaction with the lowest cost in the deadlock loop for explicit rollback according to mature practices in the field. This rollback operation is executed in conjunction with the explicit cancellation of transaction branches in the S14 tiered degradation strategy but is not constrained by the S13 clustering partition. Among them, deadlock transactions with an initial level of 1 are only handled by this kernel rollback mechanism and do not enter the explicit cancellation file of S14.

[0039] The execution phase query requests refer to the set of all concurrent query requests that are currently in the same execution phase and are all active. This set is obtained by filtering by the global transaction manager according to the execution phase identifier. The execution phase identifier is generated by the global transaction manager based on the position of the first data redistribution operator in the physical operator sequence of each query request. Query requests with the same position of the first data redistribution operator share the same execution phase identifier. For each query request in the set, its estimated execution cost (in units, synchronously output by the optimizer's cost model when generating the physical execution plan) is extracted from the database optimizer, and its estimated memory consumption (in MB) is extracted from the memory management module, resulting in two-dimensional raw metrics for each query request. In this embodiment, the set of concurrent query requests in the execution phase contains 50 requests, where the main query request causing resource pressure has an execution cost of 8500 and a memory consumption of 4096 MB.

[0040] The normalization process uses min-max normalization, which linearly maps the execution cost to the interval 0 to 100 according to the preset execution cost range [0, 20000]. The normalized value E norm =E / 20000×100, where E is the execution cost, E norm The execution cost is normalized; memory consumption is linearly mapped to the range of 0 to 100 according to a preset memory value range [0, 16384MB], and the normalized value M is... norm =M / 16384×100, where M is the memory consumption (MB), M norm The normalized value of memory consumption is set. The preset execution cost range [0, 20000] and the preset memory range [0, 16384MB] are obtained by collecting the maximum values ​​of no less than 3000 sets of execution phase samples under standard mixed load conditions for no less than 30 days under experimental cluster conditions and rounding them up. When the real-time value exceeds the range, it is clamped according to the boundary value.

[0041] The normalized execution cost and memory consumption are concatenated in time to form a two-dimensional request feature vector. The input to K-means clustering is a set of two-dimensional request feature vectors of all concurrent query requests during the execution phase (50 two-dimensional vectors in this embodiment). The number of clusters is preset to 2 (corresponding to high resource consumption clusters and low resource consumption clusters respectively). This scheme is applicable to scenarios where the execution cost and memory consumption of concurrent query requests during the execution phase exhibit a bimodal distribution in the two-dimensional feature space. When the actual samples do not exhibit a clear bimodal structure after kernel density estimation (kernel density estimation uses a Gaussian kernel, and the bandwidth is determined by multiplying 1.06 times the standard deviation of the samples by the negative fifth power of the number of samples; the main peak refers to the maximum point where the kernel density value is not less than 60% of the maximum value among all maxima and there is a minimum value on each side; if the kernel density curve has only one main peak, it is determined that there is no significant high and low resource consumption stratification, and all query requests are directly assigned to the protected set; at this time, the set to be reclaimed is an empty set, and there is no need to execute the stratification and degradation and resource reclamation process of S14. Each query request is scheduled normally according to the initial level. The maximum number of iterations for K-means clustering is preset to 50, and the convergence threshold is preset to 0.01 (i.e., iteration stops when the maximum displacement of the cluster center in this round is less than 0.01). The convergence threshold of 0.01 is dimensionless, corresponding to 0.01 units in the normalized value range of 0 to 100, which is equivalent to the slight fluctuation of execution cost or memory consumption under the original dimension. In this embodiment, when iterating to the 8th round, the maximum displacement of the cluster center drops to 0.006, which is less than the convergence threshold of 0.01, and convergence is achieved, and the first cluster center and the second cluster center are output.

[0042] For each query request, the Euclidean distance between its two-dimensional request feature vector and the first cluster center and the second cluster center is calculated, resulting in a first distance metric and a second distance metric. If the first distance metric is less than the second distance metric, the query request is determined to belong to the cluster corresponding to the first cluster center; if the second distance metric is less than the first distance metric, the query request is determined to belong to the cluster corresponding to the second cluster center; when the first and second distance metric are completely equal (this situation rarely occurs in engineering practice), the query request with the later transaction start time is preferentially assigned to the second cluster center.

[0043] After clustering, the clusters are named according to the resource consumption levels of the two cluster centers. Clusters with higher average execution costs within their samples are marked as high-resource-consumption clusters, and those with lower average execution costs are marked as low-resource-consumption clusters. In this embodiment, the average execution cost of the samples within the cluster corresponding to the first cluster center is 7500, and the average memory consumption is 3500MB, so it is marked as a high-resource-consumption cluster; the average execution cost of the samples within the cluster corresponding to the second cluster center is 1200, and the average memory consumption is 800MB, so it is marked as a low-resource-consumption cluster. The set mapping rule is as follows: query requests belonging to low-resource-consumption clusters are assigned to the protected set (which has lower resource consumption, lower cost of recovery after release, and can quickly yield resources for urgent queries), while query requests belonging to high-resource-consumption clusters are assigned to the pending-recovery set (which has higher resource consumption and is the main source of resource contention). Based on this, the protected set and the pending-recovery set are output as scheduling inputs for subsequent S14.

[0044] It should be noted that the initial level represents the business latency requirements of the query request, while the protected set and the pending set represent the resource usage status of the query request. Both are recorded in parallel in the session context of the query request and do not overwrite each other. In the hierarchical degradation in S14, only the degradation level is executed for query requests with an initial level of 1 and that are assigned to the pending set. The pause level and explicit cancellation level are not executed.

[0045] In step S14, the set to be reclaimed is hierarchically downgraded to obtain idle resources. These idle resources are then matched with the protected set to obtain a resource matching degree. Based on the resource matching degree, resources are allocated to the protected set to obtain a scheduling decision instruction, including: In one implementation, the step of hierarchically downgrading the set to be recycled to obtain idle resources includes: Based on the initial level and resource group identifier of each query request in the set to be recycled, determine the corresponding concurrency limit and memory quota limit, and suspend query requests that exceed the concurrency limit or memory quota limit to a preset waiting queue for recycling. For running requests awaiting recycling, a pre-defined hierarchical degradation strategy is applied sequentially to perform degradation and suspension processing. Specifically, the degradation process reduces concurrency and memory quota according to a pre-defined degradation coefficient. In the suspension process, if the idle resources released after the degradation process are triggered do not reach the target recycling amount, the query requests that are running but have not entered the critical stage are suspended at a pre-defined preemption point. The pre-defined preemption point is the data materialization point or data redistribution boundary in the physical operator sequence. If resources are still insufficient after both the downgrade and pause are triggered, or if there are deadlocked transactions in the set to be reclaimed, the cancellation order of query requests in the preset downgrade failure set is determined according to the preset victim criterion, and explicit cancellation is performed sequentially according to the cancellation order. The processor threads and buffer pool data pages of the cancelled transactions are reclaimed to obtain free resources. The preset victim criterion is the query request's remaining time margin in ascending order and rollback cost in ascending order. The remaining time margin is the query request's SLA deadline minus the current time and then its estimated remaining execution time. The SLA deadline is obtained by adding the query request's arrival time to its initial level's corresponding SLA response delay commitment. The rollback cost is the sum of the number of intermediate results generated by the query request and the number of locks held. When all the above criteria are the same, the cancellation order is determined in descending order of transaction start time.

[0046] In one implementation, the step of matching the idle resources with the guaranteed set to obtain a resource matching degree, and allocating resources to the guaranteed set according to the resource matching degree to obtain a scheduling decision instruction includes: The supply vector of the idle resources is matched with the demand vector of the guaranteed set to obtain the resource matching degree; Based on the resource matching degree, the capacity of the protected set is assessed to obtain the target allocation quota; Nodes are mapped according to the target allocation quota to obtain node mapping relationships. The node mapping relationships and the session context of the protected set are encapsulated to obtain scheduling decision instructions.

[0047] The pre-defined tiered degradation strategy implements admission control and runtime degradation for the collection to be reclaimed. The concurrency limit and memory quota limit for each query request in the collection to be reclaimed are determined by querying a pre-defined admission control mapping table based on its initial level and resource group identifier. This admission control mapping table is created by the database administrator during system initialization according to the hardware configuration of the resource group, specifying the concurrency limit and memory quota limit corresponding to each initial level. In this embodiment, the admission control mapping table for the resource group containing the collection to be reclaimed specifies that the concurrency limits for initial levels 1 to 5 are 16, 8, 4, 2, and 1 respectively, and the corresponding memory quota limits are 8192MB, 4096MB, 2048MB, 1024MB, and 512MB respectively. That is, the query request for initial level 3 corresponds to a concurrency limit of 4 and a memory quota limit of 2048MB. The tiered degradation strategy is triggered sequentially in three levels: degradation, pause, and explicit cancellation, with each level corresponding to independent triggering conditions and reclamation actions. The first tier is degrading, triggered when the resource utilization rate of the collection to be reclaimed (the greater of the ratio of the number of processor threads currently occupied by the collection to the total number of processor threads in the system, and the ratio of the number of buffer pool data pages currently occupied to the total number of buffer pool data pages in the system) exceeds a preset degrading trigger threshold of 70%. The preset 70% threshold is based on collecting at least 30 system operation samples of the same database model under standard mixed load conditions in an experimental cluster, recording the high-priority request SLA default rate for each sample, and using an SLA default rate not exceeding 5% as a constraint. The calculation shows that degrading is initiated when the resource utilization rate reaches 70%. The first level can maintain high resource utilization while ensuring the service quality of high-priority requests. The recycling action involves reducing the concurrency limit and memory quota limit of running query requests in the recycling set by a preset degradation coefficient of 0.5. The degradation coefficient of 0.5 is determined by conducting no less than 30 degradation experiments on the same database under load. The experiment method is to try degradation coefficients of 0.3, 0.5, 0.7, and 0.9 on the suspended transactions to be recycled, and record the average response latency of high-priority requests and the abnormal rollback rate of transactions to be recycled after each experiment. With the goal of the SLA default rate not exceeding 5% and the rollback rate not exceeding 3%, the degradation coefficient of 0.5 is obtained. In this embodiment, taking the query request concurrency limit of 4 and the memory quota limit of 2048MB before degradation of the recycling set as an example, after degradation by the degradation coefficient of 0.5, the concurrency limit is reduced to 2 and the memory quota limit is reduced to 1024MB. The excess worker threads and buffer pool pages are naturally transferred to the idle resource pool.

[0048] The second level is pause, triggered when the idle resources released after the downgrade level is triggered do not reach the target recovery amount. To avoid false triggering caused by instantaneous fluctuations in resource utilization, after the downgrade level is triggered, a preset observation window of 500ms is waited (the preset observation window of 500ms and the subsequent preset observation window of 1000ms for the third level are used to retain the effective time of the downgrade action between adjacent levels, and their values ​​correspond to the measured average effective time of the resource recovery action in the downgrade and pause levels, respectively, obtained from statistics of no less than 30 downgrade experiments in the experimental cluster) before this level is executed. If the target recovery amount has been reached within the observation window, this level will not be executed.

[0049] The reclamation action involves suspending query requests in the set to be reclaimed that are in a running state but have not yet entered the critical phase and whose initial level is not 1 at a preset preemption point (the critical phase refers to the pre-commit phase that has been written to the redo log; suspending such query requests would violate transaction atomicity). Suspension is only performed at the preset preemption point so that the intermediate results of the suspended query requests are already in the preset storage location (temporary table, overflow file, or buffer pool data page) at the time of suspension. Therefore, they can resume running at this preset storage location without saving the processor register state or worker thread context. The session identifier of the suspended query request and its preset storage... The position is suspended to a preset waiting queue for reclamation. The processor thread it occupies is released back to the worker thread pool for reuse by other query requests. The row locks and page locks it has acquired are retained and not released with the suspension. When the resource utilization rate of the waiting set falls below the preset degradation trigger level of 70% and the processor thread required can be provided by the idle resource pool, the scheduling engine retrieves the query request from the preset waiting queue for reclamation according to the transaction start time and continues to execute it from the preset storage location. The dirty pages in the buffer pool data pages exclusively occupied by the query request are not immediately written back to disk but are marked as reclaimable for subsequent replacement according to the LRU policy.

[0050] When the preset storage location is unavailable or intermediate results need to be retained in memory, the scheduling engine can also save the worker thread context corresponding to the query request to the session recovery point and unbind it from the processor core. The worker thread context includes register state, stack pointer, and pointer to the intermediate result set associated with the query request. When resources fall back, it is loaded into the session recovery point and rebound to the processor core before execution continues. It should be noted that the target reclamation amount refers to the total amount of resources that need to be reclaimed from the set to be reclaimed in this scheduling round to make up for the resource gap in the protected set. Its value is equal to the number of processor threads currently lacking in the protected set and the number of buffer pool data pages (in this embodiment, the lack is 50 processor threads and 3000 buffer pool data pages, which is consistent with the lack recorded in the demand vector below).

[0051] The third tier is explicit cancellation. The trigger conditions are: if the idle resources released after the pause are not yet sufficient to meet the target recovery amount, and the target recovery amount is still not met after a preset observation window of 1000ms following the pause, or if there are deadlocked transactions in the collection to be recovered with an initial level not equal to 1. The recovery action involves constructing a cancellation queue according to preset victim criteria. The ordering rules and definitions of each criterion are as described above. The estimated remaining execution time is calculated by the database optimizer's cost model based on the physical execution plan of the query request. For each session identifier in the queue, the execution context of the corresponding session is terminated using the explicit cancellation interface (i.e., the database kernel's KILLQUERY interface or an equivalent transaction cancellation API).

[0052] The complete semantics of explicit cancellation are as follows: After calling the explicit cancellation interface, wait for the transaction rollback to complete (the rollback process is automatically executed by the database kernel's undolog according to mature practices in this field, restoring the data pages written by the transaction to their state before the transaction started); all locks held by the transaction are released by the lock manager upon rollback completion, with the release order being the reverse of the lock acquisition order; the transaction's client connection immediately receives an error code (in this embodiment, SQLSTATE57014 is used to indicate that the transaction was explicitly cancelled by the scheduling engine) and a retry flag (a value of TRUE indicates that the client can resubmit the original query request after a preset backoff time of 500ms); dirty pages in the buffer pool are naturally converted to a reusable state after the undolog rollback, without the need for additional write-back operations. The preset degradation failure set is a subset of the set to be reclaimed, arranged according to the preset victim criterion, and its size is determined by the current target resource amount to be reclaimed.

[0053] The supply vector is a two-dimensional vector constructed by concatenating the number of processor threads in the idle resource pool and the number of buffer pool data pages obtained from the aforementioned downgrade and pause tiers according to a preset field order. This embodiment takes the state of the idle resource pool before the explicit cancellation of the third tier is triggered as an example. The number of processor threads in the idle resource pool is 36, and the number of buffer pool data pages is 2400. The set to be reclaimed contains 35 query requests. The downgrade tier reclaims 2 processor threads and 120 buffer pool data pages from each of the 10 query requests with a downgrade coefficient of 0.5. The pause tier reclaims 2 processor threads and 150 buffer pool data pages from each of the other 8 query requests that are in running state, have not entered the critical stage, and whose initial level is not 1. The remaining 17 query requests maintain their original quotas. The two tiers together reclaim 36 processor threads and 2400 buffer pool data pages. The number of processor threads is the number of threads that can be released after adjusting for the concurrency limit reduction, and the number of buffer pool data pages is the number of dirty pages marked as reclaimable. These two are counted separately and are not converted to each other.

[0054] The demand vector is a two-dimensional vector formed by concatenating the total number of processor threads currently lacking for all query requests in the protected set and the total number of buffer pool data pages in the same field order. The lack quantity is obtained by subtracting the number of resources currently held from the minimum running threshold of each query request in the protected set (i.e., the minimum number of resources required to ensure that the query request can start and complete normally). In this embodiment, the protected set contains 15 OLAP query requests, with a cumulative lack of 50 processor threads and a lack of 3000 buffer pool data pages.

[0055] The resource matching degree is calculated using a preset two-dimensional resource vector matching formula: RM = (wcpu × min(Rcpu, 1) + wpage × min(Rpage, 1)) × 100, where Rcpu = Scpu / Dcpu is the processor thread supply-demand ratio, Rpage = Spage / Dpage is the buffer pool data page supply-demand ratio, Scpu and Dcpu are the supply and demand of processor threads, Spage and Dpage are the supply and demand of buffer pool data pages, and wcpu and wpage are the preset weights of the processor thread supply-demand ratio and the buffer pool data page supply-demand ratio, respectively (in this embodiment, wcpu = 0.6 and wpage = 0.4).

[0056] When supply exceeds demand, the supply-demand ratio is clamped to 1. The process of obtaining the preset weight ratio of 0.6:0.4 is as follows: under experimental cluster conditions, at least 50 sets of supply-demand matching samples of the same model database are collected under typical mixed load conditions. Resource matching degree is calculated according to different weight combinations (0.3:0.7, 0.4:0.6, 0.5:0.5, 0.6:0.4, 0.7:0.3). The optimization objective is to maximize the Pearson correlation coefficient between the matching degree and the final system throughput improvement. Statistically, the highest correlation coefficient of 0.86 is found when the weight is 0.6:0.4. Substituting the parameters of this embodiment, the processor thread supply-demand ratio is equal to 0.72, the buffer pool data page supply-demand ratio is equal to 0.80, RM=(0.6×0.72+0.4×0.80)×100=75.2. After rounding, the resource matching degree is equal to 75.

[0057] Capacity assessment employs a pre-defined threshold-based hierarchical assessment model to compare resource matching degrees across intervals. The pre-defined capacity assessment thresholds are two boundary values: 70 and 90. The process for obtaining the boundary values ​​of 70 and 90 involves collecting no fewer than 50 system operation samples under different resource matching degrees in experimental cluster conditions, recording the system-level SLA default rate corresponding to each sample, and determining that a resource-sufficient state is characterized by an SLA default rate of less than 2% when the resource matching degree is greater than 90, a resource-critical state is characterized by an SLA default rate of 2% to 10% when the resource matching degree is between 70 and 90, and a resource-scarce state is characterized by an SLA default rate of greater than 10% when the resource matching degree is less than 70. The two boundary values ​​of 70 and 90 are the median boundary points of the SLA default rates of adjacent states.

[0058] If the resource matching degree is greater than or equal to 90, it is determined to be a resource-sufficient state, and the target allocation quota is directly equal to the amount of resources lacking in the protected set. If the resource matching degree is between 70 and 90, it is determined to be a resource-critical state, and the target allocation quota is equal to the amount of resources lacking multiplied by a preset conservative coefficient of 0.8. If the resource matching degree is less than 70, it is determined to be a resource-scarce state, and the target allocation quota is equal to the amount of resources lacking multiplied by a preset urgency coefficient of 0.6, and no less than 10% of the total system resources are reserved as base-level reserved resources. The process of obtaining the preset conservative coefficient of 0.8 and the preset urgency coefficient of 0.6 is as follows: under experimental cluster conditions, load stress tests are conducted with no less than 30 groups of different allocation ratios, with the goal of SLA default rate not exceeding 5% and system throughput maximized, and the above two coefficients are determined using a grid search method.

[0059] It should be noted that each component of the target allocation quota does not exceed the corresponding component of the supply vector. If it exceeds, the value is taken according to the corresponding component of the supply vector. In this embodiment, the resource matching degree is 75, which is a critical resource state. The target allocation quota for processor threads is calculated as 50 multiplied by 0.8, which equals 40. After clamping according to the supply of 36, 36 are taken. The target allocation quota for buffer pool data pages is equal to 3000 multiplied by 0.8, which equals 2400. This does not exceed the supply of 2400.

[0060] Subsequently, node mapping is performed on the protected set. The node mapping is implemented using data partition affinity mapping. The processor thread and buffer pool data page corresponding to the target allocation quota are mapped to the NUMA node holding the partition copy according to the partition identifier of the main data table involved in each query request in the protected set (or the data partition identifier where the operator is located). The node mapping relationship is output. Using the data partition identifier as the mapping basis can ensure that the NUMA node mapping is consistent with the actual data distribution accessed by the query request, and avoid cross-node memory access caused by the mapping basis being unrelated to the data distribution.

[0061] In scenarios where the database cluster does not provide partition affinity information or does not depend on a specific hardware topology, and NUMA optimization is uniformly scheduled by the operating system, the node mapping step can be omitted, retaining only the direct binding of processor threads to physical cores or leaving it to the operating system scheduler for unified allocation. As a secondary alternative implementation, when the cluster topology changes frequently and the proportion of remapped resources needs to be minimized, node mapping can also be implemented using consistent hashing. That is, the node mapping relationship is output using the transaction identifier of each query request in the protected set as the hash key and the NUMA node number in the database cluster topology as the hash value. MurmurHash3 is used as the hash function to construct a hash ring from 0 to 2^32 minus 1. Each NUMA node in the cluster is mapped to the hash ring according to the hash value of the node identifier, and a preset number of virtual nodes are allocated to each NUMA node to balance the load on the hash ring. Then, each resource to be allocated is bound to the nearest NUMA node in a clockwise direction according to the hash value of the transaction identifier. This ensures that only a minimum proportion of resources need to be remapped when the cluster topology changes.

[0062] It should be noted that when consistent hashing is used, the transaction identifier is not related to the data distribution, which may introduce cross-node access to memory. Therefore, it is only used in the above scenarios.

[0063] The node mapping relationship is stored in a two-dimensional table format. Each row records the corresponding binding relationship of a data partition identifier, a transaction identifier, a NUMA node number, and a physical core number. In this embodiment, 36 processor threads are bound to 4 NUMA nodes, totaling 80 physical cores, and 2400 buffer pool data pages are assigned to the local memory of the 4 NUMA nodes.

[0064] Subsequently, the instruction encapsulation protocol is used to combine and encapsulate the node mapping relationship and the session context (including fields such as transaction identifier, session identifier, and session recovery point) of the protected set to obtain the scheduling decision instruction. The instruction encapsulation protocol adopts a binary frame format, which consists of a frame header, an instruction type field (the value 0x01 indicates resource binding and wake-up), a source address field, a destination address field, a payload length field, a payload field (carrying a priority label field, a resource group identifier field, a node mapping relationship field, and a session context field), a CRC check field, and a frame tail, which facilitates subsequent transmission by S15 through message parsing.

[0065] In step S15, the scheduling decision instruction is sent as request metadata to the storage component and the collaboration module. The storage component and the collaboration module then independently execute priority scheduling locally to obtain the final query request, including: The priority label and resource group identifier in the scheduling decision instruction are sent as request metadata to the storage component and the collaboration module. The two modules independently rearrange the priority of the request queue locally based on the request metadata and output the final query request.

[0066] The final query request is a sequence of query requests executed sequentially in the order of local priority rearrangement by the storage component and the collaboration module. On the storage component side, read transactions are output in the order of the second request queue (i.e., the read transaction queue obtained after rearranging by position index). On the collaboration module side, messages to be processed are output in the order of the local rearranged queue. Both sides determine their respective execution order based on the same set of priority labels and resource group identifiers.

[0067] Parsing the protocol header of the scheduling decision command is achieved through message header parsing. The input is a binary data stream of the scheduling decision command. According to a preset frame structure definition, the frame header, command type field, source address field, destination address field, payload length field, and payload field are separated. The source address field records the network address of the database scheduling engine, and the destination address field records the network address of the target storage component. The payload field carries a priority label field, a resource group identifier field, a node mapping relationship field, and a session context field. In this embodiment, we take a source address of scheduling engine number 01, a destination address of storage component number 582, a command type of high-priority resource binding, a priority label of P1, and a resource group identifier of RG_HIGH as an example. The priority label is generated based on the initial level of the query request: initial levels 1 to 2 are mapped to high-priority label P1, initial level 3 to medium-priority label P2, and initial levels 4 to 5 to low-priority label P3. The resource group identifier is a unique identifier assigned to the resource group to which the query request belongs during system initialization.

[0068] Based on the priority tags written in the metadata header, the storage component reorders the query requests in the local first request queue (the first request queue is a queue of pending read transactions maintained locally by the storage component in the order of arrival) using a preset priority scheduling strategy. The preset priority scheduling strategy adopts a weighted round-robin formula. For each read transaction in the first request queue, the priority is recalculated according to the position index I = wp × Sp + wa × Sa, where I is the position index, wp is the priority weight, Sp is the priority score, wa is the arrival time weight, and Sa is the arrival time score. The priority score is directly mapped from the priority tag in the metadata header (high priority is assigned a value of 3, medium priority is assigned a value of 2, and low priority is assigned a value of 1; for read transactions in the first request queue that do not carry request metadata, the priority tag in the most recently issued request metadata of their respective sessions is used for mapping, and if it is still uncertain, the low priority is assigned a value of 1). The arrival time score Sa = 1 - Tnorm, where Tnorm is the normalized value of the arrival timestamp of the read transaction, Tnorm = (T - Tfirst) / (Tlast - Tfirst), where T is the arrival timestamp of the read transaction, and Tfirst and Tlast are the earliest and latest arrival timestamps in the queue, respectively, linearly mapped to the interval of 0 to 1. When the earliest and latest arrival timestamps in the queue are equal, the normalized value of the arrival time is 0.

[0069] The process of obtaining priority weight and arrival time weight is as follows: Under experimental cluster conditions, at least 50 queue rearrangement samples of the same type of storage component are collected under typical mixed load conditions. The optimization objective is to minimize the average response latency of high-priority requests after rearrangement. A grid search method is used to search within the combined space of priority weights [0.5, 0.6, 0.7, 0.8] and arrival time weights [0.2, 0.3, 0.4, 0.5]. Finally, a priority weight of 0.7 and an arrival time weight of 0.3 are determined, corresponding to the shortest average response latency for high-priority requests. Substituting the 15th transaction parameter in this embodiment (priority label P1 corresponding to priority score 3, arrival time normalized value 0.4, corresponding arrival time score Sa = 1 - 0.4 = 0.6), the position index I = 0.7 × 3 + 0.3 × 0.6 = 2.28.

[0070] The second request queue is not obtained by recalculating the position index and sorting all read transactions. Instead, a priority queue is maintained using the position index as the sorting key. When a read transaction in the first request queue arrives, it is inserted into this priority queue according to its position index. When its request metadata changes, its position is incrementally adjusted in the queue according to the new position index. When dequeuing, the read transaction with the largest position index is taken out. The time complexity of a single insertion and adjustment is O(log n), which avoids the processing overhead of recalculating the position index and sorting all read transactions in each scheduling, which is particularly considerable in the hot path of the storage component's scheduling.

[0071] To prevent low-priority read transactions from becoming starved due to persistently small position indices, read transactions that have been waiting in the queue for longer than a preset aging threshold (200ms in this embodiment) have their arrival time score Sa incremented by a preset aging step (0.1 in this embodiment) before participating in the position index calculation. This ensures that read transactions that have been waiting for a longer time have larger position indices, thus guaranteeing that they will be scheduled within a limited number of rounds. The reordering process is completed in the local execution memory area of ​​the storage component, and the scheduling engine does not extract the active queue of the storage component, avoiding concurrency safety risks caused by cross-component queue extraction.

[0072] To avoid ownership and concurrency security risks associated with extracting active queues across components, in this embodiment, the scheduling engine no longer extracts and matches the second request queue returned by the storage component. Instead, the storage component completes the rearrangement locally and returns a receipt message to the scheduling engine containing the highest priority tag and the corresponding transaction identifier for this batch. The scheduling engine confirms that the storage component has completed priority scheduling according to the unified metadata based on the receipt message.

[0073] Based on the priority tags and resource group identifiers issued by the scheduling decision instructions, the collaboration module independently executes priority scheduling in its local independent scheduling queue according to the same weighted round-robin formula as the storage component. The collaboration module is an independent component in the database cluster responsible for cross-node data exchange and message routing (such as the bus scheduler or message middleware broker of a distributed database). Its locally maintained independent scheduling queue is physically independent from the first request queue of the storage component, but logically operates according to the same set of priority tags and resource group identifiers.

[0074] The specific reordering process is as follows: After receiving the metadata header of the scheduling decision instruction, the collaboration module selects all pending messages matching the resource group identifier from the independent scheduling queue. It maintains its local reordering queue according to the same priority scheduling strategy as the storage component, where the position index equals the priority weight (0.7 times the priority score) plus the arrival time weight (0.3 times the arrival time score). The priority queue is maintained using the position index as the sorting key. The arrival time score is incremented for pending messages whose waiting time in the queue exceeds a preset aging threshold, following the same rules. Upon dequeueing, the collaboration module outputs its local reordering queue. The reordering process is completed solely by the collaboration module within its local execution memory area; the scheduling engine does not extract the collaboration module's independent scheduling queue.

[0075] In one implementation, the aforementioned storage components and collaboration modules can be deployed in a physical resource pool that is independent of the computing layer. That is, the database cluster adopts a deployment model that separates computing and storage. The scheduling engine, storage components, and collaboration modules run on independent physical nodes or independent resource pools. The three interact only through request metadata and receipt messages, do not share memory address space, and the scheduling engine does not hold internal queue handles for the storage components and collaboration modules.

[0076] Since priority scheduling in this solution is completed independently by the storage component and the collaboration module on their respective local machines, the scheduling engine neither extracts their active queues nor dispatches execution instructions for each request. Therefore, the network round-trip latency caused by the separation of computing and storage will not enter the critical path of priority scheduling. Each component can still maintain a consistent priority response order locally based on the unified priority label and resource group identifier. At the same time, when the physical resource pool of the storage component or collaboration module is expanded, shrunk, or migrated, priority synchronization can be completed by simply redistributing the request metadata once, without having to re-establish the queue mapping relationship between the computing layer and the storage layer.

[0077] In one implementation, the method further includes closed-loop feedback correction of the scheduling process: after each scheduling round, the scheduling engine collects the measured result indicators of this round, including the SLA default rate of query requests in the guaranteed set, the target recovery rate of this scheduling round, and the false alarm rate of resource pressure signals (i.e., the proportion of resource pressure signals generated but no system-level blocking occurs within a preset observation window); the deviation between the measured result indicators and the preset target value is statistically analyzed according to a preset correction period (30 scheduling rounds in this embodiment), and when the preset correction is continuous... When the SLA default rate exceeds the target value (5% in this embodiment) within a given period, the degradation trigger level is increased and the resource pressure threshold is decreased by a preset step size (0.05 in this embodiment) to trigger resource recovery actions earlier. When the false alarm rate of the resource pressure signal exceeds the target value or the target recovery achievement rate remains at 100% within a consecutive preset correction period, the degradation trigger level is decreased and the resource pressure threshold is increased by a preset step size (0.05 in this embodiment) to avoid triggering unnecessary resource recovery actions. The degradation coefficient, preset conservative coefficient, and preset emergency coefficient are corrected in the same closed-loop manner. Through the above closed-loop feedback correction, each preset threshold and coefficient no longer depends solely on the one-time offline calibration results during the commissioning phase, but can adaptively adjust with changes in the actual load pattern, maintaining the service quality of query requests in the protected set even when the load structure drifts.

[0078] In summary, this invention discloses a query asynchronous processing scheduling method based on hierarchical priority, which achieves adaptive resource protection for high-priority query requests and elastic resource reclamation for low-priority requests through asynchronous processing scheduling.

[0079] The second embodiment of the present invention provides a query asynchronous processing scheduling system based on hierarchical priority, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the query asynchronous processing scheduling method based on hierarchical priority as described above.

[0080] It should be noted that the query asynchronous processing scheduling system based on hierarchical priority provided in this embodiment of the invention is used to execute all process steps of the query asynchronous processing scheduling method based on hierarchical priority in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.

[0081] The third embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the query asynchronous processing scheduling method based on hierarchical priority as described above.

[0082] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. A query asynchronous processing scheduling method based on hierarchical priority, characterized in that, include: Query requests under mixed load are obtained, and random forest is used to classify the query requests to obtain an initial level; The query request is parsed using a syntax tree based on the initial level to obtain a sequence of physical operators. The sequence of physical operators is then segmented to obtain an execution phase. Resource usage statistics are then performed on the execution phase to obtain the computational resource usage. If the computational resource usage exceeds a preset resource threshold, a resource pressure signal is generated. Based on the resource pressure signal, the query requests in the execution phase are clustered to obtain a protected set and a set to be reclaimed. The set to be recycled is hierarchically downgraded to obtain idle resources. The idle resources are matched with the protected set to obtain the resource matching degree. Resources are allocated to the protected set according to the resource matching degree to obtain scheduling decision instructions. The scheduling decision instruction is sent as request metadata to the storage component and the collaboration module, which then independently execute priority scheduling locally to obtain the final query request.

2. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The process of obtaining query requests under mixed load involves classifying the query requests using a random forest to obtain an initial level, including: Extract the business SLA tag, tenant identifier, query type, number of concurrent connections and memory consumption of the query request as load features. After feature encoding and normalization, input the load features into the pre-trained random forest model and output the initial level.

3. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The process of parsing the query request into a syntax tree based on the initial level to obtain a sequence of physical operators, splitting the sequence of physical operators into data segments to obtain an execution phase, and performing resource usage statistics on the execution phase to obtain the computational resource usage includes: The structured query statement of the query request is parsed using a syntax tree to obtain a logical execution plan. The nodes of the logical execution plan are traversed and transformed to obtain a sequence of physical operators. The physical operator sequence is segmented according to the data redistribution boundary to obtain the execution stage; The computational resource usage is obtained by weighting the thread concurrency and memory allocation during the execution phase.

4. The query asynchronous processing scheduling method based on hierarchical priority according to claim 3, characterized in that, The step of segmenting the physical operator sequence according to the data redistribution boundary to obtain the execution phase includes: The physical operator sequence is segmented according to the data redistribution boundary to obtain a pre-execution stage and a post-execution stage. The pre-execution stage is the first execution stage before data redistribution. The scheduling actions of generating resource pressure signals, clustering query requests within the execution stage according to the resource pressure signals, hierarchically degrading the set to be recycled, and allocating resources to the protected set according to the resource matching degree are all implemented in the pre-execution stage.

5. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The process of obtaining the protected set and the set to be reclaimed includes: The execution cost and memory consumption of each query request during the execution phase are extracted, and after normalization, a two-dimensional request feature vector is obtained. The two-dimensional request feature vector is then processed by K-means clustering and divided into a high-resource-consumption cluster and a low-resource-consumption cluster, which correspond to the set to be reclaimed and the set to be guaranteed, respectively.

6. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The step of hierarchically downgrading the set to be recycled to obtain idle resources includes: Based on the initial level and resource group identifier of each query request in the set to be recycled, determine the corresponding concurrency limit and memory quota limit, and suspend query requests that exceed the concurrency limit or memory quota limit to a preset waiting queue for recycling. For running requests awaiting recycling, a pre-defined hierarchical degradation strategy is applied sequentially to perform degradation and suspension processing. Specifically, the degradation process reduces concurrency and memory quota according to a pre-defined degradation coefficient. In the suspension process, if the idle resources released after the degradation process are triggered do not reach the target recycling amount, the query requests that are running but have not entered the critical stage are suspended at a pre-defined preemption point. The pre-defined preemption point is the data materialization point or data redistribution boundary in the physical operator sequence. When resources are still insufficient after both the downgrade and pause are triggered, or when there are deadlocked transactions in the set to be reclaimed, the cancellation order of query requests in the preset downgrade failure set is determined according to the preset victim criterion, and explicit cancellation is performed in the order of cancellation to reclaim the processor threads and buffer pool data pages of the cancelled transactions and obtain free resources. The preset victim criterion is determined by the ascending order of the remaining time margin and the ascending order of the rollback cost of the query request. The remaining time margin is the SLA deadline of the query request minus the current time and then minus its estimated remaining execution time. The SLA deadline is obtained by adding the arrival time of the query request to the SLA response delay commitment corresponding to its initial level. The rollback cost is the sum of the number of intermediate results generated by the query request and the number of locks held. When all the above criteria are the same, the cancellation order is determined by the reverse order of the transaction start time.

7. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The step of matching the idle resources with the guaranteed set to obtain a resource matching degree, allocating resources to the guaranteed set according to the resource matching degree, and obtaining a scheduling decision instruction includes: The supply vector of the idle resources is matched with the demand vector of the guaranteed set to obtain the resource matching degree; Based on the resource matching degree, the capacity of the protected set is assessed to obtain the target allocation quota; Nodes are mapped according to the target allocation quota to obtain node mapping relationships. The node mapping relationships and the session context of the protected set are encapsulated to obtain scheduling decision instructions.

8. The query asynchronous processing scheduling method based on hierarchical priority according to claim 1, characterized in that, The step of sending the scheduling decision instruction as request metadata to the storage component and the collaboration module, and having the storage component and the collaboration module independently execute priority scheduling locally to obtain the final query request, includes: The priority label and resource group identifier in the scheduling decision instruction are sent as request metadata to the storage component and the collaboration module. The two modules independently rearrange the priority of the request queue locally based on the request metadata and output the final query request.

9. A query asynchronous processing scheduling system based on hierarchical priority, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the query asynchronous processing scheduling method based on hierarchical priority as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the query asynchronous processing scheduling method based on hierarchical priority as described in any one of claims 1 to 8.