CN114461659A - Searching and killing method and device, computer equipment and storage medium - Google Patents

Searching and killing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114461659A
CN114461659A CN202210193030.3A CN202210193030A CN114461659A CN 114461659 A CN114461659 A CN 114461659A CN 202210193030 A CN202210193030 A CN 202210193030A CN 114461659 A CN114461659 A CN 114461659A
Authority
CN
China
Prior art keywords
transaction
killing
searching
preset
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210193030.3A
Other languages
Chinese (zh)
Inventor
樊一兵
高天源
袁铭阳
刘运璇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210193030.3A priority Critical patent/CN114461659A/en
Publication of CN114461659A publication Critical patent/CN114461659A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2393Updating materialised views
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a searching and killing method, a searching and killing device, computer equipment, a storage medium and a computer program product, relates to the technical field of artificial intelligence, and can be used in the field of financial science and technology or other related fields. The method comprises the following steps: traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions; generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information; and searching and killing the affair corresponding to the target affair operation information on the database server based on the searching and killing statement. The searching and killing method provided by the embodiment can accurately identify the large affairs and timely search and kill the affairs, reduces the workload of manually maintaining the database, and improves the reliability and stability of the production and operation of the database.

Description

Searching and killing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of database technologies, and in particular, to a searching and killing method, apparatus, computer device, and storage medium.
Background
A transaction (transaction) is a sequence of database operations that includes database access operations as well as various other database operations. These operations are either all executed or all not executed, and are an integral unit of work.
In the related art, a transaction that has an excessively long execution time and returns a large execution result in a database is referred to as a large transaction. The operation of a large transaction may occupy resources such as a Central Processing Unit (CPU), a memory, and a disk of the database system for a long time, which may cause database congestion and affect the performance of the database. Therefore, how to kill large running transactions in the database is a problem to be solved urgently.
Disclosure of Invention
In view of the above, it is necessary to provide a searching and killing method, device, computer readable storage medium and computer program product capable of searching and killing large transactions in a database server in time.
In a first aspect, the present application provides a method for killing a virus. The method comprises the following steps:
traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions;
generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statement.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number;
the traversing of the operation information of each transaction in the preset background table and the determining of the operation information of the target transaction meeting the preset checking and killing conditions comprise the following steps:
determining the transaction operation information with the transaction execution time exceeding a preset time threshold value as target transaction operation information meeting preset checking and killing conditions;
or, determining the transaction operation information of which the operation updating line number exceeds the preset number threshold as the target transaction operation information meeting the preset checking and killing condition.
In one embodiment, the transaction execution information comprises transaction execution time and operation update line number; the method further comprises the following steps:
every other preset time interval, aiming at each transaction in the preset background table, removing the transaction with the transaction execution time at the current moment being the same as the transaction execution time at the previous moment;
and/or; and eliminating the affairs with the same operation updating line number at the current moment as the operation updating line number at the previous moment.
In one embodiment, the method further comprises:
acquiring multiple items of operation index information of a database server corresponding to the session identification information according to the session identification information corresponding to the target transaction operation information;
inputting the multiple pieces of operation index information into a preset searching and killing judgment algorithm to obtain searching and killing judgment results;
and under the condition that the searching and killing judgment result meets a preset searching and killing feasibility condition, executing the step of generating searching and killing statements according to the session identification information corresponding to the target transaction operation information.
In one embodiment, after the step of killing the transaction corresponding to the target transaction running information on the database server based on the killing statement, the method further includes:
and sending the searching and killing completion notification information to the operation and maintenance terminal corresponding to the affair corresponding to the target affair operation information.
In one embodiment, the method further comprises:
periodically accessing the database server at intervals of a preset time interval, and acquiring transaction operation information based on a system view of the database server and transaction identifiers in the preset background table, wherein the transaction operation information comprises transaction identifier information, operation time consumption information and operation updating line number information;
and storing the transaction operation information to a preset background table, wherein the transaction comprises at least one database operation.
In one embodiment, the transaction execution information further includes a transaction execution time, and the method further includes:
acquiring a target session identifier from a preset session identifier table;
judging whether a target transaction identifier corresponding to the target session identifier exists in the preset background table or not;
if the target transaction identifier exists in the preset background table, updating the transaction execution time of the transaction corresponding to the target transaction identifier according to the operation time consumption information corresponding to the target transaction identifier;
and if the target transaction identifier does not exist in the preset background table, inserting the target transaction identifier into the preset background table.
In a second aspect, the application also provides a searching and killing device. The device comprises:
the first determining module is used for traversing each transaction operation information in the preset background table and determining target transaction operation information meeting preset checking and killing conditions;
the generating module is used for generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and the searching and killing module is used for searching and killing the affair corresponding to the target affair operation information on the database server based on the searching and killing statement.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number;
the first determining module is specifically configured to:
determining the transaction operation information with the transaction execution time exceeding a preset time threshold value as target transaction operation information meeting preset checking and killing conditions;
or, determining the transaction operation information of which the operation updating line number exceeds the preset number threshold as the target transaction operation information meeting the preset checking and killing condition.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number; the device comprises:
the first removing module is used for removing the affairs with the same affair execution time at the current moment and the affair execution time at the last moment aiming at each affair in the preset background table at intervals of preset time;
a second eliminating module for eliminating; and eliminating the affairs with the same operation updating line number at the current moment as the operation updating line number at the previous moment.
In one embodiment, the apparatus further comprises:
the first acquisition module is used for acquiring a plurality of items of operation index information of the database server corresponding to the session identification information according to the session identification information corresponding to the target transaction operation information;
the first judgment module is used for inputting the multiple items of operation index information into a preset searching and killing judgment algorithm to obtain a searching and killing judgment result;
and the execution module is used for executing the step of generating the searching and killing statement according to the session identification information corresponding to the target transaction operation information under the condition that the searching and killing judgment result meets the preset searching and killing feasibility condition.
In one embodiment, the apparatus further comprises:
and the sending module is used for sending the searching and killing completion notification information to the operation and maintenance terminal corresponding to the affair corresponding to the target affair operation information.
In one embodiment, the apparatus further comprises:
the second acquisition module is used for periodically accessing the database server at preset time intervals, and acquiring transaction operation information based on a system view of the database server and the transaction identifier in the preset background table, wherein the transaction operation information comprises transaction identifier information, operation time consumption information and operation updating line number information;
and the storage module is used for storing the transaction operation information to a preset background table, wherein the transaction comprises at least one database operation.
In one embodiment, the transaction execution information further includes a transaction execution time, and the apparatus further includes:
the third acquisition module is used for acquiring the target session identifier from a preset session identifier table;
the second judgment module is used for judging whether a target transaction identifier corresponding to the target session identifier exists in the preset background table or not;
the updating module is used for updating the transaction execution time of the transaction corresponding to the target transaction identifier according to the operation time consumption information corresponding to the target transaction identifier if the target transaction identifier exists in the preset background table;
and the inserting module is used for inserting the target transaction identifier into the preset background table if the target transaction identifier does not exist in the preset background table.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the following steps when executing the computer program:
traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions;
generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statement.
In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions;
generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statement.
In a fifth aspect, the present application further provides a computer program product. The computer program product comprising a computer program which when executed by a processor performs the steps of:
traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions;
generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statement.
According to the searching and killing method, the searching and killing device, the computer equipment, the storage medium and the computer program product, the target transaction operation information meeting the preset searching and killing conditions is determined by traversing each transaction operation information in the preset background table; generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information; and searching and killing the affair corresponding to the target affair operation information on the database server based on the searching and killing statement. The searching and killing method provided by the embodiment can accurately identify the large affairs and timely search and kill the affairs, reduces the workload of manually maintaining the database, and improves the reliability and stability of the production and operation of the database.
Drawings
FIG. 1 is a diagram of an exemplary embodiment of a searching and killing method;
FIG. 2 is a schematic flow chart of a killing method according to an embodiment;
FIG. 3 is a flow diagram that illustrates the steps of determining target transaction run information in one embodiment;
FIG. 4 is a flow diagram that illustrates the step of culling transactions in one embodiment;
FIG. 5 is a flowchart illustrating the steps of generating a killer statement in one embodiment;
FIG. 6 is a flowchart illustrating steps of generating a preset background table in one embodiment;
FIG. 7 is a flowchart illustrating the step of X determining whether a target transaction identifier exists in one embodiment;
FIG. 8 is a block diagram of an exemplary embodiment of a killing device;
FIG. 9 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The searching and killing method provided by the embodiment of the application can be applied to the application environment shown in fig. 1. Wherein the monitoring server 102 communicates with the database server 104 over a network. The data storage system may store data that the database server 104 needs to process. The data storage system may be integrated on the database server 104, or may be located on the cloud or other network server. The monitoring server 102 obtains and stores information related to various database operations on the database server 104. The monitoring server 102 performs checking and killing on the target transaction in the database server 104 based on the acquired information to ensure the operation performance of the database server 104. The monitoring server 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, and the like. Database server 104 may be implemented as a stand-alone database server or as a server cluster of multiple servers. That is, the monitoring server 102 and the database server 104 may be in a one-to-n relationship.
In an embodiment, as shown in fig. 2, a searching and killing method is provided, which is exemplified by applying the searching and killing method to a monitoring server, and the searching and killing method includes the following steps:
step 202, traversing each transaction operation information in the preset background table, and determining target transaction operation information meeting preset checking and killing conditions.
Specifically, the preset background table is a data table stored in the monitoring server, the preset background table stores records of transaction operation information of each transaction, the transaction is a sequence including a plurality of database operations, and the monitoring server and the database (database server) are in a one-to-many relationship. The specific implementation manner of each database operation executed on the database server may be an SQL statement, and after the database operation is executed by the SQL statement, the execution result corresponding to the database operation is obtained, that is, what kind of operation (such as addition, deletion, and check, etc.) is actually performed on the database server. The transaction may be session-induced.
Thus, the information stored in each record stored in the preset background table may include a session identifier (transaction identifier), time consumption information, transaction execution time information, operation update line number information, database server address information for performing the database operation, and the like. The preset searching and killing condition may be a screening condition determined by the monitoring server according to actual requirements of an actual application scene. For example, the predetermined killing condition may be that the number of operation update lines is greater than or equal to a predetermined number threshold.
In this way, the monitoring server traverses the transaction operation information in the preset background table, that is, the monitoring server screens the transaction operation information in the preset background table, and determines the target transaction operation information which satisfies the operation update line number information and satisfies the preset checking and killing conditions.
And step 204, generating a killing statement according to the session identification information corresponding to the target transaction operation information.
In particular, the transaction is session-induced, that is, the session identification (session id) is the same as the identification of the transaction that the session is inducing. For a transaction, the id of the transaction is the id of the session that caused the transaction. In this embodiment, after the monitoring server screens out the target transaction operation information that meets the preset checking and killing condition, that is, the transaction id corresponding to the target transaction operation information may be determined. Thus, the monitoring server can generate the killing statement according to the session identification information and the initial killing process SQL statement.
And step 206, searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statements.
Specifically, the monitoring server accesses the database server through the database server address information carried in the target transaction operation information. And based on the searching and killing statement, searching and killing the affair corresponding to the target affair operation information when accessing the database server. The kill statement may be a kill session statement. That is to say, the monitoring server may directly push the kill session statement to the database server corresponding to the target transaction operation information based on the database server address information.
In the searching and killing method, the target transaction operation information meeting the preset searching and killing condition is determined by traversing each transaction operation information in the preset background table. And generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information. And searching and killing the affair corresponding to the target affair operation information on the database server based on the searching and killing statement. The searching and killing method provided by the embodiment can accurately identify the large affairs and timely search and kill the affairs, reduces the workload of manually maintaining the database, and improves the reliability and stability of the production and operation of the database.
In one embodiment, the transaction execution information includes a transaction execution time, which is the time the transaction has executed, i.e., the length of time the transaction has been executed, and an operation update line number. The monitoring server may update the transaction execution time according to the acquired time consumption information, and specifically, the time consumption information of the transaction may be extracted through a last _ call _ et field of the transaction (v $ session). The operation update line number represents the number of database operation results that have been returned by each database operation included in the transaction, one database operation corresponding to one database operation result.
Correspondingly, as shown in fig. 3, the specific processing procedure of step 202 "traversing each transaction operation information in the preset background table, and determining the target transaction operation information meeting the preset checking and killing condition" includes:
step 302, determining the transaction operation information with the transaction execution time exceeding the preset time threshold as the target transaction operation information meeting the preset checking and killing condition.
Specifically, the preset time threshold may be a search parameter corresponding to the transaction execution time, and the specific value of the preset time threshold may be determined according to tolerance of different database servers to the operation time of each transaction. The monitoring server may search for each transaction operation information in the preset background table through a select search statement, that is, search for the transaction operation information greater than or equal to a search parameter (preset time threshold), and determine the transaction operation information whose transaction execution time exceeds the preset time threshold as the target transaction operation information meeting the preset killing condition.
And step 304, determining the transaction operation information with the operation updating line number exceeding a preset number threshold as the target transaction operation information meeting preset checking and killing conditions.
Specifically, the preset number threshold may be a lookup parameter corresponding to the operation update line number, and a specific value of the preset number threshold may be determined according to tolerance of different database servers to each operation update line number. The monitoring server may search for each transaction operation information in the preset background table through a select search statement, that is, search for the transaction operation information greater than or equal to a search parameter (preset number threshold), and determine the transaction operation information with the operation update line number exceeding the preset number threshold as the target transaction operation information meeting the preset killing condition.
In a possible implementation manner, the monitoring server may execute step 302 or execute step 304, or execute step 302 and step 304 together, which may be determined by those skilled in the art according to an actual application scenario, and this embodiment does not limit this. The execution sequence of step 302 and step 304 is not distinguished in sequence.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number.
Correspondingly, as shown in fig. 4, the searching and killing method further includes:
step 402, eliminating the transaction with the same transaction execution time at the current moment as the transaction execution time at the previous moment for each transaction in the preset background table at intervals of a preset time interval.
Specifically, the preset time interval may be half an hour or an hour, and the specific time length of the time interval may be specifically determined according to the actual application scenarios of the monitoring server and each database server. The monitoring server screens each transaction contained in the preset background table at preset time intervals (such as half an hour). The monitoring server records the transaction execution time of each transaction in the background table after the sampling period corresponding to the current moment is preset, and the transaction execution time of each transaction in the background table after the last sampling period corresponding to the last moment is preset. The transactions with the same transaction execution time in the adjacent sampling periods are subjected to the elimination processing, that is, the monitoring server performs the elimination processing on the transactions whose transaction execution times do not change (the last _ call _ et field in the session does not increase any more) with the change of the sampling periods, and considers that the transaction execution times of the transactions are not updated any more, that is, the transaction execution ends. That is, the v $ session has no more relevant sessions.
And step 404, eliminating, at preset time intervals, the transactions with the same operation update line number at the current moment as the operation update line number at the previous moment for each transaction in the preset background table.
Specifically, the preset time interval may be half an hour or an hour, and the specific time length of the time interval may be specifically determined according to the actual application scenarios of the monitoring server and each database server. The monitoring server screens each transaction contained in the preset background table at preset time intervals (such as half an hour). The monitoring server records the operation updating line number of each transaction in the background table after the sampling period corresponding to the current moment is preset, and the operation updating line number of each transaction in the background table after the last sampling period adjacent to the sampling period is preset. And (3) removing the transaction with the same operation update line number in the adjacent sampling period, namely, the monitoring server removes the transaction with the operation update line number which does not change along with the change of the sampling period (the last _ call _ et field in session does not increase any more), and considers that the operation update line number of the transaction is not updated any more, and the transaction does not return an execution result any more, namely, the transaction is finished. That is, the v $ session has no more relevant sessions.
In a possible implementation manner, the monitoring server may execute step 402 or execute step 404, or execute step 402 and step 404 together, and those skilled in the art may specifically determine according to an actual application scenario, which is not limited in this embodiment. The execution sequence of the step 402 and the step 404 is not distinguished in sequence.
In one embodiment, as shown in fig. 5, the searching and killing method further includes:
step 502, according to the session identification information corresponding to the target transaction operation information, obtaining multiple items of operation index information of the database server corresponding to the session identification information.
And 504, inputting the multiple items of operation index information into a preset searching and killing judgment algorithm to obtain a searching and killing judgment result.
And 506, under the condition that the searching and killing judgment result meets the preset searching and killing feasibility condition, executing the step of generating searching and killing statements according to the session identification information corresponding to the target transaction operation information.
Specifically, the operation index information may be operation priority information of a transaction corresponding to the target transaction operation information and transaction importance degree information, the monitoring server may input the acquired operation priority information of the transaction to a preset checking and killing judgment algorithm, and a checking and killing result output by the preset checking and killing judgment algorithm may be suggested checking and killing and suggested reserved transaction. If the searching and killing result output by the searching and killing judgment algorithm is the suggested searching and killing, the monitoring server can determine that the searching and killing result meets the condition of the preset searching and killing feasibility, and thus, the monitoring server can execute the step of generating the searching and killing statement according to the session identification information corresponding to the target transaction operation information.
If the searching and killing result output by the searching and killing judgment algorithm is the recommended reserved transaction, the monitoring server may determine that the searching and killing result does not satisfy the condition of the preset searching and killing feasibility, so that the monitoring server may re-execute the step described in step 102, or output the prompt information of the end of traversal.
In one embodiment, after "based on the searching and killing statement, searching and killing the transaction corresponding to the target transaction operation information on the database server" in step 206, the searching and killing method further includes:
and sending the searching and killing completion notification information to the operation and maintenance terminal corresponding to the affair corresponding to the target affair operation information.
Specifically, the monitoring server may perform killing on the transaction corresponding to the target transaction operation information on the database server based on the killing statement. After killing, the monitoring server may automatically generate killing completion notification information, and send the killing completion notification information to the operation and maintenance terminal related to the transaction in an email manner or a syslog manner.
In this embodiment, by sending the searching and killing completion notification information to each operation and maintenance terminal related to the affair, whether the affair of each operation and maintenance terminal is searched and killed or not can be notified in time, the workload of maintenance personnel of the first-line database is reduced, and the stability of production and operation of the database is improved.
In one embodiment, as shown in fig. 6, the method further comprises:
step 602, periodically accessing the database server at preset time intervals, and acquiring transaction operation information based on a system view of the database server and a transaction identifier in a preset background table.
The transaction operation information includes transaction identification information, operation time consumption information, operation update line number information, address information of a database server executing the transaction, identification information of each SQL operation used by each database operation included in the transaction, and the like.
Specifically, the transaction is initiated by the session, and the transaction identification information is determined according to the session identification information, that is, the transaction identification information is the session identification information. The monitoring server can periodically access each database server at preset time intervals, and thus, the monitoring server can acquire the transaction operation information of each transaction on each database server based on the system view (Oracle system view) of each database server.
Optionally, the monitoring server may monitor the operation resource of the database server, and if the monitoring server detects that the operation resource of the database server is less than or equal to the preset operation resource threshold, the monitoring server may access the database server, obtain the transaction operation information based on the system view of the database server and the transaction identifier in the preset background table, and check and kill the transaction based on the transaction operation information.
Step 604, storing the transaction operation information to a preset background table.
Wherein the transaction includes at least one database operation.
Specifically, the preset time interval may be a preset sampling time interval, and the monitoring server periodically accesses the database server, and after the transaction operation information is acquired, may store sampling time point information corresponding to the preset sampling time interval and the transaction operation information acquired in the preset sampling time interval into a preset background table in the monitoring server.
Optionally, a transaction includes at least one database operation, for example, a transaction may include multiple database operations, each of which requires an SQL statement to implement. If any one database operation fails, the transaction corresponding to the database operation fails, the transaction performs state rollback, and the running state of the transaction is restored to the state before the transaction is not executed. That is, the database operations corresponding to the transaction are revoked.
In one embodiment, the transaction execution information further includes a transaction execution time; correspondingly, as shown in fig. 7, the searching and killing method further includes:
step 702, obtain the target session identifier from the preset session identifier table.
Specifically, the preset session identifier table may be predetermined according to an actual application scenario, and the session identifier table includes identifiers of a plurality of sessions and is arranged in sequence. The monitoring server may sequentially obtain a plurality of session identifiers from a preset session identifier table, and the session identifiers are respectively used as target session identifiers.
Step 704, determining whether a target transaction identifier corresponding to the target session identifier exists in the preset background table.
Specifically, if the target session identifier exists in the preset background table, step 706 is executed; if the target session id does not exist in the preset background table, step 708 is performed.
Step 706, if the target transaction identifier exists in the preset background table, updating the transaction execution time of the transaction corresponding to the target transaction identifier according to the operation time consumption information corresponding to the target transaction identifier.
Specifically, the monitoring server may obtain time-consuming information corresponding to the transaction in a last _ call _ et field of the v $ session in the database server, and update the transaction execution time of the transaction according to the time-consuming information.
Optionally, the time consumption information corresponding to the transaction may be a time length for which all database operations in the transaction are executed together, that is, a time length for which the transaction has been executed. In this way, the monitoring server may use the acquired time-consuming information under the transaction identifier as the transaction execution time of the transaction.
Optionally, the time-consuming information corresponding to the transaction may be a sequence including time lengths for which each database operation in the transaction is executed respectively, so that the transaction execution information of the transaction is a sum of the time lengths included in the sequence of the time lengths, that is, the transaction execution time of the transaction is a sum of the running times (operation times) of each database operation included in the transaction, and the monitoring server may update the transaction execution time according to the sum of the running times, that is, the sum of the running times is used as the transaction execution time.
Step 708, if the target transaction identifier does not exist in the preset background table, inserting the target transaction identifier into the preset background table.
Specifically, if the monitoring server does not find the target transaction identifier in the preset background table, it indicates that the monitoring server does not obtain the transaction operation information corresponding to the target transaction identifier on the database server. Therefore, the monitoring server needs to insert the target transaction identification information into a preset background table, so that the monitoring server collects the transaction operation information of the transaction corresponding to the target transaction identification in the next sampling period.
In this embodiment, the transaction execution time of the transaction is updated according to the acquired time-consuming information, so that monitoring and automatic searching and killing of large transactions affecting the performance of the database can be realized, the workload of first-line database maintenance personnel is reduced, and the stability of database production and operation is improved.
The specific implementation process of the searching and killing method is described in detail below with reference to a specific implementation manner:
in the operation process of the database server, the monitoring server periodically accesses the database server (production server), acquires transaction operation information (such as transaction identification, time consumption information, operation updating line number and the like) from a system view (Oracle system view) of the database server, and stores the sampling time point and the transaction operation information in a preset background table of the monitoring server. Wherein, the monitoring server and the production database server are in a 1-to-many relationship.
After each sampling is finished, the monitoring server traverses each transaction operation information in the preset background table, and executes the following processes: if the transaction id already exists, updating the executed time of the transaction through a last _ call _ et field of the v $ session; and if the transaction id does not exist, inserting the transaction id into a preset background table of the monitoring server. Thus, the transaction id that has not been updated in the monitoring server may be checked once at a preset time interval (e.g., one hour), and the records may be deleted. After each sampling period, the transaction execution time in the table is checked to exceed a preset time threshold (e.g., one hour) and the transaction id with the operation update line number greater than a preset number threshold, and a check and kill statement is pushed to the corresponding production database server. Meanwhile, the maintenance personnel are notified using e-mail or syslog protocol or the like.
It should be understood that, although the steps in the flowcharts related to the embodiments are shown in sequence as indicated by the arrows, the steps are not necessarily executed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the above embodiments may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the application also provides a searching and killing device for realizing the searching and killing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the method, so that specific limitations in one or more embodiments of the searching and killing device provided below can be referred to the limitations on the searching and killing method in the above, and details are not described here.
In one embodiment, as shown in fig. 8, there is provided a searching and killing apparatus including: a first determination module 801, a generation module 802, and a killing module 803, wherein:
the first determining module 801 is configured to traverse each transaction operation information in the preset background table, and determine target transaction operation information that meets a preset checking and killing condition.
The generating module 802 is configured to generate a killing statement according to the session identifier information corresponding to the target transaction operation information.
And the searching and killing module 803 is configured to search and kill a transaction corresponding to the target transaction operation information on the database server based on the searching and killing statement.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number;
the first determining module is specifically configured to:
determining the transaction operation information with the transaction execution time exceeding a preset time threshold value as target transaction operation information meeting preset checking and killing conditions;
or, determining the transaction operation information of which the operation updating line number exceeds the preset number threshold as the target transaction operation information meeting the preset checking and killing condition.
In one embodiment, the transaction execution information includes a transaction execution time and an operation update line number; the device comprises:
the first removing module is used for removing the affairs with the same affair execution time at the current moment and the affair execution time at the last moment aiming at each affair in the preset background table at intervals of preset time;
a second eliminating module for eliminating; and eliminating the affairs with the same operation updating line number at the current moment as the operation updating line number at the last moment.
In one embodiment, the apparatus further comprises:
the first acquisition module is used for acquiring a plurality of items of operation index information of the database server corresponding to the session identification information according to the session identification information corresponding to the target transaction operation information;
the first judgment module is used for inputting the multiple items of operation index information into a preset searching and killing judgment algorithm to obtain a searching and killing judgment result;
and the execution module is used for executing the step of generating the searching and killing statement according to the session identification information corresponding to the target transaction operation information under the condition that the searching and killing judgment result meets the preset searching and killing feasibility condition.
In one embodiment, the apparatus further comprises:
and the sending module is used for sending the searching and killing completion notification information to the operation and maintenance terminal corresponding to the affair corresponding to the target affair operation information.
In one embodiment, the apparatus further comprises:
the second acquisition module is used for periodically accessing the database server at preset time intervals, and acquiring transaction operation information based on a system view of the database server and the transaction identifier in the preset background table, wherein the transaction operation information comprises transaction identifier information, operation time consumption information and operation updating line number information;
and the storage module is used for storing the transaction operation information to a preset background table, wherein the transaction comprises at least one database operation.
In one embodiment, the transaction execution information further includes a transaction execution time, and the apparatus further includes:
the third acquisition module is used for acquiring the target session identifier from a preset session identifier table;
the second judgment module is used for judging whether a target transaction identifier corresponding to the target session identifier exists in the preset background table or not;
the updating module is used for updating the transaction execution time of the transaction corresponding to the target transaction identifier according to the operation time consumption information corresponding to the target transaction identifier if the target transaction identifier exists in the preset background table;
and the inserting module is used for inserting the target transaction identifier into the preset background table if the target transaction identifier does not exist in the preset background table.
The modules in the searching and killing device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 9. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing transaction related data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of killing.
Those skilled in the art will appreciate that the architecture shown in fig. 9 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It should be noted that, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
It should be noted that the method and apparatus of the embodiments of the present disclosure may be applied to the technical field of artificial intelligence, the field of financial technology, or other related fields, and the method and apparatus of the embodiments of the present disclosure are not limited to the application field.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), Magnetic Random Access Memory (MRAM), Ferroelectric Random Access Memory (FRAM), Phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, and these are all within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (10)

1. A searching and killing method is characterized by comprising the following steps:
traversing each transaction operation information in a preset background table, and determining target transaction operation information meeting preset checking and killing conditions;
generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and searching and killing the affairs corresponding to the target affair operation information on the database server based on the searching and killing statements.
2. The method of claim 1, wherein the transaction execution information comprises a transaction execution time and an operation update line number;
the traversing of the operation information of each transaction in the preset background table and the determining of the operation information of the target transaction meeting the preset checking and killing conditions comprise the following steps:
determining the transaction operation information with the transaction execution time exceeding a preset time threshold value as target transaction operation information meeting preset checking and killing conditions;
or, determining the transaction operation information of which the operation updating line number exceeds the preset number threshold as the target transaction operation information meeting the preset checking and killing condition.
3. The method of claim 1, wherein the transaction execution information comprises a transaction execution time and an operation update line number; the method further comprises the following steps:
every other preset time interval, aiming at each transaction in the preset background table, removing the transaction with the transaction execution time at the current moment being the same as the transaction execution time at the previous moment;
and/or; and eliminating the affairs with the same operation updating line number at the current moment as the operation updating line number at the previous moment.
4. The method according to claim 1, wherein after the step of killing the transaction corresponding to the target transaction running information on the database server based on the killing statement, the method further comprises:
and sending the searching and killing completion notification information to the operation and maintenance terminal corresponding to the affair corresponding to the target affair operation information.
5. The method of claim 1, further comprising:
periodically accessing the database server at intervals of a preset time interval, and acquiring transaction operation information based on a system view of the database server and transaction identifiers in the preset background table, wherein the transaction operation information comprises transaction identifier information, operation time consumption information and operation updating line number information;
and storing the transaction operation information to a preset background table, wherein the transaction comprises at least one database operation.
6. The method of claim 5, wherein the transaction execution information further comprises a transaction execution time, the method further comprising:
acquiring a target session identifier from a preset session identifier table;
judging whether a target transaction identifier corresponding to the target session identifier exists in the preset background table or not;
if the target transaction identifier exists in the preset background table, updating the transaction execution time of the transaction corresponding to the target transaction identifier according to the operation time consumption information corresponding to the target transaction identifier;
and if the target transaction identifier does not exist in the preset background table, inserting the target transaction identifier into the preset background table.
7. A killing apparatus, comprising:
the first determining module is used for traversing each transaction operation information in the preset background table and determining target transaction operation information meeting preset checking and killing conditions;
the generating module is used for generating a searching and killing statement according to the session identification information corresponding to the target transaction operation information;
and the searching and killing module is used for searching and killing the affair corresponding to the target affair operation information on the database server based on the searching and killing statement.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 6 when executed by a processor.
CN202210193030.3A 2022-02-28 2022-02-28 Searching and killing method and device, computer equipment and storage medium Pending CN114461659A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210193030.3A CN114461659A (en) 2022-02-28 2022-02-28 Searching and killing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210193030.3A CN114461659A (en) 2022-02-28 2022-02-28 Searching and killing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114461659A true CN114461659A (en) 2022-05-10

Family

ID=81415717

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210193030.3A Pending CN114461659A (en) 2022-02-28 2022-02-28 Searching and killing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114461659A (en)

Similar Documents

Publication Publication Date Title
CN109033123B (en) Big data-based query method and device, computer equipment and storage medium
US20230289255A1 (en) Automatic correlation of dynamic system events within computing devices
US9928281B2 (en) Lightweight table comparison
US9367598B2 (en) Merging an out of synchronization indicator and a change recording indicator in response to a failure in consistency group formation
US11074238B2 (en) Real-time anonymization
CN109298835B (en) Data archiving processing method, device, equipment and storage medium of block chain
CN109783457B (en) CGI interface management method, device, computer equipment and storage medium
CN109284289B (en) Data set processing method and device, computer equipment and storage medium
CN106776795B (en) Data writing method and device based on Hbase database
CN112395157A (en) Audit log obtaining method and device, computer equipment and storage medium
US10901977B2 (en) Database independent detection of data changes
US8548980B2 (en) Accelerating queries based on exact knowledge of specific rows satisfying local conditions
US9405786B2 (en) System and method for database flow management
US10747438B1 (en) Reporting using archived data
CN115858471A (en) Service data change recording method, device, computer equipment and medium
CN115185778A (en) Database monitoring method and device
CN114461659A (en) Searching and killing method and device, computer equipment and storage medium
CN110851437A (en) Storage method, device and equipment
US10713226B1 (en) Managing data using archiving
CN115203260A (en) Abnormal data determination method and device, electronic equipment and storage medium
CN114064674A (en) Data synchronization method, device, computer equipment, storage medium and product
CN113778996A (en) Large data stream data processing method and device, electronic equipment and storage medium
US11170000B2 (en) Parallel map and reduce on hash chains
CN111506557A (en) UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium
US10747461B1 (en) Updating objects for archived objects

Legal Events

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