Program operation fault diagnosis method and device, computing device and storage medium

By dynamically constructing event trees and directed graphs in an event-driven software system and performing loop detection, the problem of not being able to obtain event trigger relationships through static analysis is solved, infinite loops are avoided, and system reliability and resource utilization are improved.

CN114911645BActive Publication Date: 2025-05-16CHONGQING CLOUD KERNEL INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210606857.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-31
Publication Date
2025-05-16
Estimated Expiration
2042-05-31

AI Technical Summary

Technical Problem

In event-driven software systems, the trigger relationship between events cannot be obtained through static analysis, resulting in the system that may fall into an infinite loop, occupying system resources and causing the process to be faked.

Method used

During the running of the program to be diagnosed, the event tree is dynamically constructed, and a directed graph is built when the depth of the event tree exceeds the limit, and fault diagnosis is performed through loop detection.

Benefits of technology

By dynamically analyzing the trigger relationship between events, infinite loops can be effectively avoided, system reliability and resource utilization can be improved, fault information is located, and script errors can be fixed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114911645B_ABST
    Figure CN114911645B_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the field of computer technology, and to a method and device for diagnosing program operation faults, a computing device, and a storage medium. The specific scheme is as follows: a construction step, including, during the operation of the program to be diagnosed, for the current event that triggers the execution, constructing an event tree according to the relationship between the current event and its superior event; wherein the superior event is the event that triggers the current event; a checking step, including checking the depth of the event tree; a construction step, including, when the depth of the event tree is greater than or equal to a preset depth threshold, constructing a directed graph according to the event tree; a detection step, including performing a ring detection on the directed graph; a diagnosis step, including obtaining the fault diagnosis result of the program to be diagnosed according to the result of the ring detection. The embodiments of the present application implement program operation fault diagnosis during the operation of the program to be diagnosed, locate the fault to the script associated with the event, avoid the process pseudo-death caused by the infinite loop relationship, and improve system reliability and resource utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for diagnosing program running faults, a computing device and a storage medium. Background Art

[0002] At present, event-driven software design is widely used in various fields. From the process scheduling and I / O events of the underlying operating system kernel to the mouse click and keyboard input events of the UI interface (User Interface) and WEB (World Wide Web) webpages at the application layer, event models are used to solve continuous and random problems. On the one hand, the events in most event models are independent, and there is no connection between multiple triggering events, that is, the actions completed after an event is triggered are limited and predictable. On the other hand, in a system run by event-driven scripts, since the scripts can flexibly write arbitrary codes, the actions after the event is triggered are unpredictable, and there is a possibility of cascading to trigger any other events. When the triggering relationship between events cannot be obtained through static analysis, if there is a loop in the event triggering relationship of multiple scripts, the system will fall into an infinite loop of events, occupying system resources and possibly causing the process to die. Summary of the invention

[0003] In view of the above problems in the prior art, the embodiments of the present application provide a program running fault diagnosis method and apparatus, a computing device and a storage medium, which can implement program running fault diagnosis during the running of the program to be diagnosed, and can locate the fault information to the event-associated script, thereby avoiding the process deadlock caused by infinite loop relationship, and improving the reliability and resource utilization of the system.

[0004] To achieve the above-mentioned purpose, the first aspect of the present application provides a method for diagnosing a program operation fault, comprising:

[0005] The construction step includes constructing an event tree according to the relationship between the current event and its parent event for the current event that triggers the execution during the running of the program to be diagnosed; wherein the parent event is the event that triggers the current event;

[0006] A checking step, comprising checking the depth of the event tree;

[0007] A construction step, comprising constructing a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold;

[0008] A detection step, comprising performing a loop detection on the directed graph;

[0009] The diagnosis step includes obtaining a fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

[0010] As a possible implementation manner of the first aspect, the method further includes:

[0011] During the running of the program to be diagnosed, adding the current event to an event queue;

[0012] The head element of the event queue is taken out from the event queue in sequence, and the construction step, the checking step, the building step, the detection step and the diagnosis step are performed on the head element.

[0013] As a possible implementation of the first aspect, for the current event that triggers execution, constructing an event tree according to the relationship between the current event and its parent event includes:

[0014] Setting the instance of the superior event into a thread local variable;

[0015] In the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable;

[0016] Constructing an event tree according to the relationship between the current event and its parent event;

[0017] Remove the instance of the parent event from the thread local variables.

[0018] As a possible implementation manner of the first aspect, constructing an event tree according to a relationship between the current event and its parent event includes:

[0019] In the event tree, a parent-child event relationship is established between the current event and its parent event;

[0020] Updates the depth of the event tree.

[0021] As a possible implementation manner of the first aspect, constructing a directed graph according to the event tree includes:

[0022] Traversing the event tree downwards from the root event of the event tree, and for each parent-child event relationship in the event tree, adding a corresponding adjacent edge in the directed graph;

[0023] The directed graph is constructed based on the adjacency edges.

[0024] As a possible implementation manner of the first aspect, obtaining a fault diagnosis result of the program to be diagnosed according to a result of the ring detection includes:

[0025] When it is detected that a ring structure exists in the directed graph, it is determined that the program to be diagnosed has an operating fault.

[0026] As a possible implementation manner of the first aspect, the method further includes:

[0027] In the case where a ring structure is detected in the directed graph, a root event of the event tree is disabled.

[0028] A second aspect of the present application provides a program running fault diagnosis device, comprising:

[0029] A construction unit, used for constructing an event tree according to the relationship between the current event and its parent event for the current event that triggers the execution during the running of the program to be diagnosed; wherein the parent event is the event that triggers the current event;

[0030] A checking unit, used for checking the depth of the event tree;

[0031] A construction unit, configured to construct a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold;

[0032] A detection unit, configured to perform ring detection on the directed graph;

[0033] The diagnosis unit is used to obtain the fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

[0034] As a possible implementation manner of the second aspect, the apparatus further includes a queue management unit, wherein the queue management unit is configured to:

[0035] During the running of the program to be diagnosed, adding the current event to an event queue;

[0036] The head element of the event queue is taken out from the event queue in sequence, and the functions performed by the construction unit, the inspection unit, the building unit, the detection unit and the diagnosis unit are executed for the head element.

[0037] As a possible implementation manner of the second aspect, the construction unit is used to:

[0038] Setting the instance of the superior event into a thread local variable;

[0039] In the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable;

[0040] Constructing an event tree according to the relationship between the current event and its parent event;

[0041] Remove the instance of the parent event from the thread local variables.

[0042] As a possible implementation manner of the second aspect, the construction unit is used to:

[0043] In the event tree, a parent-child event relationship is established between the current event and its parent event;

[0044] Updates the depth of the event tree.

[0045] As a possible implementation manner of the second aspect, the construction unit is used to:

[0046] Traversing the event tree downwards from the root event of the event tree, and for each parent-child event relationship in the event tree, adding a corresponding adjacent edge in the directed graph;

[0047] The directed graph is constructed based on the adjacency edges.

[0048] As a possible implementation manner of the second aspect, the diagnosis unit is used to:

[0049] When it is detected that a ring structure exists in the directed graph, it is determined that the program to be diagnosed has an operating fault.

[0050] As a possible implementation manner of the second aspect, the device further includes a control unit, wherein the control unit is configured to:

[0051] In the case where a ring structure is detected in the directed graph, a root event of the event tree is disabled.

[0052] A third aspect of the present application provides a computing device, including:

[0053] Communication interface;

[0054] at least one processor connected to the communication interface; and

[0055] At least one memory is connected to the processor and stores program instructions, and when the program instructions are executed by the at least one processor, the at least one processor executes any method described in the first aspect above.

[0056] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, wherein when the program instructions are executed by a computer, the computer executes any of the methods described in the first aspect.

[0057] These and other aspects of the invention will become apparent from the following description of the embodiment(s). BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The following further illustrates the various features of the present invention and the relationship between the various features with reference to the accompanying drawings. The accompanying drawings are all exemplary, some features are not shown in actual proportion, and some drawings may omit the conventional features in the field involved in the present application and are not necessary for the present application, or additionally show the features that are not necessary for the present application. The combination of the various features shown in the accompanying drawings is not intended to limit the present application. In addition, throughout this specification, the same figure numerals refer to the same content. The specific description of the drawings is as follows:

[0059] Figure 1 A schematic diagram of an embodiment of a method for diagnosing a program running fault provided in an embodiment of the present application;

[0060] Figure 2 A schematic diagram of an event-driven script running process of an embodiment of a program running fault diagnosis method provided in an embodiment of the present application;

[0061] Figure 3 A schematic diagram of event type definition for an embodiment of a method for diagnosing a program running fault provided in an embodiment of the present application;

[0062] Figure 4 A schematic diagram of an embodiment of a method for diagnosing a program running fault provided in an embodiment of the present application;

[0063] Figure 5 A schematic diagram of an event instance tree of an embodiment of a method for diagnosing a program running fault provided in an embodiment of the present application;

[0064] Figure 6 A directed graph diagram of an embodiment of a method for diagnosing a program running fault provided in an embodiment of the present application;

[0065] Figure 7 A schematic diagram of an embodiment of a program running fault diagnosis device provided in an embodiment of the present application;

[0066] Figure 8 A schematic diagram of an embodiment of a program running fault diagnosis device provided in an embodiment of the present application;

[0067] Fig. 9 A schematic diagram of a computing device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0068] The words "first, second, third, etc." or module A, module B, module C and other similar terms in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that the specific order or sequence can be interchanged where permitted so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0069] In the following description, the numbers representing the steps, such as S110, S120, etc., do not necessarily mean that the steps must be executed in this manner. If permitted, the order of the previous and next steps can be interchanged, or the steps can be executed simultaneously.

[0070] The term "comprising" as used in the description and claims should not be interpreted as being limited to what is listed thereafter; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the features, integers, steps or components mentioned, but does not exclude the presence or addition of one or more other features, integers, steps or components and groups thereof. Therefore, the expression "a device comprising means A and B" should not be limited to a device consisting of components A and B only.

[0071] References to "one embodiment" or "an embodiment" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present invention. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing in various places in this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment. In addition, in one or more embodiments, the particular features, structures, or characteristics can be combined in any appropriate manner, as would be apparent to one of ordinary skill in the art from this disclosure.

[0072] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of this application. In the event of any inconsistency, the meaning described in this specification or the meaning derived from the contents recorded in this specification shall prevail. In addition, the terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application. In order to accurately describe the technical content in this application and to accurately understand the present invention, the following explanations or definitions are given to the terms used in this specification before describing the specific embodiments:

[0073] 1) Asynchronous events: An event is a program or programs that are triggered and executed under specified conditions. Programs are written in scripts and can be modified dynamically. Asynchronous means that the programs executed after an event is triggered are asynchronous.

[0074] 2) Event type: specifies the event business attributes and triggering logic. Business attributes include the functions executed by the event-related script.

[0075] 3) Event instance: An event object created after a certain type of event is triggered. One event type can create multiple event instances, that is, the event type can be triggered multiple times at the same time.

[0076] 4) Event instance tree: A tree structure constructed by event instances and their triggering relationships during program execution. The event instance tree can be referred to as the event tree.

[0077] 5) Event type directed graph: a directed graph constructed based on the event instance tree.

[0078] 6) Root event: the root node of the event tree.

[0079] The following first introduces the existing method, and then introduces the technical solution of the present application in detail.

[0080] At present, in common event-driven systems, events are often run independently after being triggered, and the impact of the event can be clearly known. For example, clicking the open file button in the UI interface of Windows desktop software will open a new file display window. If there is no other operation after the window is opened, the desktop software will not generate other events. In another case, in a system run by event-driven scripts, since the script can flexibly write any code, the action after the event is triggered cannot be predicted, and it may cascade and trigger any other events. In the existing program running fault diagnosis method, static analysis is usually performed based on the logical relationship of the program code to obtain the relationship between events, and then a directed graph is constructed based on the relationship between the events that can be obtained from the program. For an event-driven script running system, the execution code of the script cannot be statically analyzed. It is also unpredictable whether the script will trigger other events during the actual running of the program. For example, for a mouse event, it is unpredictable whether the event will be triggered during the actual running of the program and when the event will be triggered.

[0081] The existing technology has the following defects: when the trigger relationship between events cannot be obtained through static analysis, if there is a loop in the event trigger relationship of multiple scripts, the system will fall into an infinite loop of events, occupying system resources and possibly causing the process to freeze.

[0082] Based on the technical problems existing in the above-mentioned prior art, the present application provides a method for diagnosing program running faults. This method does not adopt a static analysis method, but dynamically analyzes the triggering relationship between unknown events during the program running process. Specifically, during the running of the program to be diagnosed, an event tree is constructed in real time based on the current event that triggers the execution, and a directed graph is constructed when the event tree exceeds the limit. The program to be diagnosed can be diagnosed in real time through the ring detection of the directed graph. This method can solve the technical problem mentioned in the prior art that the triggering relationship between events cannot be obtained through static analysis by dynamically analyzing the program running. In addition, the method can locate the fault information to the script associated with the event, help the script writer to fix the script error, and solve the technical problem mentioned in the prior art that the process is suspended due to an infinite loop of the event.

[0083] Figure 1 This is a schematic diagram of an embodiment of a program running fault diagnosis method provided in an embodiment of the present application. Figure 1 As shown, the program running fault diagnosis method may include:

[0084] Step S110, a construction step, includes constructing an event tree according to the relationship between the current event and its parent event for the current event that triggers the execution during the running of the program to be diagnosed; wherein the parent event is the event that triggers the current event;

[0085] Step S120, a checking step, comprising checking the depth of the event tree;

[0086] Step S130, a construction step, comprising constructing a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold;

[0087] Step S140, a detection step, comprising performing a ring detection on the directed graph;

[0088] Step S150, a diagnosis step, includes obtaining a fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

[0089] For event-driven script running systems, it is impossible to obtain the triggering relationship between events through static analysis. Therefore, the embodiment of the present invention dynamically analyzes the triggering relationship between unknown events during the running of the program to be diagnosed based on the event tree and the directed graph. A model is established for the running relationship between scripts, which is convenient for the script writer to perform fault inspection and troubleshooting. At the same time, for script events that already have an infinite loop relationship, it can also prevent the endless running of the script from causing the process to freeze, thereby improving the reliability and resource utilization of the system.

[0090] During the running of the program to be diagnosed, the corresponding event will be triggered and executed if the triggering condition is met. The current event that triggers the execution may also trigger other events during its execution. The above triggered events can be executed concurrently, and an event instance tree can be constructed based on the concurrently executed events.

[0091] In step S110, for each current event that triggers execution, a corresponding node is added to the event tree. When the parent event of the current event triggers execution, the current event has been added to the event tree. When the parent event triggers execution, the current event is added to the event tree according to the relationship between the current event and its parent event, so that the node corresponding to the current event becomes the child node of its parent event.

[0092] The depth or height of a tree refers to the maximum number of levels of nodes in the tree. In the embodiment of the present invention, the event tree is dynamically constructed during the operation of the program to be diagnosed. That is to say, a node of a corresponding event instance is added to the event tree when an event is triggered. Therefore, the depth of the node corresponding to the current event is also the depth of the event instance tree. Using the depth of the event instance tree to limit the upper limit of the event that can be triggered, and constructing an event type directed graph based on the event instance tree, is an effective means to avoid infinite loops of events and restore fault factors.

[0093] A reasonable depth threshold can be pre-set to limit the upper limit of the event that can be triggered. In step S120, the depth of the event tree is checked. In step S130, when it is checked that the depth of the event tree reaches or exceeds the depth threshold, a directed graph is constructed according to the event tree. The constructed directed graph can be used for further fault diagnosis.

[0094] In step S140, a ring detection is performed on the directed graph to detect whether there is a ring structure in the directed graph. In step S150, if a ring structure is detected in the directed graph, it can be determined that there is a running fault in the program to be diagnosed.

[0095] The embodiments of the present application can implement program operation fault diagnosis during the execution of the program to be diagnosed, and can locate the fault information to the event-related script, thereby avoiding process pseudo-death due to infinite loop relationships, and improving system reliability and resource utilization.

[0096] In one embodiment, the method further comprises:

[0097] During the running of the program to be diagnosed, adding the current event to an event queue;

[0098] The head element of the event queue is taken out from the event queue in sequence, and the construction step, the checking step, the building step, the detection step and the diagnosis step are performed on the head element.

[0099] Figure 2 This is a schematic diagram of the event-driven script running process of an embodiment of the program running fault diagnosis method provided in the embodiment of the present application. Figure 2 As shown, the construction step and the inspection step are executed in the event processing flow for each current event, and the construction step, the detection step and the diagnosis step are executed in the fault recovery process. The main flow is used to illustrate the application scenario of the embodiment of the present application.

[0100] exist Figure 2 In the example shown, the event type is defined as Figure 3 See Figure 2 and Figure 3 , the events that may be triggered during the execution of the main program flow include: device attribute value attr1 change event Event1, device attribute value attr2 change event Event2, device attribute value attr3 change event Event3, device attribute value attr4 change event Event4 and device attribute value attr5 change event Event5.

[0101] See also Figure 2 , the main process includes the following steps:

[0102] 1) The device uploads the attribute value attr1 to the application.

[0103] In one example, the attribute value may be a value of a register in a device, and the attribute value may be used as a condition for determining event triggering.

[0104] 2) After receiving the attribute value, the application compares the attribute value with the original attribute value. If the comparison result shows that a change has occurred, a device attribute value attr1 change event will be generated. Or in other cases, the event trigger condition can also be other business conditions.

[0105] 3) For the device attribute value attr1 change event, create an event instance "Event1-Instance 1" for this type of event and add it to the event queue. Then, the main process continues to complete other work.

[0106] In the above example, the program to be diagnosed is run in the main process and the event processing process. During the running of the program to be diagnosed, if the triggering condition is met, the corresponding event will be triggered for execution. The current event that triggers the execution may also trigger other events during its execution. When each event is triggered for execution, the current event that triggers the execution is added to the event queue as the tail element. According to the first-in-first-out principle of the queue, the first-in element is taken out of the event queue in turn. In the event processing process, the inspection step is executed for the first element of the team, and in the fault recovery process, the construction step, detection step and diagnosis step are executed for the first element of the team. In the event processing process, the construction step, detection step and diagnosis step are executed for the first element of the team, and in the event processing process, the construction step is executed for the cascade event triggered by the first element of the team.

[0107] In the above example, each event instance may contain not only specific business information but also public information for constructing an event tree. The public information may include the following:

[0108] 1) Event Source: describes the conditions, location, and other information that trigger the event. For example, an event can be triggered in a script, or an event can be triggered by a click on the front-end interface.

[0109] 2) Parent event: records the event that triggered the event.

[0110] 3) Sub-event list (childs): records all sub-events triggered by the event.

[0111] 4) Root event (root): records the source of the event.

[0112] 5) Event ID: A unique identifier for recording an event. You can use the ID to find information about the event, such as the type and condition. For example, Figure 3 Event1 to Event5 are the event ids.

[0113] 6) Event depth: records the depth of the event in the event tree.

[0114] 7) Event trigger timestamp (time): records the timestamp when the event is triggered.

[0115] Figure 4 This is a schematic diagram of an embodiment of a program running fault diagnosis method provided in an embodiment of the present application. Figure 4 As shown, in one embodiment, Figure 1 In step S110, for the current event that triggers execution, constructing an event tree according to the relationship between the current event and its parent event, including:

[0116] Step S210, setting the instance of the superior event into a thread local variable;

[0117] Step S220, in the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable;

[0118] Step S230, constructing an event tree according to the relationship between the current event and its parent event;

[0119] Step S240: remove the instance of the parent event from the thread local variable.

[0120] In one implementation, constructing an event tree according to the relationship between the current event and its parent event includes:

[0121] In the event tree, a parent-child event relationship is established between the current event and its parent event;

[0122] Updates the depth of the event tree.

[0123] See also Figures 1 to 4 , the event handling process includes the following steps:

[0124] 1) Thread x takes an event instance "Event1-Instance 1" from the event queue and uses the thread pool to execute asynchronous events.

[0125] 2) Check the depth of "Event1-Instance 1". The depth of "Event1-Instance 1" is the depth of the event tree that has been constructed at the current moment. If the depth checked is greater than the configured depth threshold, it is considered that there is an incorrect event trigger logic and the fault recovery process is entered; otherwise, the subsequent process is executed normally.

[0126] 3) Set "Event1-Instance 1" to the thread local variable, that is, store all the information of "Event1-Instance 1" to the thread local variable. The purpose of this process is to enable the newly triggered event to inherit the parent event information from the thread context when the script engine executes the script if an event is triggered.

[0127] 4) Using the script execution engine to execute the script associated with the event, wherein there may be one or more associated scripts.

[0128] 5) During the script execution process, new property change events may be triggered, which is called cascading event triggering.

[0129] 6) If a cascade event is triggered, create a cascade event instance "Event2-Instance 1", and set the event source and event id of the cascade event. Access the thread local variables, get the event instance "Event1-Instance 1" currently being processed from the thread context, set it as the parent event (parent) of "Event2-Instance 1", and add "Event2-Instance 1" to the child event list (childs) of "Event1-Instance 1". If parent is not empty, set the event depth (depth) of "Event2-Instance 1" to parent.depth+1; if parent is empty, set depth to 0. If the root event (root) of parent is not empty, inherit the root of parent to the root of the cascade event, otherwise set parent to root.

[0130] 7) After "Event1-Instance 1" is processed, remove the event instance from the thread local variable.

[0131] 8) Repeat the above steps to build an event instance tree in concurrently executed events.

[0132] An example event instance tree is as follows: Figure 5 As shown. Figure 5 In the example, the device uploads the attribute value attr1. If the uploaded attribute value is different from the original attribute value, the device attribute value change event Event1 is triggered and the event instance "Event1-Instance 1" is created. Then, during the execution of "Event1-Instance 1", the device attribute values ​​attr2 and attr3 are modified. Then, "Event1-Instance 1" triggers the cascade events Event2 and Event3, and creates the event instances "Event2-Instance 1" and "Event3-Instance 1" respectively. Next, during the execution of "Event2-Instance 1" and "Event3-Instance 1", new cascade events are triggered... See Figure 5 The script running process will not be described here.

[0133] See also Figure 2 In the embodiment of the present application, the head element of the event queue is taken out as the current event. In the event processing flow of the current event, if the current event triggers a sub-event, the sub-event of the current event is added to the event tree as a child node of the current event; and the original depth value of the event tree is increased by 1 and set as the depth value of the sub-event. After the sub-event is triggered, it is also added to the end of the event queue. In the subsequent process, when the sub-event becomes the head element and is taken out of the queue, the sub-event becomes the new current event. See Figure 2First, check the depth of the event for the new current event, that is, check the depth of the event tree. If the depth exceeds the limit, enter the fault recovery process. Therefore, the construction of each event instance in the event tree and the setting of its depth can be performed during the execution of its parent event. The event tree can be constructed based on the relationship between the current event and its parent event, and then the event tree depth can be used to limit the upper limit of the event that can be triggered.

[0134] In one embodiment, Figure 1 Step S130 in the step of constructing a directed graph according to the event tree comprises:

[0135] Traversing the event tree downwards from the root event of the event tree, and for each parent-child event relationship in the event tree, adding a corresponding adjacent edge in the directed graph;

[0136] The directed graph is constructed based on the adjacency edges.

[0137] In one implementation, obtaining the fault diagnosis result of the program to be diagnosed according to the result of the ring detection includes:

[0138] When it is detected that a ring structure exists in the directed graph, it is determined that the program to be diagnosed has an operating fault.

[0139] In one embodiment, the method further comprises:

[0140] In the case where a ring structure is detected in the directed graph, a root event of the event tree is disabled.

[0141] During the processing of event instances, if there is a cyclic event relationship, the depth of the event instance tree will reach or exceed the depth threshold at some point. In this case, the fault recovery process will be initiated.

[0142] See also Figures 1 to 5 The failure recovery process includes the following steps:

[0143] 1) Get the root event (root) from the event instance that generates the fault, and then traverse downward from the root.

[0144] 2) Construct an event type directed graph based on the event tree. The event type directed graph can be referred to as a directed graph. For each parent-child event relationship in the event tree, add an adjacent edge to the directed graph. Figure 5In the event instance tree shown in the figure, the following adjacent edges are added when constructing the directed graph: Event1->Event2, Event1->Event3, Event2->Event3, Event2->Event4, Event3->Event5, Event4->Event5, Event5->Event1. Since the event type directed graph is constructed based on event instances, and there are multiple instances of an event type, repeated adjacent edges will be added during the construction of the directed graph. For example, Figure 5 In the example, there is more than one adjacent edge from Event3 to Event5, and more than one adjacent edge from Event5 to Event1. For repeated adjacent edges, if the trigger conditions are different, the weight of the existing adjacent edges can be increased to form a weighted directed graph. Whether the trigger conditions are different can be determined based on the event source. The weight can be used to represent the closeness of the relationship between event types, thereby more accurately describing the relationship model of events. According to Figure 5 The event type directed graph constructed by the example is as follows Figure 6 shown.

[0145] 3) Perform cycle detection on directed graphs.

[0146] 4) If there is a ring structure in the directed graph, it means that there is an incorrect event triggering logic in the program to be diagnosed. In this case, the root event can be disabled, and all event node information involved in the ring can be saved to the database. In the above example, the disabled root event is the device attribute value change event Event1. Even if the device uploads the attr1 attribute again during the subsequent program running, event Event1 will not be triggered. By disabling the root event, the system can avoid falling into an incorrect event loop and prevent the process from being suspended while occupying resources. Users can retrieve fault information through the database, locate the event and the associated script based on the fault information, and re-enable the event after fixing the script error.

[0147] The program operation fault diagnosis method provided by the embodiment of the present application is applied to perform fault diagnosis during the operation of the program to be diagnosed, and the trigger relationship between fully asynchronous and concurrently executed unknown events can be dynamically analyzed. The system can be protected in the event logic with a cycle, and resource utilization can be improved. In contrast, in the related art, static analysis is only performed based on the logical relationship of the program code to obtain the relationship between events, and usually only the event triggering relationship in a single thread can be constructed, and it is impossible to perform fault diagnosis on concurrently executed programs. Therefore, the method based on static analysis cannot achieve the same technical effect as the embodiment of the present application.

[0148] like Figure 7As shown, the present application also provides a corresponding embodiment of a program running fault diagnosis device. Regarding the beneficial effects or technical problems solved by the device, please refer to the description in the methods corresponding to each device, or refer to the description in the content of the invention, which will not be repeated here.

[0149] In an embodiment of the program running fault diagnosis device, the device includes:

[0150] The construction unit 100 is used to construct an event tree according to the relationship between the current event and its parent event for the current event that triggers the execution of the program to be diagnosed during the execution of the program to be diagnosed; wherein the parent event is the event that triggers the current event;

[0151] A checking unit 200, configured to check the depth of the event tree;

[0152] A construction unit 300, configured to construct a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold;

[0153] A detection unit 400, configured to perform ring detection on the directed graph;

[0154] The diagnosis unit 500 is used to obtain a fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

[0155] like Figure 8 As shown, in one embodiment, the apparatus further includes a queue management unit 600, and the queue management unit 600 is used to:

[0156] During the running of the program to be diagnosed, adding the current event to an event queue;

[0157] The head element of the event queue is taken out from the event queue in sequence, and the functions performed by the construction unit, the inspection unit, the building unit, the detection unit and the diagnosis unit are executed for the head element.

[0158] In one embodiment, the construction unit 100 is used to:

[0159] Setting the instance of the superior event into a thread local variable;

[0160] In the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable;

[0161] Constructing an event tree according to the relationship between the current event and its parent event;

[0162] Remove the instance of the parent event from the thread local variables.

[0163] In one embodiment, the construction unit 100 is used to:

[0164] In the event tree, a parent-child event relationship is established between the current event and its parent event;

[0165] Updates the depth of the event tree.

[0166] In one embodiment, the construction unit 300 is used to:

[0167] Traversing the event tree downwards from the root event of the event tree, and for each parent-child event relationship in the event tree, adding a corresponding adjacent edge in the directed graph;

[0168] The directed graph is constructed based on the adjacency edges.

[0169] In one embodiment, the diagnostic unit 500 is used to:

[0170] When it is detected that a ring structure exists in the directed graph, it is determined that the program to be diagnosed has an operating fault.

[0171] In one embodiment, the device further includes a control unit 700, and the control unit 700 is configured to:

[0172] In the case where a ring structure is detected in the directed graph, a root event of the event tree is disabled.

[0173] Fig. 9 9 is a schematic structural diagram of a computing device 900 provided in an embodiment of the present application. The computing device 900 includes: a processor 910 , a memory 920 , and a communication interface 930 .

[0174] It should be understood that Fig. 9 The communication interface 930 in the computing device 900 shown in FIG. 9 may be used to communicate with other devices.

[0175] The processor 910 may be connected to a memory 920. The memory 920 may be used to store the program code and data. Therefore, the memory 920 may be a storage unit inside the processor 910, or an external storage unit independent of the processor 910, or a component including a storage unit inside the processor 910 and an external storage unit independent of the processor 910.

[0176] Optionally, the computing device 900 may further include a bus. The memory 920 and the communication interface 930 may be connected to the processor 910 via a bus. The bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc.

[0177] It should be understood that in the embodiment of the present application, the processor 910 may adopt a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Alternatively, the processor 910 may adopt one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiment of the present application.

[0178] The memory 920 may include a read-only memory and a random access memory, and provides instructions and data to the processor 910. A portion of the processor 910 may also include a nonvolatile random access memory. For example, the processor 910 may also store information on the device type.

[0179] When the computing device 900 is running, the processor 910 executes the computer-executable instructions in the memory 920 to perform the operating steps of the above method.

[0180] It should be understood that the computing device 900 according to the embodiment of the present application can correspond to the corresponding subjects in the methods according to the embodiments of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 900 are respectively for implementing the corresponding processes of each method of the present embodiment. For the sake of brevity, they will not be repeated here.

[0181] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0182] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0183] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0184] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0185] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0186] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0187] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program is used to execute a method for generating diversified questions, which includes at least one of the solutions described in the above embodiments.

[0188] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by instruction execution systems, devices or devices or used in combination with them.

[0189] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0190] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0191] Computer program code for performing the operation of the present application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent 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 type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0192] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present application is described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present invention, all of which belong to the protection scope of the present invention.

Claims

1. A method for diagnosing program operation faults, characterized in that: include: Construction steps, including setting the instance of the superior event into the thread local variable; In the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable; Constructing an event tree according to the relationship between the current event and its parent event; Remove the instance of the superior event from the thread local variable; wherein, in the event tree, establish a parent-child event relationship between the current event and its superior event; update the depth of the event tree; wherein, the superior event is the event that triggers the current event; A checking step, comprising checking the depth of the event tree; A construction step, comprising constructing a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold; A detection step, comprising performing a ring detection on the directed graph; The diagnosis step includes obtaining a fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

2. The method according to claim 1, characterized in that The method further comprises: During the running of the program to be diagnosed, adding the current event to an event queue; The head element of the event queue is taken out from the event queue in sequence, and the construction step, the checking step, the building step, the detection step and the diagnosis step are performed on the head element.

3. The method according to claim 1, characterized in that The step of constructing a directed graph according to the event tree comprises: Traversing the event tree downwards from the root event of the event tree, and for each parent-child event relationship in the event tree, adding a corresponding adjacent edge in the directed graph; The directed graph is constructed based on the adjacency edges.

4. The method according to any one of claims 1 to 3, characterized in that The step of obtaining the fault diagnosis result of the program to be diagnosed according to the result of the ring detection comprises: When it is detected that a ring structure exists in the directed graph, it is determined that the program to be diagnosed has an operating fault.

5. The method according to any one of claims 1 to 3, characterized in that The method further comprises: In the case where a ring structure is detected in the directed graph, a root event of the event tree is disabled.

6. A program operation fault diagnosis device, characterized in that: include: A construction unit for setting an instance of a superior event into a thread-local variable; In the process of triggering the execution of the superior event, obtaining the relationship between the current event and its superior event according to the thread local variable; Constructing an event tree according to the relationship between the current event and its parent event; Remove the instance of the superior event from the thread local variable; wherein, in the event tree, establish a parent-child event relationship between the current event and its superior event; update the depth of the event tree; wherein, the superior event is the event that triggers the current event; A checking unit, used for checking the depth of the event tree; A construction unit, configured to construct a directed graph according to the event tree when the depth of the event tree is greater than or equal to a preset depth threshold; A detection unit, configured to perform ring detection on the directed graph; The diagnosis unit is used to obtain a fault diagnosis result of the program to be diagnosed according to the result of the ring detection.

7. A computing device, characterized in that include: Communication interface; at least one processor connected to the communication interface; as well as At least one memory connected to the processor and storing program instructions, wherein when the program instructions are executed by the at least one processor, the at least one processor executes the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Mobile application execution sequence reduction method based on context

    CN114138662A

  • Deadlock detection method and system for parallel programs

    US20100333110A1