Database deadlock processing method and device, electronic device and storage medium
Patent Information
- Application Number
- CN202510726909.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-10-17
Smart Images

Figure CN120803759A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, in particular to a database deadlock processing method and device, an electronic device and a storage medium. BACKGROUND
[0002] During the execution of each process of a computer, a phenomenon that processes wait for each other and cannot continue to execute due to the competition for resources or program design problems is called deadlock. Deadlock often occurs in databases. Structured Query Language (SQL) databases operate on one or more relational data tables, and manage data through operations such as classification, merging, connection or selection of the relational data tables; therefore, MySQL databases often experience deadlock, for example, process 1 locks data table A and waits for data table B, while process 2 locks data table B and waits for data table A; without external intervention, the processes involved cannot proceed, and the system is in a deadlock state, and the processes that cannot proceed are called deadlock processes.
[0003] In related technologies, the deadlock position is usually located manually and the deadlock optimization scheme is analyzed. However, the above-mentioned database deadlock optimization scheme requires that the technical personnel be familiar with the entire database system, and a large amount of information needs to be analyzed manually, which results in a large amount of information processing, low efficiency and low accuracy, especially in the process of handling the deadlock of a large-scale database.
[0004] At present, there is no effective solution to the problem of low efficiency and accuracy of deadlock handling for large-scale databases in related technologies. SUMMARY
[0005] Embodiments of the present application provide a database deadlock processing method, device, electronic device and storage medium to at least solve the problem of low efficiency and accuracy of deadlock handling for large-scale databases in related technologies.
[0006] In a first aspect, the embodiments of the present application provide a database deadlock processing method, which comprises:
[0007] Collecting database error log information;
[0008] Analyzing the database error log information and obtaining deadlock information, database information and an isolation level;
[0009] Generating a deadlock element information table based on the deadlock information, the database information and the isolation level;
[0010] The deadlock meta-information table is input into the large language model after training for deadlock analysis processing, and a deadlock optimization result is output; the deadlock optimization result is used to indicate a processing operation on the database deadlock.
[0011] In some embodiments, the database error log information is collected, including:
[0012] A database server is scanned to obtain error log paths of a plurality of databases running on the database server, and based on the error log paths, the database error log information corresponding to each of the databases is collected.
[0013] In some embodiments, the database error log information is parsed, and deadlock information, database information, and an isolation level are obtained, including:
[0014] The database error log information is parsed, and deadlock log information is extracted from the database error log information.
[0015] The deadlock information and a database table name are extracted from the deadlock log information, and based on the database table name, corresponding data table structure information is obtained; wherein the database information includes the database table name and the data table structure information;
[0016] Database address information and port information in the database error log information are read, and based on the database address information and the port information, the isolation level is obtained.
[0017] In some embodiments, the database table name is extracted from the deadlock log information, including:
[0018] The deadlock log information and a preset prompt word template are input into the large language model for deadlock extraction processing, and the large language model outputs the database table name through the prompt word template.
[0019] In some embodiments, the database error log information is parsed, and deadlock log information is extracted from the database error log information, including:
[0020] The database error log information is subjected to data cleaning processing to obtain error cleaning log information, and the deadlock log information is extracted from the error cleaning log information.
[0021] In some embodiments, the deadlock meta-information table is input into the large language model after training for deadlock analysis processing, and a deadlock optimization result is output, including:
[0022] The deadlock meta-information table is scanned to obtain the isolation level, the database information, and the deadlock information.
[0023] The interface of the large language model is called, and the isolation level, the database information, and the deadlock information are passed to the called large language model, and the deadlock optimization result is obtained.
[0024] In some embodiments, after outputting the deadlock optimization result, the method further includes:
[0025] Based on the deadlock optimization result, generating optimization report information;
[0026] Establishing a mapping relationship table; the mapping relationship table is used to indicate the corresponding relationship between each database and the pushed object;
[0027] Based on the deadlock optimization result, a database to be optimized is determined; according to the mapping relationship table, a pushed object corresponding to the database to be optimized is determined, and the report information is sent to the pushed object.
[0028] In a second aspect, an embodiment of the present application provides a database deadlock processing device, comprising:
[0029] Collection module, used to collect database error log information;
[0030] A parsing module, configured to parse the database error log information and obtain deadlock information, database information, and isolation level;
[0031] A meta information generation module, configured to generate a deadlock meta information table based on the deadlock information, the database information, and the isolation level;
[0032] The optimization module is used to input the deadlock meta-information table into the trained large language model for deadlock analysis and processing, and output a deadlock optimization result; the deadlock optimization result is used to indicate the processing operation of the database deadlock.
[0033] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the database deadlock handling method as described in the first aspect above is implemented.
[0034] In a fourth aspect, an embodiment of the present application provides a storage medium on which a computer program is stored. When the program is executed by a processor, the database deadlock processing method described in the first aspect is implemented.
[0035] Compared with the related art, the database deadlock processing method, device, electronic device and storage medium provided by the embodiments of the present application can collect database error log information, analyze the database error log information and obtain deadlock information, database information and isolation level, generate a deadlock element information table based on the deadlock information, database information and isolation level, input the deadlock element information table into a large language model after training for deadlock analysis and processing, and output a deadlock optimization result, and the deadlock optimization result is used to indicate a processing operation on a database deadlock. Based on this, the workload of manually analyzing deadlock logs can be effectively reduced, an intelligent deadlock processing mode of generating accurate optimization suggestions in combination with context and historical experience is realized, various database types and complex business scenarios can be supported, and thus the problems of low efficiency and accuracy of deadlock processing for large-scale databases are solved.
[0036] The details of one or more embodiments of the present application are presented in the following drawings and description to make other features, objects and advantages of the present application more clear and simple. BRIEF DESCRIPTION OF DRAWINGS
[0037] The drawings described herein are intended to provide further understanding of the present application, form a part of the present application, and the illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. In the drawings:
[0038] Figure 1 is a hardware structure block diagram of a terminal according to a database deadlock processing method of an embodiment of the present application;
[0039] Figure 2 is a flowchart of a database deadlock processing method according to an embodiment of the present application;
[0040] Figure 3 is a flowchart of another database deadlock processing method according to an embodiment of the present application;
[0041] Figure 4 is a flowchart of a database deadlock processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described and explained below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application and should not be used to limit the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the scope of the present application. In addition, it should be understood that, although the efforts made in this development process can be complex and lengthy, some design, manufacture or production changes made on the basis of the technical content disclosed in the present application are only routine technical means for those of ordinary skill in the art related to the content disclosed in the present application, and should not be understood as insufficient disclosure of the present application.
[0043] In the present application, the term "embodiment" means that the specific features, structures or properties described in conjunction with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment to other embodiments. Those of ordinary skill in the art explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments without conflict.
[0044] Unless otherwise defined, the technical terms or scientific terms involved in the present application should be understood as the usual meaning by those of ordinary skill in the art to which the present application belongs. The terms "one", "a", "an", "the" and the like similar words involved in the present application do not represent quantity limitation, but can represent singular or plural. The terms "include", "contain", "have" and any variations thereof involved in the present application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or device including a series of steps or modules (units) is not limited to the listed steps or units, but can also include steps or units not listed, or can also include other steps or units inherent to these processes, methods, products or devices. The terms "connected", "connected", "coupled" and the like similar words involved in the present application are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The term "multiple" involved in the present application means greater than or equal to two. The term "and / or" describes the association between the associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases: A exists alone, A and B exist together, and B exists alone. The terms "first", "second", "third" and the like involved in the present application are only to distinguish similar objects, and do not represent a specific order for the objects.
[0045] The method embodiments provided by the present embodiment can be executed in a terminal, a computer or a similar computing device. Taking the case of running on a terminal,Figure 1 is a hardware structural diagram of a terminal according to a database deadlock processing method of an embodiment of the present application. As shown in Figure 1 , the terminal can include one or more (only one is shown in Figure 1 ) processors 102 (the processor 102 can include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the terminal can further include a transmission device 106 for communication function and an input and output device 108. Those skilled in the art can understand that Figure 1 the structure shown is only schematic, which does not limit the structure of the terminal. For example, the terminal can include more or less components than those shown in Figure 1 , or have a different configuration from Figure 1 .
[0046] The memory 104 can be used to store computer programs, for example, software programs of application software and modules, such as a computer program corresponding to the database deadlock processing method of an embodiment of the present application. The processor 102 performs various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the method described above. The memory 104 can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the terminal through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0047] The transmission device 106 is used to receive or send data via a network. Specific examples of the network can include a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC) which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, RF) module which is used to communicate with the Internet in a wireless manner.
[0048] The embodiment provides a database deadlock processing method, Figure 2 is a flowchart of a database deadlock processing method according to an embodiment of the present application, as shown in Figure 2 , the flowchart includes the following steps:
[0049] Step S210, collecting database error log information.
[0050] In this step, the error log information containing deadlock information is mainly collected from the database server automatically as the basis data for subsequent deadlock analysis. Specifically, first, in order to facilitate the collection of MySQL deadlock information, the following command can be executed on the MySQL server to start the deadlock log recording function, and ensure that all deadlock times are recorded to the error log as follows:
[0051] set global innodb_print_all_deadlocks = ON;
[0052] The above configuration will write the deadlock log to the MySQL error log file. Then check the new content of the log file periodically through a script or a timing task, or use a log monitoring tool to capture log updates in real time to achieve log information collection.
[0053] Step S220, parse the database error log information, and get the deadlock information, database information and isolation level.
[0054] Among them, the regular expression or log parsing tool (such as Grok, Fluentd) is used to match the deadlock paragraph in the database error log. For example, from the line containing the keyword "Transactions deadlock detected, dumping detailed information", to the line containing the keyword "WE ROLL BACK TRANSACTION" line.
[0055] The database information extraction process includes: identifying the database type according to the keyword (such as MySQL, PostgreSQL) in the log; accessing the database to execute select @@version; to obtain the database version number; and parsing the deadlock information to obtain the database table name and corresponding table structure through context analysis. That is, the above database information can include database type, database version number, database table name and table structure, etc.
[0056] In addition, different isolation levels (such as READ UNCOMMITTED, SERIALIZABLE) have a significant impact on the probability of deadlock occurrence, and need to be used as the basis for analysis. Therefore, in this step, the current isolation level (such as READ COMMITTED, REPEATABLE READ) can also be obtained by parsing the transaction information in the log or directly querying the database configuration (such as SELECT @@transaction_isolation), and then complete the various automated parsing processing of the database error log.
[0057] Step S230: Generate a deadlock meta-information table based on the deadlock information, database information, and isolation level.
[0058] Specifically, a collection is created in MongoDB. The MySQL IP address, port number, isolation level, table structure, deadlock log, and other information parsed in step S220 are integrated into a JSON object. This JSON object is then inserted into the collection using a MongoDB client (such as PyMongo). It should be noted that if writing to MongoDB fails (e.g., due to a network outage), a log is recorded and the data is retried to prevent data loss. Through these steps, the raw data parsed in step S220 is structured into a table format, facilitating subsequent analysis.
[0059] Step S240: Input the deadlock meta-information table into the trained large language model for deadlock analysis and output a deadlock optimization result; the deadlock optimization result is used to indicate the processing operation for the database deadlock.
[0060] The large language model's contextual understanding and reasoning capabilities are leveraged to analyze the root cause of the deadlock and generate actionable solutions. Specifically, a trained large language model (such as a customized DeepSeek) is invoked to convert the deadlock metadata table into natural language text (such as descriptive text in JSON format) or directly input it as structured data into the invoked large language model. Next, the large language model identifies the root cause of the deadlock based on the input information (such as circular waits, inconsistent lock escalation sequences, etc.). The model combines database type, isolation level, and SQL statement features to determine whether the deadlock is related to specific business logic or configuration, ultimately returning structured optimization recommendations.
[0061] More specifically, the large language model performs the following tasks: identifying the root cause of deadlocks and outputting deadlock links (e.g., "Transaction A locked the idx_order_customer index of the orders table, waiting for the row lock of the stock table; transaction B locked the stock table, waiting for the index lock of the orders table"); generating optimization suggestions, recommending actions (e.g., "Add a joint index (customer_id, product_id) to the orders table" or "Change the transaction isolation level to READ COMMITTED"), and suggesting SQL rewrites (e.g., "Unify the SQL order of UPDATE orders and UPDATE stock"); and outputting optimization results, storing the optimization suggestions output by the model in a structured manner, and pushing them to developers or automatically generating repair scripts based on the optimization suggestions.
[0062] On the other hand, after the deadlock optimization result is output by the large language model, for suggestions that can be automated (such as modifying the isolation level, setting the lock timeout), direct execution is performed through a database configuration management tool (such as Ansible); for suggestions involving business logic modification (such as adjusting the transaction order), the development team can be submitted for review and implementation.
[0063] Through the above steps S210 to S240, by analyzing the deadlock, database, and isolation level information in the log, and using a large language model to analyze the input parsed information, deadlock optimization suggestions are generated, thereby effectively reducing the workload of manually analyzing deadlock logs, realizing an intelligent deadlock processing method that generates accurate optimization suggestions combined with context and historical experience, and supporting multiple database types and complex business scenarios, thus solving the problem of low efficiency and accuracy of deadlock processing for large-scale databases.
[0064] In some embodiments, the above collecting database error log information can further include the following steps:
[0065] Scanning the database server to obtain the error log path of each database running on the database server, and collecting the database error log information corresponding to each database based on the error log path.
[0066] In a production environment, a database server (such as a MySQL / PostgreSQL cluster node) can run multiple database instances simultaneously (such as databases for different business lines or multiple sub-databases after sharding). The error logs of different database instances can be stored in different paths on the server. Therefore, in this step, first, an automated tool is used to scan all MySQL servers to obtain and scan the MySQL basic information table; for example, the following command is executed:
[0067] show variables like 'log_error';
[0068] Based on the error log path information obtained by executing the above command, record it in the MySQL basic information table. Finally, scan the MySQL basic information table and use an automated tool to regularly pull the MySQL log files to the deadlock log management server.
[0069] Further, the error log file naming format can be: port_IP_timestamp_error.log. Record the error log file information in the error log information table, including the Mysql IP, port, and error log file name, etc. And regularly execute this deadlock log collection step to facilitate the subsequent deadlock log parsing step to call the error log.
[0070] Through the above embodiments, an automated and batched database error log collection method is realized, so that error log information of all database instances can be efficiently and accurately obtained in a complex multi-database environment. Moreover, by automatically obtaining the deadlock log and then calling a large language model for targeted deadlock optimization analysis, the scanned data is very small, which is conducive to reducing operation costs.
[0071] In some embodiments, the above parsing of the database error log information and obtaining of the deadlock information, the database information, and the isolation level can further include the following steps:
[0072] The database error log information is parsed, and deadlock log information is extracted from the database error log information. The deadlock information and the database library table name are extracted from the deadlock log information, and the corresponding data table structure information is obtained based on the database library table name. The database information includes the database library table name and the data table structure information. The database address information and the port information in the database error log information are read, and the isolation level is obtained based on the database address information and the port information.
[0073] In the deadlock log management server, the deadlock information is obtained by screening out the deadlock-related fragments from the MySQL error log according to the error log file name through a regular expression or a log parsing tool (such as Logstash or a Python script). For example, the start marker of the deadlock log is the keyword “Transactions deadlock detected, dumping detailed information”, and the end marker is “WE ROLL BACK TRANSACTION”.
[0074] The deadlock information is then parsed to obtain the database library table name. For example, a regular expression can be used to extract the library table name (in the format “database name.table name”) in the log. Alternatively, if the library table name is not explicitly recorded in the deadlock log, a DeepSeek API can be called for natural language parsing; for example, the deadlock log fragment is encapsulated as a prompt word (Prompt) to guide the model to output a list in the format of “library name.table name”. Based on the library table name, the data table structure information is obtained, such as connecting to the target database through a MySQL client and executing SHOW CREATE TABLE database name.table name to obtain the table creation statement, and parsing the field name, data type, index, and other information.
[0075] Next, the IP address and port number are parsed from the error log file name (in the format port_IP_timestamp_error.log), and a MySQL client is connected to the instance corresponding to the IP and port to obtain the current isolation level. The isolation level directly affects the probability of deadlock occurrence (for example, a high isolation level can increase the lock holding time), so recording this information helps to analyze the root cause of the deadlock.
[0076] Through the above embodiments, the whole process from log collection, parsing to structured storage is covered, which can be applied to the operation and maintenance management of large-scale MySQL clusters.
[0077] In some embodiments, the above extracting database library table name from deadlock log information can further include the following steps:
[0078] The deadlock log information and the preset prompt word template are input into the large language model for deadlock extraction processing, and the large language model is guided to output the database library table name through the prompt word template.
[0079] The structured parsed deadlock log information (such as transaction ID, lock type, and waiting resource) and the preset prompt word template (such as "extract the database table name involved from the log and describe its associated scenario") are input into the large language model together, and the model focuses on the table name entity recognition (such as matching the pattern TABLE: 'db1.orders') and its associated analysis with the deadlock event (such as whether the table is frequently locked) in the log through the Context Guidance and Instruction Following capabilities in the template, and finally outputs the database library table name (such as db1.orders) directly associated with the deadlock event and its role description in the deadlock (such as "transaction A causes lock waiting due to updating the status field of the table").
[0080] Through the above embodiments, while ensuring the accuracy of the output, the semantic understanding ability of the large language model makes up for the limitations of traditional regular matching in complex log scenarios, thereby facilitating the improvement of the accuracy of database deadlock processing.
[0081] In some embodiments, the above parsing database error log information and extracting deadlock log information from the database error log information can further include the following steps:
[0082] The database error log information is subjected to data cleaning processing to obtain error cleaning log information, and the deadlock log information is extracted from the error cleaning log information.
[0083] Specifically, the original database error log is denoised and standardized through data cleaning preprocessing: first, the log is deduplicated, denoised (such as filtering debugging information and redundant stacks), format normalized (such as unifying the timestamp format and removing special characters), and invalid line elimination (such as deleting blank lines or non-error log entries) to generate error cleaning log information. Then, based on the cleaned log, deadlock feature recognition logic (such as regular matching deadlock keywords and pattern matching lock wait syntax structure) is applied to accurately extract log fragments directly related to deadlocks (such as entries containing DeadlockFound or Detected Deadlock) from the cleaned data.
[0084] The above embodiments are helpful to improve the accuracy and efficiency of subsequent deadlock analysis, and avoid misjudgment or omission of key information due to noise interference in the original log.
[0085] In some embodiments, the above-mentioned inputting the deadlock meta-information table into the trained large language model for deadlock analysis and processing, and outputting the deadlock optimization result, may further include the following steps:
[0086] Scan the deadlock meta-information table to obtain the isolation level, database information, and deadlock information; call the interface of the large language model, and pass the isolation level, database information, and deadlock information to the called large language model to obtain the deadlock optimization result.
[0087] Specifically, the deadlock metadata table is scanned to extract preprocessed key information (such as the isolation level REPEATABLE READ, the index definition of the orders table in the database table structure, and the lock waiting relationship of transactions in the deadlock event). This structured data is then input as context into the large language model interface (such as calling a GPT-type model through an API). The model determines the lock contention intensity based on the input isolation level, analyzes the index missing risk based on the table structure, and parses the transaction interaction pattern in the deadlock information. Finally, it outputs a deadlock optimization result that includes specific optimization measures (such as "adding an index to the orders.status field and recommending lowering the isolation level to READ COMMITTED").
[0088] The following is a detailed description of the deadlock optimization result generation process. First, scan the deadlock metadata table to obtain the following information: isolation level, table structure, and deadlock information. Then, pass it to the DeepSeek API using the following Python code:
[0089] nl_query = f"""
[0090] Mysql isolation level: {iso_level}
[0091] Mysql table structure: {table_info}
[0092] Next, according to the above information, the large language model DeepSeek provides optimization suggestions for the following Mysql deadlock log:
[0093] {deadlock_msg}
[0094] """
[0095] data = {
[0096] "model": "deepseek-r1",
[0097] "messages": [
[0098] {
[0099] "role": "user",
[0100] "content": nl_query
[0101] } ]
[0103] }
[0104] response = requests.post(url, headers=headers, data=json.dumps(data))
[0105] In this way, the deadlock optimization suggestions are obtained; then, the deadlock optimization suggestions output by the large language model are recorded in the MongoDB database to generate a deadlock optimization result table.
[0106] Through the above embodiments, discrete log data is converted into executable optimization strategies, thereby realizing end-to-end automation from problem discovery to solution.
[0107] In some of the embodiments, after outputting the deadlock optimization result, the following steps can also be included:
[0108] Based on the deadlock optimization result, generate optimization report information; establish a mapping relationship table; the mapping relationship table is used to indicate the corresponding relationship between each database and the pushed object; based on the deadlock optimization result, determine the database to be optimized; according to the mapping relationship table, determine the corresponding pushed object of the database to be optimized, and send the report information to the pushed object.
[0109] In this step, first, based on the deadlock optimization results output by the large language model (such as index addition, isolation level adjustment, etc.), a structured optimization report information (including problem description, optimization scheme, expected benefit, etc.) is generated. Then a mapping table (such as the key-value pair of the database instance ID and the corresponding operation and maintenance responsible person mailbox / work order system) is established, and through this table, the pushed object (such as the DBA team or the business responsible person) associated with the database to be optimized (such as the instance where the db1.orders table is located) is quickly located. Finally, the report information is sent to the target object by using the preset push rule (such as email, instant messaging tool or work order system API), ensuring that the optimization suggestion accurately reaches the responsible party, and at the same time, the dynamic association between the database and the operation and maintenance responsible person is realized through the mapping table, avoiding the failure of the push link caused by personnel changes or system expansion.
[0110] More specifically, first, a comparison table between the database and the developer (i.e. the above-mentioned pushed object) needs to be managed, including the following information: Mysql port, business name, developer mailbox. Combined with this information, the deadlock optimization result table is scanned, and the deadlock optimization suggestion is automatically sent to the corresponding developer, and finally the information push is completed.
[0111] Through the above embodiments, the deadlock optimization closed loop is realized through the automatic report generation and accurate push mechanism, effectively reducing the labor cost and knowledge barrier.
[0112] The present application will be described and explained below through specific embodiments. Figure 3 is a flowchart of another database deadlock processing method according to an embodiment of the present application, as shown in Figure 3 , the flowchart includes the following steps:
[0113] Step S301, deadlock log collection. Specifically, an automatic tool is used to periodically collect Mysql deadlock log information.
[0114] Step S302, deadlock log analysis. This step is mainly used to clean up Mysql log files and parse effective information, including deadlock information, Mysql database table name and Mysql table structure information.
[0115] Step S303, get optimization suggestion. Call the deadlock log analysis module, combine the deadlock related information, and generate the deadlock optimization suggestion.
[0116] Step S304, message push. Among them, the deadlock optimization suggestion is periodically pushed to the corresponding developer.
[0117] It is noted that the steps shown in the above flow or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0118] The embodiments also provide a database deadlock processing apparatus for implementing the above embodiments and preferred embodiments, which have been described and will not be repeated. As used below, the terms "module", "unit", "sub-unit" and the like can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.
[0119] Figure 4 is a structural block diagram of a database deadlock processing apparatus according to an embodiment of the present application, as shown in Figure 4 The apparatus includes a collection module 41, an analysis module 42, a meta-information generation module 43, and an optimization module 44; wherein:
[0120] The collection module 41 is configured to collect database error log information; the analysis module 42 is configured to analyze the database error log information and obtain deadlock information, database information, and an isolation level; the meta-information generation module 43 is configured to generate a deadlock meta-information table based on the deadlock information, the database information, and the isolation level; and the optimization module 44 is configured to input the deadlock meta-information table into a large language model after training to perform deadlock analysis and processing, and output a deadlock optimization result; the deadlock optimization result is used to indicate a processing operation on a database deadlock.
[0121] In some embodiments, the collection module 41 is further configured to scan a database server, obtain error log paths of a plurality of databases running on the database server, and collect database error log information corresponding to each database based on the error log paths.
[0122] In some embodiments, the analysis module 42 is further configured to analyze the database error log information and extract deadlock log information from the database error log information; the analysis module 42 is further configured to extract deadlock information and a database table name from the deadlock log information, obtain corresponding data table structure information based on the database table name; wherein the database information includes the database table name and the data table structure information; the analysis module 42 is further configured to read database address information and port information in the database error log information, and obtain an isolation level based on the database address information and the port information.
[0123] In some embodiments, the parsing module 42 is further configured to input the deadlock log information and a preset prompt word template into a large language model to perform deadlock extraction processing, and guide the large language model to output a database table name through the prompt word template.
[0124] In some embodiments, the parsing module 42 is further configured to perform data cleaning processing on the database error log information to obtain error cleaning log information, and extract deadlock log information from the error cleaning log information.
[0125] In some embodiments, the optimization module 44 is further configured to scan a deadlock meta-information table to obtain an isolation level, database information, and deadlock information; the optimization module 44 is further configured to call an interface of a large language model, and input the isolation level, database information, and deadlock information into the called large language model to obtain a deadlock optimization result.
[0126] In some embodiments, the database deadlock processing apparatus further comprises a pushing module; the pushing module is configured to generate an optimization report information based on the deadlock optimization result; the pushing module is further configured to establish a mapping relationship table; the mapping relationship table is used to indicate a corresponding relationship between each database and a pushed object; the pushing module is further configured to determine a database to be optimized based on the deadlock optimization result; determine the pushed object corresponding to the database to be optimized according to the mapping relationship table, and send the report information to the pushed object.
[0127] It should be noted that each of the above modules can be a functional module or a program module, which can be implemented by software or hardware. For the modules implemented by hardware, each of the above modules can be located in the same processor; or each of the above modules can also be located in different processors in any combination. In this embodiment, specific examples can be referred to the examples described in the above embodiments and optional implementation manners, which will not be described herein.
[0128] The embodiment also provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0129] Optionally, the electronic device can further comprise a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0130] Optionally, in the embodiment, the processor can be configured to perform the following steps through the computer program:
[0131] S1, collecting database error log information.
[0132] S2, parse the database error log information and obtain the deadlock information, database information and isolation level.
[0133] S3, generate a deadlock element information table based on the deadlock information, database information and isolation level.
[0134] S4, input the deadlock element information table into the trained large language model for deadlock analysis and processing, and output a deadlock optimization result; the deadlock optimization result is used to indicate a processing operation on the database deadlock.
[0135] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, which will not be described here again.
[0136] In addition, in combination with the database deadlock processing method in the above embodiments, the present embodiment can provide a storage medium for implementation. The storage medium has a computer program stored thereon; the computer program is executed by a processor to implement any one of the database deadlock processing methods in the above embodiments.
[0137] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0138] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0139] Those skilled in the art should understand that any combination of the technical features of the above-mentioned embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above-mentioned embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0140] The above-mentioned embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the scope of protection of the present application. Therefore, the scope of protection of the patent of the present application should be subject to the appended claims.
Claims
1. A database deadlock processing method, characterized in that: The method comprises: Collect database error log information; Parsing the database error log information and obtaining deadlock information, database information and isolation level; Generate a deadlock meta-information table based on the deadlock information, the database information and the isolation level; The deadlock meta-information table is input into the trained large language model for deadlock analysis and processing, and a deadlock optimization result is output; the deadlock optimization result is used to indicate the processing operation of the database deadlock.
2. The database deadlock processing method according to claim 1, characterized in that: The collecting of database error log information includes: Scan the database server to obtain error log paths of multiple databases running on the database server, and collect the database error log information corresponding to each of the databases based on the error log paths.
3. The database deadlock processing method according to claim 1, characterized in that: The parsing of the database error log information and obtaining deadlock information, database information, and isolation level includes: Parsing the database error log information, and extracting deadlock log information from the database error log information; Extracting the deadlock information and the database table name from the deadlock log information, and obtaining corresponding data table structure information based on the database table name; wherein the database information includes the database table name and the data table structure information; The database address information and the port information in the database error log information are read, and the isolation level is obtained based on the database address information and the port information.
4. The database deadlock processing method according to claim 3, characterized in that: The step of extracting the database table name from the deadlock log information includes: The deadlock log information and the preset prompt word template are input into the large language model for deadlock extraction processing, and the prompt word template is used to guide the large language model to output the database table name.
5. The database deadlock processing method according to claim 3, characterized in that: The parsing of the database error log information and extracting deadlock log information from the database error log information includes: The database error log information is subjected to data cleaning processing to obtain error cleaning log information, and the deadlock log information is extracted from the error cleaning log information.
6. The database deadlock processing method according to claim 1, characterized in that: The deadlock meta-information table is input into the trained large language model for deadlock analysis and processing, and the deadlock optimization result is output, including: Scan the deadlock meta-information table to obtain the isolation level, the database information, and the deadlock information; The interface of the large language model is called, and the isolation level, the database information, and the deadlock information are passed to the called large language model, and the deadlock optimization result is obtained.
7. The database deadlock processing method according to any one of claims 1 to 6, characterized in that: After outputting the deadlock optimization result, the method further includes: Based on the deadlock optimization result, generating optimization report information; Establishing a mapping relationship table; the mapping relationship table is used to indicate the corresponding relationship between each database and the pushed object; Based on the deadlock optimization result, a database to be optimized is determined; according to the mapping relationship table, a pushed object corresponding to the database to be optimized is determined, and the report information is sent to the pushed object.
8. A database deadlock processing device, characterized in that: include: Collection module, used to collect database error log information; A parsing module, configured to parse the database error log information and obtain deadlock information, database information, and isolation level; A meta information generation module, configured to generate a deadlock meta information table based on the deadlock information, the database information, and the isolation level; The optimization module is used to input the deadlock meta-information table into the trained large language model for deadlock analysis and processing, and output a deadlock optimization result; the deadlock optimization result is used to indicate the processing operation of the database deadlock.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the database deadlock processing method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the database deadlock handling method according to any one of claims 1 to 7 when running.
Citation Information
Cited By
Database lock conflict positioning method and system and medium
CN122173506A
A database lock conflict positioning method, system and medium
CN122173506B