Abnormity detection method and device for distributed database, equipment and storage medium
By configuring active threads in the connection pool of distributed databases, real-time monitoring of the connection between the application and the database, the long-term blocking problem caused by network failure is solved, and the efficiency and reliability of exception perception are improved.
Patent Information
- Application Number
- CN202411820534.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-18
AI Technical Summary
During network failure or device switching, the application's connection to the database will be blocked for a long time, resulting in transaction failure and server thread occupation cannot be released.
By configuring target active threads in the target connection pool, we can monitor the connection between the application and the distributed database in real time and perform exception detection on the first connection.
Improves the efficiency and reliability of exception perception, promptly identify and handle connection exceptions, and avoids long-term blocking of applications and transaction failures.
Smart Images

Figure CN119646096A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, in particular to the field of distributed technology, and specifically to a method, apparatus, device and storage medium for detecting anomalies in a distributed database. Background Art
[0002] When a network failure or network device switching occurs, the application's in-transit database connection will be blocked and unresponsive for a long time until a certain period of time passes before returning a failure. This problem not only causes application transactions to fail, but also causes the application server thread to be occupied for a long time and unable to be released.
[0003] Currently, to address this problem, the TCP (Transmission Control Protocol) parameters on the operating system side are usually adjusted to reduce the TCP network blocking time, thereby reducing the client blocking time. However, the TCP parameter modification is effective for all system TCP connections. Improper configuration will reduce the robustness of all TCP connections under network abnormality scenarios (including congestion); or the socketTimeout (socket timeout) parameter provided by the JDBC (Java Database Connectivity) driver is used for the timeout value of the network connection read operation; if the time spent reading from the server exceeds the setting value of this parameter, the connection is closed, but the execution of SQL (Structured Query Language) in the database will not be interrupted. Therefore, for long-running scenarios where batch processing is performed through stored procedures, since long-term network read operations are required, such problems cannot be avoided by setting socketTimeout. Summary of the invention
[0004] The present application provides a distributed database anomaly detection method, apparatus, device and storage medium to improve the efficiency and reliability of anomaly perception.
[0005] According to one aspect of the present application, a method for detecting anomalies in a distributed database is provided, the method comprising:
[0006] Initialize the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node;
[0007] When it is identified that the target application program establishes a database connection with the target distributed database for the first time, a target liveness detection thread is configured in the target connection pool; wherein the target liveness detection thread is used to monitor the connection status between the target application program and the target distributed database in real time;
[0008] The target activation detection thread is used to perform anomaly detection on the first connection between the target distributed database and the target application.
[0009] According to another aspect of the present application, a distributed database anomaly detection device is provided, the device comprising:
[0010] A connection pool initialization module is used to initialize a target connection pool according to a candidate master database node and a candidate connection object of a target distributed database; wherein the candidate connection object refers to a data object that has established a connection with the candidate master database node;
[0011] A thread configuration module, configured to configure a target liveness detection thread in the target connection pool when it is identified that the target application program establishes a database connection with the target distributed database for the first time; wherein the target liveness detection thread is used to monitor the connection status between the target application program and the target distributed database in real time;
[0012] The anomaly detection module is used to use the target activation detection thread to perform anomaly detection on the first connection between the target distributed database and the target application.
[0013] According to another aspect of the present application, an electronic device is provided, the electronic device comprising:
[0014] one or more processors;
[0015] A memory for storing one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement any one of the distributed database anomaly detection methods provided in the embodiments of the present application.
[0017] According to another aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, any one of the anomaly detection methods for a distributed database provided in the embodiments of the present application is implemented.
[0018] According to another aspect of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the computer program implements any one of the distributed database anomaly detection methods provided in the embodiments of the present application.
[0019] This application initializes the target connection pool according to the candidate master database node and candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node; when it is identified that the target application and the target distributed database have established a database connection for the first time, a target activation thread is configured in the target connection pool; wherein the target activation thread is used to monitor the connection status of the target application and the target distributed database in real time; the target activation thread is used to perform anomaly detection on the first connection between the target distributed database and the target application. The above technical solution helps to improve the efficiency of anomaly perception by setting the target activation thread to perform anomaly monitoring on the connection between the target application and the target distributed database. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a distributed database anomaly detection method provided according to Embodiment 1 of the present application;
[0021] Figure 2 is a flow chart of a distributed database anomaly detection method provided according to Embodiment 2 of the present application;
[0022] Figure 3 It is a structural diagram of an abnormality detection device for a distributed database provided according to Embodiment 3 of the present application;
[0023] Figure 4 It is a structural diagram of an electronic device for implementing the anomaly detection method of a distributed database according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present 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 data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] In addition, it should be noted that in the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of relevant data such as candidate connection objects and data objects involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0027] Embodiment 1
[0028] Figure 1 This is a flow chart of a distributed database anomaly detection method provided in accordance with the first embodiment of the present application. This embodiment is applicable to the case of real-time monitoring of the online connection between the distributed database and the application program, and can be performed by a distributed database anomaly detection device, which can be implemented in the form of hardware and / or software, and can be configured in a computer device, such as a server. Figure 1 As shown, the method includes:
[0029] S110. Initialize a target connection pool according to candidate master database nodes and candidate connection objects of a target distributed database; wherein the candidate connection object refers to a data object that has established a connection with the candidate master database node.
[0030] The target distributed database refers to the data storage system that the application will connect to and operate, which usually has multiple nodes to ensure high availability and scalability. The candidate master database node refers to the database master node that has established a connection in the distributed database. The candidate connection object refers to the data object that has established a valid connection with the candidate master database node in the target distributed database, usually referring to the connection instance that can read and write data. The target connection pool refers to a resource pool that manages the connection with the target distributed database. It contains all the connection objects with the target database for reuse when the application performs data operations.
[0031] Exemplarily, in the initial connection pool, a list of connection objects that have established connections to the current data source is added to cache, and the database master node that caches the current connection is synchronized in the list to obtain a target connection pool.
[0032] Among them, the initial connection pool refers to the database connection pool managed for the target distributed database; the connection pool is a group of database connection objects set up to reuse database connections; it can effectively reduce the overhead of frequently establishing and closing database connections and improve system performance and response speed.
[0033] Furthermore, each time the target connection pool calls the JDBC driver to add a new connection, the new connection object is updated to the cache list.
[0034] S120. When it is identified that the target application program establishes a database connection with the target distributed database for the first time, configure a target activation detection thread in the target connection pool; wherein the target activation detection thread is used to monitor the connection status between the target application program and the target distributed database in real time.
[0035] The target application refers to the application that needs to interact and operate with the target distributed database. The first connection refers to the first connection established between the target application and the target distributed database; usually, the system will perform special processing on the first connection, including configuring the connection pool, performing connection verification, etc. The target liveness detection thread refers to a thread in the system that is specifically used to detect the health of the connection with the target distributed database; it ensures that the database connection is available through regular detection operations (such as sending heartbeat packets or executing simple queries).
[0036] Exemplarily, in the target connection pool, an activation detection thread is added, and the thread synchronously establishes a dedicated activation detection database connection when the target application establishes a database connection for the first time.
[0037] S130: Use the target activation thread to perform anomaly detection on the first connection between the target distributed database and the target application.
[0038] Among them, anomaly detection refers to the process of monitoring and identifying abnormal situations that may occur during system operation (such as connection timeout, data error, etc.); the detection thread will monitor the status of the database connection in real time, and once an abnormality occurs, recovery or alarm measures will be taken in time.
[0039] Specifically, a target activation thread is used to monitor in real time whether there is an abnormal situation of connection failure or unavailability in the first connection between the target distributed database and the target application.
[0040] Furthermore, if an abnormality is found, the current connection between the target distributed database and the target application is closed in time, and the connection between the target distributed database and the target application is reestablished, and an abnormality alarm is sent asynchronously.
[0041] The embodiment of the present application initializes the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node; when it is identified that the target application and the target distributed database have established a database connection for the first time, a target activation thread is configured in the target connection pool; wherein the target activation thread is used to monitor the connection status of the target application and the target distributed database in real time; the target activation thread is used to perform anomaly detection on the first connection between the target distributed database and the target application. The above technical solution helps to improve the efficiency of anomaly perception by setting the target activation thread to perform anomaly monitoring on the connection between the target application and the target distributed database.
[0042] Embodiment 2
[0043] Figure 2 It is a flow chart of a distributed database anomaly detection method provided in accordance with the second embodiment of the present application. Based on the technical solutions of the above embodiments, this embodiment refines "using a target activation thread to perform anomaly detection on the first connection between the target distributed database and the target application" into "using a target activation thread to perform anomaly detection on the connection between the target distributed database and the target application according to a preset activation time interval and timeout waiting period, and record the number of consecutive failures of the activation thread in real time; based on the number of consecutive failures, determine whether there is an anomaly in the first connection between the target distributed database and the target application". It should be noted that for the parts not described in detail in the embodiments of the present application, please refer to the relevant statements of other embodiments. Figure 2 As shown, the method includes:
[0044] S210: Initialize a target connection pool according to candidate master database nodes and candidate connection objects of the target distributed database.
[0045] S220: When it is identified that the target application program establishes a database connection with the target distributed database for the first time, a target activation thread is configured in the target connection pool.
[0046] S230: Using the target live detection thread, according to the preset live detection time interval and timeout waiting time, perform abnormal detection on the connection between the target distributed database and the target application, and record the number of consecutive failures of the live detection thread in real time.
[0047] Among them, the detection interval refers to the time interval for the target detection thread to perform regular health checks, that is, how often the detection thread will perform a health check operation; this time interval is usually configured by the system administrator or developer according to actual needs, and it determines the frequency of the target detection thread; if it is set too short, it may cause the system to check too frequently, affecting performance; if it is set too long, it may delay the time to detect connection abnormalities; illustratively, the detection interval can be set to 5 seconds. The timeout waiting period refers to the maximum time to wait for the target distributed database to respond when the detection thread initiates a health check operation; if no response is received within this time, the detection thread will consider the connection abnormal; illustratively, the timeout waiting period can be set to 3 seconds. The number of consecutive failures refers to the number of consecutive detection failures (i.e., the health check fails) of the target detection thread within a period of time; if the detection thread fails multiple health checks in a row within the set detection interval, the system will consider that there is a problem with the connection.
[0048] For example, if the last liveness detection thread failed and the current liveness detection thread fails, the number of consecutive failures recorded is 2; if the last liveness detection thread succeeded and the current liveness detection thread failed, the number of consecutive failures recorded is 1; if the last liveness detection thread failed and the current liveness detection thread succeeded, the number of consecutive failures is not recorded; if the last liveness detection thread succeeded and the current liveness detection thread succeeded, the number of consecutive failures is not recorded.
[0049] S240. Determine whether there is an abnormality in the first connection between the target distributed database and the target application program according to the number of consecutive failures.
[0050] Optionally, if the number of consecutive failures meets the connection abnormality condition, the first connection between the target distributed database and the target application is determined to be abnormal, and the first connection between the target distributed database and the target application is closed; if the number of consecutive failures does not meet the connection abnormality condition, the target activation thread continues to be executed.
[0051] The abnormal connection condition is preset manually based on actual conditions or experience values; illustratively, the abnormal connection condition may be that the number of consecutive failures reaches 5 times.
[0052] Furthermore, after closing the first connection between the target distributed database and the target application, the historical main library node of the first connection between the target application and the target distributed database can also be obtained, and the historical main library node can be saved to the target connection pool; based on the historical main library node, the secondary connection between the target application and the target distributed database can be re-established.
[0053] The historical master database node refers to the master database node where the target application and the target distributed database last established a connection.
[0054] Specifically, the target master library node for obtaining the secondary connection between the target application and the target distributed database can be to perform a consistency check on the target master library node and the historical master library node, and if the consistency check passes, establish a secondary connection between the target application and the target distributed database; if the consistency check fails, modify the historical master library node in the target connection pool to the target master library node, and establish a secondary connection between the target application and the target master library node.
[0055] The target master database node refers to the master database node that currently establishes a connection between the target application and the target distributed database. The consistency check refers to the check to determine whether the target master database node and the historical master database node are the same master database node.
[0056] Exemplarily, each time the target connection pool establishes a database connection, it checks whether the main library node for the current connection is consistent with the main library node for the last connection established in the cache; if they are consistent, the newly established connection is returned normally; if they are inconsistent, the main library node for the last connection established in the target connection pool cache is modified to the new main library node, and the secondary connection between the target application and the target main library node is re-established.
[0057] In an optional implementation, after the historical master database node in the target connection pool is modified to the target master database node, when the target connection pool recognizes that the database master database node has changed, the current status of all connections in the target connection pool connected to the historical master database node is judged; if the current status is idle, all connections are closed; if the current status is a network read / write wait status, the connection is interrupted and an exception is returned.
[0058] It can be understood that by judging the number of consecutive failures of the live detection thread within a certain period of time, it can ensure that the application side can perceive the abnormality between the application side and the database in a short time, and trigger the re-establishment of the connection through the live detection thread to identify the failure scenario where the primary and secondary switching has occurred, and quickly interrupt the online connection pointing to the old database, ensuring that the application thread can quickly perceive the database failure and avoid the application side from entering a long period of idle waiting.
[0059] The embodiment of the present application initializes the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node; when it is identified that the target application and the target distributed database have established a database connection for the first time, a target activation thread is configured in the target connection pool; wherein the target activation thread is used to monitor the connection status of the target application and the target distributed database in real time; the target activation thread is used to detect anomalies in the connection between the target distributed database and the target application according to the preset activation time interval and timeout waiting time, and the number of consecutive failures of the activation thread is recorded in real time; according to the number of consecutive failures, it is judged whether there is an anomaly in the first connection between the target distributed database and the target application. The above technical scheme helps to improve the efficiency of anomaly perception by setting the target activation thread to monitor the connection between the target application and the target distributed database for anomalies.
[0060] Embodiment 3
[0061] Figure 3 This is a schematic diagram of the structure of a distributed database anomaly detection device provided in Example 3 of the present application, which can be applied to the situation of real-time monitoring of the online connection between the distributed database and the application program. The distributed database anomaly detection device can be implemented in the form of hardware and / or software, and the distributed database anomaly detection device can be configured in a computer device, such as a server. Figure 3 As shown, the device comprises:
[0062] The connection pool initialization module 310 is used to initialize the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node;
[0063] The thread configuration module 320 is used to configure a target live detection thread in the target connection pool when it is identified that the target application program establishes a database connection with the target distributed database for the first time; wherein the target live detection thread is used to monitor the connection status between the target application program and the target distributed database in real time;
[0064] The anomaly detection module 330 is used to use the target liveness detection thread to perform anomaly detection on the first connection between the target distributed database and the target application.
[0065] The embodiment of the present application initializes the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node; when it is identified that the target application and the target distributed database have established a database connection for the first time, a target activation thread is configured in the target connection pool; wherein the target activation thread is used to monitor the connection status of the target application and the target distributed database in real time; the target activation thread is used to perform anomaly detection on the first connection between the target distributed database and the target application. The above technical solution helps to improve the efficiency of anomaly perception by setting the target activation thread to perform anomaly monitoring on the connection between the target application and the target distributed database.
[0066] Optionally, the anomaly detection module 330 includes:
[0067] The anomaly detection unit is used to use the target liveness detection thread to perform anomaly detection on the connection between the target distributed database and the target application according to the preset liveness detection time interval and timeout waiting time, and record the number of consecutive failures of the liveness detection thread in real time;
[0068] The abnormality judgment unit is used to judge whether there is an abnormality in the first connection between the target distributed database and the target application according to the number of consecutive failures.
[0069] Optional, abnormality judgment unit, specifically used for:
[0070] If the number of consecutive failures meets the connection abnormality condition, the first connection between the target distributed database and the target application is determined to be abnormal, and the first connection between the target distributed database and the target application is closed;
[0071] If the number of consecutive failures does not meet the connection abnormality condition, the target live detection thread continues to execute.
[0072] Optionally, the device further includes a secondary connection module; the secondary connection module includes:
[0073] A node acquisition unit, used to acquire the historical master database node for the first connection between the target application and the target distributed database, and save the historical master database node to the target connection pool;
[0074] The connection establishment unit is used to re-establish a secondary connection between the target application and the target distributed database according to the historical main database node.
[0075] Optionally, the connection establishing unit is specifically configured to:
[0076] Obtain the target master database node for the secondary connection between the target application and the target distributed database;
[0077] A consistency check is performed on the target master database node and the historical master database node, and if the consistency check passes, a secondary connection is established between the target application and the target distributed database.
[0078] Optionally, the connection establishing unit is further specifically configured to:
[0079] If the consistency check fails, the historical master database node in the target connection pool is modified to be the target master database node, and a secondary connection is established between the target application and the target master database node.
[0080] The anomaly detection device for a distributed database provided in the embodiments of the present application can execute the anomaly detection method for a distributed database provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects for executing the anomaly detection method for each distributed database.
[0081] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.
[0082] Embodiment 4
[0083] Figure 4 It is a structural diagram of an electronic device 410 that implements the anomaly detection method of the distributed database of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or required herein.
[0084] like Figure 4As shown, the electronic device 410 includes at least one processor 411, and a memory connected to the at least one processor 411 in communication, such as a read-only memory (ROM) 412, a random access memory (RAM) 413, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 411 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 412 or the computer program loaded from the storage unit 418 to the random access memory (RAM) 413. In RAM413, various programs and data required for the operation of the electronic device 410 can also be stored. The processor 411, ROM412 and RAM413 are connected to each other via a bus 414. An input / output (I / O) interface 415 is also connected to the bus 414.
[0085] Multiple components in the electronic device 410 are connected to the I / O interface 415, including: an input unit 416, such as a keyboard, a mouse, etc.; an output unit 417, such as various types of displays, speakers, etc.; a storage unit 418, such as a disk, an optical disk, etc.; and a communication unit 419, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 419 allows the electronic device 410 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0086] The processor 411 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 411 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 411 executes the various methods and processes described above, such as anomaly detection methods for distributed databases.
[0087] In some embodiments, the anomaly detection method for a distributed database may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 418. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 410 via the ROM 412 and / or the communication unit 419. When the computer program is loaded into the RAM 413 and executed by the processor 411, one or more steps of the anomaly detection method for a distributed database described above may be performed. Alternatively, in other embodiments, the processor 411 may be configured as an anomaly detection method for a distributed database by any other appropriate means (e.g., by means of firmware).
[0088] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0089] The computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable distributed database anomaly detection device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0090] In the context of the present application, a computer readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device or equipment. A computer readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer readable storage medium may be a machine readable signal medium. A more specific example of a machine readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0091] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0092] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0093] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0094] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution of this application can be achieved, and this document is not limited here.
[0095] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A distributed database anomaly detection method, characterized in that: include: Initialize the target connection pool according to the candidate master database node and the candidate connection object of the target distributed database; wherein the candidate connection object refers to the data object that has established a connection with the candidate master database node; When it is identified that the target application program establishes a database connection with the target distributed database for the first time, a target liveness detection thread is configured in the target connection pool; wherein the target liveness detection thread is used to monitor the connection status between the target application program and the target distributed database in real time; The target activation detection thread is used to perform anomaly detection on the first connection between the target distributed database and the target application.
2. The method according to claim 1, characterized in that Using the target liveness detection thread, anomaly detection is performed on the first connection between the target distributed database and the target application, including: Using the target liveness detection thread, according to the preset liveness detection time interval and timeout waiting time, anomaly detection is performed on the connection between the target distributed database and the target application, and the number of consecutive failures of the liveness detection thread is recorded in real time; According to the number of consecutive failures, it is determined whether there is an abnormality in the first connection between the target distributed database and the target application.
3. The method according to claim 2, characterized in that The determining, based on the number of consecutive failures, whether there is an abnormality in the first connection between the target distributed database and the target application comprises: If the number of consecutive failures meets the connection abnormality condition, determining that the first connection between the target distributed database and the target application is abnormal, and closing the first connection between the target distributed database and the target application; If the number of consecutive failures does not satisfy the connection abnormality condition, the target live detection thread continues to be executed.
4. The method according to claim 3, characterized in that: After closing the first connection between the target distributed database and the target application, the method further includes: Obtaining a historical master database node for the first connection between the target application and the target distributed database, and saving the historical master database node to the target connection pool; According to the historical master database node, a secondary connection between the target application and the target distributed database is re-established.
5. The method according to claim 4, characterized in that The re-establishing the secondary connection between the target application and the target distributed database according to the historical master database node includes: Acquire a target master database node for secondary connection between the target application and the target distributed database; A consistency check is performed on the target master database node and the historical master database node, and if the consistency check passes, a secondary connection is established between the target application and the target distributed database.
6. The method according to claim 5, characterized in that In the case where the consistency check fails, the method further includes: The historical master library node in the target connection pool is modified into a target master library node, and a secondary connection is established between the target application and the target master library node.
7. An anomaly detection device for a distributed database, characterized in that: include: A connection pool initialization module is used to initialize a target connection pool according to a candidate master database node and a candidate connection object of a target distributed database; wherein the candidate connection object refers to a data object that has established a connection with the candidate master database node; A thread configuration module, configured to configure a target liveness detection thread in the target connection pool when it is identified that the target application program establishes a database connection with the target distributed database for the first time; wherein the target liveness detection thread is used to monitor the connection status between the target application program and the target distributed database in real time; The anomaly detection module is used to use the target activation detection thread to perform anomaly detection on the first connection between the target distributed database and the target application.
8. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the anomaly detection method for a distributed database as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the anomaly detection method for a distributed database as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the anomaly detection method for a distributed database according to any one of claims 1 to 6.