Database operation log generation method, abnormality location method, device and medium
By inserting trace identification into SQL statements to generate enhanced structured statements, the problem of waste and maintenance costs in the prior art is solved, efficient exception location is achieved and storage requirements of database operation logs are reduced.
Patent Information
- Application Number
- CN202310761074.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-26
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-06-26
AI Technical Summary
In the prior art, when using the database monitoring system to troubleshoot abnormal structured statements, it is necessary to add a reserved operation record table to the business database, resulting in waste of storage resources and high maintenance costs.
By inserting the trace identification according to the processing type of the structured statement, enhancing structured statements are generated and database operation logs are generated in the business database, which avoids adding reserved operation record tables in the business database, and inserting trace identifications directly in the SQL statements.
It reduces the storage space waste of business databases, reduces development and maintenance costs, and improves the efficiency and accuracy of abnormal positioning.
Smart Images

Figure CN116821154B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of big data technology and information security technology, and in particular to a database operation log generation method, anomaly locating method, device, and medium. Background Art
[0002] With the development of computer technology, enterprises can provide services to users in the form of microservices. For example, microservices can be provided to users by integrating business systems with multiple business databases.
[0003] In microservice maintenance scenarios, database administrators (DBAs) can use database monitoring systems to troubleshoot abnormal Structured Query Language (SQL) statements in business databases. They can then use the business system to troubleshoot multiple database services affected by these abnormal SQL statements.
[0004] Related technologies typically identify multiple database services affected by abnormal structured statements based on a reserved operation log table in a business database. However, the code and data used to store the reserved operation log table are unrelated to the business operations performed by the business database, resulting in wasted storage resources and high maintenance costs for the business database. Summary of the Invention
[0005] In view of the above problems, the present disclosure provides a database operation log generation method, anomaly locating method, device and medium.
[0006] According to a first aspect of the present disclosure, a method for generating a database operation log is provided, comprising:
[0007] Determining a tracking identifier associated with a structured statement for invoking a database service, wherein the structured statement is determined based on the service invocation request;
[0008] Determine the type of processing for structured statements;
[0009] executing execution logic matching the processing type to update the tracking identifier into the structured statement to obtain an enhanced structured statement; and
[0010] Generates database operation logs for database services based on enhanced structured statements.
[0011] According to an embodiment of the present disclosure, the processing type includes query-type structured statements and operation-type structured statements;
[0012] Execute execution logic matching the processing type to update the tracking identifier into the structured statement to obtain an enhanced structured statement, including:
[0013] When the processing type is determined to be a query-type structured statement, a first insertion position is determined according to the query condition of the structured statement; a tracking marker is inserted into the first insertion position to obtain a first enhanced structured statement;
[0014] When it is determined that the processing type is an operation-type structured statement, the tracking marker is inserted into the second insertion position to obtain a second enhanced structured statement.
[0015] According to an embodiment of the present disclosure, determining the first insertion position according to a query condition of the structured statement includes:
[0016] When it is determined that the structured statement has a query condition, the end of the query condition is determined as the first insertion position;
[0017] When it is determined that the structured statement does not contain the query condition, the end of the structured statement is determined as the first insertion position.
[0018] According to an embodiment of the present disclosure, inserting the tracking identifier into the first insertion position to obtain the first enhanced structured statement includes: when it is determined that the structured statement has a query condition,
[0019] Generate concatenated query conditions based on the tracking identifier; and
[0020] Insert the concatenated query condition into the first insertion position to obtain a first enhanced structured statement through concatenation.
[0021] According to an embodiment of the present disclosure, the method of inserting the tracking identifier into the first insertion position to obtain the first enhanced structured statement further includes: when it is determined that the structured statement does not have the query condition,
[0022] generating a target query condition that matches the tracking identifier, wherein a query result of the target query condition is the tracking identifier; and
[0023] Insert the target query condition into the first insertion position to obtain a first enhanced structured statement.
[0024] According to an embodiment of the present disclosure, inserting the tracking marker into the second insertion position to obtain a second enhanced structured statement includes:
[0025] The tracking marker is inserted into the second insertion position in the form of a comment to obtain a second enhanced structured statement.
[0026] According to an embodiment of the present disclosure, determining the processing type of the structured statement includes:
[0027] In the case where it is determined that the start of the structured statement is a first character string, the processing type is determined to be a query-type structured statement, wherein the first character string represents a selection operation;
[0028] When it is determined that the start of the structured statement is the second string, the third string or the fourth string, the processing type is determined to be an operation-type structured statement, wherein the second string represents an insert operation, the third string represents an update operation, and the fourth string represents a delete operation.
[0029] According to an embodiment of the present disclosure, before determining a tracking identifier associated with a structured statement for invoking a database service, the method includes:
[0030] Based on the interceptor in the business system program framework, structured statements are intercepted through aspect interception.
[0031] A second aspect of the present disclosure provides an exception locating method, comprising: in response to determining that a database service call is abnormal, obtaining a database operation log, wherein the database operation log is generated according to the above method; and based on the database operation log, simultaneously locating abnormal structured statements in the abnormal service and tracking identifiers of the abnormal structured statements.
[0032] A third aspect of the present disclosure provides a database operation log generating device, comprising:
[0033] an identifier determination module, configured to determine a tracking identifier associated with a structured statement based on the structured statement used to call a database service, wherein the structured statement is determined based on the service call request;
[0034] A type determination module, used to determine the processing type of the structured statement;
[0035] an execution module, configured to execute execution logic matching the processing type, so as to update the tracking identifier into the structured statement to obtain an enhanced structured statement; and
[0036] The generation module is used to generate a database operation log for a database service according to the enhanced structured statement.
[0037] A fourth aspect of the present disclosure provides an abnormality locating device, comprising:
[0038] an acquisition module, configured to acquire a database operation log in response to determining that the database service call is abnormal, wherein the database operation log is generated according to the above method; and
[0039] The exception locating module is used to locate the abnormal structured statements and the tracking identifiers of the abnormal structured statements in the abnormal service according to the database operation log.
[0040] The fifth aspect of the present disclosure provides an electronic device comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors execute the above-mentioned database operation log generation and anomaly location method.
[0041] A sixth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned database operation log generation and exception locating method.
[0042] A seventh aspect of the present disclosure further provides a computer program product, including a computer program, which implements the above-mentioned database operation log generation and exception locating method when executed by a processor.
[0043] In the embodiment of the present disclosure, since a tracking identifier is inserted into each SQL statement to obtain an enhanced SQL statement, the generated database operation log can include both the SQL statement and the tracking identifier. There is no need to add a reserved operation record table in the business database to store the mapping relationship between the SQL statement and the tracking identifier, which reduces the waste of business database storage space, reduces the proportion of irrelevant business code and data in the business database, and thus reduces development costs and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0045] Figure 1 The application scenarios of the database operation log generation method and the anomaly locating method according to the embodiments of the present disclosure are schematically shown;
[0046] Figure 2 The following schematically shows a flow chart of a method for generating a database operation log according to an embodiment of the present disclosure;
[0047] Figure 3 The flowchart of the enhanced structured sentence generation method according to the embodiment of the present disclosure is schematically shown;
[0048] Figure 4 A flowchart of generating a first enhanced structured statement or a second enhanced structured statement according to a processing type of a structured statement according to a specific embodiment of the present disclosure is schematically shown;
[0049] Figure 5 Schematically shows a flow chart of generating a database operation log during a service call according to an embodiment of the present disclosure;
[0050] Figure 6 The following schematically shows a flow chart of an abnormality location method according to an embodiment of the present disclosure;
[0051] Figure 7 The following schematically shows a structural block diagram of a database operation log generating device according to an embodiment of the present disclosure;
[0052] Figure 8 Schematically shows a structural block diagram of an abnormality locating device according to an embodiment of the present disclosure; and
[0053] Figure 9 A block diagram of an electronic device suitable for the database operation log generation method and the abnormality locating method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0054] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0055] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise," "include," etc. used herein indicate the presence of the features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0056] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0057] When expressions such as "at least one of A, B and C, etc." are used, they should generally be interpreted in accordance with the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0058] It should be noted that the database operation log generation method and device, and anomaly location method and device disclosed in the present invention can be used in the financial field and the field of cloud computing technology, and can also be used in any field other than the financial field. The application field of the database operation log generation method and device, and anomaly location method and device disclosed in the present invention is not limited.
[0059] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure and application of the data involved (including but not limited to user personal information) comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0060] In related technologies, database administrators (DBAs) can use database monitoring systems to identify abnormal structured statements in business databases. However, these abnormal structured statements detected by database monitoring systems lack a transmission link information carrier, making it impossible to directly locate the business site associated with the abnormal structured statements. To address this issue, database monitoring systems can generally be used to identify multiple database services affected by abnormal structured statements.
[0061] In actual use, the database monitoring system and the business system are separate systems. The reserved operation log table serves as a bridge between the two systems, enabling DBAs to utilize the SQL statement and TraceID fields in the reserved operation log table to troubleshoot multiple database services affected by abnormally structured statements. The reserved operation log table is typically stored in the business system. However, adding a reserved operation log table requires re-engineering the business database, increasing storage resource consumption. The business system code also stores the code logic for the reserved operation log table, adding irrelevant code to the business code, placing an additional burden on business system development and increasing maintenance costs.
[0062] To address the technical issues of storage resource waste and high business database maintenance costs caused by adding a reserved operation record table, an embodiment of the present disclosure provides a method for generating a database operation log, comprising: determining a tracking identifier associated with a structured statement used to call a database service, wherein the structured statement is determined based on a service call request; determining a processing type for the structured statement; executing execution logic matching the processing type to update the tracking identifier into the structured statement to obtain an enhanced structured statement; and generating a database operation log for the database service based on the enhanced structured statement.
[0063] Figure 1 The application scenario of the database operation log generation method according to the embodiment of the present disclosure is schematically illustrated.
[0064] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables.
[0065] The user may use at least one of the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0066] The first terminal device 101 , the second terminal device 102 , and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0067] The server 105 may be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process received user requests and other data, and feed back processing results (e.g., web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0068] For example, the server 105 may also be a business database that provides services, such as query services, storage services, computing services, etc., to users through application software in the first terminal device 101, the second terminal device 102, and the third terminal device 103.
[0069] It should be noted that the database operation log generation method and the anomaly locating method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the database operation log generation device and the anomaly locating device provided in the embodiment of the present disclosure can generally be set in the server 105. The database operation log generation method and the anomaly locating method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database operation log generation device and the anomaly locating device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0070] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0071] The following will be based on Figure 1 The scene described by Figures 2 to 5 The database operation log generation method of the disclosed embodiment is described in detail.
[0072] Figure 2 The flowchart of the method for generating a database operation log according to an embodiment of the present disclosure is schematically shown.
[0073] like Figure 2 As shown, the method 200 includes operations S210 to S240.
[0074] In operation S210 , a tracing identifier associated with a structured statement for invoking a database service is determined, wherein the structured statement is determined according to a service invocation request.
[0075] According to an embodiment of the present disclosure, Structured Query Language (SQL) is a programming language used to query, store, update, and manage databases. For example, a business system may include multiple business databases, such as a MySQL database, and provide microservices to users through multiple business databases.
[0076] According to an embodiment of the present disclosure, the process of a user requesting a business system to call a database service includes: the user sends a service call request to the business system through a terminal device; the business system receives the above service call request and converts the above service call request into an SQL statement to be executed, so as to realize the call of the database service by executing the above SQL statement to be executed.
[0077] In the embodiment of the present disclosure, the structured statement for invoking the database service can be understood as the SQL statement to be executed in the above process.
[0078] According to an embodiment of the present disclosure, after obtaining an SQL statement for calling a database service, a trace identifier (TraceID) associated with the SQL statement may be determined based on context information of a call link to which the SQL statement belongs.
[0079] According to an embodiment of the present disclosure, a call link refers to the call relationship between all services that a request passes through from the time the request is initiated to the time the request is terminated. The same request has the same trace identifier (TraceID).
[0080] According to an embodiment of the present disclosure, multiple SQL statements can be determined based on a service call request. For each SQL statement, a TraceID can be automatically generated based on information such as the request type, request initiation time, and call relationship with the context SQL statement.
[0081] According to another embodiment of the present disclosure, a toolkit provided by the database monitoring system may be called to execute a TraceID determination method in the toolkit to return the TraceID.
[0082] In operation S220 , a processing type of the structured statement is determined.
[0083] According to an embodiment of the present disclosure, various types of SQL statements are used to perform various database operations, such as query, calculation, insert, delete, update, and the like.
[0084] According to an embodiment of the present disclosure, since an SQL statement has a standard coding logic, the processing type of the SQL statement can be determined according to the code text of the SQL statement itself.
[0085] In operation S230 , execution logic matching the processing type is executed to update the tracking identifier into the structured statement to obtain an enhanced structured statement.
[0086] According to an embodiment of the present disclosure, various execution logics may be executed for SQL statements of various processing types, so as to update the tracking identifier into the SQL statement in various ways to obtain an enhanced SQL statement.
[0087] According to an embodiment of the present disclosure, for SQL statements of various processing types, executing execution logic that matches the processing type according to the operational characteristics of the SQL statements can minimize the impact on business codes and reduce waste of storage resources.
[0088] In operation S240 , a database operation log for the database service is generated according to the enhanced structured statement.
[0089] According to embodiments of the present disclosure, after an SQL statement is processed as an enhanced SQL statement, the business database can execute the enhanced SQL statement normally and call the corresponding database service. Furthermore, when executing the enhanced SQL statement, the enhanced SQL statement is recorded and a database operation log for the database service is generated after the service call is completed.
[0090] According to an embodiment of the present disclosure, the database operation log includes data used to record the execution status of SQL statements. For example, the execution result, input parameters, output parameters, etc. In an embodiment of the present disclosure, since the enhanced SQL statement includes a TraceID, the database operation log includes data recording the execution status of the enhanced SQL statement and also includes the TraceID of the SQL statement.
[0091] In the embodiment of the present disclosure, since a tracking identifier is inserted into each SQL statement to obtain an enhanced SQL statement, the generated database operation log can include both the SQL statement and the tracking identifier. There is no need to add a reserved operation record table in the business database to store the mapping relationship between the SQL statement and the tracking identifier, which reduces the waste of business database storage space, reduces the proportion of irrelevant business code and data in the business database, and thus reduces development costs and maintenance costs.
[0092] Figure 3 The flowchart of the enhanced structured sentence generation method according to an embodiment of the present disclosure is schematically shown.
[0093] Figure 3 The flowchart 300 schematically illustrates the enhanced structured sentence generation method according to an embodiment of the present disclosure, including operations S330 to S333. Operation S330 is similar to the implementation method of operation S220, and operations S331 to S333 can be used as a specific embodiment of operation S230.
[0094] In operation S330, the processing type of the structured statement is determined. If the processing type of the structured statement is determined to be a query-type structured statement, the process proceeds to operation S331; if the processing type of the structured statement is determined to be an operation-type structured statement, the process proceeds to operation S333.
[0095] In operation S331 , a first insertion position is determined according to a query condition of the structured statement.
[0096] In operation S332 , a tracking marker is inserted into a first insertion position to obtain a first enhanced structured sentence.
[0097] In operation S333 , the tracking marker is inserted into the second insertion position to obtain a second enhanced structured sentence.
[0098] According to an embodiment of the present disclosure, the processing types include query-type structured statements (Data Query Language, DQL) and operation-type structured statements (Data Manipulation Language, DML). Different execution logic can be implemented for DQL and DML to insert tracking flags into SQL statements.
[0099] According to an embodiment of the present disclosure, multiple insertion positions may be determined for SQL statements of multiple processing types.
[0100] For example, for DQL, the first insertion position can be determined based on whether the SQL statement contains a query condition, and the TraceID can be inserted at the first insertion position to obtain a first enhanced structured statement. For DML, the TraceID can be inserted at a predetermined second insertion position to obtain a second enhanced structured statement.
[0101] According to an embodiment of the present disclosure, for SQL statements belonging to DQL, the SQL statements can perform basic query operations and conditional query operations. Basic query operations can be used to query database fields, remove duplicate fields, perform simple mathematical calculations, etc. Therefore, basic operations do not require query conditions. Conditional query operations can be used to select conditions using operators or perform conditional queries using query conditions. Therefore, when determining that the processing type of the SQL statement is DQL, the first insertion position can be determined based on whether the query condition exists.
[0102] According to an embodiment of the present disclosure, for an SQL statement belonging to DML, the SQL statement can perform multiple operations, and the length and result of the SQL statement are related to the called database service. Therefore, a fixed second insertion position can be set.
[0103] According to the embodiment of the present disclosure, by analyzing the operation logic of DQL and DML type SQL statements, multiple insertion positions can be set for SQL statements of multiple processing types, and TracdID can be woven in based on the execution logic of the SQL statement, ensuring that the TracdID related to the SQL statement can be intuitively and accurately determined based on the generated database operation log.
[0104] According to an embodiment of the present disclosure, the first insertion position is determined based on the query condition of the structured statement, including: when it is determined that the query condition exists in the structured statement, the end of the query condition is determined as the first insertion position; when it is determined that the query condition does not exist in the structured statement, the end of the structured query statement is determined as the first insertion position.
[0105] According to an embodiment of the present disclosure, the query condition may be composed of a WHERE clause.
[0106] For example, the query condition may be "query users in the Shanghai area". The query condition in the SQL statement is "WHERE area=1", where "area" represents the field name of the area and "1" represents the field value representing "Shanghai area".
[0107] According to an embodiment of the present disclosure, for an SQL statement with a query condition, the end of the query condition can be used as the first insertion position so that the tracking identifier can be used as a new query condition and spliced together with the query condition in the SQL statement as the query condition of the enhanced SQL statement.
[0108] According to the SQL statement without query conditions, the tracking identifier can be constructed as a query condition, and the query condition can be used as the query condition of the enhanced SQL statement.
[0109] The embodiments of the present disclosure optimize the insertion position and insertion conditions for SQL statements belonging to DQL by judging the query conditions, so as to minimize the insertion code and reduce the impact on the business database code.
[0110] According to an embodiment of the present disclosure, a tracking identifier is inserted into a first insertion position to obtain a first enhanced structured statement, including: when it is determined that a query condition exists in the structured statement, a splicing query condition is generated according to the tracking identifier; and the splicing query condition is inserted into the first insertion position so as to obtain the first enhanced structured statement by splicing.
[0111] According to an embodiment of the present disclosure, inserting the tracking identifier into the first insertion position to obtain a first enhanced structured statement also includes: when it is determined that there is no query condition for the structured statement, generating a target query condition that matches the tracking identifier, wherein the query result of the target query condition is the tracking identifier; and inserting the target query condition into the first insertion position to obtain the first enhanced structured statement.
[0112] According to an embodiment of the present disclosure, if a query condition is determined to exist in an SQL statement, a concatenated query condition is generated to search for the tracking identifier of the SQL statement. If a query condition is determined to not exist in the SQL statement, a target query condition is generated based on the tracking identifier. The concatenated query condition cannot be used as a standalone query condition and must be concatenated with the query condition in the SQL statement to produce a correct enhanced SQL statement. The target query condition can be used as a standalone query condition.
[0113] For example, if the SQL statement contains a query condition, using the query condition "Query users in the Shanghai area" as an example, the SQL statement can be "...WHERE area=1...". "WHERE area=1" represents the query condition, and the rest is the other code of the SQL statement. The TraceID determined based on the SQL statement context information is "xxxx0001e2000".
[0114] Thus, the spliced query condition generated according to the trace identifier is “AND'Trace ID'='xxxx0001e2000'”. Inserting the spliced query condition into the first insertion position, the first enhanced structured statement obtained by splicing can be “…WHERE area=1AND'Trace ID'='xxxx0001e2000'…”.
[0115] Alternatively, if it is determined that the SQL statement does not contain a query condition, the target query condition generated to match the trace identifier is "WHERE 'Trace ID' = 'xxxx0001e2000'". The concatenated query condition is inserted into the first insertion position, and the first enhanced structured statement obtained by concatenation may be "...WHERE 'Trace ID' = 'xxxx0001e2000'..."
[0116] In the embodiments of the present disclosure, since the tracking identifier is already used as the query result of the concatenated query condition or target query condition when generating the concatenated query condition or target query condition, the first enhanced structured statement obtained by inserting the concatenated query condition or target query condition into the first insertion position can obtain the tracking identifier without executing the concatenated query condition or target condition. Therefore, the enhanced SQL statement with the tracking identifier inserted can still run normally without executing the actual tracking identifier query operation, thus avoiding affecting the actual call efficiency of the database service.
[0117] According to an embodiment of the present disclosure, for a SQL statement whose processing type is DML, a tracking identifier is inserted into a second insertion position to obtain a second enhanced structured statement, including: inserting the tracking identifier into the second insertion position in the form of a comment to obtain the second enhanced structured statement.
[0118] According to an embodiment of the present disclosure, the second insertion position includes after a special character string used to characterize a processing type of an SQL statement.
[0119] For example, for an SQL statement used to perform an update operation, the SQL statement can be "UPDATE...", where "UPDATE" is a special string. For an SQL statement used to perform an insert operation, the SQL statement can be "INSERT INTO...", where "INSERT INTO" is a special string. For an SQL statement used to perform a delete operation, the SQL statement can be "DELETE FROM...", where "DELETE FROM" is a special string. The second insertion position can be after "UPDATE", "INSERT INTO", or "DELETE FROM".
[0120] According to an embodiment of the present disclosure, the tracking character can be inserted in a comment manner supported by the business database, for example, the tracking mark can be inserted in a comment " / *...* / ".
[0121] For example, still taking the tracking identifier as "xxxx0001e2000", the SQL statement can be "UPDATE..." or "INSERT INTO..." or "DELETE FROM...". After inserting the tracking identifier into the second insertion position, the enhanced SQL statement obtained is "UPDATE / *xxxx0001e2000* / ..." or "INSERT INTO / *xxxx0001e2000* / ..." or "DELETEFROM / *xxxx0001e2000* / ...".
[0122] According to the embodiments of the present disclosure, for DML, since the length of the SQL statement is related to the actual storage path of the data table, field, etc., taking into account the differences in compilation capabilities of different developers, if the tracking identifier is inserted according to the DQL insertion method, the developer cannot intuitively and accurately determine the association between the inserted tracking identifier and the SQL statement. In the case where it is impossible to intuitively and accurately determine the association between the inserted tracking identifier and the SQL statement, it is easy to misjudge the relationship between the SQL statement and the tracking identifier, which will lead to the subsequent positioning of the wrong business site or database service, further resulting in low efficiency and low accuracy of subsequent abnormal positioning.
[0123] Regarding the writing logic of SQL statements, in SQL statements, since the special characters or special character strings that represent the processing type of SQL statements are very intuitive, clear and unambiguous, determining the second insertion position after the special characters or special character strings used to represent the processing type of SQL statements can effectively avoid incorrectly determining the relationship between the SQL statement and the tracking identifier, improve the accuracy of subsequent exception location, and eliminate the need for rework and reconfirmation, which further improves the efficiency of exception location.
[0124] According to an embodiment of the present disclosure, after the second insertion position is determined to be a special character or a special string, in order to ensure that the normal operation of the SQL statement is not affected and irrelevant execution code is not inserted, the tracking identifier can be inserted into the second insertion position in the form of a comment to obtain a second enhanced structured statement.
[0125] Figure 4 The flowchart of generating a first enhanced structured statement or a second enhanced structured statement according to a processing type of a structured statement according to a specific embodiment of the present disclosure is schematically shown.
[0126] like Figure 4 As shown, the flowchart 400 for generating a first enhanced structured statement or a second enhanced structured statement according to a processing type of a structured statement includes operations S401 to S410.
[0127] In operation S401, the processing type of the structured statement is determined. Specifically, if the processing type of the structured statement is determined to be a query-type structured statement, the process proceeds to operation S402; if the processing type of the structured statement is determined to be an operation-type structured statement, the process proceeds to operation S409.
[0128] In operation S402, it is determined whether a query condition exists. Specifically, if the SQL statement has a query condition, the process proceeds to operation S403; if the SQL statement does not have a query condition, the process proceeds to operation S406.
[0129] In operation S403 , the end of the query condition is determined as the first insertion position.
[0130] In operation S404 , a splicing query condition is generated according to the tracking identifier.
[0131] In operation S405 , the concatenated query condition is inserted into the first insertion position, so as to obtain a first enhanced structured statement by concatenation.
[0132] In operation S406 , the end of the structured statement is determined as the first insertion position.
[0133] In operation S407 , a target query condition matching the tracking identifier is generated.
[0134] In operation S408 , the target query condition is inserted into the first insertion position to obtain a first enhanced structured statement.
[0135] In operation S409 , the end of the structured statement is determined as the second insertion position.
[0136] In operation S410 , a tracking marker is inserted into a second insertion position in the form of a comment to obtain a second enhanced structured statement.
[0137] As another specific embodiment, in order to reduce the space occupied by non-business codes in the business database, when the processing type is determined to be a query-type structured statement, the position after the special string used to characterize the processing type of the SQL statement can be determined as the first insertion position, and the tracking identifier can be inserted into the first insertion position in the form of a comment to obtain the first enhanced structured statement.
[0138] According to an embodiment of the present disclosure, for an SQL statement belonging to the DQL processing type, the SQL statement may be “SELECT…”, where “SELECT” is a special character string.
[0139] According to an embodiment of the present disclosure, determining the processing type of a structured statement includes: when it is determined that the start of the structured statement is a first string, determining the processing type as a query-type structured statement, wherein the first string represents a selection operation; when it is determined that the start of the structured statement is a second string, a third string, or a fourth string, determining the processing type as an operation-type structured statement, wherein the second string represents an insert operation, the third string represents an update operation, and the fourth string represents a delete operation.
[0140] According to an embodiment of the present disclosure, the first character string, the second character string, the third character string, and the fourth character string may all be understood as special character strings, used to represent a processing type and a specific processing operation.
[0141] For example, the first string represents a selection operation and may be "SELECT"; the second string represents an insert operation and may be "INSERT INTO"; the third string represents an update operation and may be "UPDATE"; and the fourth string represents a delete operation and may be "DELETE FROM".
[0142] According to an embodiment of the present disclosure, before determining a tracking identifier associated with a structured statement for calling a database service, the method includes: intercepting the structured statement through aspect interception based on an interceptor in a business system program framework.
[0143] According to an embodiment of the present disclosure, the interceptor can intercept method calls of the business layer through aspect-oriented programming (AOP). For database service call scenarios, the interceptor can intercept structured statements.
[0144] According to an embodiment of the present disclosure, aspect interception can be achieved by configuring or rewriting the calling method in the aspect class.
[0145] In the embodiment of the present disclosure, an interceptor based on the application framework can implement the operation of adding a tracking identifier without inserting code unrelated to the business, thereby reducing the development cost and maintenance cost of the business database code.
[0146] Figure 5 The flowchart of generating a database operation log during a service call process according to an embodiment of the present disclosure is schematically shown.
[0147] In operation S501 , in response to receiving a service call request, the service call request is converted into a structured statement.
[0148] Specifically, the business system may receive a service call request for invoking a database service, and then convert the service call request into an SQL statement so as to implement the invocation of the MySQL database service by executing the SQL statement.
[0149] In operation S502 , the structured statement is intercepted by aspect interception based on the interceptor in the business system program framework.
[0150] Specifically, through the AOP aspect interception method, when the business system is driven by the database, the SQL statement to be executed is intercepted by the interceptor.
[0151] In operation S503 , a tracing identifier is determined from the call link tracing context information.
[0152] Specifically, the interceptor obtains the Trace ID from the call link tracing context through the tool method provided by the toolkit of the database monitoring system.
[0153] In operation S504, the processing type of the structured statement is determined. Specifically, if the processing type of the structured statement is determined to be a query-type structured statement, the process proceeds to operation S505. If the processing type of the structured statement is determined to be an operation-type structured statement, the process proceeds to operation S506.
[0154] In operation S505, query conditions are dynamically spliced. Specifically, by determining whether the structured statement includes a query condition, a spliced query condition or a target query condition is generated; and then the spliced query condition or the target query condition is dynamically spliced with the SQL statement.
[0155] In operation S506 , a tracking identifier is inserted through annotation.
[0156] In operation S507 , the enhanced structured statement is executed.
[0157] In operation S508 , a database operation log is generated.
[0158] The disclosed embodiments innovatively embed the trace ID (TraceID) into the SQL statement to be executed through an interceptor exposed by the business system program framework. This automatically embeds the TraceID, representing the link information, into the database service through the execution of the SQL statement. For query-type SQL statements, the TraceID is automatically incorporated by splicing the "where" condition; for operational SQL statements, the TraceID is incorporated using comments. This reduces the amount of non-business code in the business database, lowering development and maintenance costs.
[0159] Figure 6 The flowchart of the abnormality locating method according to the embodiment of the present disclosure is schematically shown.
[0160] like Figure 6 As shown, the flowchart 600 of the abnormality locating method includes operations S610 to S620.
[0161] In operation S610 , in response to determining that the database service call is abnormal, a database operation log is obtained, wherein the database operation log is determined according to the above-mentioned database operation log generation method.
[0162] In operation S620 , the abnormal structured statement and the tracking identifier of the abnormal structured statement in the abnormal service are simultaneously located according to the database operation log.
[0163] According to an embodiment of the present disclosure, determining a database service call anomaly includes: detecting execution times of multiple database services, determining a database service with an execution time exceeding a predetermined threshold as a database service with an abnormal call, and obtaining a database operation log of the database service with the abnormal call.
[0164] According to an embodiment of the present disclosure, determining that a database service call is abnormal further includes: determining the database service call that is abnormal in response to an operation of a database administrator (DBA) on the database service.
[0165] According to an embodiment of the present disclosure, since the database operation log includes execution requests of multiple SQL statements and a tracing identifier associated with each SQL statement, based on the database operation log, while locating the SQL statement that caused the exception, the tracing identifier of the abnormal SQL statement can also be located.
[0166] In related technologies, when detecting database service anomalies, a database monitoring system analyzes and queries the abnormal database service to identify the SQL statement that caused the anomaly. The database monitoring system then sends the identified abnormal SQL statement to the business system, which then determines the TraceID of the abnormal SQL statement from a reserved operation log table based on normal SQL statements.
[0167] Based on the above solution, since the database monitoring system and the business system belong to different systems, the data between the two systems are not unified. Therefore, the above process involves data interaction between the two systems, and also involves two operations: "querying abnormal SQL statements" and "querying the TraceID of abnormal SQL statements", resulting in low efficiency in abnormal location.
[0168] In the disclosed embodiments, since the database operation log includes multiple SQL statements and the TraceID associated with each SQL statement, when determining a database service call anomaly, both the abnormal SQL statement and the TraceID can be determined simultaneously by simply querying the abnormal SQL statement once, simplifying the query operation and improving the efficiency of anomaly location. Furthermore, since the database operation log includes both abnormal SQL statements and TraceIDs, the operations of locating abnormal SQL statements and TraceIDs can be implemented by a single system, eliminating the need for data exchange and further improving the efficiency of anomaly location.
[0169] In addition, since the database operation log determines multiple insertion positions and insertion methods for SQL statements of different processing types, the TraceID related to the abnormal SQL statement can be intuitively and accurately determined in the database operation log, which can reduce the error rate of abnormal location.
[0170] For example, the above-mentioned exception location method can be executed by a database monitoring system, such as Application Performance Management (APM). When the database monitoring system detects a slow SQL statement that causes a database service call exception, the tracking mark can be intuitively seen, breaking through the data barrier between the business system including multiple business databases and the database monitoring system, and realizing the SQL statement tracking of slow database operations in the business system.
[0171] Alternatively, the above-mentioned exception locating method may also be executed by a business system. For example, a monitoring module may be configured in the business system, and the monitoring module may detect slow SQL statements that cause database service call exceptions.
[0172] Figure 7 The structural block diagram of the database operation log generating device according to an embodiment of the present disclosure is schematically shown.
[0173] like Figure 7 As shown, the database operation log generating device 700 of this embodiment includes an identification determination module 710 , a type determination module 720 , an execution module 730 and a generation module 740 .
[0174] Identification determination module 710 is configured to determine a tracking identifier associated with a structured statement used to invoke a database service, wherein the structured statement is determined based on the service invocation request. In one embodiment, identification determination module 710 may be configured to perform operation S210 described above, and further description thereof will not be given here.
[0175] The type determination module 720 is used to determine the processing type of the structured statement. In one embodiment, the type determination module 720 can be used to perform the operation S220 described above, which will not be described in detail here.
[0176] The execution module 730 is used to execute the execution logic matching the processing type to update the tracking identifier into the structured statement to obtain the enhanced structured statement. In one embodiment, the execution module 730 can be used to execute the operation S230 described above, which will not be repeated here.
[0177] The generating module 740 is configured to generate a database operation log for the database service according to the enhanced structured statement. In one embodiment, the generating module 740 can be configured to execute the operation S240 described above, which will not be described in detail here.
[0178] According to an embodiment of the present disclosure, the execution module 730 includes a location determination module, a first insertion module, and a second insertion module.
[0179] When the processing type is determined to be a query-type structured statement, the position determination module is configured to determine a first insertion position according to the query condition of the structured statement. The first insertion module is configured to insert a tracking marker into the first insertion position to obtain a first enhanced structured statement.
[0180] The second inserting module is used to insert the tracking identifier into the second inserting position to obtain a second enhanced structured statement when determining that the processing type is an operation-type structured statement.
[0181] According to an embodiment of the present disclosure, a position determination module includes a first position determination unit and a second position determination unit.
[0182] The first position determining unit is configured to, when it is determined that the structured statement has a query condition, determine the end of the query condition as the first insertion position.
[0183] The second position determining unit is configured to determine the end of the structured query statement as the first insertion position when it is determined that the structured query statement does not have a query condition.
[0184] According to an embodiment of the present disclosure, the first insertion module includes a first generation unit and a first insertion unit.
[0185] The first generating unit is configured to generate a splicing query condition according to the tracking identifier.
[0186] The first inserting unit is used to insert the splicing query condition into the first inserting position, so as to obtain a first enhanced structured statement by splicing.
[0187] According to an embodiment of the present disclosure, the first insertion module further includes a second generating unit and a second inserting unit.
[0188] The second generating unit is configured to generate a target query condition that matches the tracking identifier, wherein a query result of the target query condition is the tracking identifier.
[0189] The second insertion unit is used to insert the target query condition into the first insertion position to obtain a first enhanced structured statement.
[0190] According to an embodiment of the present disclosure, the second insertion module includes a third insertion unit, which is used to insert the tracking identifier into the second insertion position in the form of a comment to obtain a second enhanced structured statement.
[0191] According to an embodiment of the present disclosure, the type determination module 720 includes a first determination unit and a second determination unit.
[0192] The first determining unit is configured to determine the processing type as a query-type structured statement when it is determined that the beginning of the structured statement is a first character string, wherein the first character string represents a selection operation.
[0193] The second determination unit is used to determine the processing type as an operation-type structured statement when it is determined that the start of the structured statement is a second string, a third string, or a fourth string, wherein the second string represents an insert operation, the third string represents an update operation, and the fourth string represents a delete operation.
[0194] According to an embodiment of the present disclosure, the database operation log generating device 700 further includes an interception module.
[0195] The interception module is used to intercept the structured statement by means of aspect interception based on the interceptor in the business system program framework before determining the tracking identifier associated with the structured statement according to the structured statement for calling the database service.
[0196] According to an embodiment of the present disclosure, any multiple modules among the identification determination module 710, the type determination module 720, the execution module 730, and the generation module 740 can be combined into a single module for implementation, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module.
[0197] According to an embodiment of the present disclosure, at least one of the identification determination module 710, the type determination module 720, the execution module 730, and the generation module 740 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in any one of the three implementation methods of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, at least one of the identification determination module 710, the type determination module 720, the execution module 730, and the generation module 740 can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is executed.
[0198] Figure 8 The structural block diagram of the abnormality locating device according to an embodiment of the present disclosure is schematically shown.
[0199] like Figure 8 As shown, the abnormality locating device 800 of this embodiment includes an acquisition module 810 and a locating module 820 .
[0200] The acquisition module 810 is configured to acquire a database operation log in response to determining that the database service call is abnormal, wherein the database operation log is generated according to the above-mentioned database operation log generation method. In one embodiment, the acquisition module 810 can be used to perform the operation S610 described above, which will not be repeated here.
[0201] The positioning module 820 is used to simultaneously locate the abnormal structured statement and the tracking identifier of the abnormal structured statement in the abnormal service according to the database operation log. In one embodiment, the positioning module 820 can be used to perform the operation S620 described above, which will not be repeated here.
[0202] According to an embodiment of the present disclosure, any multiple modules in the acquisition module 810 and the positioning module 820 can be combined into a single module, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module.
[0203] According to an embodiment of the present disclosure, at least one of the acquisition module 810 and the positioning module 820 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable manner of integrating or packaging circuits, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, at least one of the acquisition module 810 and the positioning module 820 can be at least partially implemented as a computer program module, which can perform the corresponding function when executed.
[0204] Figure 9 A block diagram of an electronic device suitable for the database operation log generation method and the abnormality locating method according to an embodiment of the present disclosure is schematically shown.
[0205] like Figure 9 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may, for example, include a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0206] Various programs and data required for the operation of the electronic device 900 are stored in the RAM 903. The processor 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. The processor 901 executes the various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 902 and / or the RAM 903. It should be noted that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also execute the various operations of the method flow according to the embodiment of the present disclosure by executing the programs stored in the one or more memories.
[0207] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage portion 908 including a hard disk; and a communication portion 909 including a network interface card such as a LAN card or a modem. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 910 as needed, so that computer programs read therefrom can be installed into the storage portion 908 as needed.
[0208] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when executed, implements the method according to the embodiments of the present disclosure.
[0209] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0210] The embodiments of the present disclosure also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the above-mentioned method provided in the embodiments of the present disclosure.
[0211] The computer program executes the above functions defined in the system / device of the embodiment of the present disclosure when the processor 901 executes the computer program. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0212] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0213] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from a removable medium 911. When the computer program is executed by the processor 901, the above-described functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0214] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).
[0215] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0216] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways, even if such combinations and / or couplings are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or couplings are intended to fall within the scope of this disclosure.
[0217] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present disclosure. It should be understood that the above are only specific embodiments of the present disclosure and are not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. A method for generating a database operation log, comprising: Determining, based on a structured statement for invoking a database service, a tracking identifier associated with the structured statement, wherein the structured statement is determined based on a service invocation request; Determining a processing type of the structured statement, the processing type including a query-type structured statement; executing execution logic matching the processing type to update the tracking identifier into the structured statement to obtain an enhanced structured statement; and generating a database operation log for the database service according to the enhanced structured statement; The executing logic matching the processing type so as to update the tracking identifier into the structured statement to obtain an enhanced structured statement includes: When it is determined that the processing type is a query-type structured statement and the structured statement contains a query condition, determining the end of the query condition as the first insertion position; In the case where it is determined that the structured statement does not have a query condition, determining the end of the structured statement as the first insertion position; Insert the tracking identifier into the first insertion position to obtain a first enhanced structured sentence.
2. The method according to claim 1, wherein The processing type includes an operation-type structured statement; The executing logic matching the processing type so as to update the tracking identifier into the structured statement to obtain an enhanced structured statement includes: When it is determined that the processing type is an operation-type structured statement, the tracking identifier is inserted into the second insertion position to obtain a second enhanced structured statement.
3. The method according to claim 1, wherein Inserting the tracking identifier into the first insertion position to obtain a first enhanced structured statement includes: if it is determined that the structured statement has a query condition, Generating a splicing query condition according to the tracking identifier; and The concatenated query condition is inserted into the first insertion position to obtain the first enhanced structured statement through concatenation.
4. The method according to claim 1, wherein The step of inserting the tracking identifier into the first insertion position to obtain a first enhanced structured statement further includes: if it is determined that the structured statement does not have a query condition, generating a target query condition that matches the tracking identifier, wherein a query result of the target query condition is the tracking identifier; and The target query condition is inserted into the first insertion position to obtain the first enhanced structured statement.
5. The method according to claim 2, wherein: Inserting the tracking mark into the second insertion position to obtain a second enhanced structured sentence, including: The tracking identifier is inserted into the second insertion position in the form of a comment to obtain the second enhanced structured statement.
6. The method according to claim 1, wherein Determining the processing type of the structured statement includes: In the case where it is determined that the structured statement starts with a first character string, the processing type is determined to be a query-type structured statement, wherein the first character string represents a selection operation; When it is determined that the start of the structured statement is the second character string, the third character string or the fourth character string, the processing type is determined as an operation-type structured statement, wherein the second character string represents an insert operation, the third character string represents an update operation, and the fourth character string represents a delete operation.
7. The method according to claim 1, wherein Before determining a tracking identifier associated with a structured statement for invoking a database service, the method includes: Based on the interceptor in the business system program framework, the structured statement is intercepted by means of aspect interception.
8. A method for locating an anomaly, comprising: In response to determining that the database service call is abnormal, obtaining a database operation log, wherein the database operation log is generated according to the method according to any one of claims 1 to 7; and According to the database operation log, the abnormal structured statement in the abnormal service and the tracking identifier of the abnormal structured statement are simultaneously located.
9. A database operation log generating device, comprising: an identifier determination module, configured to determine a tracking identifier associated with a structured statement for invoking a database service, wherein the structured statement is determined based on a service invocation request; A type determination module, configured to determine a processing type of the structured statement, wherein the processing type includes a query-type structured statement; an execution module, configured to execute execution logic matching the processing type, so as to update the tracking identifier into the structured statement to obtain an enhanced structured statement; and A generating module, configured to generate a database operation log for the database service according to the enhanced structured statement; The execution module is further configured to: When it is determined that the processing type is a query-type structured statement and the structured statement contains a query condition, determining the end of the query condition as the first insertion position; In the case where it is determined that the structured statement does not have a query condition, determining the end of the structured statement as the first insertion position; Insert the tracking identifier into the first insertion position to obtain a first enhanced structured sentence.
10. An abnormality locating device comprising: an acquisition module, configured to acquire a database operation log in response to determining that the database service call is abnormal, wherein the database operation log is generated according to the method according to any one of claims 1 to 7; and The exception locating module is used to locate the abnormal structured statement and the tracking identifier of the abnormal structured statement in the abnormal service according to the database operation log.
11. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to execute the method according to any one of claims 1 to 8.
12. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to perform the method according to any one of claims 1 to 8.
13. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method and device for recording operation log, electronic equipment and storage medium
CN111241125A