Deadlock detection method and device, electronic device and storage medium

By determining the path identification and passing it for the first node of the waiting relationship graph in a distributed database, the deadlock formed in the database is quickly detected, solving the problem of inefficient deadlock detection in the existing technology, and improving the performance and reliability of the database system.

CN119292800BActive Publication Date: 2025-05-20BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411834226.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-05-20
Estimated Expiration
2044-12-12

AI Technical Summary

Technical Problem

In the prior art, deadlock detection algorithms in distributed databases are complex, resulting in low efficiency.

Method used

A deadlock detection method is proposed. By determining the path identification for each first node in the waiting relationship diagram and controlling the path identification between nodes to pass it. If the received path identification is the same as the saved path identification, it is determined that a deadlock is formed.

Benefits of technology

It realizes fast and low-overhead deadlock detection, improves the throughput and scalability of the database system, reduces the system tail delay, and ensures service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292800B_ABST
    Figure CN119292800B_ABST
Patent Text Reader

Abstract

The present specification provides a deadlock detection method and device, an electronic device and a storage medium, the method comprising: determining a path identifier for each head node in a waiting relationship graph so that the path identifiers of different head nodes in the waiting relationship graph are different, wherein the head node is a node with an in-degree of 0; controlling each head node in the waiting relationship graph to send a path identifier to a downstream node, and controlling other nodes in the waiting relationship graph to save the received path identifier after receiving the path identifier sent by the upstream node and pass it to the downstream node; if a first node in the waiting relationship graph receives a path identifier sent by a second node that is the same as the path identifier saved by the first node, it is determined that a deadlock is formed between the first node and the second node, wherein the first node and the second node are any two nodes in the waiting relationship graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of this specification relate to the technical field of databases, and in particular, to a deadlock detection method and apparatus, an electronic device, and a storage medium. Background Art

[0002] In a distributed database, transaction concurrency control is often based on the mechanism of locking resources by transactions. Due to the characteristics of mutual exclusion, hold-and-wait, and non-preemption in the above mechanism, during the concurrent execution of transactions, contention for resources by transactions may result in a situation of circular waiting (i.e., the so-called deadlock). For example, after transaction A successfully locks data row 1 and then attempts to lock data row 2, at the same time, after transaction B successfully locks data row 2 and then attempts to lock data row 1; due to the characteristics of mutual exclusion and non-preemption, neither transaction A nor transaction B will give up the locks they have successfully acquired, thus falling into a situation of circular waiting and causing a deadlock. In order to detect deadlock nodes in a distributed database, a wait-for graph (WFG, a mathematical model representing the waiting relationships between transactions) can be used to construct a waiting relationship graph between transactions and / or tasks, and a detection algorithm can be used to detect the waiting relationship graph to unlock the detected deadlocks.

[0003] However, in the related art, the deadlock detection algorithm for the waiting relationship graph is relatively complex, resulting in low efficiency of deadlock detection. Summary of the Invention

[0004] In view of this, one or more embodiments of this specification provide a deadlock detection method and apparatus, an electronic device, and a storage medium.

[0005] To achieve the above object, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a deadlock detection method is proposed, and the method includes:

[0007] Determine a path identifier for each head node in the wait-for graph, so that the path identifiers of different head nodes in the wait-for graph are different, where the head node is a node with an in-degree of 0;

[0008] Control each head node in the wait-for graph to send the path identifier to downstream nodes, and control other nodes in the wait-for graph to save the received path identifier and pass it to downstream nodes after receiving the path identifier sent by the upstream node;

[0009] If a first node in the waiting relationship graph receives a path identifier sent by a second node that is the same as the path identifier saved by the first node, it is determined that a deadlock is formed between the first node and the second node, where the first node and the second node are any two nodes in the waiting relationship graph.

[0010] In a possible embodiment of this specification, controlling each head node in the waiting relationship graph to send a path identifier to downstream nodes includes:

[0011] If there are at least two downstream nodes for the head node, path identifiers are respectively determined for each downstream node of the head node according to the path identifier of the head node, so that the path identifiers of different downstream nodes of the head node are different;

[0012] The head node is respectively controlled to send the corresponding path identifier to each downstream node.

[0013] In a possible embodiment of this specification, controlling other nodes in the waiting relationship graph to save the received path identifier and pass it to downstream nodes after receiving the path identifier sent by an upstream node includes:

[0014] If a third node has at least two downstream nodes and the third node receives a path identifier sent by an upstream node, the received path identifier is saved, and path identifiers are determined for each downstream node of the third node according to the received path identifier, so that the path identifiers of different downstream nodes of the third node are different, where the third node is any node in the waiting relationship graph other than the head node;

[0015] The third node is respectively controlled to send the corresponding path identifier to each downstream node.

[0016] In a possible embodiment of this specification, the method further includes:

[0017] If the path identifier saved by a fourth node in the waiting relationship graph is the source identifier of the path identifier sent by a fifth node received, it is determined that a deadlock is formed between the fourth node and the fifth node;

[0018] where the fourth node and the fifth node are any two nodes in the waiting relationship graph;

[0019] For any path identifier, the path identifier is the source identifier of other path identifiers formed during the process of passing downstream.

[0020] In a possible embodiment of this specification, for any path identifier, if the path identifier is passed from one node to another node in the waiting relationship graph, it remains unchanged; if the path identifier is passed from one node to multiple other nodes in the waiting relationship graph, different suffixes are added to the path identifier to form the path identifiers of each of the multiple other nodes;

[0021] Determining that a deadlock is formed between the fourth node and the fifth node if the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node includes:

[0022] Determining that a deadlock is formed between the fourth node and the fifth node if the path identifier stored by the fourth node in the waiting relationship graph is a prefix of the path identifier sent by the received fifth node.

[0023] In a possible embodiment of this specification, the method further includes:

[0024] If the path identifier stored by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, controlling the sixth node to save the received path identifier and pass it to the downstream node, where the sixth node is any node in the waiting relationship graph.

[0025] In a possible embodiment of this specification, determining that a deadlock is formed between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node includes:

[0026] Determining that a deadlock is formed between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as any path identifier stored by the first node;

[0027] Determining that a deadlock is formed between the fourth node and the fifth node if the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node includes:

[0028] Determining that a deadlock is formed between the fourth node and the fifth node if any path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node;

[0029] Controlling the sixth node to save the received path identifier and pass it to the downstream node if the path identifier stored by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier includes:

[0030] If each path identifier stored in the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, then control the sixth node to save the received path identifier and pass it to the downstream node.

[0031] In a possible embodiment of this specification, the determining that a deadlock is formed between the first node and the second node when the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node includes:

[0032] If the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node, then determine that a deadlock is formed between the first node and the second node, with the first node as the head and the second node as the tail.

[0033] The determining that a deadlock is formed between the fourth node and the fifth node when the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node includes:

[0034] If any path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, then determine that a deadlock is formed between the fourth node and the fifth node, with the fourth node as the head and the fifth node as the tail.

[0035] According to a second aspect of one or more embodiments of this specification, a deadlock detection device is proposed. The device includes:

[0036] An initialization module, configured to determine path identifiers for each head node in the waiting relationship graph, so that the path identifiers of different head nodes in the waiting relationship graph are different, where the head node is a node with an in-degree of 0.

[0037] A transmission module, configured to control each head node in the waiting relationship graph to send path identifiers to downstream nodes, and control other nodes in the waiting relationship graph to save the received path identifiers and pass them to downstream nodes after receiving the path identifiers sent by upstream nodes.

[0038] A detection module, configured to determine that a deadlock is formed between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node, where the first node and the second node are any two nodes in the waiting relationship graph.

[0039] According to a third aspect of one or more embodiments of the present specification, there is provided a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0040] According to a fourth aspect of one or more embodiments of the present specification, there is provided an electronic device, including:

[0041] a processor;

[0042] a memory for storing instructions executable by the processor;

[0043] wherein, the processor realizes the method described in the first aspect by running the executable instructions.

[0044] According to a fifth aspect of one or more embodiments of the present specification, there is provided a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0045] The technical solutions provided by the embodiments of the present specification may include the following beneficial effects:

[0046] For the deadlock detection method provided by the embodiments of the present specification, first, a path identifier is determined for each head node in the waiting relationship graph, so that the path identifiers of different head nodes in the waiting relationship graph are different, and then each head node in the waiting relationship graph is controlled to send the path identifier to the downstream nodes, and other nodes in the waiting relationship graph are controlled to save the received path identifier and pass it to the downstream nodes after receiving the path identifier sent by the upstream node; if a node in the waiting relationship graph receives a path identifier that is the same as the path identifier it has saved, it is determined that a deadlock is formed between this node and the node that sent this path identifier to it. In this method, each node in the waiting relationship graph only needs to send the path identifier to its downstream nodes to accurately detect the deadlock of circular waiting, that is, the deadlock detection is completed with extremely low network overhead, which is fast, convenient, and has low latency, so as to improve key performances such as the throughput and scalability of the database system, and at the same time reduce the system tail latency and ensure the service quality of the database system. Description of the Drawings

[0047] Figure 1 is a schematic diagram of the architecture of a distributed database provided by an exemplary embodiment.

[0048] Figure 2 is a flowchart of a deadlock detection method provided by an exemplary embodiment.

[0049] Figure 3 is a schematic diagram of path label transfer in the case of one downstream node provided by an exemplary embodiment.

[0050] Figure 4 It is a schematic diagram of path label transfer in the case of multiple downstream nodes provided by an exemplary embodiment.

[0051] Figure 5 It is a schematic diagram of path label transfer in the case of multiple upstream nodes provided by an exemplary embodiment.

[0052] Figure 6 It is a schematic diagram of the transfer of a path number list provided by an exemplary embodiment.

[0053] Figure 7 It is a schematic structural diagram of a device provided by an exemplary embodiment.

[0054] Figure 8 It is a block diagram of a deadlock detection device provided by an exemplary embodiment. Detailed implementation manners

[0055] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with one or more embodiments of this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0056] It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily executed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step for description in other embodiments.

[0057] Next, some concepts related to this specification will be explained.

[0058] Transaction: A set composed of one or more tasks, and this set has atomicity, that is, from the perspective of the execution result of the transaction, all tasks within a transaction are either all successfully executed or all not executed.

[0059] Resource: A data row, that is, the data to be read and written by the tasks within a transaction.

[0060] Waiting relationship: Transaction A has the read and write permissions for resource R. If another transaction B wants to read and write resource R, it needs to wait for A to complete; then it is said that B and A have a waiting relationship, and B waits for A. The waiting relationship has various forms such as one-to-one, one-to-many, and many-to-one.

[0061] Downstream node: If A waits for B, then B is the downstream node of A.

[0062] Upstream node: If A waits for B, then A is the upstream node of B.

[0063] In-degree: The number of upstream nodes of a node.

[0064] Out-degree: The number of downstream nodes of a node.

[0065] Granularity: The smallest unit of the waiting relationship, which can be a task or a transaction. When the granularity is a task, task A1 of transaction A can wait for transaction B or task B1 of transaction B.

[0066] Deadlock: A transaction is blocked forever and no transaction can be successfully executed; a deadlock satisfies the following conditions: resource mutual exclusion, that is, a resource can be owned by only one transaction at a time; request and hold resources, that is, when a transaction is blocked due to requesting a resource, it does not release the resources it has obtained; non-preemptive, that is, other transactions cannot preempt a resource before a transaction actively releases it; circular wait, that is, the waiting relationships among transactions form a loop.

[0067] Deadlock detection: Identifying deadlocked transactions through an algorithm.

[0068] Waiting relationship graph: A graph formed by the waiting relationships of all transactions in the system, whose nodes are transactions or tasks of transactions, and whose edges are waiting relationships.

[0069] After a deadlock occurs in a data system, it will at least cause the following impacts:

[0070] Resource waste, deadlocks can cause resources in the system to be occupied for a long time and cannot be effectively utilized. These resources may include memory, files, locks, network connections, etc.

[0071] Program unresponsiveness, the processes or threads affected by deadlocks will stop responding and cannot continue to execute forward, thus affecting the overall performance and user experience of the system.

[0072] System crash, if a deadlock affects critical resources or processes, it may cause the entire system to crash or fail.

[0073] Difficult to debug, deadlock problems are usually hidden and complex, and it is difficult to detect and debug them during runtime, increasing the difficulty of system maintenance and optimization.

[0074] Data corruption, when accessing shared data concurrently, deadlocks may cause data inconsistency or corruption, seriously affecting the data integrity and reliability of the system.

[0075] Based on the above technical problems, at least one embodiment of this specification provides a deadlock detection method. This method can perform deadlock detection on the waiting relationship graph constructed for a data system, thereby completing deadlock detection with extremely low network overhead and solving the technical problems of complex algorithms and low efficiency existing in the retrieval detection algorithms in the related art.

[0076] Exemplarily, this method can be applied to the Figure 1 distributed database shown exemplarily.

[0077] Please refer to the Figure 2 , which exemplarily shows the flowchart of the deadlock detection method, including steps S201 to S203.

[0078] First of all, it should be stated that the upstream nodes mentioned below are all first-level upstream nodes, that is, adjacent upstream nodes; the downstream nodes mentioned below are all first-level downstream nodes, that is, adjacent downstream nodes.

[0079] In step S201, a path identifier is determined for each head node in the waiting relationship graph so that the path identifiers of different head nodes in the waiting relationship graph are different, where the head node is a node with an in-degree of 0.

[0080] For example, all the head nodes in the waiting relationship graph are sorted according to the node numbers, and path identifiers (such as path numbers) are assigned in turn according to the sorting result. If there are n head nodes, the order of the head node in the above sorting result can be used as its path identifier, that is, the path identifier of the first head node is 1, the path identifier of the second head node is 2... the path identifier of the nth head node is n.

[0081] In step S202, control each head node in the waiting relationship graph to send the path identifier to the downstream node, and control other nodes in the waiting relationship graph to save the received path identifier and pass it to the downstream node after receiving the path identifier sent by the upstream node.

[0082] For example, please refer to the Figure 3 , if the head node has a downstream node, directly send the path identifier of the head node to its downstream node. Please refer to the Figure 4, if there are at least two downstream nodes for the head node, determine path identifiers for each downstream node of the head node according to the path identifier of the head node, so that the path identifiers of different downstream nodes of the head node are different; and respectively control the head node to send the corresponding path identifiers to each downstream node. Preferably, different suffixes are added after the path number to form path identifiers for different downstream nodes. For example, add 1 to the path number of the head node to form the path identifier of the first downstream node, add 2 to the path number of the head node to form the path identifier of the second downstream node, and so on until the path number of the last downstream node of the head node.

[0083] For example, use the third node to represent any node other than the head node in the waiting relationship graph. If there is one downstream node for the third node, directly send the path identifier saved by the third node to its downstream node. If there are at least two downstream nodes for the third node and the third node receives the path identifier sent by the upstream node, save the received path identifier, and determine path identifiers for each downstream node of the third node according to the received path identifier, so that the path identifiers of different downstream nodes of the third node are different; and respectively control the third node to send the corresponding path identifiers to each downstream node. Preferably, different suffixes are added after the path number to form path identifiers for different downstream nodes. For example, add 1 to the path number saved by the third node to form the path identifier of the first downstream node, add 2 to the path number saved by the third node to form the path identifier of the second downstream node, and so on until the path number of the last downstream node of the third node.

[0084] Please refer to the appendix Figure 5 , if a node has multiple upstream nodes, it can save the path identifiers sent by the multiple upstream nodes respectively and send them to its downstream nodes in the form of a path identifier list (such as a path number list); if there are multiple downstream nodes for this node, it can perform the above path identifier transfer operation once for each saved path identifier, that is, for each saved path identifier, determine the path identifiers of each downstream node according to the path identifier and send them to each downstream node respectively. For example, a node has two upstream nodes and two downstream nodes, and the two upstream nodes send path identifiers 1 and 2 to it respectively; then this node can add the suffix 1 after the path identifier 1 to form 11, add the suffix 1 after the path identifier 2 to form 21, and send the path identifiers 11 and 21 to one of its downstream nodes, then add the suffix 2 after the path identifier 1 to form 12, and add the suffix 2 after the path identifier 2 to form 22, and send the path identifiers 21 and 22 to the other downstream node.

[0085] In step S203, if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node, where the first node and the second node are any two nodes in the waiting relationship graph.

[0086] That is: if a node in the waiting relationship graph receives a path identifier that is the same as the path identifier it stores, it is determined that a deadlock is formed between this node and the node that sent this path identifier to it.

[0087] Specifically, if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node, with the first node as the head and the second node as the tail.

[0088] It should be noted that if the first node stores multiple path identifiers, this step includes: if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as any path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node.

[0089] Exemplarily, the method may further include: if the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node; where the fourth node and the fifth node are any two nodes in the waiting relationship graph; for any path identifier, the path identifier is the source identifier of other path identifiers formed during the downstream transmission of the path identifier.

[0090] That is: if the path identifier stored by a node in the waiting relationship graph is the source identifier of the path identifier it receives, it is determined that a deadlock is formed between this node and the node that sent this path identifier to it.

[0091] Specifically, if any path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node, with the fourth node as the head and the fifth node as the tail.

[0092] Preferably, if the path identifier is passed from one node to another in the waiting relationship graph, it remains unchanged. If the path identifier is passed from one node to multiple other nodes in the waiting relationship graph, different suffixes are added to the path identifier to form the path identifiers of each of the multiple other nodes. Then, this example can be: If the path identifier saved by the fourth node in the waiting relationship graph is the prefix of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node. For example, if the path identifier saved by a certain node is (1, 2), and the newly received path identifier is (1, 2, 1), then a deadlock is formed between this node and the node that sent the path identifier (1, 2, 1).

[0093] It should be noted that if the fourth node saves multiple path identifiers, this example can include: If any path identifier saved by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node.

[0094] Based on the above examples of this step, using the sixth node to represent any node in the waiting relationship graph, if the path identifier saved by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, then control the sixth node to save the received path identifier and pass it to the downstream node, where the sixth node is any node in the waiting relationship graph. That is: When a certain node receives a new path identifier while already having a saved path identifier, if no deadlock occurs, the newly received path identifier is saved to this node.

[0095] It should be noted that if the sixth node saves multiple path identifiers, this example can include: If each path identifier saved by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, then control the sixth node to save the received path identifier and pass it to the downstream node.

[0096] Please refer to the appendix Figure 6, which exemplarily shows a state in the process of path identifier transmission of the deadlock detection method. At this time, the node with node number 4 stores the path label list [0, 0], and receives the path label list [0, 0] sent by the node with node number 5. Therefore, a deadlock is formed with the node with node number 4 as the head and the node with node number 5 as the tail. At this time, the node with node number 4 stores the path label list [0, 0], and receives the path label list [0, 0, 1] sent by the node with node number 7. Therefore, a deadlock is formed with the node with node number 4 as the head and the node with node number 7 as the tail. At this time, the node with node number 3 stores the path label list [0, 1], and receives the path label list [0, 0, 0] sent by the node with node number 8. Therefore, the node with node number 3 can save the path label list [0, 0, 0] locally, and since it has no downstream nodes temporarily, it does not transmit the path label list.

[0097] The deadlock detection method provided by the embodiments of this specification first determines path identifiers for each head node in the waiting relationship graph so that the path identifiers of different head nodes in the waiting relationship graph are different, and then controls each head node in the waiting relationship graph to send the path identifiers to downstream nodes, and controls other nodes in the waiting relationship graph to save the received path identifiers and transmit them to downstream nodes after receiving the path identifiers sent by upstream nodes; if a node in the waiting relationship graph receives a path identifier that is the same as the path identifier it stores, it is determined that a deadlock is formed between this node and the node that sends this path identifier to it. In this method, each node in the waiting relationship graph only needs to send path identifiers to its downstream nodes to accurately detect the deadlock of circular waiting, that is, the deadlock detection is completed with extremely low network overhead, which is fast and convenient, with low latency, thereby improving key performance such as the throughput and scalability of the database system, and at the same time reducing the system tail latency to ensure the service quality of the database system.

[0098] Figure 7 is a schematic structural diagram of a device provided by an exemplary embodiment. Please refer to Figure 7 , at the hardware level, this device includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710. Of course, it may also include other hardware required for other tasks. One or more embodiments of this specification can be implemented based on a software approach. For example, the processor 702 reads the corresponding computer program from the non-volatile memory 710 into the memory 708 and then runs it. Of course, in addition to the software implementation method, one or more embodiments of this specification do not exclude other implementation methods, such as logical devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, and can also be hardware or logical devices.

[0099] Please refer to Figure 8 , the deadlock detection device can be applied to devices such as Figure 7 shown to implement the technical solutions of this specification. The deadlock detection device may include:

[0100] An initialization module 801, configured to determine a path identifier for each head node in the waiting relationship graph, so that the path identifiers of different head nodes in the waiting relationship graph are different, where the head node is a node with an in-degree of 0;

[0101] A transmission module 802, configured to control each head node in the waiting relationship graph to send a path identifier to downstream nodes, and control other nodes in the waiting relationship graph to save the received path identifier and transmit it to downstream nodes after receiving the path identifier sent by the upstream node;

[0102] A detection module 803, configured to determine that a deadlock is formed between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier saved by the first node, where the first node and the second node are any two nodes in the waiting relationship graph.

[0103] In a possible embodiment of this specification, when the transmission module is configured to control each head node in the waiting relationship graph to send a path identifier to downstream nodes, it is used for:

[0104] If the head node has at least two downstream nodes, determine path identifiers for each downstream node of the head node according to the path identifier of the head node, so that the path identifiers of different downstream nodes of the head node are different;

[0105] Control the head node to send the corresponding path identifier to each downstream node respectively.

[0106] In a possible embodiment of this specification, when the transmission module is configured to control other nodes in the waiting relationship graph to save the received path identifier and transmit it to downstream nodes after receiving the path identifier sent by the upstream node, it is used for:

[0107] If the third node has at least two downstream nodes and the third node receives the path identifier sent by the upstream node, save the received path identifier, and determine path identifiers for each downstream node of the third node according to the received path identifier, so that the path identifiers of different downstream nodes of the third node are different, where the third node is any node in the waiting relationship graph other than the head node;

[0108] Control the third node to send the corresponding path identifier to each downstream node respectively.

[0109] In a possible embodiment of this specification, the detection module is further configured to:

[0110] If the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node;

[0111] Wherein, the fourth node and the fifth node are any two nodes in the waiting relationship graph;

[0112] For any path identifier, the path identifier is the source identifier of other path identifiers formed during the downstream transfer process of the path identifier.

[0113] In a possible embodiment of this specification, for any path identifier, if the path identifier is transferred from one node to another node in the waiting relationship graph, it remains unchanged; if the path identifier is transferred from one node to multiple other nodes in the waiting relationship graph, different suffixes are added to the path identifier to form the path identifiers of each of the multiple other nodes;

[0114] When the detection module is configured to determine that a deadlock is formed between the fourth node and the fifth node if the path identifier stored by the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is configured to:

[0115] If the path identifier stored by the fourth node in the waiting relationship graph is a prefix of the path identifier sent by the received fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node.

[0116] In a possible embodiment of this specification, the transfer module is further configured to:

[0117] If the path identifier stored by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, it controls the sixth node to save the received path identifier and transfer it to the downstream node, where the sixth node is any node in the waiting relationship graph.

[0118] In a possible embodiment of this specification, when the detection module is configured to determine that a deadlock is formed between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored by the first node, it is configured to:

[0119] If the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as any path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node;

[0120] When the detection module is used to determine that a deadlock occurs between the fourth node and the fifth node if the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is used for:

[0121] If any path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock occurs between the fourth node and the fifth node;

[0122] When the transfer module is used to control the sixth node to save and transfer the received path identifier to the downstream node if the path identifier stored in the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, it is used for:

[0123] If each path identifier stored in the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, it is controlled that the sixth node saves the received path identifier and transfers it to the downstream node.

[0124] In a possible embodiment of the present specification, when the detection module is used to determine that a deadlock occurs between the first node and the second node if the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored in the first node, it is used for:

[0125] If the first node in the waiting relationship graph receives a path identifier sent by the second node that is the same as the path identifier stored in the first node, it is determined that a deadlock with the first node as the head and the second node as the tail occurs between the first node and the second node;

[0126] When the detection module is used to determine that a deadlock occurs between the fourth node and the fifth node if the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is used for:

[0127] If any path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the received fifth node, it is determined that a deadlock with the fourth node as the head and the fifth node as the tail occurs between the fourth node and the fifth node.

[0128] One or more embodiments of the present specification also propose a computer program product, including computer programs / instructions, and when the computing program / instructions are executed by a processor, the steps of the method provided in any of the above embodiments are implemented.

[0129] One or more embodiments of this specification also propose a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method provided in any of the above embodiments are implemented.

[0130] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any several of these devices.

[0131] In a typical configuration, a computer includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.

[0132] The memory may include non-permanent memory in the computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0133] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can be implemented by any method or technology for storing information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

[0134] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, commodity or device comprising said element.

[0135] The specific embodiments of this specification are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0136] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a", "the" and "said" used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0137] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this specification are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entrances are provided for the user to choose to authorize or refuse.

[0138] It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".

[0139] The foregoing are only preferred embodiments of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of one or more embodiments of this specification shall be included within the scope of protection of one or more embodiments of this specification.

Claims

1. A deadlock detection method, the method comprising: Determine a path identifier for each head node in the waiting relationship graph, so that the path identifiers of different head nodes in the waiting relationship graph are different, wherein the head node is a node with an in-degree of 0; Control each head node in the waiting relationship graph to send a path identifier to a downstream node, and control other nodes in the waiting relationship graph to save and transmit the received path identifier to the downstream node after receiving the path identifier sent by the upstream node; If a first node in the waiting relationship graph receives a path identifier sent by a second node that is identical to the path identifier saved by the first node, it is determined that a deadlock is formed between the first node and the second node, wherein the first node and the second node are any two nodes in the waiting relationship graph; The controlling each head node in the waiting relationship graph to send a path identifier to a downstream node includes: If the first node has at least two downstream nodes, determine a path identifier for each downstream node of the first node according to the path identifier of the first node, so that the path identifiers of different downstream nodes of the first node are different; Controlling the first node to send a corresponding path identifier to each downstream node respectively; The method further comprises: If the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node; Wherein, the fourth node and the fifth node are any two nodes in the waiting relationship graph; For any path identifier, the path identifier is the source identifier of other path identifiers formed during the transmission of the path identifier to the downstream; The method further comprises: If the path identifier saved by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, the sixth node is controlled to save the received path identifier and pass it to the downstream node, wherein the sixth node is any node in the waiting relationship graph.

2. The deadlock detection method according to claim 1, wherein the step of controlling other nodes in the waiting relationship graph to save the received path identifier after receiving the path identifier sent by the upstream node and passing it to the downstream node comprises: If there are at least two downstream nodes of the third node, and the third node receives a path identifier sent by an upstream node, the received path identifier is saved, and a path identifier of each downstream node of the third node is determined according to the received path identifier, so that the path identifiers of different downstream nodes of the third node are different, wherein the third node is any node in the waiting relationship graph except the first node; The third node is controlled to send a corresponding path identifier to each downstream node respectively.

3. The deadlock detection method according to claim 1, for any path identifier, if the path identifier is passed from one node to another node in the waiting relationship graph, it remains unchanged; if the path identifier is passed from one node to another plurality of nodes in the waiting relationship graph, different suffixes are added to the path identifier to form the path identifier of each node in the other plurality of nodes; If the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node, determining that a deadlock is formed between the fourth node and the fifth node includes: If the path identifier stored in the fourth node in the waiting relationship graph is a prefix of the path identifier received and sent by the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node.

4. The deadlock detection method according to claim 1, wherein if a first node in the waiting relationship graph receives a path identifier sent by a second node that is identical to a path identifier saved by the first node, then determining that a deadlock is formed between the first node and the second node comprises: If a first node in the waiting relationship graph receives a path identifier sent by a second node that is identical to any path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node; If the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node, determining that a deadlock is formed between the fourth node and the fifth node includes: If any path identifier stored in the fourth node in the waiting relationship graph is a source identifier of a path identifier received and sent by the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node; If the path identifier stored in the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, controlling the sixth node to store the received path identifier and transmit it to the downstream node includes: If each path identifier stored in the sixth node in the waiting relationship diagram is different from the received path identifier and is not the source identifier of the received path identifier, the sixth node is controlled to store the received path identifier and pass it to the downstream node.

5. The deadlock detection method according to claim 1, wherein if a first node in the waiting relationship graph receives a path identifier sent by a second node that is identical to the path identifier saved by the first node, then determining that a deadlock is formed between the first node and the second node comprises: If a first node in the waiting relationship graph receives a path identifier sent by a second node that is identical to the path identifier stored by the first node, it is determined that a deadlock is formed between the first node and the second node with the first node as the head and the second node as the tail; If the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node, determining that a deadlock is formed between the fourth node and the fifth node includes: If any path identifier saved by the fourth node in the waiting relationship graph is the source identifier of the path identifier received from the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node with the fourth node as the head and the fifth node as the tail.

6. A deadlock detection device, comprising: An initialization module, used for determining a path identifier for each head node in a waiting relationship graph, so that the path identifiers of different head nodes in the waiting relationship graph are different, wherein the head node is a node with an in-degree of 0; A transmission module, used to control each head node in the waiting relationship graph to send a path identifier to a downstream node, and control other nodes in the waiting relationship graph to save and transmit the received path identifier to the downstream node after receiving the path identifier sent by the upstream node; a detection module, configured to determine that a deadlock is formed between a first node and a second node in the waiting relationship graph if the first node receives a path identifier sent by a second node that is identical to the path identifier stored by the first node, wherein the first node and the second node are any two nodes in the waiting relationship graph; The transmission module is used to control each head node in the waiting relationship graph to send a path identifier to a downstream node, and is used to: If the first node has at least two downstream nodes, determine a path identifier for each downstream node of the first node according to the path identifier of the first node, so that the path identifiers of different downstream nodes of the first node are different; Controlling the first node to send a corresponding path identifier to each downstream node respectively; The detection module is also used for: If the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node; Wherein, the fourth node and the fifth node are any two nodes in the waiting relationship graph; For any path identifier, the path identifier is the source identifier of other path identifiers formed during the transmission of the path identifier to the downstream; The transfer module is also used for: If the path identifier saved by the sixth node in the waiting relationship graph is different from the received path identifier and is not the source identifier of the received path identifier, the sixth node is controlled to save the received path identifier and pass it to the downstream node, wherein the sixth node is any node in the waiting relationship graph.

7. The deadlock detection device according to claim 6, wherein the transmission module is used to control other nodes in the waiting relationship diagram to store and transmit the received path identifier to the downstream node after receiving the path identifier sent by the upstream node, and is used to: If the third node has at least two downstream nodes, and the third node receives a path identifier sent by an upstream node, the received path identifier is saved, and the path identifier of each downstream node of the third node is determined according to the received path identifier, so that the path identifiers of different downstream nodes of the third node are different, wherein, The third node is any node in the waiting relationship graph except the first node; The third node is controlled to send a corresponding path identifier to each downstream node respectively.

8. The deadlock detection device according to claim 6, for any path identifier, if the path identifier is passed from one node to another node in the waiting relationship graph, it remains unchanged; if the path identifier is passed from one node to another plurality of nodes in the waiting relationship graph, different suffixes are added to the path identifier to form the path identifier of each node in the other plurality of nodes; The detection module is used for determining that a deadlock is formed between the fourth node and the fifth node if the path identifier stored in the fourth node in the waiting relationship graph is the source identifier of the path identifier sent by the fifth node: If the path identifier stored in the fourth node in the waiting relationship graph is a prefix of the path identifier received and sent by the fifth node, it is determined that a deadlock is formed between the fourth node and the fifth node.

9. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 5.

10. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 5 by running the executable instructions.

11. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 5.