Server, terminal equipment and database lock waiting information acquisition method
By adding a kernel probe at the lock wake function of the database, collecting and storing lock waiting information, the problem of incomplete lock waiting information in the database is solved, and a non-invasive full-quantity lock waiting information is achieved, improving database performance.
Patent Information
- Application Number
- CN202410254529.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-06
- Publication Date
- 2025-02-11
AI Technical Summary
The lock waiting information acquired in the database is incomplete, resulting in the inability to fully analyze the lock waiting problem, affecting the database performance and concurrent processing capabilities.
By creating a database kernel probe based on kernel technology, adding a probe at the database lock wake-up function, collecting lock waiting information and storing it, realizing a non-invasive full lock waiting information acquisition.
It realizes the non-invasive acquisition of full lock waiting information, avoids the need to modify the database kernel source code, and improves database performance and concurrent processing capabilities.
Smart Images

Figure CN119415527A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a server, a terminal device and a method for obtaining database lock waiting information. Background Art
[0002] MySQL database is an open source relational database management system (RDBMS). It can speed up data access and improve flexibility by storing data in different interrelated data tables. MySQL database can support multiple storage engines, including InnoDB, MyISAM, etc. You can choose the appropriate storage engine according to different usage scenarios.
[0003] In a database, when a transaction holds a lock on specific data (such as a row, table, etc.), other transactions need to wait for the transaction to release the lock before they can perform data operations such as reading, writing, and updating the data. If other transactions wait for too long, lock waiting problems will occur, thereby reducing the performance and concurrent processing capabilities of the database, and even causing system access jams, program timeout errors, and other problems. In order to analyze the root cause of the lock wait, you can view the lock wait information based on the system table of the database. However, the built-in lock wait information printing method based on the database management system table cannot output all the information completely. If you need to complete the missing information, you need to modify the database kernel source code to achieve it. When privately deployed, you need to upgrade the kernel, and it is not possible to achieve non-intrusiveness. Summary of the invention
[0004] The present application provides a server, a terminal device and a method for obtaining lock waiting information of a database to solve the problem of incomplete lock waiting information obtained in a database.
[0005] In a first aspect, some embodiments of the present application provide a server, including a storage module and a processing module, wherein the storage module is configured to store data to form a database; and the processing module is configured to execute the following program steps:
[0006] Creating a probe, wherein the probe is a database kernel probe built based on kernel technology;
[0007] The probe is added to the lock wake-up function of the database, and the lock wake-up function is used to send a wake-up notification for indicating acquisition of the target lock to the waiting lock transaction when the locking transaction releases the target lock on the target data resource; the locking transaction is a transaction holding the target lock, and the waiting lock transaction is a transaction waiting to acquire the target lock, and the target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource;
[0008] When the lock wake-up function sends the wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored, where the lock waiting information includes locking transaction information and waiting lock transaction information.
[0009] In a second aspect, some embodiments of the present application provide a terminal device, including a communicator and a controller, wherein the communicator is configured to establish a communication connection with a server, wherein the server is equipped with a database, and a probe is provided on the lock wake-up function of the database, wherein the probe is used to collect lock waiting information when the lock wake-up function sends a wake-up notification to the waiting lock transaction, and the lock wake-up function is used to send a wake-up notification to the waiting lock transaction to indicate the acquisition of the target lock when the locked transaction releases the target lock on the target data resource; the locked transaction is a transaction holding the target lock, and the waiting lock transaction is a transaction waiting to acquire the target lock, and the target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource. The controller is configured to execute the following program steps:
[0010] An acquisition request for acquiring lock waiting information sent to the server, wherein the acquisition request is used to enable the server to feed back the stored lock waiting information collected based on the probe to the terminal device;
[0011] Receive the lock waiting information fed back by the server.
[0012] In a second aspect, some embodiments of the present application provide a method for obtaining database lock waiting information, the method comprising:
[0013] Creating a probe, wherein the probe is a database kernel probe built based on kernel technology;
[0014] The probe is added to the lock wake-up function of the database, and the lock wake-up function is used to send a wake-up notification for indicating acquisition of the target lock to the waiting lock transaction when the locking transaction releases the target lock on the target data resource; the locking transaction is a transaction holding the target lock, and the waiting lock transaction is a transaction waiting to acquire the target lock. The target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource;
[0015] When the lock wake-up function sends the wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored, where the lock waiting information includes locking transaction information and waiting lock transaction information.
[0016] It can be seen from the above technical solutions that the present application provides a method for obtaining lock waiting information of a server, a terminal device and a database. The method first creates a probe and adds the probe to the lock wake-up function of the database. The lock wake-up function is used to send a wake-up notification to the waiting lock transaction to indicate the acquisition of the target lock when the locked transaction releases the target lock on the target data resource. When the lock wake-up function sends a wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored. The locked transaction is a transaction that holds the target lock, and the waiting lock transaction is a transaction that is waiting to obtain the target lock. The target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource. The method is based on non-invasive detection technology, and applies a probe to the database kernel lock wake-up function to achieve non-invasive acquisition of full lock waiting information. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 An architectural diagram of a MySQL database provided for some embodiments of the present application;
[0019] Figure 2 A schematic diagram of a process for obtaining lock waiting information based on a system table provided in some embodiments of the present application;
[0020] Figure 3 A schematic diagram of an operation scenario of database access provided in some embodiments of the present application;
[0021] Figure 4 A schematic diagram of a server structure provided for some embodiments of the present application;
[0022] Figure 5 A schematic diagram of the data interaction relationship between the client and the server provided in some embodiments of the present application;
[0023] Figure 6 A flowchart of a method for obtaining database lock waiting information provided in some embodiments of the present application;
[0024] Figure 7 A timing interaction diagram of a lock wake-up mechanism provided in some embodiments of the present application;
[0025] Figure 8 An architectural diagram of collecting lock wait information based on eBPF probes provided in some embodiments of the present application;
[0026] Fig. 9 A schematic diagram of a process for generating a lock waiting formation diagram provided in some embodiments of the present application;
[0027] Fig.10 A schematic diagram of a lock-wait swimlane diagram provided for some embodiments of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the exemplary embodiments of the present application clearer, the technical solutions in the exemplary embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0029] Based on the exemplary embodiments shown in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete technical solution separately.
[0030] It should be understood that the terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented according to an order other than those given in the diagrams or descriptions of the embodiments of this application.
[0031] In addition, the terms "include" and "have" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to those components expressly listed but may include other components not expressly listed or inherent to such products or devices.
[0032] The database in the embodiment of the present application is a warehouse that organizes, stores and manages data according to the data structure. The database is a collection of a large amount of data stored in a computer, organized, shareable and uniformly managed. The database can store and manage data according to the data structure, can realize data sharing, reduce data redundancy, maintain data independence, realize centralized control and ensure data security and reliability.
[0033] Databases can be divided into relational databases and non-relational databases. Among them, relational databases refer to databases that use relational models to organize data. The data structure of a relational database is a table. A relational database is a data organization composed of two-dimensional tables and the connections between them. It has the advantages of being easy to use, easy to maintain, and supporting complex queries, such as MySQL, Oracle, and SQL Server. Non-relational databases are a collection of data structured storage methods that use key-value pairs to store data, including Cloudant, MongoDb, redis, HBase, etc. It has the characteristics of being distributed, highly flexible, and scalable, and is suitable for processing massive data and high-concurrency read and write scenarios.
[0034] The database can be mounted on various electronic devices to provide stable and efficient data storage and management services. For example, the electronic devices provided in the embodiments of the present application can be various types of terminal devices or servers, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms; the terminal device can also have a variety of implementation forms, for example, it can be a laptop, a tablet computer, a personal computer, a smart TV, a laser projection device, etc.
[0035] like Figure 1 , which is an architecture diagram of the MySQL database provided in the embodiment of the present application. The MySQL logical system (MySQL Server) architecture may include four infrastructure layers, namely, a connection layer, a service layer, an engine layer, and a storage layer.
[0036] The connection layer is the top-level connection component of the MySQL database, which is used to provide connection services to the client and mainly complete some tasks such as connection processing, authorization authentication and related security management. Figure 1 As shown in the figure, the connection layer includes support interfaces, i.e., interfaces for clients to connect to databases, such as JDBC, ODBC, and C standard API functions. In order to improve service performance, a thread pool is introduced in the connection layer to provide threads for clients that have passed authentication and secure access. Since it takes a lot of time to establish a connection each time, the function of the connection pool is to cache these connections so that the established connection can be used directly next time, reducing the time spent on creating and releasing threads.
[0037] In some embodiments, connection processing is when a client sends a connection request to the MySQL server, MySQL Server will allocate a thread from the thread pool to connect to the client, and all future requests from the client will be assigned to this thread. Authorization authentication is when the client initiates a connection request to the MySQL server, MySQL Server will authenticate the client initiating the connection, such as the user name, client host address and user password. Security management is when the client connects to the MySQL server, MySQL Server will determine which specific operations the client can perform based on the client's permissions.
[0038] The service layer (MySQL Server) is the core service function of the MySQL database, such as SQL interface, cached query, SQL analysis and optimization, and execution of some built-in functions. All cross-storage engine functions are also implemented in this layer, such as procedures and functions. In this layer, the MySQL database will parse the query and create the corresponding internal parse tree, and perform corresponding optimizations on it, such as determining the order of query tables, whether to use indexes, etc., and finally generate the corresponding execution operations.
[0039] like Figure 1 As shown in Figure 1, the service layer includes management tools and services, SQL interface, parser, optimizer and cache. Management tools and services provide system management and control tools, such as backup and recovery, security, replication, cluster management, partition management, case management, template management, workbench, query browsing, merge toolkit and other database management functions. SQL interface is used to receive SQL commands from the client and process them to obtain the results required by the client.
[0040] The parser performs syntax and lexical analysis on the query statements sent by the client. When the SQL statement is passed to the parser, the parser will first perform syntax analysis on the SQL statement. If there is a syntax error in the statement, the corresponding error message will be returned. After the syntax check passes, the parser will query the cache. If there is a corresponding statement in the cache, the result will be returned directly without performing the next optimization execution operation.
[0041] The optimizer optimizes the query statement before querying, such as selecting the appropriate index and data reading method.
[0042] The cache includes global and local engine-specific caches and buffer pools. If there is a hit query result in the cache, the data can be retrieved from the cache without repeated parsing and execution. The cache mechanism of the cache is composed of a series of small caches, such as table cache, record cache, key cache, permission cache, etc.
[0043] That is to say, during the execution of the service layer, if there is a query result that hits the SQL statement in the cache, the data is read directly. If there is no query result, the parser parses and preprocesses the SQL statement, and then submits it to the engine layer after optimization by the optimizer.
[0044] The engine layer is used to provide various storage engines, which are responsible for storing and extracting data in the MySQL database and providing a unified interface for the service layer to access data. Different storage engines have different functions. For example, MyISAM is used to manage non-transactional tables, providing high-speed storage and retrieval, as well as full-text search capabilities. It also supports three different storage formats: static tables, dynamic tables, and compressed tables. InnoDB provides transaction security with commit, rollback, and crash recovery capabilities. It supports auto-growth columns and foreign key constraints. MEMORY uses content that exists in memory to create tables.
[0045] The storage layer mainly stores data on the file system running on the electronic device and completes the interaction with the storage engine. The stored physical files include redolog, undolog, binlog, errorlog, querylog, slowlog, data, index, etc.
[0046] In the MySQL database, logs record various information about the database operation status, including error information, query information, transaction information, etc. Logs are the key basis for abnormality investigation, performance analysis and optimization, data recovery and backup. Logs in MySQL are mainly divided into two types: service layer logs and engine layer logs. Among them, service layer logs are used to record various operations and abnormal situations of the MySQL Server layer, including error logs (Error Log), binary logs (Binary Log), relay logs (Relay Log), DDL logs (DDL Log), query logs (General Log) and slow query logs (Slow Query Log).
[0047] The error log is used to record abnormal status and error information when the MySQL Server is running, such as database startup failure, connection error, SQL statement error, insufficient permissions, insufficient disk space, etc. In the internal implementation of MySQL, the error log is automatically generated and recorded by the service layer. When the MySQL Server is started, it will automatically create an error log file and continuously record abnormal information during operation. When an abnormal situation occurs during the execution of the MySQL Server, detailed error and warning information will be recorded in the error log file, and a separate error number will be generated for each error log event for storage management.
[0048] Binary log is a binary log that records the execution of modification statements. It is used to record the modification operations performed by MySQL Server in binary format, such as inserting, updating, and deleting operations on data tables. The generation and writing of binary logs are completed in the MySQL service layer. During the execution of MySQL, all modification operations are handed over to MySQL Server for processing and recorded in the binary log.
[0049] Relay log is a type of log in the master-slave replication process of MySQL database, which is used to record the relay information of the backup server. The relay log is generated on the slave server, which records the binary log information copied from the master server and is stored on the local disk.
[0050] DDL log is a type of log used to record data definition language operations in MySQL database. DDL operations are used to manage, maintain, and modify the structure of database objects, such as creating and modifying data tables, views, indexes, and stored procedures. DDL logs record all details and metadata information of DDL operations in the database, including the DDL statement itself, metadata information of the operation object, and modification time.
[0051] The query log (General Log) is a basic log type in the MySQL database, which is used to record the access and operation information of the MySQL Server. The MySQL Server will record the information of each client connecting to the database server and each operation event in the query log, including connection and disconnection information, executed queries and SQL statements, etc.
[0052] Slow Query Log is a logging method for MySQL database. It is used to record query statements with slow execution time. When MySQL Server records query statements with slow execution time, it will record the syntax and execution time of these statements in the slow query log.
[0053] In the MySQL database, each storage engine has its own engine-level log, which is used to record engine-level operations and information. The engine-level log mainly records transaction information, modification information, data page information, lock information, I / O operations, etc.
[0054] For example, the InnoDB storage engine has two engine-level logs: redo log and undo log. Among them, redo log is a type of log recorded when the MySQL database performs data persistence. It is used to record the modification operations of data files in the InnoDB storage engine to ensure the data consistency of the MySQL database in the event of abnormal crashes. In the MySQL database, redo logs use a fixed-size circular buffer for storage. The buffer size can be configured through parameters. After storing a preset number of logs, a new log file will be created and operation records will continue to be written.
[0055] Undo Log is a type of log that records transactions in the InnoDB storage engine in the MySQL database. It is used to record the status information before the modification operations made by each transaction being executed in order to implement the rollback of the transaction.
[0056] The above log files record various events and operations of the MySQL database, including executing queries, updating data, executing transactions, etc. By analyzing these log files, relevant information about the performance of the database process can be obtained, thereby realizing the performance detection of the database management system.
[0057] Based on the above MySQL database architecture, the execution process of log query in MySQL database includes the following stages: connection, query, analysis, optimization, execution, and result return. The client can call MySQL through the SQL support interface. MySQL processes and returns the execution result.
[0058] First, the client calls MySQL through the SQL support interface and inputs a request to obtain log data. After receiving the request, MySQL will temporarily place the request in the connection pool and manage it through the management service and tools. When the request enters the processing queue from the waiting queue, the manager will pass the request to the SQL interface. After the SQL interface receives the request, it will compare the requested data with the data in the cache. If they match, the processing result will be directly returned through the cache. Otherwise, the query will be made to the file system in the storage layer, and the SQL interface will pass it to the parser. The parser will determine whether the SQL statement is correct. If it is correct, it will convert it into a data structure. After the parser completes the processing, it will pass the processed request to the optimizer. The optimizer will generate multiple execution plans, and the database will eventually select the best solution to execute. After determining the optimal execution plan, the SQL statement will be processed by the storage engine, which will obtain the corresponding data from the file system and return it by the original path.
[0059] In some embodiments, database operations are executed with transactions as the basic unit. A transaction is a collection of SQL statements that are executed as a whole to ensure the integrity and consistency of the data. During the execution of a transaction, in order to maintain the integrity and consistency of the database and to handle the problem of concurrent access to data by multiple transactions, the database management system will implement a locking mechanism based on its storage engine, including locking and waiting for locking. Among them, locking means that when a transaction is accessing a data resource, in order to ensure the consistency and integrity of the data, it will lock this data resource to prevent other transactions from modifying the resource at the same time until the transaction holding the lock is completed and the lock is released. Waiting for locking means that when a transaction needs to access a data resource that has been locked by other transactions, it needs to wait for the lock on the data resource to be released before it can access the locked data resource. The process of other transactions waiting for the lock is called lock waiting.
[0060] Among them, locks are a control mechanism in the database that is used to manage concurrent access to shared resources. In the database, the types of locks are divided into table locks, page locks, row locks (record locks, gap locks, and adjacent key locks) according to granularity. That is to say, in database operations, when a transaction holds a lock on specific data (such as a row, table, etc.), other transactions need to wait for the transaction to release the lock before they can access the data. If other transactions wait for too long to hold the lock, a lock waiting problem will occur, thereby reducing the performance and concurrent processing capabilities of the database, and even leading to reduced business execution efficiency, causing business applications to experience problems such as system access jams and program timeout errors.
[0061] When a lock wait problem occurs, at the code level, you can only perceive that a certain interface has timed out and slowed down, and at the database level, you can only perceive that the execution speed of the normally executed SQL statements has slowed down. In order to solve the lock wait problem, it is necessary to analyze the lock wait formation process, and by analyzing the lock waiting transactions and locking transactions involved in the lock wait, find the corresponding business code logic, and then set the corresponding repair business logic to avoid the lock wait. Among them, the lock waiting transaction refers to the transaction that is waiting to obtain the lock, and the locking transaction refers to the transaction that holds the lock and prevents the lock waiting transaction from accessing the data. When the lock waiting transaction needs to access the data held by the locked transaction, the lock waiting transaction will be blocked until the locking transaction releases the lock.
[0062] Therefore, obtaining accurate and comprehensive information about the lock waiting transactions and locking transactions involved in the lock waiting is the key to solving the lock waiting problem.
[0063] In some embodiments, in order to analyze the root cause of the lock wait, the lock wait information can be viewed based on the system table of the database. The system table of the database is used to store metadata information of various objects in the database. When a lock wait occurs, the lock wait information will be stored in the system table, which includes the identifier of the transaction waiting to obtain the lock, the identifier of the transaction holding the lock, the type of lock and the request status, etc. By querying the system table, the relevant information of these lock waits can be obtained.
[0064] However, based on the system table, only the transaction information of the currently executing waiting lock transaction and locking transaction can be obtained, and the information such as which SQL in the locking transaction caused the lock wait, the table involved in the SQL, the type of lock added by the SQL, etc. cannot be obtained, and the SQL field information of the lock wait information in the database management system table cannot be displayed.
[0065] For example, Figure 2 As shown, it is a flow chart of obtaining lock waiting information based on the system table provided by an embodiment of the present application. Taking the MySQL database as an example, first, query the current transaction to confirm whether there is a lock wait. The database management system executes the "show status like′innodb_row_lock" command to query the row lock status of the InnoDB engine in the current MySQL database. If the InnoDB engine is processing row locks, the value returned by this command will be greater than 0, indicating that there is currently a transaction waiting or holding a row lock. Then you can call the information_schema.INNODB_TRX table to query the relevant information of the current ongoing transaction from the table, including the status of the transaction, start time, locks held, etc. By viewing this information, you can determine whether there is a transaction blocked by a lock.
[0066] Then query the transaction details of the current lock waiting and obtain blocking_pid. Blocking_pid is the process identifier of the transaction holding the lock. The database management system can obtain the transactions currently waiting for the lock and the transactions that block the execution of these transactions by querying the view SYS.INNODB_LOCK_WAITS.
[0067] After obtaining blocking_pid, query the SQL thread statement thread_id through blocking_pid. Thread_id is the identifier of the thread. The database management system can call the performance_schema.threads table and find the thread_id holding the lock based on blocking_pid.
[0068] Query SQL statements by thread_id. The database management system can call the performance_schema.events_statements_history table and query the SQL statements executed by the thread according to the thread_id.
[0069] Based on the above steps, the SQL statement causing the blockage and the identifier thread_id of the corresponding thread are determined. In an emergency, in order to immediately solve the blocking problem, the database management system can execute the "kill thread_id" command to end the thread, thereby releasing the blockage.
[0070] The above steps are based on the system table to achieve the lock waiting location of the MySQL database. It can be seen that the system table-based method is limited. It can only obtain the lock waiting transaction and locking transaction involved in the current lock waiting. The SQL of the transaction is incomplete, and the information of the lock waiting transaction is also incomplete. In other words, the transaction information of the current lock waiting transaction and locking transaction obtained based on the system table is incomplete, and the process of lock waiting formation cannot be fully restored. It can only analyze the jamming problem caused by the current lock waiting, and cannot analyze the jamming problem caused by the lock waiting that has ended.
[0071] In addition, the method based on the system table is a sampling method. To obtain lock waiting information based on the system table, a collector is required to execute the process at a fixed frequency through sampling. The data collected by the above method is not full data, which may result in some jitter lock waiting scenarios not being collected, and it is impossible to customize the lock waiting information with performance issues.
[0072] In some embodiments, since the SQL of normal business in the database will also set a lock waiting mechanism. Therefore, in order to filter the lock waiting information that affects the database performance, the lock waiting time can be used to measure whether it affects the database performance. For example, defining a lock waiting time greater than 1s will affect the database performance. In order to implement the above-mentioned lock waiting information screening, it is necessary to modify the database version kernel source code to support printing of transaction SQL related information of waiting locks when the specified lock waiting time exceeds a certain threshold. At the same time, it is also necessary to collect the full amount of SQL audit logs and locking information. The above method requires replacing the database kernel, and the kernel needs to be upgraded for private deployment.
[0073] In some embodiments, lock wait events in a database may be monitored and collected based on non-intrusive detection technology. For example, a probe may be added to a lock-related function in a database using kernel technology to detect information about lock wait events. However, since the amount of lock-related data in a database is large, and in particular, the database uses row-level locks, resulting in a high frequency of calls to lock-related functions. If a probe is directly added to a lock-related function, a large amount of system resources for data collection and processing may be consumed, thereby reducing database performance.
[0074] It can be seen that the above implementation method, based on the built-in lock waiting information printing of the database management system table, cannot output all the information completely. If the missing information needs to be supplemented, the database kernel source code needs to be modified to achieve it. The kernel needs to be upgraded for private deployment, and it cannot be non-invasive. Adding detection to lock-related functions such as locking based on non-invasive detection technology will lead to a large amount of system resource consumption for data collection and processing. Whether through the system table or by detecting the locking function, it is impossible to obtain the full amount of lock waiting events with low consumption.
[0075] In some embodiments, some embodiments of the present application provide a method for obtaining database lock wait information. Based on non-intrusive detection technology, the database lock wait information is comprehensively captured without modifying or upgrading the database kernel source code, so as to comprehensively analyze the lock wait jam scenario and understand the root cause of the business execution jam problem.
[0076] like Figure 3 As shown, it is a schematic diagram of the operation scenario of database access provided by the embodiment of the present application. In the embodiment of the present application, the server 100 can constitute a server network system with the terminal device 200, and a database is mounted on the server 100 to provide database services to the terminal device 200. To this end, the server 100 can be connected by allowing the terminal device 200 to communicate through a local area network (LAN), a wireless local area network (WLAN) and other networks. The server 100 can provide various content and interactions to the terminal device 200. The server 100 can be a cluster or multiple clusters, and can include one or more types of servers.
[0077] The terminal device 200 is a device that triggers the call to the database, including but not limited to a communication terminal, a smart phone, a smart TV, a tablet computer, a personal computer (PC), a smart wearable device, a gaming device, etc. In some embodiments, the terminal device 200 may send a database connection request to the server 100 to establish a database connection with the server 100. After the connection is established, the terminal device 200 may communicate with the database instance by sending query statements or other messages of a specific protocol to perform data query, update or other operations.
[0078] like Figure 4 As shown, in order to establish a communication connection between the terminal device 200 and the server 100, a component for establishing a communication connection needs to be provided on the terminal device 200 and the server 100. That is, a communicator can be provided in the terminal device 200, and a communication module can be provided in the server 100. The communication module can establish a communication connection relationship with the communicator of the terminal device 200 according to various communication protocol types. Among them, the communication module can include other network communication protocol chips or near field communication protocol chips such as a Wifi module, a Bluetooth module, a wired Ethernet module, and at least one of an infrared receiver. For example, a wired Ethernet module can be built-in in both the terminal device 200 and the server 100. In the process of the terminal device 200 accessing the database on the server 100, the terminal device 200 can transmit the request data for accessing the database to the network line through the wired Ethernet module, and pass it to the server 100 through the network line, and the server 100 then receives the request data from the network line through the wired Ethernet module.
[0079] The connection relationship between the terminal device 200 and the server 100 can be "many-to-one", that is, multiple terminal devices 200 can establish a communication connection with the same server 100, so that the server 100 can provide services for multiple terminal devices 200. The connection relationship between the terminal device 200 and the server 100 can also be "many-to-many", that is, multiple terminal devices 200 can establish a communication connection with multiple servers 100, so that the multiple servers 100 can provide different services for the terminal devices 200 respectively. Obviously, in some application scenarios, the connection relationship between the terminal device 200 and the server 100 can also be "one-to-one", that is, one server 100 specifically provides services for one terminal device 200.
[0080] In some embodiments, in order to provide services for the terminal device 200, a storage module and a processing module may also be provided in the server 100. Among them, the storage module may store various resource data, information files and control programs. The processing module may include a central processing unit (CPU). The CPU processor is used to execute the operating system and application instructions stored in the storage module, and to execute various applications, data and content according to various interactive instructions received from the outside, so as to finally perform various forms of processing on the data. The CPU processor may also include multiple processors. For example, the processing module may include a main processor and one or more sub-processors.
[0081] In addition to the above-mentioned communication module, storage module and processing module, the server 100 may also include other components according to specific service functions. For example, a video processor, an audio processor, a graphics processor (Graphics Processing Unit, GPU), etc. Among them, the video processor is used to receive an external video signal, and according to the standard codec protocol of the input signal, perform video processing such as decompression, decoding, scaling, noise reduction, frame rate conversion, resolution conversion, image synthesis, etc., so as to obtain a video signal directly displayed or played for the terminal device 200. The graphics processor is used to generate various graphic objects, such as icons, operation menus, and user input instructions to display graphics, etc. By receiving various interactive instructions input by the terminal device 200, various objects are displayed according to the display attributes, and rendering is performed based on the various objects obtained. The audio processor is used to receive an external audio signal, decompress and decode it according to the standard codec protocol of the input signal, as well as noise reduction, digital-to-analog conversion and amplification processing, and obtain a sound signal to feed back to the terminal device 200.
[0082] The database lock waiting information acquisition method provided in the embodiment of the present application can be executed by the server 100 or by the terminal device 200. In the following embodiments, the execution subject of the database lock waiting information acquisition method provided in the embodiment of the present application is the above-mentioned server 100 as an example to illustrate the method of the embodiment of the present application. Figure 5 As shown, it is a schematic diagram of the data interaction relationship between the terminal device 200 and the server 100 provided in an embodiment of the present application, and the terminal device 200 is in communication connection with the server 100. The server 100 can collect and store the lock waiting information of the database based on the non-intrusive detection technology. The terminal device 200 can send an acquisition request for acquiring the lock waiting information to the server 100 based on the user's control instruction, and the server 100 sends the stored lock waiting information to the terminal device 200 according to the acquisition request of the terminal device 200. After receiving the lock waiting information, the terminal device 200 can display the lock waiting information in the form of text, image, video, etc.
[0083] It should be noted that the database described in the embodiments of the present application is explained using the MySQL database as an example of the technical solution. It should be understood that the provided technical solution can also be applied to other types of databases.
[0084] In order to implement the database lock waiting information acquisition method, the server 100 should at least include a storage module and a processing module. The storage module is configured to store data to form a database; the processing module is configured to execute the program steps corresponding to the database lock waiting information acquisition method, such as Figure 6FIG. 1 is a flow chart of a method for obtaining database lock waiting information provided in an embodiment of the present application, which specifically includes the following contents:
[0085] S100: Create a probe.
[0086] The probe is a database kernel probe built based on kernel technology. For example, an Extended Berkeley Packet Filter (Ebpf) can be used to add a probe to the database source code, thereby non-invasively capturing relevant data in the database.
[0087] S200: Add a probe to the lock wake-up function of the database.
[0088] Among them, the lock wake-up function (Notify lock) is used to send a wake-up notification to the waiting lock transaction to instruct the acquisition of the target lock when the locked transaction releases the target lock on the target data resource. The locked transaction is the transaction holding the target lock, and the waiting lock transaction is the transaction waiting to acquire the target lock. The target lock is a control mechanism for access to the target data resource in the database, which is used to control access to the target data resource. The transaction holding the target lock can perform data operations on the target data resource.
[0089] It can be understood that the lock wake-up function is a notification mechanism for handling lock waiting in the database management system. When a transaction accesses a data resource stored in the database, in order to avoid data inconsistency, the database management system uses a lock mechanism to control that only the transaction can perform data operations such as reading, modifying or deleting on the data resource. When the transaction completes the operation on the data resource, the transaction releases the lock so that other transactions can acquire the lock and access the data resource. When another transaction accesses the data resource, since the data resource has been locked by the transaction, the transaction needs to wait until the lock is released. The database management system will wake up the transaction waiting to access the data resource when the lock is released based on the lock wake-up function, so that the transaction can continue to execute and complete its operation. Through the lock wake-up function, the lock transaction can be woken up in time when the lock is released, reducing the waiting time of the transaction and the waste of system resources, thereby improving the concurrency performance of the database.
[0090] In some embodiments, the database management system uses an internal lock data structure (such as a lock table, a lock queue, or a lock map) to track and manage lock information. When allocating a lock, the lock data structure is set to reflect the allocation of the lock and its related information. Among them, the lock data structure includes information such as a lock state flag, a lock type, and a lock holder. The lock state flag is used to indicate the current lock state of the data resource. For example, the lock state flag includes an unlocked state and a locked state, so that the database management system can determine whether a lock can be allocated and whether other transactions waiting for the resource need to be awakened. The lock type is used to indicate the type of the allocated lock, such as a shared lock, an exclusive lock, an update lock, etc. The lock holder is used to indicate the transaction currently holding the lock, for example, the lock holder can be an identifier of a transaction. By maintaining the information of the above lock data structure, the database system can effectively manage the allocation and release of locks in a concurrent environment to ensure the consistency and integrity of the data.
[0091] like Figure 7 As shown, it is a timing interaction diagram of the lock wake-up mechanism provided by an embodiment of the present application. The above lock mechanism and the lock wake-up mechanism are managed and controlled by the lock manager (Lock Manager). The lock manager is a component in the database management system, which is responsible for managing and controlling the locks in the database. When the first transaction needs to access the target data resource stored in the database, it will send an acquisition request indicating the acquisition of the target lock on the target data resource to the lock manager in the database management system. The acquisition request contains the identifier of the first transaction, the resource identifier of the target data resource (such as table name, row ID, etc.) and the required lock type (such as shared lock, exclusive lock, etc.). The lock manager can respond to the acquisition request, set the lock data structure associated with the target lock according to the information in the acquisition request, change the lock state flag in the lock data structure from an unlocked state to a locked state, set the lock type to the lock type indicated by the acquisition request, set the lock holder to the identifier of the first transaction, etc., to configure the target lock to the first transaction, so that the first transaction can access the target data resource and complete its operation.
[0092] When the second transaction needs to access the target data resource stored in the database, it will send an acquisition request to the lock manager to indicate the acquisition of the target lock on the target data resource. In response to the acquisition request, the database management system can query the lock state flag, lock type and other factors affecting lock allocation in the lock data structure associated with the current target lock to determine whether to configure a lock for the second transaction. If the lock is not configured for the second transaction, a wait notification for indicating the waiting to acquire the target lock is sent to the second transaction, and the wait notification indicates that the target lock requested by the second transaction is currently unavailable, so that the second transaction enters a wait state.
[0093] When the first transaction completes the data operation on the target data resource, it sends a release request to the lock manager to instruct the release of the target lock. In response to the release request, the lock manager can update the lock data structure to reflect that the target lock has been released. The lock wake-up function is called, and a wake-up notification for instructing the acquisition of the target lock is sent to the second transaction through the lock wake-up function, so that after the second transaction receives the wake-up notification, it can send an acquisition request for instructing the acquisition of the target lock on the target data resource to the database management system.
[0094] When there are multiple second transactions, the database management system can select one or more transactions to wake up according to factors such as transaction priority, waiting time, resource requirements, etc.
[0095] For the first transaction and the second transaction, when a probe is set at the location of the lock wake-up function, the first transaction is a locked transaction holding the target lock, and the second transaction is a wait-lock transaction waiting to acquire the target lock.
[0096] S300: When the lock wake-up function sends a wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored.
[0097] After adding a probe to the lock wake-up function of the database, when the locked transaction releases the lock, the lock waiting transaction can be awakened through the lock wake-up function. This operation will trigger the data collection operation of the probe, and the full amount of lock waiting information can be collected through the probe. Among them, the lock waiting information includes the locked transaction information and the lock waiting transaction information. The locked transaction information is the relevant information of the locked transaction, and the lock waiting transaction information is the relevant information of the lock waiting transaction, including but not limited to the identifier (ID) of the transaction, the SQL statements that constitute the transaction, the execution order of the SQL statements, the start and end time of the execution, the transaction type (such as read, write, update and other operation types), the operation content (the specific operations performed in the transaction, such as which data is read, modified or deleted, etc.), the time the lock is held, the length of the lock waiting time, etc.
[0098] like Figure 8 As shown, it is an architecture diagram for collecting lock waiting information based on eBPF probe provided by an embodiment of the present application. Taking MySQL database as an example, an agent program is run in the user space to start and manage the eBPF probe program. The eBPF probe program needs to run in the kernel. The bytecode is the compilation result of the eBPF probe program and can be directly executed by the kernel. Therefore, before starting the eBPF probe program, the eBPF source code needs to be compiled into bytecode, and then the bytecode is injected into the kernel through a specific system call. After the bytecode is injected, the kernel will execute the corresponding eBPF probe program to detect the lock waiting information.
[0099] BPF Maps (Berkeley Packet Filter) is a structure used to transfer data between user space and kernel space. It is used to store data in kernel space and is accessed and operated by eBPF programs in the kernel. RingBuffer is a structure used to store data streams and cache data in user space. By using BPF Maps and RingBuffer, efficient network packet capture can be achieved, while also reducing frequent system calls and data copies.
[0100] The eBPF probe program is set at the lock wake-up function in the MySQL database. The eBPF probe program collects data based on the user probe mechanism (uprobe). Uprobe is a user space probe that can register a callback function when the user space program executes a specific function, thereby capturing data at a specific location. Uprobe can be used to probe the read() function in the MySQL database that reads data from the lock wake-up function. When the read() function is called, the callback function is triggered to obtain the lock wait information.
[0101] After the eBPF probe program collects the lock waiting information from the lock wake-up function, it can perform custom data filtering on the lock waiting information to filter out the lock waiting information that affects the database performance. For example, all SQL statements and lock waiting events of the waiting transactions and locking transactions whose waiting time is greater than the waiting time threshold can be filtered out from the lock waiting information, so as to analyze the reasons that affect the database performance.
[0102] In order to facilitate the analysis and processing of the lock waiting information collected by the probe, after the lock waiting information is collected, the lock waiting information can be submitted to the user state program. The user state program can directly print the stored lock waiting information, or send the lock waiting information to the downstream system, such as the message middleware, in a synchronous or asynchronous manner, so as to further analyze and process the lock waiting data.
[0103] In this embodiment, by writing an eBPF probe program, the probe is set at the lock wake-up function. The advantage of this detection point is that the amount of data is small, and there will be no performance problem of copying a large amount of locked data. Only when the current lock is released to wake up the transaction SQL waiting for the lock, will data be generated. That is, for the lock waiting event of the database, when a lock is released and wakes up other transaction SQLs, the probe detection will be triggered to collect the lock waiting event, obtain the lock waiting time and related information of the transaction SQL, and thus obtain the full amount of lock waiting information.
[0104] In some embodiments, after the lock waiting information is obtained, the lock waiting information can be analyzed to analyze the cause of the lock waiting. In order to restore the complete lock waiting formation process, it can be presented in the form of a lock waiting formation graph. Fig. 9 As shown, it is a schematic diagram of the process of generating a lock waiting formation graph provided by an embodiment of the present application. After obtaining the locked transaction information and the waiting lock transaction information, the structured query language packages in the waiting lock transaction information can be sorted according to the execution time of the structured query language packages in the locked transaction information to obtain a locked transaction table. According to the execution time of the structured query language packages in the waiting lock transaction information, the structured query language packages in the waiting lock transaction information can be sorted to obtain a waiting lock transaction table. Finally, the locked transaction table and the waiting lock transaction table are associated with each other to generate a lock waiting formation graph.
[0105] By forming a lock wait graph, you can analyze the relevant information of the lock wait, such as the start and end time of the lock wait: by analyzing the execution time of the transaction SQL, you can determine the start and end time points of the lock wait, and then calculate the length of the lock wait. The causal relationship of lock wait: by analyzing the execution order and execution time of the transaction SQL, you can determine which transaction requests the lock first, which transaction requests the lock later, and the causal relationship between them. Solution to lock wait: by analyzing the execution results of the transaction SQL, you can understand how the lock wait is resolved, such as transaction rollback, lock escalation, timeout retry and other mechanisms. The impact of lock wait: analyze the impact of lock wait on system performance, such as whether lock wait causes transaction delays, increased system response time or increased resource utilization.
[0106] In some embodiments, in order to analyze the cause of the lock wait, a target structured query language package can be extracted from the lock waiting transaction information, and the target structured query language package is a structured query language package whose lock waiting time is greater than the lock waiting time threshold. By obtaining a preset lock waiting time threshold, traversing the structured query language packages in the lock waiting transaction information, the structured query language package whose lock waiting time is greater than the lock waiting time threshold is marked as the target structured query language package.
[0107] After filtering out the target structured query language package, the target resource identifier and execution start time of the target structured query language package can be obtained. The target resource identifier is used to characterize the data resource on which the target structured query language package performs data operations, such as table name, row ID, etc. In the lock waiting formation graph, query the structured query language package with the same target resource identifier and an execution end time earlier than the execution start time, so as to obtain the root cause structured query language package that affects the execution of the target structured query language package based on the lock waiting formation graph query. The root cause structured query language package is a structured query language package whose execution end time is before the execution start time of the target structured query language package and the same data resource as the target structured query language package performs data operations.
[0108] For example, the lock wait diagram can be a swimlane diagram, such as Fig.10 As shown, it is a schematic diagram of the lock waiting lane chart of the embodiment of the present application. The lock waiting lane chart can show the lock waiting relationship between database transactions. Among them, the lock waiting lane chart represents transactions as lanes (i.e., vertical bars), and according to the lock waiting situation between transactions, the lanes are grouped according to the execution time of the transaction (i.e., time axis), so as to intuitively show the concurrent execution and lock waiting situation between transactions.
[0109] exist Fig.10 The lock waiting swim lane diagram shown shows the lock waiting relationship between transaction A (identifier 66318842) and transaction B (identifier 66318844). Based on the lock waiting swim lane diagram, we can filter out the transaction SQLs with a lock waiting time longer than 3s and find the root cause SQL that affects the execution time of the transaction SQL. Fig.10 As shown, when the SQL statement (lock SQL) in transaction B is executed, it needs to access the data resource ResourceB, and can request to obtain the lock of the data resource ResourceB identified as ddl30704-0, and perform corresponding data operations on it. The SQL statement (wait lock SQL) in transaction A is blocked when requesting to obtain the lock of the data resource ResourceB identified as ddl30704-0. Only after transaction B releases the lock of ResourceB, transaction A can obtain the lock of data resource ResourceB and perform corresponding data operations on it.
[0110] In this embodiment, eBPF technology is used to add probes to the lock wake-up part of the MySQL source code. By applying probes to the MySQL kernel lock wake-up function, lock waiting transaction information with performance issues is captured and screened, and non-intrusive full lock waiting information acquisition is achieved. It can be understood that this solution is not limited to using Ebpf technology to detect and capture information on some source code functions of the MySQL kernel SQL. Although the function probes of other database engines are slightly different, the overall solution idea is consistent.
[0111] Based on the database lock waiting information acquisition method provided in the above embodiments, some embodiments of the present application further provide a server 100, wherein the server 100 includes a storage module and a processing module, wherein the storage module is configured to store data to form a database; and the processing module is configured to execute the following program steps:
[0112] Create a probe. The probe is a database kernel probe built based on kernel technology.
[0113] Add a probe to the lock wakeup function of the database. The lock wakeup function is used to send a wakeup notification to the waiting lock transaction to instruct the acquisition of the target lock when the locking transaction releases the target lock on the target data resource. The locking transaction is the transaction that holds the target lock, and the waiting lock transaction is the transaction that is waiting to acquire the target lock. The target lock is a control mechanism for access control to the target data resource. The transaction holding the target lock can perform data operations on the target data resource.
[0114] When the lock wake-up function sends a wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe. The lock waiting information includes the locking transaction information and the waiting lock transaction information.
[0115] Based on the database lock waiting information acquisition method provided in the above embodiments, some embodiments of the present application also provide a terminal device 200, wherein the terminal device 200 includes a communicator and a controller, the communicator is configured to establish a communication connection with a server, the server is equipped with a database, and a probe is provided on the lock wake-up function of the database, and the probe is used to collect lock waiting information when the lock wake-up function sends a wake-up notification to the waiting lock transaction. The lock wake-up function is used to send a wake-up notification to the waiting lock transaction to indicate the acquisition of the target lock when the locked transaction releases the target lock on the target data resource. The locked transaction is a transaction that holds the target lock, and the waiting lock transaction is a transaction that is waiting to acquire the target lock. The target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource. The controller is configured to execute the following program steps:
[0116] An acquisition request for acquiring lock waiting information sent to the server, where the acquisition request is used to enable the server to feed back the stored lock waiting information collected based on the probe to the terminal device.
[0117] Receive lock waiting information fed back by the server.
[0118] It can be seen from the above technical solutions that the server, terminal device and database lock waiting information acquisition method provided by the above embodiments can first create a probe, and add the probe to the lock wake-up function of the database. The lock wake-up function is used to send a wake-up notification to the waiting lock transaction to indicate the acquisition of the target lock when the locked transaction releases the target lock on the target data resource. When the lock wake-up function sends a wake-up notification to the waiting lock transaction, the lock waiting information is collected based on the probe, and the lock waiting information is stored. The locked transaction is a transaction that holds the target lock, and the waiting lock transaction is a transaction that is waiting to obtain the target lock. The target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource. The method is based on non-invasive detection technology, and a probe is applied to the database kernel lock wake-up function to achieve non-invasive full lock waiting information acquisition.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0120] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
Claims
1. A server, characterized in that: include: A storage module configured to store data to form a database; The processing module is configured as follows: Creating a probe, wherein the probe is a database kernel probe built based on kernel technology; The probe is added to the lock wake-up function of the database, and the lock wake-up function is used to send a wake-up notification for indicating acquisition of the target lock to the waiting lock transaction when the locking transaction releases the target lock on the target data resource; the locking transaction is a transaction holding the target lock, and the waiting lock transaction is a transaction waiting to acquire the target lock, and the target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource; When the lock wake-up function sends the wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored, where the lock waiting information includes locking transaction information and waiting lock transaction information.
2. The server according to claim 1, characterized in that: It also includes a communication module, which is configured to establish a communication connection with a terminal device; the processing module is also configured to: After the probe collects the lock waiting information, storing the lock waiting information; Receiving an acquisition request for acquiring lock waiting information sent by the terminal device; In response to the acquisition request, the lock waiting information is sent to the terminal device.
3. The server according to claim 1, characterized in that: The processing module is further configured to: Sorting the structured query language packages in the locking transaction information according to the execution time of the structured query language packages in the locking transaction information to obtain a locking transaction table; Sorting the structured query language packages in the wait-lock transaction information according to the execution time of the structured query language packages in the wait-lock transaction information to obtain a wait-lock transaction table; A lock waiting graph is generated according to the locking transaction table and the waiting lock transaction table.
4. The server according to claim 3, characterized in that: The processing module is further configured to: Extracting a target structured query language package from the lock-waiting transaction information, wherein the target structured query language package is a structured query language package whose lock-waiting time is greater than a lock-waiting time threshold; A root cause structured query language package is formed according to the lock wait graph, wherein the root cause structured query language package is a structured query language package whose execution end time is before the execution start time of the target structured query language package and whose data resource is the same as the data operation performed by the target structured query language package.
5. The server according to claim 4, characterized in that: The processing module performs the step of extracting a target structured query language package from the equal lock transaction information, and is further configured to: Get the lock waiting time threshold; Traversing the structured query language package in the lock-waiting transaction information; The structured query language package whose waiting lock time is longer than the waiting lock time threshold is marked as a target structured query language package.
6. The server according to claim 3, characterized in that: The processing module performs the step of forming a graph query root cause structured query language package according to the lock wait, and is further configured to: Acquire a target resource identifier and an execution start time of the target structured query language package, wherein the target resource identifier is used to represent a data resource on which the target structured query language package performs a data operation; The lock waiting formation graph is searched for a structured query language package having the same identifier as the target resource and an execution end time earlier than the execution start time, so as to obtain a root cause structured query language package.
7. The server according to claim 1, characterized in that: The processing module is further configured to: Receiving an acquisition request sent by a first transaction indicating acquisition of a target lock on a target data resource, the acquisition request including an identifier of the first transaction, an identifier of the target data resource, and a lock type; Setting a lock data structure associated with the target lock according to the acquisition request; The target lock is configured for the first transaction, so that the first transaction serves as a locked transaction.
8. The server according to claim 7, characterized in that: The processing module is further configured to: In response to an acquisition request sent by the second transaction indicating the acquisition of a target lock on a target data resource, sending a wait notification indicating waiting to acquire the target lock to the second transaction, so that the second transaction serves as a wait lock transaction; When the first transaction releases the target lock, a wakeup notification for instructing to acquire the target lock is sent to the second transaction through the lock wakeup function.
9. A terminal device, characterized in that: include: A communicator, the communicator being configured to establish a communication connection with a server, the server being equipped with a database, a probe being provided on a lock wake-up function of the database, the probe being used to collect lock waiting information when the lock wake-up function sends a wake-up notification to a waiting lock transaction, the lock wake-up function being used to send a wake-up notification for indicating acquisition of the target lock to the waiting lock transaction when the locked transaction releases the target lock on the target data resource; the locked transaction is a transaction holding the target lock, the waiting lock transaction is a transaction waiting to acquire the target lock, the target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource; The controller is configured as: An acquisition request for acquiring lock waiting information sent to the server, wherein the acquisition request is used to enable the server to feed back the stored lock waiting information collected based on the probe to the terminal device; Receive the lock waiting information fed back by the server.
10. A method for obtaining database lock waiting information, characterized in that: The method comprises: Creating a probe, wherein the probe is a database kernel probe built based on kernel technology; The probe is added to the lock wake-up function of the database, and the lock wake-up function is used to send a wake-up notification for indicating acquisition of the target lock to the waiting lock transaction when the locking transaction releases the target lock on the target data resource; the locking transaction is a transaction holding the target lock, and the waiting lock transaction is a transaction waiting to acquire the target lock. The target lock is used to control access to the target data resource, and the transaction holding the target lock can perform data operations on the target data resource; When the lock wake-up function sends the wake-up notification to the waiting lock transaction, lock waiting information is collected based on the probe, and the lock waiting information is stored, where the lock waiting information includes locking transaction information and waiting lock transaction information.