A method, device and equipment for detecting deadlocks in data query scheduling

By generating a query plan tree and analyzing the execution order relationship, the hash connection and scheduling deadlocks of public temporary tables during the query process are detected, and the deadlock problem during the query process is solved, and accurate deadlock detection and processing is achieved.

CN117312346BActive Publication Date: 2025-07-15BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311322425.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-12
Publication Date
2025-07-15
Estimated Expiration
2043-10-12

AI Technical Summary

Technical Problem

In the prior art, there may be scheduling deadlocks caused by hash connections and the use of public temporary tables during the query process, resulting in query failure and lack of effective detection methods.

Method used

By generating a query plan tree, traversing the right-hand link and analyzing the execution order relationship of the operator nodes, checking whether there is a public temporary table consumption operator node with a scheduling dependency in the query plan tree, and determining whether there is a scheduling deadlock.

Benefits of technology

It can accurately detect and determine whether there is a scheduling deadlock in the query plan tree, and promptly identify the public temporary table consumption and production operator nodes that cause deadlocks, so as to improve query processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117312346B_ABST
    Figure CN117312346B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, and device for detecting data query scheduling deadlocks. The query plan tree generated from the query statement includes a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node. Determine at least one right table chain in the tree. The right table chain includes leaf nodes. When the parent node of the operator node in the right table chain is a hash join operator node, the operator node is the right child node of its parent node. The right table chain includes the parent node, and the right table chain also includes the root node of the non-hash join operator node. Traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and traverse other operator nodes in the tree, and analyze the execution order relationship between the operator nodes traversed in the tree. When two identical common temporary table consumption operator nodes with scheduling dependencies are found in the tree based on the execution order relationship, and their upstream operator is the same common temporary table production operator, it is determined that there is a scheduling deadlock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly relates to a method, device and equipment for detecting data query scheduling deadlocks. Background Art

[0002] Common Table Expressions (CTE) is a commonly used Structured Query Language (SQL) syntax for defining common temporary tables in a query. The query process is usually constructed as a pipeline, with the query process scheduled from top to bottom and executed from bottom to top.

[0003] Hash Join is a multi-table operation method for joining two tables. When both the use of CTE and the use of Hash Join appear in the pipeline of the query process, there may be a situation of scheduling deadlock, which may lead to query failure. Currently, there is an urgent need for a method for detecting scheduling deadlocks to detect whether there is a scheduling deadlock in the query process. Summary of the Invention

[0004] In view of this, this application provides a method, device and equipment for detecting data query scheduling deadlocks, which can accurately detect whether there is a scheduling deadlock in the query process.

[0005] To solve the above problems, the technical solutions provided in this application are as follows:

[0006] In a first aspect, this application provides a method for detecting data query scheduling deadlocks, the method including:

[0007] Obtain a query statement and generate a query plan tree corresponding to the query statement; the query plan tree includes multiple operator nodes and the query logical relationships between the multiple operator nodes; the operator nodes include common temporary table production operator nodes, common temporary table consumption operator nodes, and hash join operator nodes;

[0008] Traverse the query plan tree to determine at least one right table chain in the query plan tree; the right table chain includes leaf nodes in the query plan tree and root nodes that are not hash join operator nodes; when the father node of the operator node in the right table chain is a hash join operator node, the operator node is the right child node of its father node, and the right table chain includes the father node of the operator node;

[0009] Traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and traverse the other operator nodes of the query plan tree. Analyze the execution order relationship between the traversed operator nodes in the query plan tree, and find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship indicates that the execution order between the two identical common temporary table consumption operator nodes is different.

[0010] When the upstream operator nodes of the two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node, it is determined that there is a scheduling deadlock.

[0011] In a second aspect, the present application provides a detection device for data query scheduling deadlock. The device includes:

[0012] A generation unit, configured to obtain a query statement and generate a query plan tree corresponding to the query statement; the query plan tree includes multiple operator nodes and the query logical relationship between the multiple operator nodes; the operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node.

[0013] A first determination unit, configured to traverse the query plan tree to determine at least one right table chain in the query plan tree; the right table chain includes the leaf nodes in the query plan tree and the root nodes that are not the hash join operator nodes; when the father node of the operator node in the right table chain is the hash join operator node, the operator node is the right child node of its father node, and the right table chain includes the father node of the operator node.

[0014] A search unit, configured to traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and traverse the other operator nodes of the query plan tree. Analyze the execution order relationship between the traversed operator nodes in the query plan tree, and find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship indicates that the execution order between the two identical common temporary table consumption operator nodes is different.

[0015] A second determination unit, configured to determine that there is a scheduling deadlock when the upstream operator nodes of the two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node.

[0016] In a third aspect, the present application provides an electronic device, including:

[0017] One or more processors;

[0018] A storage device, on which one or more programs are stored,

[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the data query scheduling deadlock detection methods.

[0020] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, any of the data query scheduling deadlock detection methods is implemented.

[0021] Thus, the present application has the following beneficial effects:

[0022] The present application provides a method, apparatus, and device for detecting a data query scheduling deadlock. First, a query statement is obtained, and a query plan tree corresponding to the query statement is generated. The query plan tree includes a plurality of operator nodes and the query logical relationships between the plurality of operator nodes. The operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node. Then, there may be a scheduling deadlock in the query plan tree. Based on this, the query plan tree is traversed to determine at least one right table chain in the query plan tree. The right table chain includes leaf nodes and hash join operator nodes in the query plan tree. When the parent node of the operator node in the right table chain is a hash join operator node, the operator node is the right child node of its parent node, and the right table chain includes the parent node of the operator node; when the root node of the query plan tree is not a hash join operator node, the right table chain includes the root node. It can be seen that the right table chain includes a hash join operator node and the right child node of the hash join operator node. Then, when there is a scheduling deadlock in the query plan tree, it is usually caused by the scheduling dependency of the link other than the right table chain in the query plan tree on the right sub-link of the hash join operator node in the right table chain. Specifically, the common temporary table production operator node in the link other than the right table chain in the query plan tree has a scheduling dependency on the same common temporary table production operator node in the right sub-link of the hash join operator node in the right table chain.

[0023] Therefore, in this application, each right table chain is used as the traversal reference. Starting from the leaf node of the right table chain, the operator nodes in the right table chain are traversed from bottom to top, and the other operator nodes of the query plan tree are also traversed to analyze the execution order relationship between the traversed operator nodes in the query plan tree. The execution order relationship can be further used to analyze whether there is a scheduling dependency between two identical common temporary table consumption operator nodes in the query plan tree. Thus, two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree are found. When the upstream operator nodes of the two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node, it is determined that there is a scheduling deadlock. In this way, it is possible to more accurately determine whether there is a scheduling deadlock situation in the query plan tree, and it is also possible to more accurately determine the common temporary table consumption operator node and the common temporary table production operator node that cause the scheduling deadlock. Description of the Drawings

[0024] Figure 1a - Figure 1b Schematic diagrams of two query plan trees provided by an embodiment of this application;

[0025] Figure 2 Flowchart of a method for detecting data query scheduling deadlock exemplarily provided by an embodiment of this application;

[0026] Figure 3a - Figure 3e Schematic diagram of a query plan tree with a scheduling deadlock provided by an embodiment of this application;

[0027] Figure 4 Schematic diagram of a query plan tree with a cache operator added provided by an embodiment of this application;

[0028] Figure 5 Schematic diagram of the structure of a device for detecting data query scheduling deadlock provided by an embodiment of this application;

[0029] Figure 6 Schematic diagram of the basic structure of an electronic device provided by an embodiment of this application. Detailed Embodiments

[0030] To make the above objects, features, and advantages of this application more obvious and understandable, the following further describes the embodiments of this application in detail with reference to the drawings and specific embodiments.

[0031] To facilitate the understanding and explanation of the technical solutions provided by the embodiments of this application, the background technology of the embodiments of this application will be described first.

[0032] A Common Table Expression (CTE) is a commonly used Structured Query Language (SQL) syntax for defining a common temporary table used in a query. Inside the query engine, the common temporary table is usually generated uniformly and then output to each place where the common temporary table is used to reduce duplicate calculations and achieve the reuse of the common temporary table. In the embodiments of this application, the place where the common temporary table is generated can be referred to as a CTE Producer, and the place where the common temporary table is used can be referred to as a CTE Consumer. The same CTE Producer can be reused in multiple CTE Consumers.

[0033] Hash Join is a multi-table operation method for joining two tables, which is simply referred to as Join in the embodiments of this application. During the query process, Hash Join may be used for multi-table operations. As an important operator of the query engine, the execution mode of Hash Join includes a hash table construction phase and a hash table probing phase. The two tables operated by Hash Join can be referred to as the left table and the right table. In the hash table construction phase, the data of the right table is read to construct the hash table, and the data of the left table is not processed at this time. In the hash table probing phase, each piece of data of the left table is read to probe and output the relevant data in the hash table.

[0034] The query process is usually constructed into a pipeline (which can also be referred to as a query plan tree). The query process includes a scheduling process and an execution process. The scheduling process is a top-down scheduling (starting from the root node of the query plan tree and going top-down), and the execution process is a bottom-up execution (starting from the leaf nodes of the query plan tree and going bottom-up). When the upstream operator of the pipeline starts to execute, the downstream operator needs to process the intermediate results of the upstream operator in a timely manner to avoid buffer exhaustion. CTE and Hash Join may be used simultaneously in the pipeline of the query process, which may lead to a scheduling deadlock situation during the query process, and thus cause the query to fail.

[0035] See Figure 1a and Figure 1b , Figure 1a - Figure 1b are schematic diagrams of two query plan trees provided by the embodiments of this application. Figure 1a shows the inlining execution mode of CTE in the query engine when both CTE and Hash Join exist in the query plan tree. As Figure 1aAs shown, Scan is the scan operator and Aggregate is the aggregation operator. In the CTE inlining execution mode, a CTE Consumer operator can be added after each aggregation operator. The common temporary tables obtained by each CTE Consumer operator are not generated and passed by the same CTE Producer operator. Therefore, each CTE Consumer operator is executed independently. It can be seen that the execution plan in the CTE inlining execution mode maintains a relatively simple tree structure, can perform query optimization more thoroughly (such as predicate pushdown), and the execution scheduling is also relatively easy.

[0036] Figure 1b Shows the CTE sharing execution mode of the query engine when there are both CTE and Hash Join in the query plan tree. As Figure 1b shown, the common temporary tables obtained by the two CTE Consumer operators are generated and passed by the same CTE Consumer operator. That is, the CTE Producer will be executed uniformly in the CTE sharing execution mode, and then the common temporary table will be output to the two CTE Consumer usage locations. It can be seen that the CTE sharing execution mode can avoid duplicate calculation of the data in the common temporary table. When the calculation cost of the common temporary table itself is relatively high, it can significantly optimize the query performance.

[0037] For example, when the query needs to obtain the growth of the total order amount, a query plan tree can be constructed for this purpose. Furthermore, the query on the growth of the total order amount can be completed according to the query plan tree. Specifically, the constructed query plan tree can be as Figure 1b shown. The result data of the JOIN in the query plan tree is the growth data of the total order amount. The result data obtained by the left CTE Consumer through the common temporary table is the total order amount on a certain day last year, and the result data obtained by the right CTE Consumer through the common temporary table is the total order amount on the same day this year. Through the JOIN operation, the result data obtained by the left CTE Consumer can be connected with the result data obtained by the right CTE Consumer, and then the growth data of the total order amount on the same day this year compared with the total order amount on the same day last year (that is, the total order amount on the same day this year minus the total order amount on the same day last year) can be obtained. The data used by the left CTE Consumer and the right CTE Consumer involves the total order amount of each day of each year, and the common temporary table can be constructed by the same CTE Producer and passed to the left CTE Consumer and the right CTE Consumer. The data in the common temporary table is the total order amount of each day of each year.

[0038] For example, the common temporary tables obtained by the left CTE Consumer and the right CTE Consumer are the same. For example, the first row of the common temporary table records that the total order amount on August 1, 2023 is 1 million, and the second row records that the total order amount on August 1, 2022 is 500,000. Then, the result data obtained by the left CTE Consumer through the common temporary table can be the data in the second row of the common temporary table, and the result data obtained by the right CTE Consumer through the common temporary table can be the data in the first row of the common temporary table. After performing a JOIN operation, the total order amount of 1 million on August 1, 2023 and the total order amount of 500,000 on August 1, 2022 can be reflected in the same row at the same time. Thus, the growth data of the total order amount can be calculated.

[0039] However, there may be a scheduling deadlock situation in the query plan tree under the CTE sharing execution mode. As Figure 1b shown, when the two tables operated by the Hash Join are two identical CTE Consumer operators and the common temporary tables used by the two CTE Consumer operators are from the same CTE Producer, it means that the common temporary tables in the two identical CTE Consumer operators are the same and are both generated by the same CTE Producer. Moreover, the common temporary table in the same CTE Consumer is both the left table and the right table of the Hash Join operation.

[0040] Based on this, since the query process is executed from bottom to top in the query plan tree during scheduling and the right table data (hash table construction phase) will be executed first under the Hash Join operation, the Hash Join operation will first read the right table data, that is, the data in the common temporary table of the right CTE Consumer operator. Then, at this time, it will drive the calculation of the CTE Producer downward, generate the common temporary table and pass it to the right CTE Consumer operator. However, since the same CTE Producer is used, the common temporary table generated by the CTE Producer will also be output to the left CTE Consumer at the same time, so the left CTE Consumer operator will also receive the common temporary table passed by the CTE Producer. However, at this time, the Hash Join is still in the hash table construction phase and cannot process the data received by the left CTE Consumer, thus forming a scheduling deadlock. It can be seen that the scheduling deadlock occurs during the execution of the query plan tree. Due to the scheduling deadlock, the data of the common temporary table will also accumulate in the buffer of the left CTE Consumer and may eventually exceed the buffer cache limit, causing the buffer to be exhausted, and then leading to a query failure.

[0041] In practical applications, scheduling deadlocks may occur during the query processes implemented based on TPC-H and TPC-DS. In summary, there is an urgent need for a method for detecting scheduling deadlocks to detect whether there are scheduling deadlocks during the query process.

[0042] Based on this, the embodiments of the present application provide a method, device, and equipment for detecting data query scheduling deadlocks. First, obtain a query statement and generate a query plan tree corresponding to the query statement. The query plan tree includes multiple operator nodes and the query logical relationships between the multiple operator nodes. The operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node. Then, there may be a scheduling deadlock in the query plan tree. Based on this, traverse the query plan tree to determine at least one right table chain in the query plan tree. The right table chain includes leaf nodes and hash join operator nodes in the query plan tree. When the parent node of the operator node in the right table chain is a hash join operator node, the operator node is the right child node of its parent node, and the right table chain includes the parent node of the operator node. When the root node of the query plan tree is not a hash join operator node, the right table chain includes the root node. Taking each right table chain as the traversal reference, start traversing the operator nodes in the right table chain from the leaf node of the right table chain from bottom to top, and traverse the other operator nodes of the query plan tree to analyze the execution order relationship between the traversed operator nodes in the query plan tree. The execution order relationship can be further used to analyze whether there is a scheduling dependency between two identical common temporary table consumption operator nodes in the query plan tree. Thus, find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree, and when the upstream operator nodes of the two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node, it is determined that there is a scheduling deadlock. In this way, it is possible to more accurately determine whether there is a scheduling deadlock situation in the query plan tree, and it is also possible to more accurately determine the common temporary table consumption operator node and the common temporary table production operator node that cause the scheduling deadlock.

[0043] It can be understood that for the defects existing in the above solutions, they are all the results obtained by the applicant after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of the present application below for the above problems should all be the contributions made by the applicant to the embodiments of the present application during the process of the present application.

[0044] To facilitate the understanding of this application, a method for detecting data query scheduling deadlocks provided by an embodiment of this application will be described below with reference to the accompanying drawings. This method can be applied to a terminal device and / or a server, which is not limited here. Among them, the terminal device includes but is not limited to smart phones, tablet computers, laptop computers, smart watches, etc. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms.

[0045] See Figure 2 As shown, this figure is a flowchart of a method for detecting data query scheduling deadlocks provided by an embodiment of this application. As Figure 2 shown, this method may include S201 - S204:

[0046] S201: Obtain a query statement and generate a query plan tree corresponding to the query statement; the query plan tree includes multiple operator nodes and the query logical relationships between the multiple operator nodes; the operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node.

[0047] The query statement is used for data query. The query statement can be a statement in the structured query language SQL, which is not limited here. Furthermore, the query engine can construct a corresponding query plan tree based on the query statement. The query plan tree can be regarded as an execution plan formulated to achieve data query. The scheduling process of the query plan tree is from top to bottom, but the execution process is from bottom to top. For example, the result of the query plan tree is to obtain A, and A is obtained from B and C, and both B and C rely on D, that is, the top - down scheduling. When executing, it is necessary to first obtain D, then obtain B and C based on D, and then obtain A, that is, the bottom - up execution.

[0048] The query plan tree is a tree - like structure, including multiple operators and the query logical relationships (also called pipeline relationships) between the multiple operator nodes. The multiple operators can be represented hierarchically, such as Figure 1bAs shown, the 1-layer operator is the bottommost operator. The input of the 2-layer operator depends on the output of the 1-layer operator. The input of the 3-layer operator depends on the output of the 2-layer operator. The input of the 4-layer operator depends on the output of the 3-layer operator. The 5-layer operator is the topmost operator. The 1-layer operator is the Scan operator, the 2-layer operator is the Aggregate operator, the 3-layer operator is the CTE Producer operator, the 4-layer operator consists of two identical CTE Consumer operators, and the 5-layer operator is the Join operator. There is a direct flow relationship from the Scan operator to the Aggregate operator, from the Aggregate operator to the CTE Producer operator, from the CTE Producer operator to the two identical CTE Consumer operators respectively, and from the two identical CTE Consumer operators to the Join operator. That is, the input of the downstream operator (upper-layer operator) depends on the output of the adjacent upstream operator (lower-layer operator) with a direct flow relationship.

[0049] As can be seen from the above analysis process, scheduling deadlocks occur in a query plan tree that simultaneously has a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node. Therefore, the query plan tree in this step should at least include a common temporary table production operator node (CTE Producer operator), a common temporary table consumption operator node (CTE Consumer operator), and a hash join operator node (Hash Join operator) to detect whether a scheduling deadlock may occur during the execution of the query plan tree. Among them, the common temporary table production operator node is used to generate a common temporary table for passing to the common temporary table consumption operator node.

[0050] S202: Traverse the query plan tree to determine at least one right table chain in the query plan tree; the right table chain includes the leaf nodes and the root nodes of non-hash join operator nodes in the query plan tree; when the father node of an operator node in the right table chain is a hash join operator node, the operator node is the right child node of its father node, and the right table chain includes the father node of the operator node.

[0051] In the embodiment of the present application, in order to implement the detection of scheduling deadlocks, first traverse the query plan tree to determine at least one right table chain in the query plan tree. Among them, the right table chain meets the following conditions: the right table chain includes the leaf nodes and the hash join operator nodes in the query plan tree. When the father node of an operator node in the right table chain is a hash join operator node, the operator node is the right child node of its father node, and the right table chain includes the father node of the operator node (i.e., this hash join operator node). When the root node of the query plan tree is not a hash join operator node, the right table chain includes the root node.

[0052] The applicant has found through research that scheduling deadlocks occur when there is a dependency relationship between the left table and the right table of the Hash Join operator. This dependency relationship can be reflected as a sequential relationship where the right table needs to be executed first and then the left table. However, the sequential relationship between the left and right tables conflicts with the characteristic of the CTE Producer operator that simultaneously outputs multiple tables to the same CTE Consumer operator. When the CTE Producer operator generates a common temporary table, in addition to the right CTE Consumer operator under the Hash Join operator being able to receive the common temporary table, the left CTE Consumer operator under the Hash Join operator can also receive the common temporary table and generate data, but this data cannot be processed by the Hash Join operator, thus forming a scheduling deadlock.

[0053] Therefore, it is necessary to find the operators with dependency relationships in the query plan tree. The right table chain includes the hash join operator node and the right child node of the hash join operator node. When there is a scheduling deadlock in the query plan tree, it is usually caused by the scheduling dependency between the link other than the right table chain in the query plan tree and the right sub-link of the hash join operator node in the right table chain. Specifically, it is the scheduling dependency of the common temporary table production operator node in the link other than the right table chain in the query plan tree on the same common temporary table production operator node in the right sub-link of the hash join operator node in the right table chain. Among them, the right sub-link of a node is the link between the node and its right child node and the sub-link of its right child node. And, the right table chain includes leaf nodes. When there are multiple leaf nodes, subsequent steps can be executed for multiple right table chains to avoid missing scheduling deadlock situations in the query plan tree as much as possible.

[0054] In a possible implementation manner, an embodiment of the present application provides a specific implementation manner for traversing a query plan tree to determine at least one right table chain in the query plan tree, including:

[0055] A1: Assign a first mark to the root node of the query plan tree.

[0056] When traversing the query plan tree, start traversing from the root node of the query plan tree and assign a first mark to the root node. Among them, the first mark can be a first value, such as a boolean value, such as true. It can be understood that this is only an example and does not constitute a limitation. For example, the first mark can also be other marks other than boolean values.

[0057] A2: Traverse the operator nodes in the query plan tree from the root node top - down. If the traversed operator node is a hash - join operator node, assign a first label to the right child node of the hash - join operator node and a second label to the left child node of the hash - join operator node; if the traversed operator node is not a hash - join operator node, assign the value of the operator node to both the left child node and the right child node of the traversed operator node until the leaf nodes of the query plan tree are traversed.

[0058] After assigning the first label to the root node, traverse the operator nodes in the query plan tree from the root node top - down. During the traversal, follow the assignment rule, which differentiates whether the traversed operator node is a hash - join operator node or not.

[0059] That is, if the traversed operator node is a hash - join operator node, assign a first label (e.g., true) to the right child node of the hash - join operator node and a second label to the left child node of the hash - join operator node. As an optional example, when the first label is true, the second label can be a second value, such as another boolean value, e.g., false. Additionally, if the traversed operator node is not a hash - join operator node, assign the value of the operator node to both the left child node and the right child node of the traversed operator node.

[0060] Traverse the operator nodes in the query plan tree from the root node top - down, and assign values to each operator node in the query plan tree according to the assignment rule of the operator node until the leaf nodes of the query plan tree are traversed.

[0061] A3: Traverse the operator nodes with the first label in the query plan tree from the leaf nodes with the first label bottom - up until the traversed operator node is the second label, and determine the link composed of the traversed operator nodes as the right - table chain in the query plan tree.

[0062] It can be understood that if an operator node has multiple parent nodes, the operator node may have multiple labels. For example, it may include both the first label and the second label at the same time. When determining the right - table chain in the query plan tree, if an operator node is assigned both the first label and the second label, the main focus is on the first label (e.g., true) of the operator node.

[0063] In practical applications, leaf nodes may have multiple parent nodes and are usually assigned both the first label and the second label. In this step, the main focus is on the first label of the leaf nodes.

[0064] After assigning labels to each operator node in the query plan tree, the right table chain in the query plan tree is determined. Specifically, starting from the first labeled leaf node, traverse the first labeled operator nodes in the query plan tree from bottom to top until the traversed operator node is the second label, and determine the link composed of the traversed operator nodes as the right table chain in the query plan tree.

[0065] It can be seen that the number of right table chains in the query plan tree is equal to the number of first labeled leaf nodes in the query plan tree.

[0066] To facilitate the understanding of A1 - A3, the process of A1 - A3 will be described below with reference to the accompanying drawings. Refer to Figure 3a - Figure 3e , Figure 3a - Figure 3e which is a schematic diagram of the query plan tree with scheduling deadlocks provided by the embodiment of the present application. Taking the five query plan trees shown in Figure 3a - Figure 3e as an example, determine the right table chain in the query plan tree.

[0067] As Figure 3a shown, the first traversed operator node is the Join node as the root node, so the root node of the query plan tree is assigned true. Since the Join node is a hash join operator node, the right child node (i.e., the right CTE Consumer) of the hash join operator node is assigned true, and the left child node (i.e., the left CTE Consumer) of the hash join operator node is assigned false. The right CTE Consumer and the left CTE Consumer are the same CTE Producer. Then, traverse the operator nodes in the query plan tree from top to bottom. The left CTE Consumer operator node is a non - hash join operator node, and both its left and right child nodes are CTE Producer operators, so the child nodes (i.e., CTE Producer) of the left CTE Consumer operator node are assigned the same false. The right CTE Consumer operator node is a non - hash join operator node, and both its left and right child nodes are CTE Producer operators, so the child nodes (also CTE Producer) of the right CTE Consumer operator node are assigned the same true. Thus, the leaf nodes of the query plan tree are traversed.

[0068] At this time, the only leaf node with true is the CTE Producer operator node. At this time, starting from the CTE Producer operator node, traverse the operator nodes with true in the query plan tree from bottom to top until the traversed operator node is false. Then, the traversed operator nodes include the CTE Producer operator node, the right CTE Consumer operator node, and the Join operator node. ThenFigure 3a There is only one right table chain in the query plan tree shown, that is, Join - right - hand side CTE Consumer - CTE Producer (the flow relationship is from CTE Producer to the right - hand side CTE Consumer, and from the right - hand side CTE Consumer to Join, which is a bottom - up flow relationship).

[0069] As Figure 3b shown, the first operator node traversed is the Join node (a 4 - layer operator node) acting as the root node, so true is assigned to the root node of the query plan tree. Since the Join node is a hash - join operator node, true is assigned to the right child node of the hash - join operator node (i.e., the 3 - layer CTE Consumer), and false is assigned to the left child node of the hash - join operator node (i.e., the 3 - layer Join). Then, the operator nodes in the query plan tree are traversed from top to bottom. The 3 - layer Join is a hash - join operator node, so true is assigned to the right child node of the 3 - layer Join (i.e., the 2 - layer Scan), and false is assigned to the left child node of the hash - join operator node (i.e., the 2 - layer CTE Consumer). At the same time, the 3 - layer CTE Consumer is a non - hash - join operator node, so the same true is assigned to both the left and right child nodes of the 3 - layer CTE Consumer (i.e., CTE Producer). Further, the 2 - layer CTE Consumer is also a non - hash - join operator node, so the same false is assigned to both the left and right child nodes of the 2 - layer CTE Consumer (also CTE Producer). Among them, the 3 - layer CTE Consumer and the 2 - layer CTE Consumer are the same CTE Producer. Thus, the leaf nodes of the query plan tree are traversed.

[0070] At this time, the leaf nodes that are true are the Scan operator node and the CTE Producer operator node. At this time, starting from the Scan operator node and the CTE Producer operator node respectively, traverse the operator nodes that are true in the query plan tree from bottom to top until the operator node traversed is false. Specifically, the operator nodes traversed from bottom to top starting from the Scan operator node include the Scan operator node and the 3-layer Join operator node, and the right table chain it represents is 3-layer Join-Scan (the flow relationship is the flow relationship from Scan to the 3-layer Join). The operator nodes traversed from bottom to top starting from the CTE Producer operator node include the CTE Producer operator node, the 3-layer CTE Consumer operator node, and the 4-layer Join operator node, and the right table chain it represents is 4-layer Join-3-layer CTE Consumer-CTE Producer (the flow relationship is the flow relationship from CTE Producer to the 3-layer CTE Consumer, and the flow relationship from the 3-layer CTE Consumer to the 4-layer Join). Therefore, Figure 3b There are two right table chains in the shown query plan tree.

[0071] As Figure 3c shown, compared with Figure 3b , Figure 3c the Scan operator node in

[0072] is false, and the 2-layer CTE Consumer operator node is true. Based on this, under the 2-layer CTE Consumer operator node, the CTE Producer operator node is true; under the 3-layer CTE Consumer operator node, the CTE Producer operator node is also true. Figure 3cAmong them, the only leaf node with a value of true is the CTE Producer operator node. At this time, the operator nodes traversed from bottom to top starting from the CTE Producer operator node include the CTE Producer operator node, the 2-layer CTE Consumer operator node, and the 3-layer Join operator node. The right table chain it represents is 3-layer Join - 2-layer CTE Consumer - CTE Producer (the flow relationship is from the CTE Producer to the 2-layer CTE Consumer, and from the 2-layer CTE Consumer to the 3-layer Join). In addition, the operator nodes traversed from bottom to top starting from the CTE Producer operator node can also include the CTE Producer operator node, the 3-layer CTE Consumer operator node, and the 4-layer join operator node. The right table chain it represents is 4-layer Join - 3-layer CTE Consumer - CTE Producer (the flow relationship is from the CTE Producer to the 3-layer CTE Consumer, and from the 3-layer CTE Consumer to the 4-layer Join). Among them, the 3-layer CTE Consumer and the 2-layer CTE Consumer are for the same CTE Producer. Therefore, Figure 3c There are two right table chains in the query plan tree shown.

[0073] Such as Figure 3dAs shown, the first operator node traversed is the Join node (the Join operator node at the 4th level) serving as the root node, so the root node of the query plan tree is assigned true. Since the Join node at the 4th level is a hash join operator node, the right child node of the hash join operator node (i.e., the Join operator node at the 3rd level) is assigned true, and the left child node of the hash join operator node (i.e., the CTE Consumer at the 3rd level) is assigned false. Then, traverse the operator nodes in the query plan tree from top to bottom. The Join at the 3rd level is a hash join operator node, so the right child node of the Join at the 3rd level (i.e., the Scan at the 2nd level) is assigned true, and the left child node of the hash join operator node (i.e., the CTE Consumer at the 2nd level) is assigned false. At the same time, the CTE Consumer at the 3rd level is a non-hash join operator node, so both the left and right child nodes of the CTE Consumer at the 3rd level (i.e., the CTE Producer) are assigned the same false. Further, the CTE Consumer at the 2nd level is also a non-hash join operator node, so both the left and right child nodes of the CTE Consumer at the 2nd level (also the CTE Producer) are assigned the same false. Finally, the CTE Producer only has the false value. Among them, the CTE Consumer at the 3rd level and the CTE Consumer at the 2nd level are the same CTE Producer. Thus, the leaf nodes of the query plan tree are traversed.

[0074] At this time, the leaf node with the value of true is the Scan operator node. At this time, start traversing the operator nodes with the value of true in the query plan tree from bottom to top until the operator node traversed is false. Specifically, the operator nodes traversed from bottom to top starting from the Scan operator node include the Scan operator node, the Join operator node at the 3rd level, and the Join operator node at the 4th level, and the right table chain it represents is 4th level Join - 3rd level Join - Scan (the flow relationship is the flow relationship from Scan to the 3rd level Join and the flow relationship from the 3rd level Join to the 4th level Join). Therefore, Figure 3b There is a right table chain in the shown query plan tree.

[0075] It can be seen that Figure 3b - Figure 3d the CTE Consumer at the 3rd level and the CTE Consumer at the 2nd level in are the same CTE Producer, that is, two identical CTE Consumers under nested Join operator nodes (such as the Join operator node at the 3rd level and the Join operator node at the 4th level are in a nested relationship) use the same CTE Producer (i.e., the upstream operator is the same CTE Producer).

[0076] Such asFigure 3e As shown, the first operator node traversed is the Union operator node as the root node, so true is assigned to the root node of the query plan tree. Since the Union node is a non-hash join operator node, true is assigned to the left and right child nodes of the hash join operator node respectively, that is, both Join[2] and Join[3] are true. Then, the operator nodes in the query plan tree are traversed from top to bottom. Since both Join[2] and Join[3] are hash join operator nodes, true can be assigned to the right child node of Join[2] (i.e., CTE Consumer[1](1)), and false is assigned to the left child node of Join[2] (i.e., CTE Consumer[0](1)). The same applies to Join[3], that is, true is assigned to the right child node of Join[3] (i.e., CTE Consumer[0](2)), and false is assigned to the left child node of Join[3] (i.e., CTE Consumer[1](2)). Among them, CTE Consumer[0](1) and CTE Consumer[0](2) are two identical CTE Consumer operator nodes that use the same CTE Producer[0]. In addition, CTE Consumer[1](1) and Consumer[1](2) are two identical CTE Consumer operator nodes that use the same CTE Producer[1].

[0077] Then, CTE Consumer[0](1), CTE Consumer[0](2), CTE Consumer[1](1), Consumer[1](2), etc. are all non-hash join operator nodes, so the left and right child nodes of the non-hash join operator node are both assigned the same boolean value as the non-hash join operator node. Thus, the leaf nodes of the query plan tree are traversed.

[0078] The leaf nodes CTE Producer[0] and CTE Producer[1] of the query plan tree each correspond to two boolean values, namely true and false. At this time, the leaf nodes with the value true are CTE Producer[0] and CTE Producer[1]. Starting from CTE Producer[0] and CTE Producer[1] respectively, traverse the operator nodes with the value true in the query plan tree from bottom to top until the traversed operator node has the value false. Specifically, the operator nodes traversed from bottom to top starting from CTE Producer[0] include CTE Producer[0], CTE Consumer[0](2), Join[3], and Union. The right table chain it represents is Union - Join[3] - CTE Consumer[0](2) - CTE Producer[0] (the flow relationship is the flow relationship from CTE Producer[0] to CTE Consumer[0](2), from CTE Consumer[0](2) to Join[3], and from Join[3] to Union). The operator nodes traversed from bottom to top starting from CTE Producer[1] include CTE Producer[1], CTE Consumer[1](1), Join[2], and Union. The right table chain it represents is Union - Join[2] - CTE Consumer[1](1) - CTE Producer[1] (the flow relationship is the flow relationship from CTE Producer[1] to CTE Consumer[1](1), from CTE Consumer[1](1) to Join[2], and from Join[2] to Union). Therefore, Figure 3e There are two right table chains in the shown query plan tree.

[0079] It can be seen that Figure 3e the Union in

[0080] is a merge operator used to merge the data of two or more streams into a single stream. The child nodes under Union are executed in parallel, that is, Join[2] and Join[3] are executed in parallel. Then the same CTE Consumer in the parallel - executed Join[2] and Join[3] uses the same CTE Producer. For example, CTE Consumer[0](1) under Join[2] and CTE Consumer[0](2) under Join[3] use the same CTE Producer[0].S203: Traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and traverse the other operator nodes of the query plan tree, analyze the execution order relationship between the traversed operator nodes in the query plan tree, and find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship means that the execution order between two identical common temporary table consumption operator nodes is different.

[0081] After determining the right table chain in the query plan tree, two identical common temporary table production operator nodes with a scheduling dependency relationship in the query plan tree can be found based on the right table chain, so as to determine whether there is a scheduling deadlock in the query plan tree. Specifically, since the query plan tree represents the flow relationship between operator nodes (reflecting the execution order between operator nodes), the execution order relationship between each operator node in the query plan tree can be analyzed. For example, Figure 3a the execution order of the CTEProducer operator node in

[0082] is the earliest. When specifically implemented, traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and traverse the other operator nodes of the query plan tree, so as to analyze the execution order relationship between each traversed operator node. In this way, since the common temporary table production operator nodes in the link of the query plan tree other than the right table chain may have a scheduling dependency on the same common temporary table production operator node in the right sub-link of the hash join operator node in the right table chain, traversing the operator nodes in the query plan tree in the above manner can conveniently analyze the execution order relationship between each traversed operator node.

[0083] After determining the execution order relationship between the traversed operator nodes, find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree based on the execution order relationship between the traversed operator nodes, that is, find two identical common temporary table consumption operator nodes with different execution orders.

[0084] It can be understood that when the number of right table chains is multiple, each right table chain needs to be traversed separately, and during the traversal of the operator nodes of each right table chain, the other operator nodes in the query plan tree also need to be traversed to analyze the execution order relationship between the traversed operator nodes. That is, each right table chain needs to execute step S203, but the analyzed execution order relationships do not affect each other and are all used to find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree.

[0085] In a possible implementation manner, the embodiment of the present application provides a specific implementation manner for traversing the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up in S203, traversing the other operator nodes of the query plan tree, and analyzing the execution order relationship between the traversed operator nodes in the query plan tree, including:

[0086] B1: Determine that the leaf nodes of the right table chain are the nodes with the earliest execution order.

[0087] Since the execution process of the query plan tree is bottom-up, the leaf nodes of the query plan tree are the nodes with the earliest execution order. Based on this, after determining the right table chain, determine that the leaf nodes in the right table chain are the nodes with the earliest execution order.

[0088] For example, Figure 3a the execution order of the CTE Producer operator node in the right table chain of is the earliest.

[0089] B2: Traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up, and determine the execution order relationship between the operator nodes in the right table chain according to the order rule. Traverse the other operator nodes of the query plan tree, and determine the execution order relationship between the other operator nodes according to the order rule.

[0090] In this step, first traverse the operator nodes in the right table chain from the leaf nodes of the right table chain bottom-up. At the same time, during the process of traversing the operator nodes in the right table chain, also traverse the other operator nodes of the query plan tree. During the traversal process, determine the execution order relationship between the traversed operator nodes according to the order rule.

[0091] As an optional example, the order rule includes one or more of the following:

[0092] When the downstream operator node is not a hash join operator node, determine that the execution order of the adjacent upstream operator node and the downstream operator node is the same;

[0093] When there is a hash join operator node, determine that the execution order of the hash join operator node is later than the execution order of the right child node of the hash join operator node, and is the same as the execution order of the left child node of the hash join operator node.

[0094] It can be understood that since the scheduling deadlock in the query plan tree is related to the Join operator node and the CTE Consumer under the Join operator node, in step B2 of the embodiment of the present application, the execution order relationship between the Join operator node and its adjacent left and right child nodes is concerned. Therefore, it is determined that the execution order of the Join operator node is later than the execution order of the right child node of the Join operator node, and the execution order of the Join operator node is the same as the execution order of the left child node of the Join operator node, so as to reflect the execution mode of the hash join operator node and reflect the sequence of execution order. That is, in the execution mode of the hash join operator node, the execution order of the hash table construction phase (reflected in the execution order of the right child node of the Join operator node) is earlier than the execution order of the hash table probing phase (reflected in the execution order of the left child node of the Join operator node).

[0095] When the downstream operator node is a non-Join operator node, it means that its adjacent upstream operator node may be a Join operator node or a non-Join operator node. The execution order of adjacent upstream and downstream operator nodes that are both non-Join, or upstream operator nodes that are Join operator nodes but adjacent downstream operator nodes are non-Join operator nodes, is determined to be the same execution order, and the sequence of their execution order is ignored.

[0096] In this way, based on the setting of the above order rules, it is convenient to find two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree.

[0097] In practical applications, when traversing the operator nodes in the right table chain from the leaf node of the right table chain from bottom to top and traversing the other operator nodes of the query plan tree, an order value can be assigned to the traversed operator nodes to reflect the execution order relationship between the operator nodes through the order value.

[0098] Furthermore, two identical common temporary table consumption operator nodes with different order values in the query plan tree can be determined as two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree. Among them, different order values indicate different execution orders, and there is a scheduling dependency relationship between the two identical common temporary table consumption operator nodes.

[0099] In specific implementation, the embodiment of the present application provides a specific implementation manner of traversing the operator nodes in the right table chain from the leaf node of the right table chain from bottom to top and traversing the other operator nodes of the query plan tree, and assigning order values to the traversed operator nodes, including C1 - C5:

[0100] C1: Assign an order value to the leaf node of each right table chain.

[0101] After determining the right table chain, the leaf node of the right table chain is the node with the earliest execution order, and an order value is assigned to the leaf node of each right table chain. For example, the leaf nodes of the right table chain are all assigned a value of 0. This is only an example and does not constitute a limitation. Other values other than 0 can also be assigned. In addition, the order values of the leaf nodes of each right table chain can be the same or different.

[0102] It can be understood that when the number of right table chains is multiple, each right table chain needs to be traversed separately, and during the traversal of the operator nodes of each right table chain, other operator nodes in the query plan tree also need to be traversed, and an order value is assigned to the traversed operator nodes. That is, each right table chain needs to execute steps C1 - C5, but the order value results between them do not affect each other.

[0103] For example, the right table chains are right table chain 1 and right table chain 2. When traversing right table chain 1, other operator nodes in the query plan tree are also traversed. The set of the order values of the operator nodes traversed last is represented by set 1, and set 1 includes the operator nodes traversed this time and the order values of the operator nodes. When traversing right table chain 2, other operator nodes in the query plan tree are also traversed. The set of the order values of the operator nodes traversed last is represented by set 2, and set 2 includes the operator nodes traversed this time and the order values of the operator nodes. Then, set 1 and set 2 do not affect each other, and can be used separately to find two identical common temporary table consumption operator nodes with scheduling dependencies in the query plan tree. As long as two identical common temporary table consumption operator nodes with scheduling dependencies are found and can meet the subsequent S204, it is determined that there is a scheduling deadlock.

[0104] C2: Determine the operator node in the traversed right table chain as the current node, and obtain the father node of the current node; the father node of the current node is the father node of the current node in the right table chain.

[0105] Steps C2 - C5 will be introduced taking one right table chain as an example. It can be seen that the leaf node of the right table chain is the operator node in the initially traversed right table chain, so the current node is initially the leaf node of the right table chain.

[0106] C3: If the father node of the current node is not empty and is not a hash join operator node, assign the order value of the current node to the father node of the current node, and determine the father node of the current node as the next operator node to be traversed in the right table chain, and re - execute determining the traversed operator node as the current node, obtaining the father node of the current node and subsequent steps.

[0107] It can be understood that "the father node of the current node is non - empty and not a hash - join operator node" represents "the downstream operator node is not a hash - join operator node" in the order rule. "Assigning the order value of the current node to the father node of the current node" represents "determining that the execution order of the upstream operator node and the adjacent downstream operator node is the same" in the order rule.

[0108] For example, when the leaf node of the right table chain is assigned a value of 0, if its father node in the right table chain is non - empty and not a hash - join operator node, then the father node of this leaf node is also assigned a value of 0.

[0109] Furthermore, determine the father node of the current node as the next operator node traversed in the right table chain, and re - execute C2 and subsequent steps until the traversal ends. That is, subsequently, start traversing the operator nodes in the right table chain from the leaf node of the right table chain from bottom to top.

[0110] C4: If the father node of the current node is non - empty and is a hash - join operator node, assign the sum of the order value of the current node and a preset value to the father node of the current node and the left child node of the father node of the current node. Take the left child node of the father node of the current node as the object node to execute the left - table - chain judgment logic, and take the current node as the object node to execute the left - table - chain judgment logic; determine the father node of the current node as the next operator node traversed in the right table chain, and re - execute the step of determining the traversed operator node as the current node, obtaining the father node of the current node and subsequent steps.

[0111] It can be understood that since the current node is a node in the right table chain, if the father node of the current node is non - empty and is a hash - join operator node, then the current node is the right child node of this hash - join operator node.

[0112] Furthermore, the statement in this step "if the father node of the current node is non - empty and is a hash - join operator node, assign the sum of the order value of the current node and a preset value to the father node of the current node and the left child node of the father node of the current node" corresponds to "when there is a hash - join operator node, determine that the execution order of the hash - join operator node is later than the execution order of the right child node of the hash - join operator node, and is the same as the execution order of the left child node of the hash - join operator node" in the order rule.

[0113] As an optional example, the preset value can be 1, which is not limited here. For example, if the order value of the current node is 0, the preset value is 1, and the father node of the current node is non - empty and is a hash - join operator node, then the order value of the father node (Join operator node) of the current node is 1, and the left child node of this Join operator node is also 1.

[0114] Based on the above, the left child node of the father node of the current node and the current node are both used as object nodes to execute the left table chain judgment logic.

[0115] Among them, the left table chain judgment logic is specifically as follows: Determine whether the object node is a hash join operator node; if so, assign the order value of the object node to the left child node of the object node, if not, assign the order value of the object node to each child node of the object node; Determine the child node with the assigned order value of the object node as the object node, and re-execute the judgment on whether the object node is a hash join operator node and subsequent steps until the object node is a leaf node.

[0116] It can be understood that the left child node in the above content belongs to other operator nodes in the query plan tree except the operator nodes in the right table chain.

[0117] Furthermore, determine the father node of the current node as the next operator node traversed in the right table chain, and re-execute C2 and subsequent steps until the traversal ends. That is, subsequently, the operator nodes in the right table chain will be traversed from the leaf nodes of the right table chain from bottom to top.

[0118] C5: If the current node is not a hash join operator node and the father node of the current node is empty, use the current node as an object node to execute the left table chain judgment logic.

[0119] The current node is not a hash join operator node and the father node of the current node is empty, indicating that the current node is the root node in the right table chain. At this time, the traversal can end after traversing this root node. When traversing the root node, if the root node is not a Join operator node, directly use the current node as an object node and execute the left table chain judgment logic.

[0120] In addition, if the current node is a hash join operator node and the father node of the current node is empty, directly end the traversal process.

[0121] To facilitate the understanding of C1 - C5 more, the following will combine Figure 3a - Figure 3e to give an example of the order values of the operator nodes in the query plan tree. Among them, the order values of the leaf nodes in the right table chain are all set to 0, and the preset values are all set to 1.

[0122] Such as Figure 3aAs shown, there is one right table chain, and the flow relationship of the right table chain is CTE Producer - Right CTE Consumer - Join. The leaf node in the right table chain is CTE Producer, and its value is assigned as 0. Since the leaf node CTE Producer is the operator node for the initial traversal, it is determined as the current node, and its parent node in the right table chain is the Right CTE Consumer. If the Right CTE Consumer is non-empty and not a hash join operator node, then the sequence value of CTE Producer is assigned to the Right CTE Consumer, and the sequence value of the Right CTE Consumer is also 0. Furthermore, the Right CTE Consumer is determined as the next operator node to be traversed in the right table chain.

[0123] When traversing the Right CTE Consumer, the Right CTE Consumer is the current node. If its parent node is non-empty and is Join, then the sum of the sequence value of the Right CTE Consumer and the preset value (i.e., 0 + 1 = 1) is assigned to Join and the left child node of Join (i.e., the Left CTE Consumer). Also, the Left CTE Consumer is used as the object node to execute the left table chain judgment logic, and the Right CTE Consumer is used as the object node to execute the left table chain judgment logic. It can be understood that when both the Left CTE Consumer and the Right CTE Consumer are used as object nodes to execute the left table chain judgment logic and they are not Join, then their sequence values are assigned to their respective child nodes. Since the child nodes of both the Left CTE Consumer and the Right CTE Consumer are CTE Producer, the newly assigned sequence values of CTE Producer are 1 and 0 respectively.

[0124] Furthermore, the parent node of the Right CTE Consumer in the right table chain (i.e., Join) is determined as the next operator node to be traversed in the right table chain. When traversing Join, Join is the current node. Since its parent node is empty, Join is the root node in the right table chain, and the traversal process ends directly.

[0125] Based on the above, the sequence value of the CTE Producer is assigned three times. The first time is when initially traversing the CTE Producer, and it is assigned a value of 0. Subsequently, since the sequence value of the right CTE Consumer is 0, when executing the left table chain judgment logic, the CTE Producer is assigned a value of 0; since the sequence value of the left CTE Consumer is 1, when executing the left table chain judgment logic, the CTE Producer is assigned a value of 1. After the traversal, it can be seen that the left CTE Consumer and the right CTE Consumer use the same CTE Producer, but the assignments for the left CTE Consumer and the right CTE Consumer are different, and there are multiple different assignments for the CTE Producer.

[0126] As Figure 3b shown, there are two right table chains. For one of the right table chains, the flow relationship is Scan - 3 - layer Join, and for the other right table chain, the flow relationship is CTE Producer - 3 - layer CTE Consumer - 4 - layer Join.

[0127] First, take the right table chain with the flow relationship of Scan - 3 - layer Join as an example. The leaf node in the right table chain is Scan, and it is assigned a value of 0. Since the leaf node Scan is the operator node of the initial traversal, it is determined as the current node, and its parent node in the right table chain is the 3 - layer Join. The 3 - layer Join is non - empty and is a hash - join operator node, so the sum of the sequence value of Scan and the preset value (i.e., 0 + 1 = 1) is assigned to the 3 - layer Join and the left child node of the 3 - layer Join (i.e., the 2 - layer CTE Consumer). And, the 2 - layer CTE Consumer is used as the object node to execute the left table chain judgment logic. When the 2 - layer CTE Consumer is used as the object node to execute the left table chain judgment logic, since it is not a Join, its sequence value is assigned to each of its child nodes, that is, the CTE Producer is assigned 1. And Scan has no child nodes, so the left table chain judgment logic is not executed for it.

[0128] Furthermore, the parent node of Scan in the right table chain (i.e., the 3 - layer Join) is determined as the next operator node to be traversed in the right table chain. When traversing the 3 - layer Join, the 3 - layer Join is the current node. Since its parent node is empty, the 3 - layer Join is the root node in the right table chain, and the traversal process is directly ended.

[0129] During this traversal process, there is no situation where two identical CTE Consumers are traversed, and the assignment of the CTE Producer is only one, and there is no multiple - assignment situation.

[0130] Take the right table chain of the flow relationship as the CTE Producer layer - CTE Consumer layer 3 - Join layer 4 as an example. The leaf node in the right table chain is the CTE Producer, and its value is assigned as 0. Since the leaf node CTE Producer is the operator node for the initial traversal, it is determined as the current node. Its parent node in the right table chain is the CTE Consumer layer 3. If the CTE Consumer layer 3 is non - empty and not a hash - join operator node, then the sequence value of the CTE Producer is assigned to the CTE Consumer layer 3, and the sequence value of the CTE Consumer layer 3 is also 0. Furthermore, the CTE Consumer layer 3 is determined as the next operator node to be traversed in the right table chain.

[0131] When traversing the CTE Consumer layer 3, the CTE Consumer layer 3 is the current node. Its parent node is non - empty and is the Join layer 4. Then the sum of the sequence value of the CTE Consumer layer 3 and the preset value (i.e., 0 + 1 = 1) is assigned to the Join layer 4 and the left child node of the Join layer 4 (i.e., the Join layer 3). Also, the Join layer 3 and the CTE Consumer layer 3 are used as object nodes to execute the left - table - chain judgment logic respectively. When using the Join layer 3 as the object node to execute the left - table - chain judgment logic, since it is a Join, the sequence value 1 of the Join layer 3 is assigned to its left child node, i.e., the CTE Consumer layer 2. Furthermore, when using the CTE Consumer layer 2 as the object node, since it is not a Join, the sequence value 1 of the CTE Consumer layer 2 is assigned to its left and right child nodes, i.e., the CTE Producer is assigned as 1. When using the CTE Consumer layer 3 as the object node to execute the left - table - chain judgment logic respectively, since it is not a Join, the sequence value 0 of the CTE Consumer layer 3 is assigned to its left and right child nodes, i.e., the CTE Producer is assigned as 0.

[0132] Furthermore, the parent node of the CTE Consumer layer 3 in the right table chain (i.e., the Join layer 4) is determined as the next operator node to be traversed in the right table chain. When traversing the Join layer 4, the Join layer 4 is the current node. Since its parent node is empty, the Join layer 4 is the root node in the right table chain, and the traversal process is directly ended.

[0133] During this traversal process, the sequence value of the CTE Producer is assigned three times. The first time is when initially traversing the CTE Producer, and a value of 0 is assigned to it. Subsequently, since the sequence value of the 2-layer CTE Consumer is 1, when executing the left table chain judgment logic, the value of 1 is assigned to the CTE Producer; since the sequence value of the 3-layer CTE Consumer is 0, when executing the left table chain judgment logic, the value of 0 is assigned to the CTE Producer. After the traversal ends, it can be seen that the 2-layer CTE Consumer and the 3-layer CTE Consumer use the same CTE Producer, but the assignments to the 2-layer CTE Consumer and the 3-layer CTE Consumer are different, and multiple assignments to the CTE Producer are different.

[0134] As Figure 3c shown, there are two right table chains. For one of the right table chains, the flow relationship is CTE Producer - 2-layer CTE Consumer - 3-layer Join, and for the other right table chain, the flow relationship is CTE Producer - 3-layer CTE Consumer - 4-layer Join.

[0135] First, take the right table chain with the flow relationship of CTE Producer - 2-layer CTE Consumer - 3-layer Join as an example. The leaf node in the right table chain is the CTE Producer, and a value of 0 is assigned to it. Since the leaf node CTE Producer is the operator node of the initial traversal, it is determined as the current node. Its parent node in the right table chain is the 2-layer CTE Consumer. If the 2-layer CTE Consumer is non-empty and not a hash join operator node, then the sequence value of the CTE Producer is assigned to the 2-layer CTE Consumer, and the sequence value of the 2-layer CTE Consumer is also 0. Furthermore, the 2-layer CTE Consumer is determined as the next operator node to be traversed in the right table chain.

[0136] When traversing the 2-layer CTE Consumer, if the 2-layer CTE Consumer is the current node and its parent node is non-empty and is a 3-layer Join, then the sum of the sequence value of the 2-layer CTE Consumer and the preset value (i.e., 0 + 1 = 1) is assigned to the 3-layer Join and the left child node of the 3-layer Join (i.e., the Scan operator node). And, the left table chain judgment logic is executed for Scan and the 2-layer CTE Consumer as object nodes respectively. When the left table chain judgment logic is executed for the 2-layer CTE Consumer as an object node, if it is not a Join, then the sequence value 0 of the 2-layer CTE Consumer is assigned to its left and right child nodes, that is, the CTE Producer is assigned 0. And Scan has no child nodes, so the left table chain judgment logic is not executed for it.

[0137] Furthermore, the parent node of the 2-layer CTE Consumer in the right table chain (i.e., the 3-layer Join) is determined as the next operator node to be traversed in the right table chain. When traversing the 3-layer Join, since the 3-layer Join is the current node and its parent node is empty, the 3-layer Join is the root node in the right table chain, and the traversal process is directly ended.

[0138] During this traversal process, the sequence value of the CTE Producer is assigned twice. The first time is when initially traversing the CTE Producer, and 0 is assigned to it. Subsequently, since the sequence value of the 2-layer CTE Consumer is 0, when the left table chain judgment logic is executed, 0 is assigned to the CTE Producer. Therefore, during this traversal process, there is no situation of traversing two identical CTE Consumers, and the two assignments of the CTE Producer are the same.

[0139] Taking the right table chain with the flow relationship of CTE Producer - 3-layer CTE Consumer - 4-layer Join as an example. The leaf node in the right table chain is the CTE Producer, and 0 is assigned to it. Since the leaf node CTE Producer is the operator node of the initial traversal, it is determined as the current node, and its parent node in the right table chain is the 3-layer CTE Consumer. If the 3-layer CTE Consumer is non-empty and not a hash join operator node, then the sequence value of the CTE Producer is assigned to the 3-layer CTE Consumer, and the sequence value of the 3-layer CTE Consumer is also 0. Furthermore, the 3-layer CTE Consumer is determined as the next operator node to be traversed in the right table chain.

[0140] When traversing the 3 - layer CTE Consumer, if the 3 - layer CTE Consumer is the current node, its parent node is non - empty and is a 4 - layer Join, then the sum of the sequence value of the 3 - layer CTE Consumer and a preset value (i.e., 0 + 1 = 1) is assigned to the 4 - layer Join and the left child node of the 4 - layer Join (i.e., the 3 - layer Join). And the 3 - layer Join and the 3 - layer CTE Consumer are used as object nodes to execute the left - table chain judgment logic respectively. When the 3 - layer Join is used as an object node to execute the left - table chain judgment logic, since it is a Join, the sequence value 1 of the 3 - layer Join is assigned to its left child node, i.e., Scan. Furthermore, when the 3 - layer CTE Consumer is used as an object node, since it is not a Join, the sequence value 1 of the 3 - layer CTE Consumer is assigned to its left and right child nodes, i.e., the CTE Producer is assigned 1.

[0141] Furthermore, the parent node of the 3 - layer CTE Consumer in the right - table chain (i.e., the 4 - layer Join) is determined as the next operator node to be traversed in the right - table chain. When traversing the 4 - layer Join, the 4 - layer Join is the current node. Since its parent node is empty, the 4 - layer Join is the root node in the right - table chain, and the traversal process ends directly.

[0142] During this traversal process, the sequence value of the CTE Producer is assigned once. That is, initially when traversing the CTE Producer for the first time, 0 is assigned to it. Therefore, during this traversal process, there is no situation of traversing two identical CTE Consumers, and the assignment of the CTE Producer is only once.

[0143] As Figure 3d shown, there is one right - table chain, and the flow relationship of the right - table chain is Scan - 3 - layer Join - 4 - layer Join. The leaf node in the right - table chain is Scan, and 0 is assigned to it. Since the leaf node Scan is the operator node for the initial traversal, it is determined as the current node, and its parent node in the right - table chain is the 3 - layer Join. The 3 - layer Join is non - empty and is a hash - join operator node, then the sum of the sequence value of Scan and a preset value (i.e., 0 + 1 = 1) is assigned to the 3 - layer Join and the left child node of the 3 - layer Join (i.e., the 2 - layer CTE Consumer). And the 2 - layer CTE Consumer is used as an object node to execute the left - table chain judgment logic. When the 2 - layer CTE Consumer is used as an object node to execute the left - table chain judgment logic, since it is not a Join, its sequence value is assigned to its respective child nodes, i.e., the CTE Producer is assigned 1. And Scan has no child nodes, so the left - table chain judgment logic is not executed on it.

[0144] Furthermore, the father node of Scan (i.e., the 3-layer Join) is determined as the next operator node to be traversed in the right table chain. When traversing the 3-layer Join, with the 3-layer Join as the current node and its father node being non-empty and the 4-layer Join, the sum of the sequence value of the 3-layer Join and the preset value (i.e., 1 + 1 = 2) is assigned to the 4-layer Join and the left child node of the 4-layer Join (i.e., the 3-layer CTE Consumer). Moreover, the 3-layer CTE Consumer and the 3-layer Join are used as object nodes to execute the left table chain judgment logic respectively. When using the 3-layer CTE Consumer as the object node to execute the left table chain judgment logic, since it is not a Join, the sequence value 2 of the 3-layer CTE Consumer is assigned to its left and right child nodes, that is, the CTE Producer is assigned 2. When using the 3-layer Join as the object node to execute the left table chain judgment logic, since it is a Join, the sequence value 1 of the 3-layer Join is assigned to its left child node, that is, the 2-layer CTE Consumer is assigned 2. Furthermore, the 2-layer CTE Consumer is used as the object node to execute the left table chain judgment logic, making the CTE Producer assigned 1.

[0145] Furthermore, the father node of the 3-layer Join in the right table chain (i.e., the 4-layer Join) is determined as the next operator node to be traversed in the right table chain. When traversing the 4-layer Join, with the 4-layer Join as the current node, since its father node is empty, the 4-layer Join is the root node in the right table chain, and the traversal process is directly ended.

[0146] During this traversal process, the sequence value of the CTE Producer is assigned 3 times, and the values assigned three times are 1, 2, and 1 respectively. Additionally, during this traversal process, there is a situation where the 2-layer CTE Consumer and the 3-layer CTE Consumer use the same CTE Producer, and the assignments of the 2-layer CTE Consumer and the 3-layer CTE Consumer are different (1 and 2 respectively), resulting in different multiple assignments of the CTE Producer.

[0147] As Figure 3e shown, there are two right table chains. The flow relationship of one right table chain is CTE Producer[0] - CTE Consumer[0](2) - Join[3] - Union, and the flow relationship of the other right table chain is CTE Producer[1] - CTE Consumer[1](1) - Join[2] - Union.

[0148] First, take the right table chain with the flow relationship of CTE Producer[0] - CTE Consumer[0](2) - Join[3] - Union as an example. The leaf node in the right table chain is CTE Producer[0], and it is assigned a value of 0. Since the leaf node CTE Producer[0] is the operator node for the initial traversal, it is determined as the current node. Its parent node in the right table chain is CTE Consumer[0](2). Since CTE Consumer[0](2) is non-empty and not a hash join operator node, the sequence value of CTE Producer[0] is assigned to CTE Consumer[0](2), and the sequence value of CTE Consumer[0](2) is also 0. Furthermore, CTE Consumer[0](2) is determined as the next operator node to be traversed in the right table chain.

[0149] When traversing CTE Consumer[0](2), CTE Consumer[0](2) is the current node. Its parent node is non-empty and is Join[3]. Then, the sum of the sequence value of CTE Consumer[0](2) and the preset value (i.e., 0 + 1 = 1) is assigned to Join[3] and the left child node of Join[3] (i.e., CTE Consumer[1](2)). Also, the left table chain judgment logic is executed for CTE Consumer[1](2) and CTE Consumer[0](2) as object nodes respectively. When the left table chain judgment logic is executed for CTE Consumer[1](2) as an object node, since it is not a Join, the sequence value 1 of CTE Consumer[1](2) is assigned to its left and right child nodes, i.e., CTE Producer[1]. Furthermore, when CTE Consumer[0](2) is used as an object node, since it is not a Join, the sequence value 0 of CTE Consumer[0](2) is assigned to its left and right child nodes, that is, CTE Producer[0] is assigned a value of 0.

[0150] Furthermore, Join[3] (the parent node of CTE Consumer[0](2) in the right table chain) is determined as the next operator node to be traversed in the right table chain. When traversing Join[3], Join[3] is the current node. Its parent node is non-empty and is Union, and Union is not a Join. Then, the sequence value 1 of Join[3] is assigned to Union.

[0151] Furthermore, determine Union (the parent node of Join[3] in the right table chain) as the next operator node to be traversed in the right table chain. When traversing Union, Union is the current node, it is not a Join and its parent node is empty, so Union is the root node in the right table chain. And directly execute the left table chain judgment logic for Union as the object node. Since Union is not a Join, when executing the left table chain judgment logic, assign the sequence value 1 of Union to its left and right child nodes, that is, assign 1 to both Join[2] and Join[3], indicating that Join[2] and Join[3] are executed simultaneously. Furthermore, execute the left table chain judgment logic for Join[2] and Join[3] respectively as object nodes, so that CTE Consumer[0](1) and CTE Producer[0] are 1, and make CTE Consumer[1](2) and CTE Producer[1] be 1.

[0152] During this traversal process, the sequence value of CTE Producer[0] is assigned 3 times, which are 0, 0, and 1 respectively; the sequence value of CTE Producer[1] is assigned 2 times, both are 1. Thus, during this traversal process, there is a situation where CTE Consumer[0](1) and CTE Consumer[0](2) use the same CTE Producer[0], and the assignments of CTE Consumer[0](1) and CTE Consumer[0](2) are different (1 and 0 respectively), making the different assignments of CTE Producer[0] be 1 and 0.

[0153] Take the right table chain with the flow relationship of CTE Producer[1] - CTE Consumer[1](1) - Join[2] - Union as an example. The leaf node in the right table chain is CTE Producer[1], and assign 0 to it. Since the leaf node CTE Producer[1] is the operator node for the initial traversal, determine it as the current node. Its parent node in the right table chain is CTE Consumer[1](1). Since CTE Consumer[1](1) is not empty and not a hash join operator node, assign the sequence value of CTE Producer[1] to CTE Consumer[1](1), and the sequence value of CTE Consumer[1](1) is also 0. Furthermore, determine CTE Consumer[1](1) as the next operator node to be traversed in the right table chain.

[0154] When traversing CTE Consumer[1](1), if CTE Consumer[1](1) is the current node and its parent node is non-empty and is Join[2], then the sum of the sequence value of CTE Consumer[1](1) and the preset value (i.e., 0 + 1 = 1) is assigned to Join[2] and the left child node of Join[2] (i.e., CTE Consumer[0](1)). And, the left table chain judgment logic is respectively executed with CTE Consumer[0](1) and CTEConsumer[1](1) as object nodes. When the left table chain judgment logic is respectively executed with CTE Consumer[0](1) as the object node, since it is not Join, the sequence value 1 of CTE Consumer[0](1) is assigned to its left and right child nodes, that is, CTE Producer[0]. Further, when CTE Consumer[1](1) is used as the object node and it is not Join, the sequence value 0 of CTE Consumer[1](1) is assigned to its left and right child nodes, that is, CTE Producer[1] is assigned 0.

[0155] Furthermore, Join[2] (the parent node of CTE Consumer[1](1) in the right table chain) is determined as the next operator node to be traversed in the right table chain. When traversing Join[2], if Join[2] is the current node and its parent node is non-empty and is Union, and Union is not Join. Then the sequence value 1 of Join[2] is assigned to Union.

[0156] Furthermore, Union (the parent node of Join[2] in the right table chain) is determined as the next operator node to be traversed in the right table chain. When traversing Union, if Union is the current node, it is not Join and its parent node is empty, and Union is the root node in the right table chain. And, the left table chain judgment logic is directly executed with Union as the object node. Since Union is not Join, when executing the left table chain judgment logic, the sequence value 1 of Union is assigned to its left and right child nodes, that is, both Join[2] and Join[3] are assigned 1, indicating that Join[2] and Join[3] are executed simultaneously. Further, the left table chain judgment logic is respectively executed with Join[2] and Join[3] as object nodes, making CTE Consumer[0](1) and CTE Producer[0] equal to 1, and making CTEConsumer[1](2) and CTE Producer[1] equal to 1.

[0157] During this traversal process, the sequence value of CTE Producer[0] was assigned 2 times, both being 1; the sequence value of CTE Producer[1] was assigned 3 times, being 0, 0, and 1 respectively. Thus, during this traversal process, there is a situation where CTE Consumer[1](1) and CTE Consumer[1](2) use the same CTE Producer[1], and the assignments of CTE Consumer[1](1) and CTE Consumer[1](2) are different (being 0 and 1 respectively), resulting in different assignments of CTE Producer[1] being 1 and 0.

[0158] S204: When the upstream operator nodes of two identical common temporary table consumption operator nodes with scheduling dependency relationships are the same common temporary table production operator node, it is determined that there is a scheduling deadlock.

[0159] It can be understood that the execution orders of two identical common temporary table consumption operator nodes are different, which means that one of the common temporary table consumption operator nodes needs to wait for the other common temporary table consumption operator node to execute before starting to execute, manifested as a dependency relationship, and this dependency relationship is caused by the Join operator node. When the upstream operator nodes of two identical common temporary table consumption operator nodes with scheduling dependency relationships are the same common temporary table production operator node, since the same common temporary table production operator node will output data to two identical common temporary table consumption operator nodes, it will cause a data caching phenomenon during the execution process, thereby leading to a scheduling deadlock. It can be seen that in this step, not only can it be detected whether there is a scheduling deadlock phenomenon in the query plan tree during the execution process, but also the two identical common temporary table consumption operator nodes and the upstream same common temporary table production operator node that cause the scheduling deadlock phenomenon can be determined more accurately. Thus, the operator nodes causing the scheduling deadlock phenomenon can be processed targeted, improving the processing efficiency.

[0160] Take Figure 3a - Figure 3e as an example to determine the scheduling deadlock phenomenon in the query plan tree. As Figure 3aAs shown, the left CTE Consumer and the right CTE Consumer are two identical CTE Consumers, and there are different assignments for the left CTE Consumer and the right CTE Consumer. Then, there is a scheduling dependency relationship between the left CTE Consumer and the right CTE Consumer. Since the left CTE Consumer and the right CTE Consumer use the same CTE Producer, there is a scheduling deadlock phenomenon in the query plan tree, and it is caused by the scheduling dependency of the left CTE Consumer under the same CTE Producer on the right CTE Consumer. It can be understood as the scheduling dependency of the left CTE Consumer in the link of the query plan tree other than the right table chain on the right CTE Consumer in the right sub-link of the Join operator node in the right table chain. That is, it is possible to accurately know the CTE Consumer and CTE Producer that cause the scheduling deadlock.

[0161] As Figure 3b shown, based on the traversal of the right table chain with a flow relationship of Scan - 3 - layer Join, it is known that there are no two identical CTE Consumers, and there is only one assignment for the CTE Producer, without the situation of multiple assignments. Therefore, there is no scheduling deadlock phenomenon. And based on the traversal of the right table chain with a CTE Producer - 3 - layer CTE Consumer - 4 - layer Join, the 2 - layer CTE Consumer and the 3 - layer CTE Consumer are two identical CTE Consumers, and there are different assignments for the 2 - layer CTE Consumer and the 3 - layer CTE Consumer. Then, there is a scheduling dependency relationship between the 2 - layer CTE Consumer and the 3 - layer CTE Consumer. Since the 2 - layer CTE Consumer and the 3 - layer CTE Consumer use the same CTE Producer, there is a scheduling deadlock phenomenon in the query plan tree, and it is caused by the scheduling dependency of the 2 - layer CTE Consumer under the same CTE Producer on the 3 - layer CTE Consumer. It can be understood as the scheduling dependency of the 2 - layer CTE Consumer in the link of the query plan tree other than the right table chain on the 3 - layer CTE Consumer in the right sub - link of the 4 - layer Join operator node in the right table chain. That is, it is possible to accurately know the CTE Consumer and CTE Producer that cause the scheduling deadlock.

[0162] As Figure 3cAs shown in the figure, based on the right table chain traversal of the CTE Producer - 2 layer to CTE Consumer - 3 layer Join according to the flow relationship, it is known that there is no traversal to two identical CTE Consumers, and the two assignments of the CTE Producer are the same. Therefore, there is no scheduling deadlock. Based on the right table chain traversal of the CTE Producer - 3 layer to CTE Consumer - 4 layer Join according to the flow relationship, it is known that there is no traversal to two identical CTE Consumers, and the CTE Producer has only one assignment. Therefore, there is also no scheduling deadlock. Therefore, although Figure 3c there are two identical CTE Consumers (i.e., the 2 - layer CTE Consumer and the 3 - layer CTE Consumer) in the query plan tree of Figure 3c , and the two identical CTE Consumers are under the nested Join operator node and share the same CTE Producer, during the traversal of the two right table chains, neither involves traversing to these two identical CTE Consumers simultaneously, so there is no scheduling deadlock. Specifically analyzed, since the execution method of Join is to process the data in the right sub - node first, and both the 2 - layer CTE Consumer and the 3 - layer CTE Consumer are right sub - nodes under the Join operator node, there is no situation where the execution order of the 2 - layer CTE Consumer and the 3 - layer CTE Consumer is different.

[0163] As Figure 3d shown, based on the right table chain traversal of the Scan - 3 layer Join - 4 layer Join according to the flow relationship, the 2 - layer CTE Consumer and the 3 - layer CTE Consumer are two identical CTE Consumers, and there are different assignments (1 and 2 respectively) for the 2 - layer CTE Consumer and the 3 - layer CTE Consumer, then there is a scheduling dependency relationship between the 2 - layer CTE Consumer and the 3 - layer CTE Consumer. Since the 2 - layer CTE Consumer and the 3 - layer CTE Consumer use the same CTE Producer, there is a scheduling deadlock phenomenon in the query plan tree, and it is caused by the scheduling dependency of the 3 - layer CTE Consumer on the 2 - layer CTE Consumer under the same CTE Producer. It can be understood that it is the 3 - layer CTE Consumer in the link of the query plan tree other than the right table chain that has a scheduling dependency on the 2 - layer CTE Consumer in the right sub - link of the 4 - layer Join operator node in the right table chain. That is, it is possible to accurately know the CTE Consumer and CTE Producer that cause the scheduling deadlock.

[0164] As Figure 3e shown, based on the right table chain traversal with the flow relationship as CTE Producer[0]-CTE Consumer[0](2)-Join[3]-Union, it is known that CTE Consumer[0](1) and CTE Consumer[0](2) are two identical CTE Consumers, and there are different assignments for CTE Consumer[0](1) and CTE Consumer[0](2) (1 and 0 respectively), then there is a scheduling dependency relationship between CTE Consumer[0](1) and CTE Consumer[0](2). Since CTE Consumer[0](1) and CTE Consumer[0](2) use the same CTE Producer[0], there is a scheduling deadlock phenomenon in the query plan tree, and it is caused by the scheduling dependency of CTE Consumer[0](1) on Consumer[0](2) under the same CTE Producer[0]. It can be understood as the scheduling dependency of CTE Consumer[0](1) in the link of the query plan tree other than the right table chain on Consumer[0](2) in the right sub-link of Join[3] in the right table chain. That is, it is possible to accurately know the CTE Consumer (i.e., CTE Consumer[0](1) on Consumer[0](2)) and CTE Producer[0] that cause the scheduling deadlock.

[0165] Based on the right table chain traversal of CTE Producer[1]-CTE Consumer[1](1)-Join[2]-Union, it is known that CTE Consumer[1](1) and CTE Consumer[1](2) are two identical CTE Consumers, and there are different assignments for CTE Consumer[1](1) and CTE Consumer[1](2) (0 and 1 respectively). Then there is a scheduling dependency between CTE Consumer[1](1) and CTE Consumer[1](2). Since CTE Consumer[1](1) and CTE Consumer[1](2) use the same CTE Producer[1], there is a scheduling deadlock in the query plan tree, and it is caused by the scheduling dependency of CTE Consumer[1](2) on CTE Consumer[1](1) under the same CTE Producer[1]. It can be understood that it is the scheduling dependency of CTE Consumer[1](2) in the link of the query plan tree other than the right table chain on CTE Consumer[1](1) in the right sub-link of Join[2] in the right table chain. That is, it is possible to accurately know the CTE Consumers (i.e., CTE Consumer[1](1) and CTE Consumer[1](2)) and CTE Producer[1] that cause the scheduling deadlock.

[0166] From the above content, it can also be determined whether there is a scheduling deadlock by whether there are multiple assignments for the same CTE Producer and whether the multiple assignments are the same. That is, after the traversal of the right table chain is completed, if the multiple assignments of the same CTE Producer are different, it is determined that there is a scheduling deadlock.

[0167] In a possible implementation manner, an embodiment of the present application provides a specific implementation manner for determining the existence of a scheduling deadlock when the upstream operator nodes of two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node, including:

[0168] When the upstream operator nodes of two identical common temporary table consumption operator nodes with a scheduling dependency relationship are the same common temporary table production operator node and the common temporary table does not meet the preset conditions, it is determined that there is a scheduling deadlock;

[0169] Among them, the preset condition is that the data volume of the target data is less than the data volume threshold or the execution time of the common temporary table consumption operator node for the target data is less than the time threshold; the target data is obtained from the common temporary table.

[0170] The target data is obtained from a common temporary table and is related to the query plan. It is the data that cannot be processed after being sent from the operator node that produces the common temporary table to the operator node that consumes the common temporary table. The amount of the target data is specifically determined by the query plan tree. It can be seen that the embodiments of the present application do not limit the data volume threshold and the time threshold, and can be set according to the actual situation.

[0171] It can be understood that if there is a scheduling deadlock phenomenon during the execution of the query plan tree, but in actual applications, whether a deadlock occurs is also related to the actual data volume stored in the buffer and the operator execution time. For example, if the data volume in the buffer of the operator node that consumes the common temporary table is small or the data in the buffer can be processed within a very short time, then no scheduling deadlock will actually occur.

[0172] See Figure 4 , Figure 4 is a schematic diagram of a query plan tree with a cache operator provided by an embodiment of the present application. Combining Figure 4 , the method provided by the embodiments of the present application further includes the following steps:

[0173] When it is determined that there is a scheduling deadlock, obtain the target common temporary table consumption operator node in the query plan tree that caches the target data; the target data is the data that cannot be processed by the target hash join operator node due to the scheduling deadlock, and the target hash join operator is the parent node of the target common temporary table consumption operator node;

[0174] Add a cache operator between the target common temporary table consumption operator node and the target hash join operator node to store the target data into the storage space corresponding to the cache operator.

[0175] Among them, the target data is also the data that cannot be processed after being sent from the operator node that produces the common temporary table to the target common temporary table consumption operator node.

[0176] The cache operator can be called a Buffer operator. As Figure 4 shown, there is a scheduling dependency of the left CTE Consumer on the right CTE Consumer, resulting in a scheduling deadlock. At this time, the target common temporary table consumption operator node is the left CTE Consumer, and the target hash join operator node is the Join operator node. Then, a Buffer operator is added between the left CTE Consumer and Join to store the target data into the Buffer operator. The storage device in the Buffer operator can include dedicated memory and / or disk, etc., for providing storage space. Then, the target data can be cached into the dedicated memory or spilled to the disk to avoid the buffer of the left CTE Consumer from being exhausted as much as possible, so as to ensure the normal execution of the query.

[0177] In addition, in order to avoid the scheduling deadlock in the query plan tree as much as possible, the query plan tree that references the CTE and Join operator nodes can also be rewritten in an inlined mode.

[0178] Based on the implementation manners provided in the above aspects of the present application, further combinations can be made to provide more implementation manners.

[0179] Those skilled in the art can understand that in the above method of the specific implementation manner, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.

[0180] Based on the method for detecting data query scheduling deadlock provided in the above method embodiment, the embodiment of the present application also provides a device for detecting data query scheduling deadlock. The device for detecting data query scheduling deadlock will be described below with reference to the drawings. Since the principle of solving problems by the device in the embodiment of the present disclosure is similar to the above method for detecting data query scheduling deadlock in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0181] See Figure 5 As shown, this figure is a schematic structural diagram of a device for detecting data query scheduling deadlock provided by an embodiment of the present application. As Figure 5 shown, the device for detecting data query scheduling deadlock includes:

[0182] A generating unit 501, configured to obtain a query statement and generate a query plan tree corresponding to the query statement; the query plan tree includes a plurality of operator nodes and query logical relationships between the plurality of operator nodes; the operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node;

[0183] A first determining unit 502, configured to traverse the query plan tree and determine at least one right table chain in the query plan tree; the right table chain includes leaf nodes in the query plan tree and root nodes that are not the hash join operator nodes; when the father node of the operator node in the right table chain is the hash join operator node, the operator node is the right child node of its father node, and the right table chain includes the father node of the operator node;

[0184] A search unit 503 is configured to traverse operator nodes in the right table chain from the leaf node of the right table chain bottom-up, and traverse other operator nodes of the query plan tree, analyze the execution order relationship between the traversed operator nodes in the query plan tree, and search for two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship indicates that the execution orders between two identical common temporary table consumption operator nodes are different;

[0185] A second determination unit 504 is configured to determine that there is a scheduling deadlock when the upstream operator nodes of the two identical common temporary table consumption operator nodes with the scheduling dependency relationship are the same common temporary table production operator node.

[0186] In a possible implementation, the first determination unit 502 includes:

[0187] An assignment subunit is configured to assign a first tag to the root node of the query plan tree;

[0188] A first traversal subunit is configured to traverse operator nodes in the query plan tree from the root node top-down. If the traversed operator node is the hash join operator node, assign a first tag to the right child node of the hash join operator node and assign a second tag to the left child node of the hash join operator node; if the traversed operator node is not the hash join operator node, assign the value of the operator node to both the left child node and the right child node of the traversed operator node until the leaf node of the query plan tree is traversed;

[0189] A second traversal subunit is configured to traverse the operator nodes with the first tag in the query plan tree from the leaf node with the first tag bottom-up until the traversed operator node is the second tag, and determine the link formed by each traversed operator node as the right table chain in the query plan tree;

[0190] Wherein, the number of right table chains in the query plan tree is equal to the number of leaf nodes with the first tag in the query plan tree.

[0191] In a possible implementation, the search unit 503 includes:

[0192] A first determination subunit is configured to determine that the leaf node of the right table chain is the node with the earliest execution order;

[0193] A second determination subunit is configured to traverse operator nodes in the right table chain from the leaf node of the right table chain bottom-up, and determine the execution order relationship between the operator nodes of the right table chain according to the order rule;

[0194] A third determination subunit, configured to traverse other operator nodes of the query plan tree, and determine the execution order relationship between the other operator nodes according to the order rule;

[0195] Wherein, the order rule includes one or more of the following:

[0196] When the downstream operator node is not the hash join operator node, determine that the execution order of the adjacent upstream operator node and the downstream operator node is the same;

[0197] When there is a hash join operator node, determine that the execution order of the hash join operator node is later than the execution order of the right child node of the hash join operator node, and is the same as the execution order of the left child node of the hash join operator node.

[0198] In a possible implementation manner, the lookup unit 503 includes:

[0199] A third traversal subunit, configured to traverse operator nodes in the right table chain from the leaf node of the right table chain bottom-up, and traverse other operator nodes of the query plan tree, and assign an order value to the traversed operator nodes; the order value is used to represent the execution order relationship between operator nodes;

[0200] A fourth determination subunit, configured to determine two identical common temporary table consumption operator nodes with different order values in the query plan tree as two identical common temporary table consumption operator nodes having a scheduling dependency relationship in the query plan tree.

[0201] In a possible implementation manner, the third traversal subunit includes:

[0202] A first assignment subunit, configured to assign an order value to the leaf node of each right table chain;

[0203] An acquisition subunit, configured to determine the operator node traversed in the right table chain as the current node, and acquire the parent node of the current node; the parent node of the current node is the parent node of the current node in the right table chain;

[0204] A second assignment subunit, configured to, if the parent node of the current node is not empty and is not the hash join operator node, assign the order value of the current node to the parent node of the current node, and determine the parent node of the current node as the next operator node traversed in the right table chain, and re-execute the step of determining the operator node traversed as the current node, acquiring the parent node of the current node and subsequent steps;

[0205] A third assignment subunit, configured to, if the parent node of the current node is not null and is the hash join operator node, assign the sum of the sequence value of the current node and a preset value to the parent node of the current node and the left child node of the parent node of the current node, use the left child node of the parent node of the current node as an object node to execute a left table chain judgment logic, and use the current node as an object node to execute the left table chain judgment logic; determine the parent node of the current node as the operator node that will be traversed next in the right table chain, re-execute the step of using the traversed operator node as the current node, obtaining the parent node of the current node and subsequent steps;

[0206] A fourth assignment subunit, configured to, if the current node is not the hash join operator node and the parent node of the current node is null, use the current node as the object node to execute a left table chain judgment logic; wherein, the left table chain judgment logic is to judge whether the object node is the hash join operator node; if so, assign the sequence value of the object node to the left child node of the object node, if not, assign the sequence value of the object node to each child node of the object node; determine the object node with the assigned sequence value as the object node, and re-execute the step of judging whether the object node is the hash join operator node and subsequent steps until the object node is a leaf node.

[0207] In a possible implementation manner, the common temporary table production operator node is configured to generate a common temporary table for passing to the common temporary table consumption operator node for use;

[0208] The second determination unit 504 is specifically configured to:

[0209] When the upstream operator nodes of two identical common temporary table consumption operator nodes with scheduling dependency relationships are the same common temporary table production operator node and the common temporary table does not meet the preset conditions, determine that there is a scheduling deadlock;

[0210] Wherein, the preset conditions are that the data volume of the target data is less than a data volume threshold or the execution time of the common temporary table consumption operator node for the target data is less than a time threshold; the target data is obtained from the common temporary table.

[0211] In a possible implementation manner, the apparatus further includes:

[0212] An obtaining unit, configured to, when it is determined that there is a scheduling deadlock, obtain a target common temporary table consumption operator node in the query plan tree that caches target data; the target data is data that a target hash join operator node cannot process due to the scheduling deadlock, and the target hash join operator is the parent node of the target common temporary table consumption operator node;

[0213] An adding unit is configured to add a caching operator between the target common temporary table consuming operator node and the target hash join operator node, so as to store the target data into a storage space corresponding to the caching operator.

[0214] It should be noted that for the specific implementation of each unit in this embodiment, reference can be made to the relevant descriptions in the above method embodiments. The division of units in the embodiments of the present application is illustrative only, and is only a logical function division. In actual implementation, there may be other division methods. Each functional unit in the embodiments of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. For example, in the above embodiment, the processing unit and the sending unit may be the same unit or different units. The above integrated unit may be implemented in the form of hardware or in the form of a software functional unit.

[0215] Based on the method for detecting data query scheduling deadlock provided in the above method embodiments, the present application further provides an electronic device, including: one or more processors; a storage device storing one or more programs thereon, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting data query scheduling deadlock described in any of the above embodiments.

[0216] Next, with reference to Figure 6 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present application. The terminal devices in the embodiments of the present application may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices, tablet computers), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 6 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present application.

[0217] As Figure 6As shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0218] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.

[0219] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart may be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for performing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present application are executed.

[0220] The electronic device provided by the embodiment of the present application and the method for detecting data query scheduling deadlock provided by the above embodiment belong to the same inventive concept. Technical details not described in detail in this embodiment may be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0221] Based on the method for detecting data query scheduling deadlock provided by the above method embodiment, an embodiment of the present application provides a computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method for detecting data query scheduling deadlock as described in any of the above embodiments.

[0222] It should be noted that the above-mentioned computer-readable medium in the present application may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium may be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present application, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0223] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (Hyper Text Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks (“LAN”), wide area networks (“WAN”), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.

[0224] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist separately without being assembled into the electronic device.

[0225] The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to execute the above-mentioned method for detecting data query scheduling deadlocks.

[0226] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The foregoing programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by connecting through the Internet using an Internet service provider).

[0227] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0228] The units involved in the embodiments described in this application can be implemented in software or in hardware. Among them, the name of the unit / module does not, in some cases, constitute a limitation on the unit itself. For example, the voice data acquisition module can also be described as the "data acquisition module".

[0229] The functions described above herein can be performed, at least in part, by one or more hardware logic components. For example, by way of non-limitation, exemplary types of hardware logic components that can be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), and so on.

[0230] In the context of the present application, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0231] It should be noted that the various embodiments in this specification are described in a progressive manner, and the key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the systems or devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and reference can be made to the description in the method part for the relevant parts.

[0232] It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" may mean: only A exists, only B exists, and both A and B exist simultaneously. Among them, A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one (one) of the following" or its similar expression refers to any combination of these items, including any combination of single items (ones) or plural items (ones). For example, at least one (one) of a, b, or c may mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c may be single or multiple.

[0233] It should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent in such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.

[0234] The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be implemented directly in hardware, in a software module executed by a processor, or in a combination thereof. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well known in the art.

[0235] The foregoing description of the disclosed embodiments enables those skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Thus, the present application is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting data query scheduling deadlocks, characterized in that, The method includes: Obtaining a query statement and generating a query plan tree corresponding to the query statement; the query plan tree includes a plurality of operator nodes and the query logical relationships between the plurality of operator nodes; the operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node; Traversing the query plan tree to determine at least one right table chain in the query plan tree; the right table chain includes leaf nodes in the query plan tree and root nodes that are not the hash join operator nodes; when the parent node of the operator node in the right table chain is the hash join operator node, the operator node is the right child node of its parent node, and the right table chain includes the parent node of the operator node; Starting from the leaf node of the right table chain, traversing the operator nodes in the right table chain from bottom to top, and traversing the other operator nodes of the query plan tree, analyzing the execution order relationship between the traversed operator nodes in the query plan tree, and finding two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship indicates that the execution order between two identical common temporary table consumption operator nodes is different; When the upstream operator nodes of the two identical common temporary table consumption operator nodes with the scheduling dependency relationship are the same common temporary table production operator node, it is determined that there is a scheduling deadlock.

2. The method according to claim 1, wherein The traversing the query plan tree to determine at least one right table chain in the query plan tree includes: Assigning a first mark to the root node of the query plan tree; Starting from the root node, traversing the operator nodes in the query plan tree from top to bottom. If the traversed operator node is the hash join operator node, assigning the first mark to the right child node of the hash join operator node and assigning the second mark to the left child node of the hash join operator node; if the traversed operator node is not the hash join operator node, assigning the value of the operator node to both the left child node and the right child node of the traversed operator node until the leaf nodes of the query plan tree are traversed; Starting from the leaf node with the first mark, traversing the operator nodes with the first mark in the query plan tree from bottom to top until the traversed operator node is the second mark, and determining the link composed of each traversed operator node as the right table chain in the query plan tree; Wherein, the number of the right table chains in the query plan tree is equal to the number of the leaf nodes with the first mark in the query plan tree.

3. The method according to claim 1 or 2, characterized in that, The starting from the leaf node of the right table chain, traversing the operator nodes in the right table chain from bottom to top, and traversing the other operator nodes of the query plan tree, and analyzing the execution order relationship between the traversed operator nodes in the query plan tree includes: Determining that the leaf node of the right table chain is the node with the earliest execution order; Starting from the leaf node of the right table chain, traversing the operator nodes in the right table chain from bottom to top, and determining the execution order relationship between the operator nodes of the right table chain according to the order rule; Traverse the other operator nodes of the query plan tree, and determine the execution order relationship between the other operator nodes according to the order rule; Among them, the order rule includes one or more of the following: When the downstream operator node is not the hash join operator node, determine that the execution order of the adjacent upstream operator node and the downstream operator node is the same; When there is a hash join operator node, determine that the execution order of the hash join operator node is later than the execution order of the right child node of the hash join operator node, and is the same as the execution order of the left child node of the hash join operator node.

4. The method according to claim 1, characterized in that, The method of traversing the operator nodes in the right table chain from the leaf node of the right table chain bottom-up, traversing the other operator nodes of the query plan tree, analyzing the execution order relationship between the traversed operator nodes in the query plan tree, and finding two identical common temporary table consumption operator nodes with scheduling dependency relationships in the query plan tree includes: Traverse the operator nodes in the right table chain from the leaf node of the right table chain bottom-up, and traverse the other operator nodes of the query plan tree, and assign an order value to the traversed operator nodes; the order value is used to represent the execution order relationship between operator nodes; Determine two identical common temporary table consumption operator nodes with different order values in the query plan tree as two identical common temporary table consumption operator nodes with scheduling dependency relationships in the query plan tree.

5. The method according to claim 4, wherein The method of traversing the operator nodes in the right table chain from the leaf node of the right table chain bottom-up, traversing the other operator nodes of the query plan tree, and assigning an order value to the traversed operator nodes includes: Assign an order value to the leaf node of each right table chain; Determine the traversed operator node in the right table chain as the current node, and obtain the father node of the current node; the father node of the current node is the father node of the current node in the right table chain; If the father node of the current node is not empty and is not the hash join operator node, assign the order value of the current node to the father node of the current node, and determine the father node of the current node as the next traversed operator node in the right table chain, and re-execute the step of determining the traversed operator node as the current node, obtaining the father node of the current node and subsequent steps; If the father node of the current node is not empty and is the hash join operator node, assign the sum of the order value of the current node and a preset value to the father node of the current node and the left child node of the father node of the current node, execute the left table chain judgment logic with the left child node of the father node of the current node as the object node, and execute the left table chain judgment logic with the current node as the object node; determine the father node of the current node as the next traversed operator node in the right table chain, and re-execute the step of determining the traversed operator node as the current node, obtaining the father node of the current node and subsequent steps; If the current node is not the hash join operator node and the parent node of the current node is empty, use the current node as the object node to execute the left table chain judgment logic; wherein, the left table chain judgment logic is to judge whether the object node is the hash join operator node; if so, assign the order value of the object node to the left child node of the object node, if not, assign the order value of the object node to each child node of the object node; determine the object node with the assigned order value child node as the object node, and re-execute the judgment of whether the object node is the hash join operator node and subsequent steps until the object node is a leaf node.

6. The method according to claim 1, wherein The common temporary table production operator node is used to generate a common temporary table for passing to the common temporary table consumption operator node for use; When the upstream operator nodes of two identical common temporary table consumption operator nodes with scheduling dependency relationships are the same common temporary table production operator node, it is determined that there is a scheduling deadlock, including: When the upstream operator nodes of two identical common temporary table consumption operator nodes with scheduling dependency relationships are the same common temporary table production operator node and the common temporary table does not meet the preset conditions, it is determined that there is a scheduling deadlock; Wherein, the preset conditions are that the data volume of the target data is less than the data volume threshold or the execution time of the common temporary table consumption operator node for the target data is less than the time threshold; the target data is obtained from the common temporary table.

7. The method according to claim 1, characterized in that The method further includes: When it is determined that there is a scheduling deadlock, obtain the target common temporary table consumption operator node in the query plan tree that caches the target data; the target data is the data that the target hash join operator node cannot process due to the scheduling deadlock, and the target hash join operator is the parent node of the target common temporary table consumption operator node; Add a cache operator between the target common temporary table consumption operator node and the target hash join operator node to store the target data in the storage space corresponding to the cache operator.

8. A detection device for data query scheduling deadlock, characterized in that, The device includes: A generation unit, configured to obtain a query statement and generate a query plan tree corresponding to the query statement; the query plan tree includes a plurality of operator nodes and the query logic relationships between the plurality of operator nodes; the operator nodes include a common temporary table production operator node, a common temporary table consumption operator node, and a hash join operator node; A first determination unit, configured to traverse the query plan tree to determine at least one right table chain in the query plan tree; the right table chain includes a leaf node in the query plan tree and a root node that is not a hash join operator node; when the parent node of the operator node in the right table chain is a hash join operator node, the operator node is the right child node of its parent node, and the right table chain includes the parent node of the operator node; A search unit, configured to traverse the operator nodes in the right table chain from the leaf node of the right table chain upwards to the bottom, and traverse the other operator nodes of the query plan tree, analyze the execution order relationship between the traversed operator nodes in the query plan tree, and search for two identical common temporary table consumption operator nodes with a scheduling dependency relationship in the query plan tree; the scheduling dependency relationship indicates that the execution orders between the two identical common temporary table consumption operator nodes are different; A second determination unit, configured to determine that a scheduling deadlock exists when the upstream operator nodes of the two identical common temporary table consumption operator nodes with the scheduling dependency relationship are the same common temporary table production operator node.

9. An electronic device, characterized in that, Comprising: One or more processors; A storage device storing one or more programs thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting data query scheduling deadlock according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a processor, the method for detecting data query scheduling deadlock according to any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Data query method, computer system and non-transitory computer readable medium

    CN109299133A

  • Deadlock detection method, system and device and readable storage medium

    CN111858075A