Search

CN-120780740-B - Analysis method and device for connection leakage, electronic equipment and storage medium

CN120780740BCN 120780740 BCN120780740 BCN 120780740BCN-120780740-B

Abstract

The embodiment of the application provides a method and a device for analyzing connection leakage, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of obtaining connection data of each potential leakage connection, generating call stack signatures of each potential leakage connection based on call stack information of each potential leakage connection, determining suspicious call stack signatures from the obtained call stack signatures, extracting multiple classes of call stack information corresponding to the suspicious call stack signatures, decompiling byte codes corresponding to the multiple classes to obtain source codes of the multiple classes, and determining a source code analysis result based on the suspicious call stack signatures, the source codes of the multiple classes and the connection data corresponding to the suspicious call stack signatures, wherein the source code analysis result is used for indicating whether codes and positions of codes causing connection leakage exist or not. Thus, the root cause of the connection leakage problem can be accurately positioned, and the stability and performance of the system are improved.

Inventors

  • DU ZHONGYUAN
  • LI LEI

Assignees

  • 北京基调网络股份有限公司

Dates

Publication Date
20260508
Application Date
20250529

Claims (12)

  1. 1. A method of analyzing a connection leak, comprising: acquiring respective connection data of each potential leakage connection, wherein the connection use time of each potential leakage connection is longer than a use time threshold value, and the connection data comprises call stack information; Generating call stack signatures of the potential leakage connections based on the call stack information of the potential leakage connections respectively; the method comprises the following steps of respectively acquiring and analyzing a time sequence of one call stack signature to obtain a time distribution uniformity metric value corresponding to the one call stack signature, wherein the time sequence comprises a plurality of potential leakage connection time points corresponding to the one call stack signature; normalizing and weighting summation is carried out on the obtained occurrence times of the call stack signatures and the uniformity measurement values of the corresponding time distribution, so as to obtain suspicious values of the call stack signatures; based on the suspicious values of the call stack signatures, suspicious call stack signatures with suspicious values meeting preset suspicious conditions are screened from the call stack signatures; extracting a plurality of classes of call stack information corresponding to the suspicious call stack signature, decompiling byte codes corresponding to the classes, and obtaining source codes of the classes; and determining a source code analysis result based on the suspicious call stack signature, the source codes of the classes and the connection data corresponding to the suspicious call stack signature, wherein the source code analysis result is used for indicating whether codes causing connection leakage and the positions of the codes exist or not.
  2. 2. The method of claim 1, wherein the connection data further comprises a connection identifier, a connection acquisition time, a connection usage duration, and thread information.
  3. 3. The method of claim 1, wherein generating the call stack signature for each potential leaky connection based on the call stack information for each potential leaky connection, respectively, comprises: for each potential leakage connection, the following operations are respectively executed: Carrying out standardization processing on call stack information of a potential leakage connection; Core information is extracted from the call stack information of the potential leakage connection, and a call stack signature of the potential leakage connection is generated based on the core information.
  4. 4. The method of claim 3, wherein normalizing call stack information for a potential leaky connection comprises: and filtering the bonded store-free frames in the call stack information of the potential leakage connection, wherein the bonded store-free frames are stack frames irrelevant to application program codes.
  5. 5. The method of claim 1, wherein decompiling the bytecodes corresponding to the plurality of classes to obtain source codes of the plurality of classes, comprises: filtering irrelevant classes in the classes, and/or screening out the classes belonging to an upper layer stack frame from the classes, wherein the irrelevant classes are classes irrelevant to a connection leakage event, and the upper layer stack frame is a stack frame with stack frame depth meeting a preset depth condition in call stack information corresponding to the suspicious call stack signature; decompiling the byte codes corresponding to the classes through a decompiling tool to obtain source codes of the classes.
  6. 6. The method of claim 1, wherein prior to determining the source code analysis result based on the suspicious call stack signature, the source codes of the plurality of classes, and the connection data corresponding to the suspicious call stack signature, further comprising: filtering irrelevant codes in source codes of the multiple classes, wherein the irrelevant codes are codes irrelevant to core business logic.
  7. 7. The method of claim 2, wherein the determining the source code analysis result based on the suspicious call stack signature, the source codes of the plurality of classes, and connection data corresponding to the suspicious call stack signature comprises: Inputting the suspicious call stack signature, the source codes of the plurality of classes and the connection data corresponding to the suspicious call stack signature into a code analysis model to obtain a source code analysis result output by the code analysis model, wherein when codes causing connection leakage exist in the source code analysis result, the source code analysis result comprises an exception report, and the exception report comprises the class, the method and the line number causing connection leakage and corresponding code fragments.
  8. 8. The method of claim 1, wherein the method further comprises: When the running state of the connection pool is abnormal or the source code analysis result is that codes causing connection leakage exist, the running state and the source code analysis result are input into an optimization model, and configuration optimization suggestions output by the optimization model are obtained.
  9. 9. The method of claim 8, wherein the method further comprises: and when the utilization rate of the connection pool is larger than the utilization rate threshold value, or the time required by the application program to acquire one connection from the connection pool is longer than the acquisition time threshold value, determining that the operation state of the connection pool is abnormal.
  10. 10. An analysis device for connection leakage, comprising: the acquisition module is used for acquiring respective connection data of each potential leakage connection, wherein the connection use time of each potential leakage connection is longer than a use time threshold value, and the connection data comprises call stack information; The first processing module is used for respectively generating call stack signatures of all potential leakage connections based on call stack information of all the potential leakage connections, respectively acquiring and analyzing a time sequence of one call stack signature to obtain uniformity metric values of time distribution corresponding to the one call stack signature, wherein the time sequence comprises a plurality of time points of the potential leakage connections corresponding to the one call stack signature, normalizing and weighting and summing the obtained occurrence times of all the call stack signatures and the uniformity metric values of the corresponding time distribution to obtain suspicious values of all the call stack signatures, and screening suspicious call stack signatures with suspicious values meeting preset suspicious conditions from all the call stack signatures based on the suspicious values of all the call stack signatures; The second processing module is used for extracting a plurality of classes of call stack information corresponding to the suspicious call stack signature, decompiling byte codes corresponding to the classes, and obtaining source codes of the classes; The analysis module is used for determining a source code analysis result based on the suspicious call stack signature, the source codes of the classes and the connection data corresponding to the suspicious call stack signature, wherein the source code analysis result is used for indicating whether codes causing connection leakage and the positions of the codes exist or not.
  11. 11. An electronic device, comprising: processor, and A memory in which a program is stored, Wherein the program comprises instructions which, when executed by the processor, cause the processor to perform the method of any of claims 1-9.
  12. 12. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-9.

Description

Analysis method and device for connection leakage, electronic equipment and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a method and apparatus for analyzing connection leakage, an electronic device, and a storage medium. Background With the advent of the internet and the large data age, databases became a central component of many applications. Applications require frequent interactions with databases to store and retrieve data. To improve performance and efficiency, many applications employ a pool of database connections to manage creation and release of database connections. The database connection pool is a technical component for efficiently managing database connections, and by pre-creating and maintaining a certain number of connections for reuse by an application program, the overhead of connection establishment and closure is reduced, the performance is improved, and the resource utilization is optimized. However, in the use process of the database connection pool, a connection leakage condition may occur, which leads to connection resource exhaustion or performance bottleneck. Where connection leakage refers to an application not properly freeing a database connection after it has been used, resulting in connection resources not being reclaimed and reused. Therefore, how to accurately locate the root of the connection leakage problem is a problem that needs to be solved at present. Disclosure of Invention The embodiment of the application provides a connection leakage analysis method, a device, electronic equipment and a storage medium, which are used for accurately positioning the root cause of the connection leakage problem, so that the stability and performance of a system are improved. In a first aspect, an embodiment of the present application provides a method for analyzing connection leakage, where the method includes: Acquiring respective connection data of each potential leakage connection, wherein the connection use time of each potential leakage connection is longer than a use time threshold value, and the connection data comprises call stack information; Generating call stack signatures of all potential leakage connections based on call stack information of all potential leakage connections respectively, and determining suspicious call stack signatures from all obtained call stack signatures; extracting a plurality of classes of call stack information corresponding to suspicious call stack signatures, decompiling byte codes corresponding to the classes, and obtaining source codes of the classes; And determining a source code analysis result based on the suspicious call stack signature, source codes of a plurality of classes and connection data corresponding to the suspicious call stack signature, wherein the source code analysis result is used for indicating whether codes causing connection leakage and the positions of the codes exist or not. In an alternative embodiment, the connection data further includes a connection identifier, a connection acquisition time, a connection use duration, and thread information. In an alternative embodiment, generating a call stack signature for each potential leaky connection based on call stack information for each potential leaky connection, respectively, includes: For each potential leakage connection, the following operations are performed: Carrying out standardization processing on call stack information of a potential leakage connection; core information is extracted from call stack information of a potential leakage connection, and a call stack signature of the potential leakage connection is generated based on the core information. In an alternative embodiment, normalizing call stack information for a potential leaky connection includes: And filtering the no bonded store frames in the call stack information of one potential leakage connection, wherein the no bonded store frames are stack frames irrelevant to application program codes. In an alternative embodiment, determining the suspicious call stack signature from the obtained call stack signatures includes: determining suspicious values of the call stack signatures based on the occurrence times of the call stack signatures and the time distribution uniformity metric values of the potential leakage connections corresponding to the call stack signatures; and screening suspicious call stack signatures with suspicious values meeting preset suspicious conditions from the call stack signatures based on the suspicious values of the call stack signatures. In an alternative embodiment, determining the suspicious value of each call stack signature based on the occurrence number of each call stack signature and the time distribution uniformity metric value of the plurality of potential leakage connections corresponding to each call stack signature, includes: The method comprises the following steps of respectively acquirin