Service recovery method and device, equipment and storage medium

By monitoring the network connection of the software server, periodically checking and automatically closing invalid connections, the problem of long service recovery time caused by failure is solved, and the rapid and automatic service recovery is achieved, and a high availability mechanism is provided.

CN120448169APending Publication Date: 2025-08-08BEIJING QINGYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510524001.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The problem of business recovery time caused by failures between software services and database services is too long, especially in the case of network instability or node downtime, and business side failures caused by long-term waiting.

Method used

By monitoring the network connection of the software server, periodically check the execution time of the in-use connection, determine the invalid connection and automatically close and repair it, avoiding long-term waiting.

Benefits of technology

It realizes rapid and automatic business recovery without changing the operating system kernel configuration and restarting the server, providing a secure and automated high-availability mechanism to avoid task blockage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448169A_ABST
    Figure CN120448169A_ABST
Patent Text Reader

Abstract

The invention discloses a service recovery method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: determining whether to start service recovery according to a difference value between current time and end time of executing service recovery in the last round; if the start is determined, determining the execution duration of an in-use connection, the in-use connection being a communication connection which is executing the SQL statement; determining the in-use connection of which the execution duration is greater than a preset threshold as a to-be-checked connection, and determining an invalid connection in the to-be-checked connection as a to-be-repaired connection; and realizing service recovery by closing and repairing the to-be-repaired connection. According to the technical scheme provided by the embodiment of the invention, the connection can be automatically closed and repaired, and the SQL statement in the software server can be continuously executed, so that the task is not blocked, and the service is quickly and automatically recovered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a service recovery method, apparatus, device and storage medium. Background Art

[0002] In the computing field, the implementation of software services in various business scenarios requires increasingly complex data storage, querying, updating, and analysis. Software services must accurately acquire and process data in real time to provide users with a responsive and reliable service experience. This requires software services to have access to relational database services. Leveraging the characteristics of relational databases, they can ensure data integrity and security, enabling efficient data operations within complex business logic.

[0003] However, when disasters and network instability occur in some database-related nodes, the communication between the software service and the database service will be interrupted. Although the interruption time is controllable (such as 5 minutes), the SQL statements executed by the software service may have to wait for a long time (such as 2 hours) for the database service to return a message. This long wait time is usually much longer than the interruption time, which will further cause long-term failures on the business side. Summary of the Invention

[0004] The present invention provides a business recovery method, apparatus, device and storage medium to solve the problem of long business recovery time caused by failure between software services and database services.

[0005] In a first aspect, the present invention provides a service recovery method, applied to a software server, comprising:

[0006] Determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery;

[0007] If it is determined to start, then determining the execution duration of the in-use connection, wherein the in-use connection is a communication connection that is executing an SQL statement;

[0008] Determine in-use connections whose execution time is longer than a preset threshold as connections to be checked, and determine invalid connections among the connections to be checked as connections to be repaired;

[0009] Service recovery is achieved by closing and repairing the connection to be repaired.

[0010] In a second aspect, the present invention provides a service recovery device, comprising:

[0011] A judgment module is used to determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery;

[0012] an execution duration determination module, configured to determine the execution duration of an in-use connection if the information returned by the determination module is "start", wherein the in-use connection is a communication connection that is executing an SQL statement;

[0013] a connection-to-be-repaired determining module, configured to determine in-use connections whose execution time is greater than a preset threshold as connections to be checked, and to determine invalid connections among the connections to be checked as connections to be repaired;

[0014] The service recovery module is used to realize service recovery by closing and repairing the connection to be repaired.

[0015] In a third aspect, the present invention provides an electronic device, comprising:

[0016] at least one processor;

[0017] and a memory communicatively coupled to the at least one processor;

[0018] The memory stores a computer program that can be executed by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the service recovery method of the first aspect mentioned above.

[0019] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the business recovery method of the first aspect when executed.

[0020] The business recovery solution provided by the present invention determines whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery. If it is determined to start, the execution time of the in-use connection is determined, wherein the in-use connection is a communication connection that is executing an SQL statement. The in-use connection with an execution time greater than a preset threshold is determined as a connection to be checked, and the invalid connection among the in-use connections is determined as a connection to be repaired. Business recovery is achieved by closing and repairing the connection to be repaired. By adopting the above technical solution, there is no need to change any configuration of the operating system kernel, no manual intervention is required, and no need to restart the software server. By establishing a monitoring mechanism for the network connection of the software server, targeted periodic checks are performed on the connections in use. When it is found that the connection is unavailable, the connection is automatically closed and repaired, allowing the SQL statement in the software server to continue to execute, so that the task is not blocked and the business is quickly and automatically restored, providing a safe and automated business high-availability mechanism.

[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 This is a flowchart of a service recovery method provided according to Embodiment 1 of the present invention;

[0024] Figure 2 This is a flowchart of a service recovery method provided according to Embodiment 2 of the present invention;

[0025] Figure 3 This is a structural diagram of a service recovery device provided according to Embodiment 3 of the present invention;

[0026] Figure 4 It is a structural diagram of an electronic device provided according to the fourth embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first," "second," and the like in the specification and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than that illustrated or described herein. In the description of the present invention, unless otherwise specified, "plurality" refers to two or more. "And / or" describes an association relationship between associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship. 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 that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or device.

[0029] PostgreSQL is an open source relational database component, and PGServer Cluster is a database service cluster. PGPool usually refers to the PostgreSQL database cluster, which is a middleware for the PostgreSQL database. It provides functions such as connection pooling, load balancing, automatic failover, and high availability. PGPool and PGServer may be deployed in the same node, and there is usually no restriction on the deployment location. For example, PGPool1 and PGPool2 can access PGServer through a vip address (i.e., virtual IP). APP can access the PGPool service through this PGPoolvip address, thereby being able to access PGServer and interact with data. PGPoolvip plays a role in high availability. For example: when vip is configured in PGPool1, APP can access PGPool1. When PGPool1 fails, vip will switch to PGPool2, and then APP will access PGPool2. Disaster recovery is achieved through vip drift, thereby achieving high availability of APP access to database services. However, when a task in the APP is executing SQL statements to interact with the database service, the following situations may occur:

[0030] 1) The network between the app and the PGPool VIP client is unstable. This instability could be caused by a network failure or high load on either node. There are many factors that can cause instability, which are not detailed here. At this stage, the SQL statement executed by PGServer may have completed, and PGPool attempted to return the result to the app. However, due to the unstable network, the database connection in the app did not receive this response. At this point, the database connection in the app continues to wait for a response. Furthermore, the app's task will be blocked for a long time. The duration of this blockage is related to the Linux kernel configuration.

[0031] 2) The node hosting the PGPool VIP crashes. At this point, the VIP will migrate to a healthy PGPool node. During this phase, even if the SQL query completes, the downed PGPool node cannot properly return the result to the app's database connection. The app's database connection will continue to wait for a response. Furthermore, the app's tasks will be blocked for a long time. This blocking time also depends on the Linux kernel configuration.

[0032] For example, when the kernel is configured as "net.ipv4.TCP_keepalive_time=7200", it means that a health detection packet will be sent every 7200 seconds for a normal connection. For example, when the database connection in the APP accesses PGPool, a TCP connection will be established. The kernel of the operating system of the node where the APP is located will manage this TCP connection and send a health detection packet to PGPool every 7200 seconds to maintain a normal connection. When PGPool receives the packet and finds that the connection is abnormal, it will reply with a reset packet. At this time, the database connection in the APP will reset itself, thereby recycling the invalid connection. Since the system default configuration is 7200 seconds, this blocking time can be up to 2 hours.

[0033] To reduce downtime, simply lower the value of the Linux kernel configuration net.ipv4.TCP_keepalive_time (for example, net.ipv4.TCP_keepalive_time = 300). If probe packets are sent every five minutes, the node may have a large number of TCP connections. This direct configuration means that all TCP connections will send probe packets every five minutes. This increases network traffic and increases network load. Furthermore, environments typically have a large number of TCP connections, such as push services that require hundreds of thousands of TCP connections. This results in frequent probe packet sending, increasing network load and consuming network resources. Furthermore, for sensitive services, prolonged task blocking, even for five minutes, is unacceptable.

[0034] Restarting the software service can restore normal operations. Restarting the app will release the problematic database connection. However, this approach can interrupt the original task flow, causing difficult-to-fix issues and impacting the operational consistency of the business.

[0035] Example 1

[0036] Figure 1 A flowchart of a business recovery method is provided for embodiment 1 of the present invention. This embodiment is applicable to situations where business needs to be restored. The method can be executed by a business recovery device, which can be implemented in the form of hardware and / or software. The business recovery device can be configured in an electronic device, which can be composed of two or more physical entities or one physical entity.

[0037] like Figure 1 As shown, the service recovery method provided in the first embodiment of the present invention is applied to the software server and specifically includes the following steps:

[0038] S101: Determine whether to start service recovery based on the difference between the current time and the end time of the previous round of service recovery.

[0039] In this embodiment, the time difference between the current time and the end time of the previous round of service recovery can be determined. If the difference is appropriate, such as equal to or greater than a preset value, service recovery can be started. By setting the preset value, service recovery can be performed regularly. The software server can be an app.

[0040] S102: If it is determined to start, determine the execution duration of the active connection, wherein the active connection is a communication connection that is executing an SQL statement.

[0041] In this embodiment, after determining that the service recovery step can be started, the connection duration of the communication connection in which the software server is executing the SQL statement, that is, the execution duration, can be determined first.

[0042] S103: Determine in-use connections whose execution duration is longer than a preset threshold as connections to be checked, and determine invalid connections among the connections to be checked as connections to be repaired.

[0043] In this embodiment, if the execution time is greater than or equal to a preset threshold, the in-use connection may be determined as a connection to be checked, and the connection to be checked may be checked to see if it is an invalid connection. The invalid connection may be determined as a connection to be repaired.

[0044] S104: Service recovery is achieved by closing and repairing the connection to be repaired.

[0045] In this embodiment, the connection to be repaired can be reset, that is, closed, and the connection to be repaired can be repaired by continuing to execute or throwing the SQL statement called by the task in the software service, so that the task can continue to be processed, thereby not blocking the task flow and achieving business recovery.

[0046] The technical solution of the embodiment of the present invention does not require any configuration changes to the operating system kernel, nor does it require manual intervention, let alone restarting the software server. By establishing a monitoring mechanism for the network connection of the software server, targeted periodic checks are performed on the connections in use. When a connection is found to be unavailable, the connection is automatically closed and repaired, allowing the SQL statements in the software server to continue to execute, thereby preventing tasks from being blocked and quickly and automatically restoring business, providing a secure and automated business high-availability mechanism.

[0047] Optionally, the method for repairing the connection to be repaired includes: determining whether the execution statement corresponding to the connection to be repaired is a preset query statement, and if so, re-executing the execution statement corresponding to the connection to be repaired; or, if the execution method of the execution statement corresponding to the connection to be repaired is a target method, repairing the connection to be repaired through the execution method, wherein the target method includes automatically repairing the connection to be repaired after detecting that the connection to be repaired is closed.

[0048] Specifically, if the execution statement for the connection to be repaired is a preset query, such as a SQL statement beginning with "select," you can attempt to re-execute the statement. Otherwise, the statement is thrown, allowing the task to proceed normally without blocking the business. If the execution statement for the connection to be repaired is not a preset query, it means that the data may have changed, but it is usually unknown whether the data has actually changed. In this case, for data security, the only option is to throw an exception.

[0049] Alternatively, the automatic repair method can also be embedded in the execution method of the SQL statement, that is, in the execution function of the SQL statement. The target method can be understood as: when the SQL execution function determines that the connection is invalid, it will be automatically repaired directly. The advantage of this setting is that the connection repair can be achieved without complex multi-threaded communication. Usually, if the task of executing the SQL statement is thread A, and thread B executes this method, after thread B has determined the invalid connection, cross-thread communication (such as variable marking) is required to notify thread A to repair the connection. This is more cumbersome in implementation. If thread A actively detects an invalid connection when executing the SQL statement, it will be automatically repaired directly, which is simpler and more intuitive in implementation.

[0050] Example 2

[0051] Figure 2This is a flow chart of a service recovery method provided in the second embodiment of the present invention. The technical solution of the embodiment of the present invention is further optimized on the basis of the above optional technical solutions, and provides a specific method for restoring the service.

[0052] Optionally, determining the execution duration of the active connection includes: obtaining first connection information and second connection information, wherein the first connection information includes identifier association information of the active connection, and the second connection information includes identifier association information of the communication connection for executing the SQL statement and the corresponding execution start time; determining a target execution start time corresponding to the identifier association information in the second connection information that matches the first connection information, and determining the difference between the current time and the target execution start time as the execution duration of the active connection. This configuration has the advantage of accurately determining the execution duration of the active connection by comparing the first connection information with the second connection information.

[0053] Optionally, before determining an invalid connection among the connections to be checked as a connection to be repaired, the method further includes: obtaining a source address and a source port of the connection to be checked, and determining the connection to be checked as an invalid connection if no connection corresponding to the source address and the source port exists in the target service node to which the connection to be checked is connected. This arrangement has the advantage of providing a method for accurately and quickly determining invalid connections.

[0054] Optionally, determining whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery includes: determining the difference between the current time and the end time of the previous round of business recovery; if the difference is equal to a preset threshold, starting business recovery.

[0055] like Figure 2 As shown, a service recovery method provided by Embodiment 2 of the present invention specifically includes the following steps:

[0056] S201. Determine the difference between the current time and the end time of the previous round of service recovery; if the difference is equal to a preset threshold, start service recovery.

[0057] Specifically, the difference between the current time and the end time of the previous round of service recovery is also equal to the difference between the preset period and the duration of the previous round of service recovery. If this difference is equal to the preset threshold, service recovery begins; if the difference is less than the preset threshold, the waiting period continues.

[0058] S202: Acquire first connection information and second connection information, wherein the first connection information includes identification association information of the active connection, and the second connection information includes identification association information of the communication connection for executing the SQL statement and the corresponding execution start time.

[0059] Specifically, the first connection information and the second connection information may be stored in different preset files respectively.

[0060] Optionally, the second connection information is stored in a preset LRU mapping table; wherein, the updating method of the preset LRU mapping table includes: obtaining a connection object identifier and an associated first in-use connection identifier, and determining whether the connection object identifier exists in the preset LRU mapping table; if so, determining whether the second connection identifier corresponding to the connection object identifier in the preset LRU mapping table is consistent with the first in-use connection identifier; if not, updating the second connection identifier to the first in-use connection identifier, and updating the execution start time corresponding to the second connection identifier to the current time.

[0061] Specifically, a limited LRU (Least Recently Used) mapping table can be pre-created. This table is a common page replacement algorithm and cache eviction strategy. The length of the mapping table is equal to the maximum number of connections on the software server, that is, the maximum number of connections that the software service on the software server can connect to the (database) service. If the number of connections that the software service can use to access the database service is not limited, it may lead to an unlimited growth of database connections. Each connection can only execute one SQL statement at a time. The second connection information is stored in the preset LRU mapping table.

[0062] Exemplarily, the LRU mapping table can be a Key-Value structure. The Key is Socket, which is a number. In Linux network connections, Socket is an integer used to identify a network connection, which is similar to a file descriptor. Through this number, the operating system can track and manage different network connections. The data of Value includes: creation time (which can be recorded as create_time), that is, the execution start time, connection object identifier (which can be recorded as conn_id), and in-use connection identifier (which can be recorded as used_id). Among them, the in-use connection identifier (that is, the second connection identifier) in the second connection information represents the connection identifier determined when the connection is in use. When step S202 is executed, the connection identifier in the second connection information may include in-use and out-of-use connection identifiers.

[0063] After obtaining the conn_id, if there is no record in the LRU mapping table, a new record can be created, and the conn_id, the corresponding used_id (i.e., the first in-use connection identifier), and the Socket association are added to the LRU mapping table, and the corresponding create_time is set to the time of the new record. If there is a record in the LRU mapping table, it can be determined whether the conn_id and the corresponding used_id are recorded in the LRU mapping table. When the conn_id or the corresponding used_id does not exist, the non-existent conn_id or the corresponding used_id is updated to the LRU mapping table, and create_time is set to the time of this update. When both conn_id and used_id exist, the LRU mapping table is not changed.

[0064] Optionally, both the first connection information and the second connection information are stored in the current software server; the method for updating the in-use connection identifier in the identifier association information in the first connection information includes: if the current software server executes an SQL statement to establish a communication connection, then adding 1 to the in-use connection identifier in the identifier association information in the first connection information to obtain an updated in-use connection identifier.

[0065] Specifically, a dictionary of active connections can be established in advance, and the first connection information can be stored in the dictionary of active connections. During the SQL statement execution phase, the dictionary of active connections can be refreshed. The dictionary of active connections can also be a Key-Value structure. The Key is a self-incrementing digital serial number, that is, the active connection identifier. The Value is the connection object. The connection objects in the dictionary of active connections will be reused, but the active connection identifier will usually not be repeated before the preset maximum is reached. Each time the software server executes an SQL statement, the active connection identifier will be increased by 1. When the preset maximum is reached (such as the maximum of int64), the active connection identifier can be assigned a value of 1, so that the active connection identifier starts counting from 1 again. Therefore, the active connection identifier will not appear repeatedly in the active connection dictionary. Among them, based on the active connection identifier in the identifier association information in the first connection information, the connection object identifier and socket stored in the current software server can be determined.

[0066] S203: Determine the target execution start time corresponding to the identification association information matching the first connection information in the second connection information, and determine the difference between the current time and the target execution start time as the execution duration of the active connection.

[0067] Specifically, the identification information in the second connection information that is consistent with the identification information in the first connection information can be determined, and the execution start time corresponding to the identification information can be determined as the target execution start time. The difference between the current time and the target execution start time can be determined as the execution duration of the active connection.

[0068] S204: Determine the in-use connection whose execution time is longer than a preset threshold as a connection to be checked.

[0069] Exemplarily, the preset threshold may be 60 seconds.

[0070] S205: Obtain the source address and source port of the connection to be checked. If no connection corresponding to the source address and the source port exists in the node of the target service to which the connection to be checked is connected, determine the connection to be checked as an invalid connection.

[0071] Exemplary methods for determining an invalid connection may include:

[0072] 1) Send a liveness packet (also called a probe packet) directly through the connection to be checked. If the target service (such as PGPool1) to which the connection to be checked is connected finds that the connection is invalid, it will actively reply with a reset packet, otherwise it will reply normally. After receiving the reset packet, the connection to be checked can be determined as an invalid connection. Of course, in some network environments, the target service may not reply. In this case, you can set an upper limit on the number of probes. For example, if the target service does not reply for more than 3 consecutive times after probing every 5 seconds, the connection to be checked will be determined as an invalid connection.

[0073] 2) Obtain the source address and source port of the connection to be checked, and then determine whether a connection with the source address and source port exists in the node of the target service to be connected. If not, the connection is determined to be invalid and the connection to be checked is determined to be invalid. If it exists and is in the established state, the connection to be checked is determined to be valid.

[0074] Among them, in some network environments, the target service address and target port will go through NAT (Network Address Translation), so it is necessary to combine specific environmental information to determine the real address and port of the target service. The above two methods can be used separately or in combination (that is, both methods are executed once). The method can be determined according to the environmental conditions to make the method of determining invalid connections more accurate. For method 1), when the connection fails, some nodes in the intermediate network link may directly discard the detection packet due to network environment reasons. At this time, it is necessary to detect several times. When the preset number of times is reached and there is no response, the connection to be checked will be determined as an invalid connection.

[0075] S206: Determine the invalid connection among the connections to be checked as a connection to be repaired.

[0076] S207: Determine the invalid connection among the connections to be checked as a connection to be repaired.

[0077] S208: Service recovery is achieved by closing and repairing the connection to be repaired, and step 201 is executed.

[0078] The business recovery method provided by the embodiment of the present invention performs periodic detection on the connections in use, monitors the connections in use in the software service by comparing the first connection information with the second connection information, accurately determines the execution time of the connections in use, and provides a method for accurately and quickly determining invalid connections. When an invalid connection in the software service is determined, the task process can be closed and repaired to enable the task process to operate normally, which can achieve high business availability in scenarios such as network instability and disasters, allowing the task process to operate even under such harsh conditions.

[0079] Example 3

[0080] Figure 3 This is a schematic diagram of the structure of a service recovery device provided by the third embodiment of the present invention. Figure 3 As shown, the device includes: a judgment module 301, an execution time determination module 302, a connection to be repaired determination module 303 and a service recovery module 304, wherein:

[0081] A judgment module is used to determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery;

[0082] an execution duration determination module, configured to determine the execution duration of an in-use connection if the information returned by the determination module is "start", wherein the in-use connection is a communication connection that is executing an SQL statement;

[0083] a connection-to-be-repaired determining module, configured to determine in-use connections whose execution time is greater than a preset threshold as connections to be checked, and to determine invalid connections among the connections to be checked as connections to be repaired;

[0084] The service recovery module is used to realize service recovery by closing and repairing the connection to be repaired.

[0085] The business recovery device provided by the embodiment of the present invention does not require any configuration changes to the operating system kernel, nor does it require manual intervention, let alone restarting the software server. By establishing a monitoring mechanism for the network connection of the software server, targeted periodic checks are performed on the connections in use. When a connection is found to be unavailable, the connection is automatically closed and repaired, allowing the SQL statement in the software server to continue to execute, thereby preventing tasks from being blocked and quickly and automatically recovering the business, providing a safe and automated business high-availability mechanism.

[0086] Optionally, the execution duration determination module includes:

[0087] An information acquisition unit, configured to acquire first connection information and second connection information, wherein the first connection information includes identifier association information of an active connection, and the second connection information includes identifier association information of a communication connection for executing an SQL statement and a corresponding execution start time;

[0088] The execution duration determination unit is used to determine the target execution start time corresponding to the identification association information matching the first connection information in the second connection information, and determine the difference between the current time and the target execution start time as the execution duration of the active connection.

[0089] Optionally, the second connection information is stored in a preset LRU mapping table; wherein, the updating method of the preset LRU mapping table includes: obtaining a connection object identifier and an associated first in-use connection identifier, and determining whether the connection object identifier exists in the preset LRU mapping table; if so, determining whether the second connection identifier corresponding to the connection object identifier in the preset LRU mapping table is consistent with the first in-use connection identifier; if not, updating the second connection identifier to the first in-use connection identifier, and updating the execution start time corresponding to the second connection identifier to the current time.

[0090] Optionally, both the first connection information and the second connection information are stored in the current software server; the method for updating the in-use connection identifier in the identifier association information in the first connection information includes: if the current software server executes an SQL statement to establish a communication connection, then adding 1 to the in-use connection identifier in the identifier association information in the first connection information to obtain an updated in-use connection identifier.

[0091] Optionally, the service recovery module includes:

[0092] A business recovery model unit is used to determine whether the execution statement corresponding to the connection to be repaired is a preset query statement. If so, re-execute the execution statement corresponding to the connection to be repaired; or, if the execution mode of the execution statement corresponding to the connection to be repaired is a target mode, repair the connection to be repaired through the execution mode, wherein the target mode includes automatically repairing the connection to be repaired when it is detected that the connection to be repaired is closed.

[0093] Optionally, the device further includes:

[0094] An invalid connection determination module is used to obtain the source address and source port of the connection to be checked before determining the invalid connection in the connection to be checked as the connection to be repaired, and when there is no connection corresponding to the source address and the source port in the node of the target service connected to the connection to be checked, the connection to be checked is determined to be an invalid connection.

[0095] Optionally, the judgment module includes:

[0096] A difference determination unit, configured to determine a difference between the current time and the end time of the previous round of service recovery;

[0097] The service recovery starting unit is configured to determine to start service recovery if the difference is equal to a preset threshold.

[0098] The service recovery device provided in the embodiment of the present invention can execute the service recovery method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0099] Example 4

[0100] Figure 4 A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, 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 merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0101] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., which is communicatively connected to the at least one processor 41. The memory stores a computer program that can be executed by the at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 into the random access memory (RAM) 43. Various programs and data required for the operation of the electronic device 40 can also be stored in the RAM 43. The processor 41, ROM 42, and RAM 43 are connected to each other via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0102] Multiple components in the electronic device 40 are connected to the I / O interface 45, including an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a magnetic disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0103] Processor 41 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. Processor 41 executes the various methods and processes described above, such as the service recovery method.

[0104] In some embodiments, the service recovery method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the service recovery method described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to perform the service recovery method in any other appropriate manner (e.g., via firmware).

[0105] Various embodiments of the systems and techniques described 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), system-on-chip (SOC) systems, complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes 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.

[0106] Computer programs for implementing the methods of the present invention 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 data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0107] The computer device provided above can be used to execute the service recovery method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0108] Example 5

[0109] In the context of the present invention, a computer-readable storage medium may be a tangible medium, wherein the computer-executable instructions, when executed by a computer processor, are used to perform a business recovery method, the method comprising:

[0110] Determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery;

[0111] If it is determined to start, then determining the execution duration of the in-use connection, wherein the in-use connection is a communication connection that is executing an SQL statement;

[0112] Determine in-use connections whose execution time is longer than a preset threshold as connections to be checked, and determine invalid connections among the connections to be checked as connections to be repaired;

[0113] Service recovery is achieved by closing and repairing the connection to be repaired.

[0114] In the context of the present invention, computer-readable storage medium can be a tangible medium that can contain or store a computer program for use with an instruction execution system, device or equipment or used in conjunction with an instruction execution system, device or equipment. Computer-readable storage medium can 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, computer-readable storage medium can be a machine-readable signal medium. A more specific example of a machine-readable storage medium can 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.

[0115] The computer device provided above can be used to execute the service recovery method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0116] It is worth noting that in the embodiment of the above-mentioned business recovery device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0117] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A business recovery method, applied to a software server, characterized in that: include: Determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery; If it is determined to start, then determining the execution duration of the in-use connection, wherein the in-use connection is a communication connection that is executing an SQL statement; Determine in-use connections whose execution time is longer than a preset threshold as connections to be checked, and determine invalid connections among the connections to be checked as connections to be repaired; Service recovery is achieved by closing and repairing the connection to be repaired.

2. The method according to claim 1, characterized in that The determining of the execution duration of the active connection includes: Acquire first connection information and second connection information, wherein the first connection information includes identifier association information of an active connection, and the second connection information includes identifier association information of a communication connection for executing an SQL statement and a corresponding execution start time; The target execution start time corresponding to the identification association information matching the first connection information in the second connection information is determined, and the difference between the current time and the target execution start time is determined as the execution duration of the active connection.

3. The method according to claim 2, characterized in that The second connection information is stored in a preset LRU mapping table; wherein the updating method of the preset LRU mapping table includes: Obtaining a connection object identifier and an associated first in-use connection identifier, and determining whether the connection object identifier exists in the preset LRU mapping table; If so, determining whether the second connection identifier corresponding to the connection object identifier in the preset LRU mapping table is consistent with the first in-use connection identifier; If they are inconsistent, the second connection identifier is updated to the first in-use connection identifier, and the execution start time corresponding to the second connection identifier is updated to the current time.

4. The method according to claim 2 or 3, characterized in that The first connection information and the second connection information are both stored in the current software server; the updating method of the in-use connection identifier in the identifier association information in the first connection information includes: If the current software server executes an SQL statement to establish a communication connection, the in-use connection identifier in the identifier association information in the first connection information is increased by 1 to obtain an updated in-use connection identifier.

5. The method according to claim 1, wherein Methods for repairing the connection to be repaired include: Determine whether the execution statement corresponding to the connection to be repaired is a preset query statement. If so, re-execute the execution statement corresponding to the connection to be repaired, or, If the execution mode of the execution statement corresponding to the connection to be repaired is a target mode, the connection to be repaired is repaired by the execution mode, wherein the target mode includes automatically repairing the connection to be repaired when it is detected that the connection to be repaired is closed.

6. The method according to claim 1, characterized in that Before determining the invalid connection among the connections to be checked as the connection to be repaired, the method further includes: The source address and source port of the connection to be checked are obtained, and when no connection corresponding to the source address and the source port exists in the node of the target service to which the connection to be checked is connected, the connection to be checked is determined to be an invalid connection.

7. The method according to claim 1, characterized in that The determining whether to start service recovery according to the difference between the current time and the end time of the previous round of service recovery includes: Determine the difference between the current time and the end time of the previous round of business recovery; If the difference is equal to the preset threshold, it is determined to start service recovery.

8. A service recovery device, characterized in that: include: A judgment module is used to determine whether to start business recovery based on the difference between the current time and the end time of the previous round of business recovery; an execution duration determination module, configured to determine the execution duration of an in-use connection if the information returned by the determination module is "start", wherein the in-use connection is a communication connection that is executing an SQL statement; a connection-to-be-repaired determining module, configured to determine in-use connections whose execution time is greater than a preset threshold as connections to be checked, and to determine invalid connections among the connections to be checked as connections to be repaired; The service recovery module is used to realize service recovery by closing and repairing the connection to be repaired.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to execute the service recovery method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the service recovery method according to any one of claims 1 to 7 when executed.