CN111475322A - Method and device for positioning stuck thread, computer equipment and readable storage medium - Google Patents

Method and device for positioning stuck thread, computer equipment and readable storage medium Download PDF

Info

Publication number
CN111475322A
CN111475322A CN202010150630.2A CN202010150630A CN111475322A CN 111475322 A CN111475322 A CN 111475322A CN 202010150630 A CN202010150630 A CN 202010150630A CN 111475322 A CN111475322 A CN 111475322A
Authority
CN
China
Prior art keywords
thread
stuck
target
dump file
monitoring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010150630.2A
Other languages
Chinese (zh)
Inventor
陈东杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN202010150630.2A priority Critical patent/CN111475322A/en
Publication of CN111475322A publication Critical patent/CN111475322A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0715Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a system implementing multitasking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0778Dumping, i.e. gathering error/state information after a fault for later diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application belongs to the field of information security and discloses a method and a device for positioning a stuck thread, computer equipment and a readable storage medium. The method comprises the steps of obtaining a thread id with a thread mark and a thread calling function, then obtaining log information of a stuck thread from a dump file according to the thread id, and obtaining triggering time of the stuck thread according to the log information; and obtaining a target stuck thread from the dump file according to the trigger time, taking the thread id of the target stuck thread as the target thread id, and finally determining the thread problem of the target stuck thread according to the target thread id and a thread calling function. The method solves the technical problem that the problem of the stuck thread is processed with longer time efficiency in the prior art, and further the subsequent work is influenced.

Description

Method and device for positioning stuck thread, computer equipment and readable storage medium
Technical Field
The present application relates to the field of information security, and in particular, to a method and an apparatus for locating a stuck thread, a computer device, and a readable storage medium.
Background
In an application system, programs are presented in a background in a process mode, threads are further divided of the processes, each thread is an independent path in the process, a stuck thread is one of a plurality of threads, the execution time of the stuck thread exceeds the default time, the stuck thread is derived into an exclusive thread (hogging) after the process is changed into the stuck thread for a long time, and the application system is jammed and slowly operated after the hogging threads reach a certain number; traditional solution adopts and collects the thread dump file, gives the developer with the thread dump file, fixes a position specific thread problem by the developer, if the developer troubleshooting problem ability is less strong, leads to the problem to handle the ageing longer, and then influences subsequent work, consequently, fixes a position fast the stuck thread and awaits a solution urgently.
Disclosure of Invention
Based on this, it is necessary to provide a method, an apparatus, a computer device, and a readable storage medium for locating a stuck thread to solve the technical problem of long processing time due to the fact that features cannot be accurately extracted in the prior art.
A method of locating a stuck thread, the method comprising:
triggering stuck thread monitoring according to a triggering instruction of the stuck thread monitoring;
performing thread marking scanning on the thread dump file to obtain a scanning result, wherein the thread is marked as a mark preset on the stuck thread;
if the scanning result is that the thread dump file comprises a stuck thread, acquiring a thread id and a thread calling function of the stuck thread;
acquiring the log information of the stuck thread from the thread dump file according to the thread id, and acquiring the trigger 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 taking the thread id of the target stuck thread as a target thread id;
and determining the thread problem of the target stuck thread according to the target thread id and the thread calling function.
A device to locate a stuck thread, the device comprising:
the monitoring triggering module is used for triggering stuck thread monitoring according to a triggering instruction of the stuck thread monitoring;
the result scanning module is used for carrying out thread mark scanning on the thread dump file to obtain a scanning result, wherein the thread mark is a mark preset on the stuck thread;
the information extraction module is used for acquiring a thread id and a thread calling function of the stuck thread if the scanning result is that the thread dump file comprises the stuck thread;
the time acquisition module is used for acquiring the log information of the stuck thread from the thread dump file according to the thread id and acquiring the trigger time of the stuck thread according to the log information;
the thread extraction module is used for obtaining a target stuck thread from the thread dump file according to the trigger time and taking the thread id of the target stuck thread as a target thread id;
and the problem positioning module is used for determining the thread problem of the target stuck thread according to the target thread id and the thread calling function.
A computer device comprising a memory and a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method of locating a stuck thread described above when executing the computer program.
A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method of locating a stuck thread.
According to the method, the device, the computer equipment and the readable storage medium for positioning the stuck thread, the thread id with the thread mark and the thread calling function are obtained, then the log information of the stuck thread is obtained from the dump file according to the thread id, and the trigger time of the stuck thread is obtained according to the log information; and obtaining a target stuck thread from the dump file according to the trigger time, taking the thread id of the target stuck thread as the target thread id, and finally determining the thread problem of the target stuck thread according to the target thread id and the thread calling function, so that the technical problem that the problem of the stuck thread is longer in processing timeliness and further subsequent work is influenced in the prior art is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application environment of a method for locating a stuck thread;
FIG. 2 is a schematic flow chart diagram of a method of locating a stuck thread;
FIG. 3 is a flowchart illustrating another embodiment of a method for locating a stuck thread;
FIG. 4 is a schematic flow chart of step 206 of FIG. 2;
FIG. 5 is a schematic flow chart of step 208 in FIG. 2;
FIG. 6 is a schematic flow chart of step 210 in FIG. 2;
FIG. 7 is a schematic diagram of a device to locate a stuck thread;
FIG. 8 is a diagram of a computer device in one embodiment.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The method for positioning the stuck thread provided by the embodiment of the invention can be applied to the application environment shown in FIG. 1. The application environment may include a terminal 102, a network 106, and a server 104, where the network 106 is used to provide a communication link medium between the terminal 102 and the server 104, and the network 106 may include various connection types, such as wired, wireless communication links, or fiber optic cables.
A user may use the terminal 102 to interact with the server 104 over the network 106 to receive or send messages, etc. The terminal 102 may have installed thereon various communication client applications, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal 102 may be various electronic devices having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, an e-book reader, an MP3 player (moving picture Experts Group Audio L layer iii, mpeg compressed standard Audio layer 3), an MP4 player (moving picture Experts Group Audio L layer iv, mpeg compressed standard Audio layer 4), a laptop portable computer, a desktop computer, and the like.
The server 104 may be a server that provides various services, such as a background server that provides support for pages displayed on the terminal 102.
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, and accordingly, the apparatus for locating a stuck thread is generally disposed in a server/terminal device.
It should be understood that the number of terminals, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Wherein, the terminal 102 communicates with the server 104 through the network. The server 104 may obtain the dump file and the number of threads from the terminal 102, obtain a thread id with a thread mark and a thread calling function, obtain log information of the stuck thread from the dump file according to the thread id, and obtain the trigger time of the stuck thread according to the log information; and obtaining a target stuck thread from the dump file according to the trigger time, taking the thread id of the target stuck thread as the target thread id, and finally determining the thread problem of the target stuck thread according to the target thread id and a thread calling function. The terminal 102 and the server 104 are connected through a network, the network may be a wired network or a wireless network, the terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a method for locating a stuck thread is provided, which is described by taking the method as an example for being applied to a server in fig. 1, and includes the following steps:
step 202, triggering stuck thread monitoring according to a trigger instruction of stuck thread monitoring.
A Stuck thread is a thread whose execution time exceeds a preset time, which may become the longest time of the Stuck thread, and generally, the longest time of the Stuck thread may be 600 s. The stuck thread is a thread for detecting the health state of the thread in weblogic middleware, the weblogic middleware is a middleware of an opportunistic javaEE framework, the weblogic is a Java application server for developing, centralizing, deploying and managing large-scale distributed web applications, network applications and database applications, and the weblogic is a bridge between an operating system and an application program.
In this embodiment, stuck thread monitoring is one of monitoring systems, and the monitoring systems may include thread monitoring, waiting thread monitoring, active thread monitoring, stuck thread monitoring, and the like.
And step 204, performing thread mark scanning on the thread dump file to obtain a scanning result, wherein the thread mark is a mark preset on the stuck thread.
The memory image of the thread is stored in the thread dump file, and the state of the thread is stored in the thread dump file. In this embodiment, the thread states in the thread dump file may include waiting threads, active threads, and stuck threads, among others. Thread mark scanning is to scan threads in a thread dump file, and a thread with a thread mark needs to be scanned. In this embodiment, the content collected by the thread dump file is thread information processed by the current application, and includes recording program thread activity, waiting, sticky information, and the like.
Specifically, the thread dump file is traversed, whether a thread marked by a stuck thread exists in the thread dump file is searched, and finally a scanning result is obtained. The scanning result can be that the dump file has a stuck thread with a preset mark, or can be that the stuck thread with the preset mark is scanned.
Further, the thread mark may be a yellow mark, that is, the thread having the yellow mark in the thread dump file is a stuck thread.
In step 206, if the scanning result is that the thread dump file includes a stuck thread, a thread id of the stuck thread and a thread calling function are obtained.
In this embodiment, in the thread dump file, the thread dump file stores stuck thread information, where the stuck thread information includes a number of a stuck, a program method of a stuck thread, an associated thread of the stuck thread, and the like.
The number of the stuck thread can be a number, an letter or a combination of the number and the letter, the number of the stuck thread is usually used for searching the stuck thread with the same number in a log, the stuck threads in the stuck file with the same number are the same stuck thread, that is, as long as the numbers (ids) of the stuck threads are the same, the stuck thread in the thread dump file and the stuck thread in the log are the same stuck thread.
The thread call function of the stuck thread specifically includes a function name and program code data, where the function name may include interrupt (): interrupt thread, sleep (): water vast thread, STOP (): stop thread, run (): thread body or start (): start threads, etc.; the program code data may be specific numerical parameters; illustratively, the numerical parameter is 5.
And step 208, acquiring the log information of the stuck thread from the thread dump file according to the thread id, and acquiring the trigger time of the stuck thread according to the log information.
The log information includes information in the thread dump file and service information corresponding to the thread, and the like. Specifically, in an actual business scenario, the business information corresponding to the thread may include an insurance policy number and a barcode of the insurance company.
The trigger time of the Stuck thread refers to the starting time of the Stuck thread, and can be 19 minutes and 47 seconds at 18 pm of 2019-11-04 days, for example.
And step 210, obtaining a target stuck thread from the thread dump file according to the trigger time, and taking the thread id of the target stuck thread as the target thread id.
The target stuck threads are stuck threads triggered at the time point of the trigger time, and are obtained from the thread dump file, and the thread id of the thread is taken as the target thread id.
And step 212, determining the thread problem of the target stuck thread according to the target thread id and the thread calling function.
And after the target thread id is obtained, taking the target thread id as a parameter of a thread calling function, calling the parameter through the thread calling function to obtain a problem single number of the stuck thread, and determining the problem of the stuck thread according to the problem single number.
Specifically, if the target thread id is 5, 5 is taken as a parameter to be brought into the program code data:
ESC[0mAcceptForIntfAction.getCurrentRequestObject:{ACCEPTMAP={APPLY_TYPE=5,POLN0=P040000010782507
running the program code data to obtain a problem single number of a stuck thread, wherein the problem single number is P040000010782507; wherein each question sheet number corresponds to a specific thread question.
In the embodiment, the method includes the steps of obtaining a thread id with a thread mark and a thread calling function, then obtaining log information of a stuck thread from a dump file according to the thread id, and obtaining triggering time of the stuck thread according to the log information; obtaining a target stuck thread from the dump file according to the trigger time, taking the thread id of the target stuck thread as the target thread id, and finally determining the thread problem of the target stuck thread according to the target thread id and the thread calling function, so that the technical problem that the problem of the stuck thread is longer in processing timeliness and further subsequent work is influenced in the prior art is solved; the problem of the stuck thread is directly solved by the method, and the problem of the stuck thread is quickly positioned.
In one embodiment, as shown in fig. 3, before step 202, the method further includes:
step 302, call thread monitoring interface. The thread monitoring interface may be an API monitoring interface in stuck thread monitoring for monitoring the state, information, etc. of a thread. In this embodiment, stuck thread monitoring is one of monitoring systems, and the monitoring system may include thread monitoring, waiting thread monitoring, active thread monitoring, stuck thread monitoring, and the like.
Step 304, collecting the number of threads from the thread monitoring interface. After guessing the number of threads from the thread monitoring interface, whether the number of threads reaches a preset threshold value needs to be judged.
Step 306, if the number of threads exceeds a preset threshold, a trigger instruction is generated. If the number of the threads reaches a preset threshold value, it is indicated that the process of the application system becomes a STUCK thread for a long time, the process is derived into a ringing thread, and after the ringing thread reaches the preset number, congestion occurs in the application, and the phenomena of congestion, slow operation and the like occur in the user side; a trigger instruction for the outgoing stuck thread monitoring needs to be generated.
According to the embodiment, the number of the threads is acquired through the thread monitoring interface, and whether a stuck thread instruction is generated or not is determined according to the number of the threads, so that a user can analyze and process a problem stuck thread in time according to a dump file, and the timeliness of problem stuck thread positioning is improved.
In one embodiment, as shown in FIG. 4, step 206, comprises:
in step 402, if the thread dump file includes a thread with a thread mark, the scanning result is that the thread dump file includes a stuck thread. The preset thread mark may be a yellow mark, that is, the thread with the yellow mark in the thread dump file is a stuck thread. The threads needing to be checked can be directly acquired through the thread mark, and the threads which are not important currently can be omitted.
Step 404, acquiring a stuck thread, and receiving a stuck thread reading instruction; and after the stuck thread with the yellow mark is obtained from the thread dump file, reading the information prompt of the stuck thread according to the received stuck thread reading instruction.
And 406, obtaining information prompt of the stuck thread according to the stuck thread reading instruction. And the obtained information prompt of the stuck thread is written with the thread information of the stuck thread, and the thread information can be the thread id of the thread, a thread calling function and the like.
Step 408, obtain thread id and thread call function from the information prompt. The thread calling function specifically includes a program name and program code data, where the program method name may include interrupt (): interrupt thread, sleep (): sleep thread, wait (): waiting thread, stop (): stop thread, run (): thread body and start (): starting threads and the like; the program code data may be specific numerical parameters; illustratively, numerical parameter 5.
In this embodiment, by obtaining the stuck thread with the thread mark, obtaining the thread id and the thread call function of the stuck thread, the thread to be checked can be directly obtained, and the current unimportant thread is omitted, so that the time efficiency of data acquisition is improved, the amount of data processing is reduced, and the efficiency of data processing at the server is improved.
In one embodiment, as shown in FIG. 5, step 208, comprises:
step 502, obtaining the running time of the stuck thread from the log information. The log information contains stuck threads with the same number, and the stuck threads with the same number refer to stuck threads with the same thread id in the thread dump file. The run length of a Stuck thread is the run length of the thread from the trigger to the current time.
And step 504, acquiring the current time, and obtaining the trigger time according to the current time and the operation duration. The current time is the time point of the current processing stuck thread, and the trigger time of the stuck thread can be obtained according to the running time length and the current time.
The associated thread causing the STUCK thread, particularly the weblogic general method thread, can not see what function of the system is temporarily, or needs to return to the STUCK thread. The main reason of the STUCK main thread is that the program uses a transaction lock to lock a corresponding program session when processing a transaction, so that the subsequent operation cannot generate repeated data, the subsequent thread waits for the release of the database lock due to the database lock, and finally the application is in a waiting state and is not released all the time. And searching for STUCK threads near the abnormal time (trigger time) point in the corresponding thread dump file, wherein the function point corresponding to the thread content is a 020-channel security acceptance function.
For example, the STUCK thread identifies that a timeout occurs in 637 seconds after the last thread is started in the thread dump file, and it can be concluded that the function of the STUCK thread is executed before 637 seconds, that is, a thread id is the same as the STUCK thread id before 637 seconds, and the thread id is the starting process of the target STUCK thread.
Specifically, with the current time of the STUCK thread, 19 minutes and 47 seconds at 18 pm of 2017-8-5 minus 637 seconds, a 59 minutes and 10 seconds triggered STUCK thread at 17 pm of 2017-8-5 is obtained.
In the embodiment, the running time is obtained from the log information corresponding to the stuck thread, and the trigger time of the stuck thread is obtained by combining the current time, so that the calculation is simple and convenient.
In one embodiment, as shown in FIG. 6, step 210, comprises:
step 602, using the target thread id as a parameter of the thread calling function. And the obtained target thread id is used as a parameter of a thread calling function, and the problem is reproduced through the access.
Step 604, call thread call function to get thread problem.
Through the embodiment, the thread problem of the stuck thread is obtained in a parameter access recurrence mode and is finally solved by developers, so that the timeliness of problem positioning is improved.
It should be understood that although the various steps in the flowcharts of fig. 2-6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-6 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 7, there is provided a device for locating a stuck thread, where the device for locating a stuck thread corresponds to the method for locating a stuck thread in the above embodiment one by one. The device for positioning the stuck thread comprises the following steps:
the monitoring triggering module 702 is configured to trigger stuck thread monitoring according to a triggering instruction for stuck thread monitoring;
a result scanning module 704, configured to perform thread mark scanning on the thread dump file to obtain a scanning result, where the thread mark is a mark preset on the stuck thread;
an information extraction module 706, configured to obtain a thread id and a thread call function of a stuck thread if the scanning result indicates that the thread dump file includes the stuck thread;
a time obtaining module 708, configured to obtain log information of the stuck thread from the thread dump file according to the thread id, and obtain a trigger time of the stuck thread according to the log information;
the thread extraction module 710 is configured to obtain a target stuck thread from the thread dump file according to the trigger time, and use a thread id of the target stuck thread as a target thread id;
and the problem positioning 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.
Further, before monitoring the trigger module 702, the means for locating the stuck thread further includes:
and the interface calling module is used for calling the thread monitoring interface.
And the thread acquisition module is used for acquiring the number of threads from the thread monitoring interface.
And the instruction generation module is used for generating the trigger instruction if the number of the threads exceeds a preset threshold value.
Further, the information extraction module 706 includes:
and the information scanning submodule is used for enabling the scanning result to be that the thread dump file comprises a stuck thread if the dump file comprises the thread marked by the thread.
And the instruction receiving submodule is used for acquiring a stuck thread and receiving a stuck thread reading instruction.
And the information reading submodule is used for obtaining the information prompt of the stuck thread according to the stuck thread reading instruction.
And the data acquisition submodule is used for acquiring the thread id and the thread calling function from the information prompt.
Further, the time obtaining module 708 includes:
and the time length obtaining submodule is used for obtaining the running time length of the stuck thread from the log information.
And the trigger time submodule is used for acquiring the current time and obtaining the trigger time according to the current time and the operation duration.
Further, a trigger time submodule, comprising:
and the trigger calculation unit is used for subtracting the running time length from the current time to obtain the trigger time.
Further, the problem location module 712 includes:
and the parameter generation submodule is used for taking the target thread id as a parameter of the thread calling function.
And the reference positioning submodule is used for calling the thread calling function to obtain the thread problem.
The device for positioning the stuck thread acquires the thread id with the thread mark and the thread calling function, acquires the log information of the stuck thread from the dump file according to the thread id, and acquires the trigger time of the stuck thread according to the log information; and obtaining a target stuck thread from the dump file according to the trigger time, taking the thread id of the target stuck thread as the target thread id, and finally determining the thread problem of the target stuck thread according to the target thread id and the thread calling function, so that the technical problem that the problem of the stuck thread is longer in processing timeliness and further subsequent work is influenced in the prior art is solved.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile 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 an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing user order data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of locating a stuck thread. The thread problem of the stuck thread is obtained in a parameter recurrence mode and is finally solved by developers, so that the timeliness of problem positioning is improved.
As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the steps of the method for locating a stuck thread in the above-described embodiment, such as the steps 202 to 212 shown in fig. 2, or when the processor executes the computer program, the processor implements the functions of the modules/units of the apparatus for locating a stuck thread in the above-described embodiment, such as the functions of the modules 702 to 712 shown in fig. 7. To avoid repetition, further description is omitted here.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and the computer program when executed by a processor implements the steps of the method for locating a stuck thread in the above embodiments, such as the steps 202 to 212 shown in fig. 2, or the processor implements the functions of the modules/units of the apparatus for locating a stuck thread in the above embodiments, such as the functions of the modules 702 to 712 shown in fig. 7. To avoid repetition, further description is omitted here. The thread problem of the stuck thread is obtained in a parameter recurrence mode and is finally solved by developers, so that the timeliness of problem positioning is improved.
It will be understood by those of ordinary skill in the art that all or a portion of the processes of the methods of the embodiments described above may be implemented by a computer program that may be stored on a non-volatile computer-readable storage medium, which when executed, may include the processes of the embodiments of the methods described above, wherein any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for those skilled in the art, without departing from the spirit and scope of the present invention, several changes, modifications and equivalent substitutions of some technical features may be made, and these changes or substitutions do not make the essence of the same technical solution depart from the spirit and scope of the technical solution of the embodiments of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for locating a stuck thread, the method comprising:
triggering stuck thread monitoring according to a triggering instruction of the stuck thread monitoring;
performing thread marking scanning on the thread dump file to obtain a scanning result, wherein the thread is marked as a mark preset on the stuck thread;
if the scanning result is that the thread dump file comprises a stuck thread, acquiring a thread id and a thread calling function of the stuck thread;
acquiring the log information of the stuck thread from the thread dump file according to the thread id, and acquiring the trigger 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 taking the thread id of the target stuck thread as a target thread id;
and determining the thread problem of the target stuck thread according to the target thread id and the thread calling function.
2. The method according to claim 1, before the triggering the stuck thread monitoring according to the triggering instruction of the stuck thread monitoring, further comprising:
calling a thread monitoring interface;
collecting the number of threads from the thread monitoring interface;
and if the number of the threads exceeds a preset threshold value, generating the trigger instruction.
3. The method according to claim 1, wherein if the scan result is that a stuck thread is included in the thread dump file, obtaining a thread id and a thread calling function of the stuck thread comprises:
if the thread dump file comprises the thread with the thread mark, the scanning result is that the thread dump file comprises a stuck thread;
acquiring a stuck thread and receiving a stuck thread reading instruction;
obtaining an information prompt of the stuck thread according to the stuck thread reading instruction;
and acquiring the thread id and the thread calling function from the information prompt.
4. The method according to claim 1, wherein the obtaining the trigger time of the stuck thread according to the log information comprises:
acquiring the running time of the stuck thread from the log information;
and acquiring the current time, and acquiring the trigger time according to the current time and the operation duration.
5. The method of claim 4, wherein obtaining the trigger time based on the current time and the run length comprises:
and subtracting the running time length from the current time to obtain the trigger time.
6. The method according to claim 1, wherein the determining the thread problem of the target stuck thread according to the target thread id and the thread calling function comprises:
taking the target thread id as a parameter of the thread calling function;
and calling the thread calling function to obtain the thread problem.
7. An apparatus for locating a stuck thread, comprising:
the monitoring triggering module is used for triggering stuck thread monitoring according to a triggering instruction of the stuck thread monitoring;
the result scanning module is used for carrying out thread mark scanning on the thread dump file to obtain a scanning result, wherein the thread mark is a mark preset on the stuck thread;
the information extraction module is used for acquiring a thread id and a thread calling function of the stuck thread if the scanning result is that the thread dump file comprises the stuck thread;
the time acquisition module is used for acquiring the log information of the stuck thread from the thread dump file according to the thread id and acquiring the trigger time of the stuck thread according to the log information;
the thread extraction module is used for obtaining a target stuck thread from the thread dump file according to the trigger time and taking the thread id of the target stuck thread as a target thread id;
and the problem positioning module is used for determining the thread problem of the target stuck thread according to the target thread id and the thread calling function.
8. The apparatus of claim 7, further comprising, prior to monitoring the trigger module:
the interface calling module is used for calling the thread monitoring interface;
the thread collecting module is used for collecting the number of threads from the thread monitoring interface;
and the instruction generation module is used for generating the trigger instruction if the number of the threads exceeds a preset threshold value.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202010150630.2A 2020-03-05 2020-03-05 Method and device for positioning stuck thread, computer equipment and readable storage medium Pending CN111475322A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010150630.2A CN111475322A (en) 2020-03-05 2020-03-05 Method and device for positioning stuck thread, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010150630.2A CN111475322A (en) 2020-03-05 2020-03-05 Method and device for positioning stuck thread, computer equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN111475322A true CN111475322A (en) 2020-07-31

Family

ID=71747348

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010150630.2A Pending CN111475322A (en) 2020-03-05 2020-03-05 Method and device for positioning stuck thread, computer equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN111475322A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114003390A (en) * 2021-11-16 2022-02-01 平安养老保险股份有限公司 Method and device for determining abnormal thread, computer equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114003390A (en) * 2021-11-16 2022-02-01 平安养老保险股份有限公司 Method and device for determining abnormal thread, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109325349A (en) A kind of method for managing security, terminal device and computer readable storage medium
CN109901881B (en) Plug-in loading method and device of application program, computer equipment and storage medium
CN111400125A (en) Memory overflow monitoring method, device, equipment and storage medium of JAVA process
CN112597020A (en) Interface testing method and device, computer equipment and storage medium
CN112631911A (en) Automatic testing method and device, computer equipment and storage medium
CN110881224B (en) Network long connection method, device, equipment and storage medium
CN110765085A (en) Log information writing method, system, storage medium and mobile terminal
CN111475322A (en) Method and device for positioning stuck thread, computer equipment and readable storage medium
CN113220403A (en) Method and device for h5 intercepting Android return event and electronic equipment
CN111124627B (en) Method and device for determining call initiator of application program, terminal and storage medium
CN115328764A (en) Test code optimization method based on automatic test and related equipment thereof
CN110087232A (en) A kind of call processing method based on smart machine, device and server
CN113722225A (en) Page testing method and device, computer equipment and storage medium
CN112631812A (en) Identification setting method and device, electronic equipment and storage medium
CN111338960A (en) Buried point data acquisition method and device
CN112771499A (en) Message loading method, message loading device and mobile terminal
CN114690988B (en) Test method and device and electronic equipment
CN112732568B (en) System log acquisition method and device, storage medium and terminal
CN111327513B (en) Message data pushing method and device, computer equipment and storage medium
CN112925693B (en) System monitoring method, device, computer equipment and storage medium
CN112241283B (en) Software upgrading method, device, computer equipment and storage medium
WO2024066622A1 (en) Cloud system testing method and apparatus
CN112134755A (en) Method and device for monitoring public gateway interface program
CN115878460A (en) Regression testing method, device, computer equipment and storage medium
CN113836025A (en) Page testing method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination