Method, device, computer equipment and readable storage medium for locating stuck threads
By monitoring the trigger instructions of the stick thread and mark scanning of the thread dump file, obtaining the thread id and calling functions, and combining log information to determine the trigger time of the stick thread, the problem of inaccurate positioning of the stick thread in the existing technology is solved, and the efficiency of problem handling is improved.
Patent Information
- Application Number
- CN202010150630.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-05
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2040-03-05
AI Technical Summary
In the prior art, it is impossible to quickly and accurately locate the stuck thread, resulting in a long time-consuming problem handling and affecting subsequent work.
By monitoring the trigger instructions of the stick thread, mark the thread dump file, obtain the thread id and call function, determine the trigger time of the stick thread based on the thread id and call function, and determine the thread problem based on the thread id and call function.
It realizes rapid positioning of the stick thread, improves the timeliness of problem handling, and reduces the direct troubleshooting time of thread dump files.
Smart Images

Figure CN111475322B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security, and in particular to a method, apparatus, computer device, and readable storage medium for locating a stuck thread. Background Art
[0002] In application systems, programs are presented as processes in the background. Threads are a further division of processes, and each thread is an independent path within its process. A stuck thread is one of many threads, a thread whose execution time exceeds the default time. After a process becomes stuck for a long time, it will evolve into a monopolized thread (hogging). When the number of hogging threads reaches a certain level, the application system will experience congestion and slow operation. Traditional solutions collect thread dump files and provide them to developers, who then identify specific thread issues. If developers lack problem-solving capabilities, the problem resolution process will be long, which in turn affects subsequent work. Therefore, quickly locating stuck threads is an urgent problem. Summary of the Invention
[0003] Based on this, it is necessary to address the above technical problems. This application provides a method, device, computer equipment and readable storage medium for locating stuck threads to solve the technical problem in the prior art that it is impossible to accurately extract features, resulting in a long problem processing time.
[0004] A method for locating a stuck thread, the method comprising:
[0005] Trigger stuck thread monitoring according to the trigger instruction of stuck thread monitoring;
[0006] Performing a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread;
[0007] If the scanning result shows that the thread dump file includes a stuck thread, obtaining the thread ID and thread calling function of the stuck thread;
[0008] Obtaining log information of the stuck thread from the thread dump file according to the thread ID, and obtaining a triggering time of the stuck thread according to the log information;
[0009] Obtaining a target stuck thread from the thread dump file according to the trigger time, and using the thread ID of the target stuck thread as the target thread ID;
[0010] The thread problem of the target stuck thread is determined according to the target thread ID and the thread calling function.
[0011] A device for locating a stuck thread, the device comprising:
[0012] The monitoring trigger module is used to trigger the stuck thread monitoring according to the trigger instruction of the stuck thread monitoring;
[0013] a result scanning module, configured to perform a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread;
[0014] an information extraction module, configured to obtain a thread ID and a thread calling function of the stuck thread if the scanning result indicates that the thread dump file includes a stuck thread;
[0015] a time acquisition module, configured to acquire the log information of the stuck thread from the thread dump file according to the thread ID, and obtain the triggering time of the stuck thread according to the log information;
[0016] a thread extraction module, configured to obtain a target stuck thread from the thread dump file according to the trigger time, and use the thread ID of the target stuck thread as the target thread ID;
[0017] The problem locating module is used to determine the thread problem of the target stuck thread according to the target thread ID and the thread calling function.
[0018] A computer device includes a memory and a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for locating a stuck thread are implemented.
[0019] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for locating a stuck thread.
[0020] The above-mentioned method, apparatus, computer device and readable storage medium for locating a stuck thread obtain a thread ID and a thread call function with a thread tag, then obtain log information of the stuck thread from a dump file based on the thread ID, and obtain the trigger time of the stuck thread based on the log information; then obtain the target stuck thread from the dump file based on the trigger time, and use the thread ID of the target stuck thread as the target thread ID; finally, determine the thread problem of the target stuck thread based on the target thread ID and the thread call function, thereby solving the technical problem in the prior art that the problem of stuck thread is time-consuming and thus affects subsequent work. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0022] Figure 1 A schematic diagram of the application environment for locating stuck threads;
[0023] Figure 2 A flowchart of a method for locating a stuck thread;
[0024] Figure 3 A flowchart of another embodiment of a method for locating a stuck thread;
[0025] Figure 4 for Figure 2 Flow diagram of step 206;
[0026] Figure 5 for Figure 2 Flow diagram of step 208;
[0027] Figure 6 for Figure 2 Flow diagram of step 210;
[0028] Figure 7 A schematic diagram of a device for locating a stuck thread;
[0029] Figure 8 FIG. 1 is a schematic diagram of a computer device according to an embodiment. DETAILED DESCRIPTION
[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0031] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0032] In order to make the purpose, technical solutions and advantages of this application more clear, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0033] The method for locating a stuck thread provided by the embodiment of the present invention can be applied to the following situations: Figure 1 In the application environment shown, the application environment may include a terminal 102, a network 106, and a server 104. The network 106 is used to provide a communication link medium between the terminal 102 and the server 104. The network 106 may include various connection types, such as wired or wireless communication links or optical fiber cables.
[0034] The user can use the terminal 102 to interact with the server 104 via the network 106 to receive or send messages, etc. Various communication client applications can be installed on the terminal 102, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0035] Terminal 102 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers and desktop computers, etc.
[0036] The server 104 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal 102 .
[0037] It should be noted that the method for locating a stuck thread provided in the embodiment of the present application is generally executed by a server / terminal. Accordingly, the apparatus for locating a stuck thread is generally provided in a server / terminal device.
[0038] It should be understood that Figure 1 The number of terminals, networks, and servers in the embodiment is merely illustrative. Any number of terminals, networks, and servers may be used as required.
[0039] The terminal 102 communicates with the server 104 via a network. The server 104 can obtain a dump file and the number of threads from the terminal 102, then obtain the thread ID and thread call function with a thread tag, and then obtain the log information of the stuck thread from the dump file based on the thread ID, and obtain the trigger time of the stuck thread based on the log information; then obtain the target stuck thread from the dump file based on the trigger time, and use the thread ID of the target stuck thread as the target thread ID, and finally determine the thread problem of the target stuck thread based on the target thread ID and the thread call function. The terminal 102 and the server 104 are connected via a network, which can be a wired network or a wireless network. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server 104 can be implemented as an independent server or a server cluster composed of multiple servers.
[0040] In one embodiment, Figure 2 As shown, a method for locating stuck threads is provided, which is applied to Figure 1 The server in the example is used as an example to illustrate the following steps:
[0041] Step 202: trigger the stuck thread monitoring according to the stuck thread monitoring trigger instruction.
[0042] A stuck thread is one whose execution time exceeds a preset timeout, which is also known as the maximum stuck time. Typically, a stuck thread can be stuck for up to 600 seconds. A stuck thread is a thread used to monitor thread health in WebLogic middleware, a Java EE-based middleware. WebLogic is a Java application server used to develop, centralize, deploy, and manage large-scale distributed web, network, and database applications. It acts as a bridge between the operating system and applications.
[0043] In this embodiment, stuck thread monitoring is a type of monitoring in a monitoring system. The monitoring system may include thread monitoring, waiting thread monitoring, active thread monitoring, stuck thread monitoring, and the like.
[0044] Step 204 : Perform a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread.
[0045] A thread dump file stores a memory image of a thread and its status. In this embodiment, the thread status in the thread dump file may include waiting threads, active threads, and stuck threads. Thread tag scanning scans the threads in the thread dump file, specifically identifying threads with thread tags. In this embodiment, the thread dump file contains information about threads currently being processed by the application, including information about program thread activity, waiting, and stuck threads.
[0046] Specifically, the thread dump file is traversed, and a thread with a stuck thread mark is searched in the thread dump file to obtain a scan result. The scan result may be a stuck thread with a preset mark in the dump file, or a stuck thread with a preset mark not found in the scan.
[0047] Furthermore, the thread mark may be a yellow mark, that is, a thread with a yellow mark in the thread dump file is a stuck thread.
[0048] Step 206: If the scanning result shows that the thread dump file includes a stuck thread, the thread ID and thread calling function of the stuck thread are obtained.
[0049] In this embodiment, the thread dump file stores stuck thread information, where the stuck thread information includes a stuck number, a program method of the stuck thread, and associated threads of the stuck thread.
[0050] The stuck thread number can be a number, a letter, or a combination of numbers and letters. The stuck thread number is usually used to find stuck threads with the same number in the log. Stuck threads with the same number in stuck files are the same stuck thread. That is, as long as the stuck thread number (ID) is the same, the stuck thread in the thread dump file and the stuck thread in the log are the same stuck thread.
[0051] The thread calling function of the stuck thread specifically includes the function name and program code data, wherein the function name may include interrupt(): interrupt thread, sleep(): stop thread, STOP(): stop thread, run(): thread body or start(): start thread, etc.; the program code data may be a specific numerical parameter; for example, the numerical parameter is 5.
[0052] Step 208: Obtain the log information of the stuck thread from the thread dump file according to the thread ID, and obtain the triggering time of the stuck thread according to the log information.
[0053] The log information includes information in the thread dump file and business information corresponding to the thread, etc. Specifically, in an actual business scenario, the business information corresponding to the thread may include the insurance company's policy number and barcode, etc.
[0054] The trigger time of the stuck thread refers to the start time of the stuck thread, for example, it can be 18:19:47 on the afternoon of November 4, 2019.
[0055] Step 210: Obtain the target stuck thread from the thread dump file according to the trigger time, and use the thread ID of the target stuck thread as the target thread ID.
[0056] The target stuck thread is the stuck thread triggered at the trigger time. These stuck threads are obtained from the thread dump file, and the thread ID of the thread is used as the target thread ID.
[0057] Step 212: Determine the thread problem of the target stuck thread based on the target thread ID and the thread calling function.
[0058] After obtaining the target thread ID, the target thread ID is used as a parameter of the thread calling function. The thread calling function is called with the parameter to obtain the problem number of the stuck thread, and the stuck thread problem is determined based on the problem number.
[0059] Specifically, if the target thread ID is 5, 5 is passed as a parameter into the program code data:
[0060] ESC[0mAcceptForIntfAction.getCurrentRequestObject: {ACCEPTMAP={APPLY_TYPE=5, POLN0=P040000010782507
[0061] Running the above program code data yields the stuck thread's issue ticket number P040000010782507; each issue ticket number corresponds to a specific thread problem.
[0062] This embodiment obtains a thread ID and a thread calling function with a thread tag, then obtains the log information of the stuck thread from the dump file according to the thread ID, and obtains the trigger time of the stuck thread according to the log information; obtains the target stuck thread from the dump file according to the trigger time, and uses the thread ID of the target stuck thread as the target thread ID; finally, determines the thread problem of the target stuck thread according to the target thread ID and the thread calling function, thereby solving the technical problem in the prior art that it takes a long time to solve the problem of stuck thread, thereby affecting subsequent work; avoids directly troubleshooting the stuck thread problem in the thread dump file, and realizes the rapid location of the stuck thread problem.
[0063] In one embodiment, Figure 3 As shown, before step 202, the following steps are also included:
[0064] Step 302: Call a thread monitoring interface. The thread monitoring interface can be an API monitoring interface in stuck thread monitoring, used to monitor thread status, information, etc. In this embodiment, stuck thread monitoring is a type of monitoring in a monitoring system, which can include thread monitoring, waiting thread monitoring, active thread monitoring, and stuck thread monitoring.
[0065] Step 304: The number of threads is collected from the thread monitoring interface. After the number of threads is guessed from the thread monitoring interface, it is necessary to determine whether the number of threads reaches a preset threshold.
[0066] In step 306, if the number of threads exceeds a preset threshold, a trigger instruction is generated. If the number of threads reaches the preset threshold, it indicates that the application system process has become stuck threads for a long time, evolving into hogging threads. When the number of hogging threads reaches the preset number, the application will become congested, and the user will experience slow operations. Therefore, a trigger instruction is generated to initiate stuck thread monitoring.
[0067] This embodiment obtains the number of threads through the thread monitoring interface and determines whether to generate a stuck thread instruction based on the number of threads, so that users can analyze and process the problem stuck thread in a timely manner based on the dump file, thereby improving the timeliness of locating the problem stuck thread.
[0068] In one embodiment, Figure 4 As shown, step 206 includes:
[0069] In step 402, if the thread dump file includes a thread with a thread marker, the scan result indicates that the thread dump file includes a stuck thread. The preset thread marker may be a yellow marker, meaning that a thread with a yellow marker in the thread dump file is a stuck thread. The thread marker allows direct access to the desired thread, while ignoring currently unimportant threads.
[0070] Step 404: Get the stuck thread and receive a stuck thread read instruction. After getting the stuck thread with a yellow mark from the thread dump file, read the stuck thread information prompt according to the received stuck thread read instruction.
[0071] Step 406: Obtain a stuck thread information prompt according to the stuck thread read instruction. The obtained stuck thread information prompt contains thread information of the stuck thread, which may include a thread ID, a thread call function, and the like.
[0072] Step 408: Obtain the thread ID and thread calling function from the information prompt. The thread calling function specifically includes the program name and program code data, where program method names may include interrupt(), sleep(), wait(), stop(), run(), and start(). The program code data may be a specific numeric parameter, for example, the numeric parameter is 5.
[0073] This embodiment obtains the stuck thread with a thread tag, obtains the thread ID and thread calling function of the stuck thread, and can directly obtain the thread that needs to be viewed, and ignores the currently unimportant threads, thereby improving the time efficiency of data acquisition, reducing the amount of data processing, and improving the efficiency of server-side data processing.
[0074] In one embodiment, Figure 5 As shown, step 208 includes:
[0075] Step 502: Obtain the running time of the stuck thread from the log information. If there are stuck threads with the same ID in the log information, these threads have the same ID as the thread in the thread dump file. The running time of the stuck thread is the running time from the time the thread was triggered to the current time.
[0076] Step 504: Get the current time and get the trigger time based on the current time and the running time. The current time is the time point of the current processing of the stuck thread, and the trigger time of the stuck thread can be obtained based on the running time and the current time.
[0077] The associated thread causing the STUCK thread is specifically a WebLogic general method thread. It's unclear what system functionality is causing this, or whether it requires a return to the STUCK thread method. The main thread is stuck because the program, while processing a transaction, uses a transaction lock to lock the corresponding program session to ensure that subsequent operations do not generate duplicate data. The database lock causes subsequent threads to wait for the database lock to be released, ultimately leaving the application in a wait state. In the corresponding thread dump file, search for STUCK threads near the time of the exception (trigger time). The thread content corresponds to the 020 channel security acceptance function.
[0078] For example, if the stuck thread is marked in the thread dump file as timing out 637 seconds after the last thread start, it can be concluded that the function of the stuck thread was executed 637 seconds ago, that is, there was a thread ID that was the same as the STUCK thread ID 637 seconds ago, and this thread ID was the starting process that triggered the target stuck thread.
[0079] Specifically, the current time of the stuck thread is 18:19:47 on August 5, 2017 minus 637 seconds to obtain the STUCK thread triggered at 17:59:10 on August 5, 2017.
[0080] In this embodiment, the triggering time of the stuck thread is obtained by obtaining the running time from the log information corresponding to the stuck thread and combining it with the current time, which is simple to calculate.
[0081] In one embodiment, Figure 6 As shown, step 210 includes:
[0082] Step 602: Use the target thread ID as a parameter of the thread calling function. Use the obtained target thread ID as a parameter of the thread calling function to reproduce the problem through this parameter input.
[0083] Step 604: The calling thread calls the function to obtain the thread problem.
[0084] Through this embodiment, the thread problem of the stuck thread is obtained by inputting parameters and reproducing, and is finally solved by the developer, thereby improving the timeliness of problem location.
[0085] It should be understood that although Figure 2-Figure 6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-Figure 6 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages does not have to be sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0086] In one embodiment, Figure 7 As shown, a device for locating a stuck thread is provided, and the device for locating a stuck thread corresponds to the method for locating a stuck thread in the above embodiment. The device for locating a stuck thread includes:
[0087] A monitoring triggering module 702 is configured to trigger stuck thread monitoring according to a stuck thread monitoring trigger instruction;
[0088] A result scanning module 704 is configured to perform a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread;
[0089] An information extraction module 706 is configured to obtain a thread ID and a thread calling function of the stuck thread if the scanning result indicates that the thread dump file includes a stuck thread;
[0090] A time acquisition module 708 is configured to acquire the log information of the stuck thread from the thread dump file according to the thread ID, and obtain the triggering time of the stuck thread according to the log information;
[0091] A thread extraction module 710 is configured to obtain a target stuck thread from the thread dump file according to the trigger time, and use the thread ID of the target stuck thread as the target thread ID;
[0092] The problem locating module 712 is configured to determine a thread problem of the target stuck thread according to the target thread ID and the thread calling function.
[0093] Furthermore, before monitoring the trigger module 702, the apparatus for locating the stuck thread further includes:
[0094] The interface calling module is used to call the thread monitoring interface.
[0095] The thread collection module is used to collect the number of threads from the thread monitoring interface.
[0096] The instruction generation module is used to generate the trigger instruction if the number of threads exceeds a preset threshold.
[0097] Furthermore, the information extraction module 706 includes:
[0098] The information scanning submodule is configured to, if the dump file includes a thread with the thread tag, scan the result as follows: the thread dump file includes a stuck thread.
[0099] The instruction receiving submodule is used to obtain the stuck thread and receive the stuck thread reading instructions.
[0100] The information reading submodule is used to obtain the information prompt of the stuck thread according to the stuck thread reading instruction.
[0101] The data acquisition submodule is used to obtain the thread ID and the thread calling function from the information prompt.
[0102] Furthermore, the time acquisition module 708 includes:
[0103] The duration acquisition submodule is used to obtain the running duration of the stuck thread from the log information.
[0104] The trigger time submodule is used to obtain the current time and obtain the trigger time according to the current time and the running time.
[0105] Furthermore, the trigger time submodule includes:
[0106] The trigger calculation unit is used to subtract the running time from the current time to obtain the trigger time.
[0107] Furthermore, the problem location module 712 includes:
[0108] The parameter generation submodule is used to use the target thread ID as a parameter of the thread calling function.
[0109] The input parameter positioning submodule is used to call the thread calling function to obtain the thread problem.
[0110] The above-mentioned device for locating a stuck thread obtains a thread ID with a thread tag and a thread calling function, then obtains log information of the stuck thread from a dump file based on the thread ID, and obtains the trigger time of the stuck thread based on the log information; obtains the target stuck thread from the dump file based on the trigger time, and uses the thread ID of the target stuck thread as the target thread ID. Finally, the thread problem of the target stuck thread is determined based on the target thread ID and the thread calling function, thereby solving the technical problem in the prior art that the problem of stuck thread is processed in a long time, thereby affecting subsequent work.
[0111] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store user order data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for locating a stuck thread is implemented. The thread problem of the stuck thread is obtained by inputting parameters and reproducing, and finally solved by the developer, thereby improving the timeliness of problem locating.
[0112] Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0113] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0114] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for locating a stuck thread in the above embodiment are implemented, for example: Figure 2 Steps 202 to 212 shown, or when the processor executes the computer program, implement the functions of the modules / units of the apparatus for locating a stuck thread in the above embodiment, for example Figure 7 The functions of modules 702 to 712 are shown in FIG. 7 and will not be described again here to avoid repetition.
[0115] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for locating a stuck thread in the above embodiment are implemented, such as Figure 2 Steps 202 to 212 shown, or when the processor executes the computer program, implement the functions of the modules / units of the apparatus for locating a stuck thread in the above embodiment, for example Figure 7 The functions of modules 702 to 712 are shown. To avoid repetition, they are not described here. The thread problem of the stuck thread is obtained by inputting parameters and reproducing, and finally solved by the developer, which improves the timeliness of problem location.
[0116] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0117] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0118] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The above-mentioned embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, they can also make several modifications, improvements or equivalent replacements of some technical features, and these modifications or replacements do not make the essence of the same technical solution depart from the spirit and scope of the technical solution of each embodiment of the present invention, and all belong to the scope of protection of this application. Therefore, the scope of protection of the patent in this application shall be based on the attached claims.
Claims
1. A method for locating a stuck thread, characterized in that: The method comprises: Trigger the stuck thread monitoring according to the stuck thread monitoring trigger instruction; Performing a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread; If the scanning result shows that the thread dump file includes a stuck thread, obtaining the thread ID and thread calling function of the stuck thread; Obtaining log information of the stuck thread from the thread dump file according to the thread ID, and obtaining a triggering time of the stuck thread according to the log information; Obtaining a target stuck thread from the thread dump file according to the trigger time, and using the thread ID of the target stuck thread as the target thread ID; Determine the thread problem of the target stuck thread according to the target thread ID and the thread calling function; Before triggering the stuck thread monitoring according to the trigger instruction of the stuck thread monitoring, the method further includes: Call thread monitoring interface; Collect the number of threads from the thread monitoring interface; If the number of threads exceeds a preset threshold, generating the trigger instruction; The thread monitoring interface is the API monitoring interface in stuck thread monitoring.
2. The method according to claim 1, characterized in that If the scanning result indicates that the thread dump file includes a stuck thread, obtaining the thread ID and thread calling function of the stuck thread includes: If the thread dump file includes a thread with the thread tag, the scanning result is that the thread dump file includes a stuck thread; Get the stuck thread and receive the stuck thread read instruction; Obtaining information prompts of the stuck thread according to the stuck thread reading instruction; The thread ID and the thread calling function are obtained from the information prompt.
3. The method according to claim 1, characterized in that The obtaining the triggering time of the stuck thread according to the log information includes: Obtaining the running time of the stuck thread from the log information; The current time is obtained, and the trigger time is obtained according to the current time and the running time.
4. The method according to claim 3, characterized in that The obtaining the trigger time according to the current time and the running time includes: The trigger time is obtained by subtracting the running time from the current time.
5. The method according to claim 1, characterized in that Determining the thread problem of the target stuck thread according to the target thread ID and the thread calling function includes: Using the target thread id as a parameter of the thread calling function; The thread calling function is called to obtain the thread problem.
6. A device for locating a stuck thread, characterized in that: The apparatus for locating a stuck thread implements the method for locating a stuck thread according to any one of claims 1 to 5 when executing a computer program, and the apparatus for locating a stuck thread comprises: The monitoring trigger module is used to trigger the monitoring of the stuck thread according to the trigger instruction of the stuck thread monitoring; A result scanning module is used to perform a thread mark scan on the thread dump file to obtain a scan result, wherein the thread mark is a preset mark on the stuck thread; an information extraction module, configured to obtain a thread ID and a thread calling function of the stuck thread if the scanning result indicates that the thread dump file includes a stuck thread; a time acquisition module, configured to acquire the log information of the stuck thread from the thread dump file according to the thread ID, and obtain the triggering time of the stuck thread according to the log information; a thread extraction module, configured to obtain a target stuck thread from the thread dump file according to the trigger time, and use the thread ID of the target stuck thread as the target thread ID; The problem locating module is used to determine the thread problem of the target stuck thread according to the target thread ID and the thread calling function.
7. The device according to claim 6, characterized in that Before the monitoring trigger module, it also includes: Interface calling module, used to call thread monitoring interface; A thread collection module, configured to collect the number of threads from the thread monitoring interface; The instruction generation module is used to generate the trigger instruction if the number of threads exceeds a preset threshold.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.