Session recovery method and device, equipment, storage medium and program product

By using a server-driven session state management mechanism, cross-node synchronization and accurate recovery of session state are achieved, solving the business interruption problem caused by session state loss and improving system availability and business continuity.

CN121940267APending Publication Date: 2026-04-28CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202512017622.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In enterprise-level information systems, traditional failover strategies lead to session state loss, resulting in business interruption, increased latency, and data errors.

Method used

Through a server-driven session state management mechanism, distributed caching of session identifiers and session state information is used to achieve cross-node synchronization and accurate recovery of session state. Dynamic backup strategies reduce redundant data transmission, and direct query mechanisms based on identifiers and backup node pre-positioning strategies shorten fault recovery time.

Benefits of technology

This ensures that session state can be accurately restored after failover, avoids duplicate execution of business processes, reduces network load and storage overhead, and improves overall system availability and business continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121940267A_ABST
    Figure CN121940267A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a session recovery method and device, equipment, a storage medium and a program product, and relates to the field of database management. The method comprises the following steps: receiving a session connection request from a client, wherein the session connection request comprises a first session identifier; corresponding first session state information is acquired according to the first session identifier, the first session state information is used for indicating state information of session connection previously established between the client and the second data node, and the first session state information comprises the first session identifier, first session node information and a first session state parameter; and recovering the session connection with the client based on the first session state information. According to the method provided by the invention, the problem of service interruption caused by loss of the session state is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database management, and more particularly to a session recovery method, apparatus, device, storage medium, and program product. Background Technology

[0002] In modern enterprise information systems, database node clusters, as core data processing and storage components, play a crucial role in ensuring business continuity. With the expansion of business scale and the widespread adoption of distributed architectures, database node clusters have become the mainstream deployment model to handle scenarios such as high-concurrency access and hardware failures. For example, in industries with extremely high requirements for data consistency and service availability, such as finance, telecommunications, and healthcare, database node clusters ensure uninterrupted service through redundant node deployment and failover mechanisms (such as master-slave switching).

[0003] However, in the above implementation, when the data node connected to the client fails, the traditional failover strategy usually restores service by rebuilding the connection to the backup node, but this process will cause the original session state to be lost. Users need to resubmit business requests and repeat the operation process, which not only increases business latency, but may also cause data errors or business anomalies due to inconsistent states. Summary of the Invention

[0004] This application provides a session recovery method, apparatus, device, storage medium, and program product to solve the technical problem of service interruption caused by session state loss.

[0005] In a first aspect, this application provides a session recovery method applied to a first data node. The database node cluster includes a first data node and a second data node. The method includes: receiving a session connection request from a client, the session connection request including a first session identifier; obtaining corresponding first session status information based on the first session identifier, the first session status information indicating the status information of a session connection previously established between the client and the second data node, the first session status information including a first session identifier, first session node information, and first session status parameters; and restoring the session connection with the client based on the first session status information.

[0006] In one possible implementation of the first aspect, before receiving a session connection request from the client, the method further includes: receiving first session state information from the second data node and storing it in the first storage space corresponding to the first data node.

[0007] Obtaining the corresponding first session status information based on the first session identifier includes: obtaining the first session status information in the first storage space based on the first session identifier.

[0008] In one possible implementation of the first aspect, the first data node is an adjacent available data node of the second data node; or, the first data node is any data node in the database node cluster; or, the first node is a data node in the database node cluster determined by a hash algorithm based on the first session identifier and the database node cluster node status information, wherein the database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, and the data node availability information is used to indicate the available data nodes in the database node cluster; or, the first data node is the data node with the least load among the available nodes in the database node cluster.

[0009] In one possible implementation of the first aspect, the database node cluster further includes a third data node, which obtains the corresponding first session status information based on the first session identifier, including: sending the first session identifier to the third data node; and receiving the first session status information sent by the third data node.

[0010] In one possible implementation of the first aspect, the third data node is the data node that is physically closest to the client, or the third data node is the data node that is closest to the client's network topology.

[0011] In one possible implementation of the first aspect, restoring the session connection with the client based on the first session state information includes: establishing a session connection with the client and restoring session context information based on the first session state information, wherein the session context information includes at least one of session state information, session parameters, and session cache.

[0012] Secondly, this application provides a session recovery method applied to a second data node, wherein the database node cluster includes a first data node. The method includes: after establishing a session connection with a client, generating first session state information, the first session state information being used to instruct the first data node to establish a session connection with the client, the first session state information including a target session identifier, session node information, and session state parameters; sending the first session identifier to the client; determining at least one target data node among the data nodes in the database node cluster; and sending the first session state information to the at least one target data node.

[0013] In one possible implementation of the second aspect, determining at least one target data node among the data nodes of the database node cluster includes: determining an available data node adjacent to the second data node as at least one target data node; or, determining all data nodes of the database node cluster as at least one target data node; or, determining at least one target data node by a hash algorithm based on a first session identifier and database node cluster node status information, wherein the database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, the data node availability information being used to indicate the available data nodes in the database node cluster; or, determining the data node with the lowest load among the available nodes in the database node cluster as at least one target data node.

[0014] Thirdly, this application provides a session recovery method applied to a client, wherein the database node cluster includes a first data node and a second data node, the method comprising: establishing a session connection with the second data node; receiving a first session identifier from the second data node; after the session connection with the second data node becomes abnormal, sending a session connection request to the first data node, the session connection request including the first session identifier; and establishing a session connection with the first data node.

[0015] Fourthly, this application provides a session recovery device, comprising:

[0016] The transceiver module is used to receive a session connection request from the client, which includes a first session identifier; and to obtain the corresponding first session status information based on the first session identifier. The first session status information is used to indicate the status information of the session connection previously established between the client and the second data node. The first session status information includes the first session identifier, the first session node information, and the first session status parameters.

[0017] The processing module is used to restore the session connection with the client based on the first session state information.

[0018] Fifthly, this application provides a session recovery device, comprising:

[0019] The transceiver module is used to send the first session identifier to the client and send the first session status information to at least one target data node.

[0020] The processing module is used to generate first session state information after establishing a session connection with the client. The first session state information is used to instruct the first data node to establish a session connection with the client. The first session state information includes the target session identifier, session node information, and session state parameters; and to determine at least one target data node in the data nodes of the database node cluster.

[0021] Sixthly, this application provides a session recovery apparatus, comprising:

[0022] The transceiver module is used to establish a session connection with the second data node; receive a first session identifier from the second data node; and send a session connection request to the first data node after the session connection with the second data node fails, the session connection request including the first session identifier.

[0023] The processing module is used to establish a session connection with the first data node.

[0024] In a seventh aspect, this application provides an electronic device, including: a processor and a memory communicatively connected to the processor;

[0025] The memory stores instructions that the computer executes;

[0026] The processor executes computer-executable instructions stored in memory to implement the method of any of the first aspects, or the method of any of the second aspects, or the method of any of the third aspects.

[0027] Eighthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method of any one of the first aspects, or the method of any one of the second aspects, or the method of any one of the third aspects.

[0028] Ninthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method of any of the first aspects, or the method of any of the second aspects, or the method of any of the third aspects.

[0029] The session recovery method, apparatus, device, storage medium, and product provided in this application solve the business interruption problem caused by session state loss in existing technologies through a server-driven session state management mechanism. A distributed caching mechanism for session identifiers and session state information ensures accurate recovery of session state after failover, avoiding duplicate execution of business processes. Dynamic backup strategies reduce redundant data transmission, lowering network load and storage overhead. A direct query mechanism based on identifiers and a backup node pre-positioning strategy shorten fault recovery time. Attached Figure Description

[0030] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0031] Figure 1 A schematic diagram illustrating a scenario for a session recovery method provided in an embodiment of this application;

[0032] Figure 2 A flowchart illustrating a session recovery method provided in an embodiment of this application;

[0033] Figure 3 A flowchart illustrating another session recovery method provided in an embodiment of this application;

[0034] Figure 4 A flowchart illustrating another session recovery method provided in an embodiment of this application;

[0035] Figure 5 This is a schematic diagram of the structure of a transaction preprocessing device provided in an embodiment of this application;

[0036] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0037] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation

[0038] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0039] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of the relevant data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation access points for users to choose to authorize or refuse.

[0040] Figure 1 This is a schematic diagram illustrating a scenario where the session recovery method of this application is applied. The database node cluster may include multiple data nodes, such as... Figure 1 As shown, the database node cluster may include a first data node, a second data node, a third data node, and a fourth data node. A client may establish a session connection with any one of the multiple data nodes included in the database node cluster.

[0041] Each data node is configured with a session state manager, which is a management program used for caching session state, synchronizing session state, and querying session state. For example... Figure 1 As shown, the first data node, the second data node, the third data node and the fourth data node are respectively configured with session state manager 1, session state manager 2, session state manager 3 and session state manager 4. The session state managers of different data nodes can communicate with each other. For example, the session state information generated by the data node can be backed up to other data nodes.

[0042] For example Figure 1 As shown, after the second data node establishes a session connection with the client, it can generate corresponding session state information and back it up to other data nodes in the database node cluster, such as the first data node. It can also send the session identifier from the session state information to the client.

[0043] If the client experiences an anomaly in its session connection with the second data node and the connection is lost, the client can establish a session connection with the first data node based on the aforementioned session identifier. This session connection is established based on the session state information stored in the first data node.

[0044] In modern enterprise information systems, database node clusters, as core data processing and storage components, play a crucial role in ensuring business continuity. With the expansion of business scale and the widespread adoption of distributed architectures, database node clusters have become the mainstream deployment model to handle scenarios such as high-concurrency access and hardware failures. For example, in industries with extremely high requirements for data consistency and service availability, such as finance, telecommunications, and healthcare, database node clusters ensure uninterrupted service through redundant node deployment and failover mechanisms (such as master-slave switching).

[0045] However, in the above implementation, when the data node connected to the client fails, the traditional failover strategy usually restores service by rebuilding the connection to the backup node, but this process will cause the original session state to be lost. Users need to resubmit business requests and repeat the operation process, which not only increases business latency, but may also cause data errors or business anomalies due to inconsistent states.

[0046] The session recovery method, apparatus, device, storage medium, and program products provided in this application are intended to solve the above-mentioned technical problems of the prior art.

[0047] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0048] Figure 2 This is a flowchart illustrating a session recovery method provided in an embodiment of this application, as shown below. Figure 2 As shown, the method includes:

[0049] S201, The first data node receives a session connection request from the client, which includes a first session identifier.

[0050] The client sends a session connection request to the first data node. The session connection request includes a first session identifier, which is a unique identifier of the session connection previously established by the client with the second data node.

[0051] Accordingly, the first data node receives a session connection request from the client.

[0052] S202, The first data node obtains the corresponding first session status information based on the first session identifier.

[0053] The first data node obtains the corresponding first session status information based on the first session identifier in the session connection request. The first session status information is the status information of the session connection previously established between the client and the second data node. The first session status information may include the first session identifier, the first session node information, and the first session status parameters.

[0054] The first session identifier is a globally unique session identifier for the previous session connection between the client and the second data node. It is a string or value used to uniquely identify the database node cluster session previously established between the client and the second data node, ensuring that the session can be independently tracked and recovered. For example, it can be a session_id generated by a hash algorithm, such as "S12345".

[0055] The first session node information is used to indicate which data node handled the session. For example, it may include information such as node IP / Port, node ID (e.g., node-07), or shard / replica location (e.g., shard=3, replica=1).

[0056] The first session state parameter can be session-related runtime context parameter information, such as user identity (user_id, tenant_id), transaction snapshot timestamp, time zone, language, client version, and incomplete streaming query cursors.

[0057] In addition to the above, the first session status information may also include other information, which is not limited here.

[0058] S203, The first data node resumes the session connection with the client based on the first session state information.

[0059] After obtaining the first session state information, the first data node can restore the session connection with the client based on the first session state information.

[0060] It is understandable that after obtaining the first session state information, the first data node can establish a session connection with the client, and the second data node has the session context information with the client. Therefore, it can be understood that the session connection between the client and the database node cluster has been restored.

[0061] This possible implementation addresses the business interruption issue caused by session state loss in existing technologies through a collaborative mechanism between unique identifiers and session state information. Specifically, the unique identifier ensures that each session state can be tracked independently, and distributed storage enables cross-node synchronization of state information, avoiding the need to re-execute business processes after a failure. For example, in a bank transaction system, if the primary node fails, after the client reconnects to the backup node, it can directly locate the state information (such as uncommitted transfer transactions) using the unique identifier, and reconstruct the transaction context accordingly, without requiring the user to re-enter transfer information. This server-driven session state management mechanism reduces business interruption time, decreases the coupling between the client and server, and improves overall system availability.

[0062] In some embodiments, such as Figure 3 As shown below, an embodiment of a session recovery method is provided, which may include:

[0063] S301. The client establishes a session connection with the second data node.

[0064] The client can establish a session connection with the second data node in the database. This session connection refers to the logical communication channel established between the client and the second database node cluster node for interaction. It includes both the underlying network connection (such as TCP) and the upper-layer session context information (such as identity information, status information, configuration information, etc.).

[0065] S302, The second data node generates session state information.

[0066] After establishing a session connection with the client, the second data node can generate corresponding first session status information. This first session status information is used to instruct the first data node to establish a session connection with the client. The first session status information may include the target session identifier, session node information, and session status parameters.

[0067] The first session identifier is a globally unique session identifier for the previous session connection between the client and the second data node. It is a string or value used to uniquely identify the database node cluster session previously established between the client and the second data node, ensuring that the session can be independently tracked and recovered. For example, it can be a session_id generated by a hash algorithm, such as "S12345".

[0068] The first session node information is used to indicate which data node handled the session. For example, it may include information such as node IP / Port, node ID (e.g., node-07), or shard / replica location (e.g., shard=3, replica=1).

[0069] The first session state parameter can be session-related runtime context parameter information, such as user identity (user_id, tenant_id), transaction snapshot timestamp (for MVCC), time zone, language, client version, and incomplete streaming query cursors.

[0070] In addition to the above, the first session status information may also include other information, which is not limited here.

[0071] S303, the second data node sends the first session identifier to the client.

[0072] After generating the first session state information, the second data node can send the first session identifier to the client.

[0073] Accordingly, the client receives the first session identifier sent by the second data node.

[0074] For example, the second data node can generate a globally unique identifier using a universally unique identifier (UUID) algorithm, such as generating session_id="abc123xyz" based on a timestamp and node identifier. This session identifier is then sent to the client via a protocol message.

[0075] In this possible implementation, data nodes generate strongly unique identifiers using the UUID algorithm, ensuring global uniqueness in session state management. For example, in a distributed financial trading system, session identifiers for different nodes all include a timestamp and a node ID, avoiding identifier conflicts. This improves system compatibility and scalability, adapting to large-scale data node cluster environments.

[0076] S304. The second data node determines at least one target data node among the data nodes in the database node cluster.

[0077] After generating the first session state information, the second data node can identify at least one target data node in the database node cluster as a data node to back up the first session state information.

[0078] S305, the second data node sends the first session status information to the target data node.

[0079] After identifying at least one target data node, the second data node can send the first session state information to the at least one target data node.

[0080] Accordingly, the at least one target data node can receive the first session state information from the second data node and store it in the corresponding storage space.

[0081] like Figure 3 As shown, in some embodiments, at least one target data node may include a first data node.

[0082] In this embodiment, the execution order of step S303 (the second data node sending the first session identifier to the client) and step S305 (the second data node sending the first session status information to the target data node) is not limited. That is, the second data node can send the first session identifier to the client first and then send the first session status information to the target data node; or it can send the first session status information to the target data node first and then send the first session identifier to the client.

[0083] S306. After the session connection with the second data node fails, the client sends a session connection request to the first data node.

[0084] If the client encounters an anomaly in the session connection with the second data node and is unable to continue the session with the second data node, the client can send a session connection request to the first data node, which includes the first session identifier.

[0085] Accordingly, the first data node can receive the session connection request sent by the client.

[0086] 307. The first data node obtains the corresponding first session status information based on the first session identifier.

[0087] After receiving a session connection request from the client, the first data node obtains the corresponding first session status information based on the first session identifier in the session connection request.

[0088] 308. The first data node resumes the session connection with the client based on the first session state information.

[0089] After obtaining the first session state information, the first data node can restore the session connection with the client based on the first session state information according to the session connection request.

[0090] It is understandable that after obtaining the first session state information, the first data node can establish a session connection with the client, and the second data node has the session context information with the client. Therefore, it can be understood that the session connection between the client and the database node cluster has been restored.

[0091] In this embodiment of the application, the first data node obtains the first session state information either from its internal storage space or from the storage space of other data nodes in the database node cluster. These will be described separately below:

[0092] First, the first data node obtains the first session state information from its internal storage space.

[0093] In some embodiments, such as Figure 3 As shown, the second data node can send the first session state information to the first data node.

[0094] Correspondingly, the first data node can receive the first session state information from the first data node and store it in the first storage space corresponding to the first data node.

[0095] In this case, step 307 above, where the first data node obtains the corresponding first session status information based on the first session identifier, can be that the first data node obtains the first session status information in the first storage space based on the first session identifier.

[0096] The first storage space of the first data node may include multiple session state information, and the first data node can determine the first session state information therein based on the first session identifier.

[0097] In some embodiments, the second data node determines at least one target data node among the data nodes in the database node cluster, specifically including:

[0098] The second data node can determine that the available data node adjacent to the second data node is at least one target data node; wherein, the available data node adjacent to the second data node is the next available node selected in the node order.

[0099] Alternatively, the second data node can also determine that all data nodes in the database node cluster are at least one target data node; or,

[0100] Alternatively, the second data node can also determine at least one target data node using a hash algorithm based on the first session identifier and the database node cluster node status information. The database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, which indicates the available data nodes in the database node cluster; or...

[0101] The hash algorithm is an algorithm that maps input data to a fixed-length output. It can be used to determine at least one target data node. For example, it can be: backupNode = hash(session_id)%N, where N is the total number of data nodes in the database node cluster. For example, it can also be used to map session_id="abc123xyz" to data node 2 using a consistent hashing algorithm.

[0102] In this possible implementation, a dynamically configurable backup strategy further enhances system flexibility and disaster recovery capabilities. For example, in financial trading systems, hashing algorithms can reduce redundant data transmission and avoid wasting network bandwidth; the next available node strategy provides rapid recovery capabilities in small clusters. By pre-locating target data nodes, cross-node query latency is reduced, ensuring rapid retrieval of status information after a failure, while supporting the high availability requirements of database node clusters of different sizes.

[0103] Specifically, the second data node can determine at least one target data node based on the first session identifier and the database node cluster node status information through a hash algorithm. For example, when the number of cluster nodes changes from 3 to 2, the algorithm recalculates backupNode=hash(session_id)%2 to ensure that the target data node is always a live node.

[0104] Alternatively, the second data node can also determine that among the available nodes in the database node cluster, the data node with the lowest load is at least one target data node.

[0105] Load is an indicator that describes the resource usage of a data node; for example, the CPU utilization of data node 1 is 85%.

[0106] In addition, the second data node can also determine at least one target data node as the data node for backing up the state information of the first session through other means, which are not limited here.

[0107] In this possible implementation, dynamically adjusting the hash algorithm parameters further enhances the system's adaptability to changes in the state information of the database node cluster. For example, in a telecommunications billing system, if the number of nodes in the database node cluster increases from 3 to 4 due to expansion, the system automatically updates the hash algorithm parameters to ensure that the new node is included in the backup strategy and to avoid missing state information. This reduces the need for manual intervention and improves the system's automation level.

[0108] On the other hand, the target data node selection process is further optimized through a load-aware mechanism. For example, in a banking system, the master node may be unable to process backup requests in a timely manner due to high concurrency load, while a dynamic strategy can back up the state to a standby node with a lower load, avoiding resource consumption. This improves the overall stability of the database node cluster and reduces fault recovery time.

[0109] Therefore, in some embodiments, the first data node is an adjacent available data node of the second data node; or,

[0110] The first data node can also be any data node in the database node cluster; or,

[0111] The first data node can also be a data node in a database node cluster, determined by a hash algorithm based on the first session identifier and the database node cluster node status information. The database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, which indicates the available data nodes in the database node cluster; or...

[0112] The first data node can also be the data node with the lowest load among the available nodes in the database node cluster.

[0113] In addition, the first data node can also be any other data node among the available nodes in the database node cluster, which is not specified here.

[0114] Second, the first data node obtains the first session state information from the storage space of other data nodes in the database node cluster.

[0115] In some embodiments, such as Figure 4 As shown, the database node cluster also includes a third data node. The at least one target data node determined in step S305 above includes the third data node, that is, the second data node sends the first session state information to the third data node for backup.

[0116] Step S307 above, where the first data node obtains the corresponding first session status information based on the first session identifier, may specifically include:

[0117] S3071, The first data node sends the first session identifier to the third data node.

[0118] It is understandable that if the first data node's storage space does not contain the first session state information, the first data node can obtain the first session state information from the storage space of other data nodes. The third data node contains this first session state information; therefore, the first data node can send the first session identifier to the third data node, enabling the third data node to send the first session state information back to the first data node.

[0119] Correspondingly, the third data node can receive the first session identifier.

[0120] S3072, The first data node receives the first session status information sent by the third data node.

[0121] After receiving the first session identifier, the third data node can store the corresponding first session status information in its storage space and send it to the first data node.

[0122] Correspondingly, the first data node can receive the first session state information sent by the third data node.

[0123] In some embodiments, the third data node is the data node that is physically closest to the client, or the third data node is the data node that is closest to the client's network topology.

[0124] Understandably, the second data node can send the first session state information to multiple data nodes for backup. When the first data node needs to obtain the first session state information from these data nodes, the first data node needs to determine one of them to obtain the first session state information. Specifically, it can determine the data node that is physically closest to the client, or it can determine the data node that is closest to the client's network topology. In addition, other methods can be used to determine the data node used to obtain the first session state information, which are not limited here.

[0125] Physical distance refers to the distance between the physical location of the client and the physical location of the data node. Network topology distance refers to the distance in the network connection structure between the client and the cluster nodes.

[0126] For example, the first data node can determine the data node closest to the client's network topology based on the round-trip time (RTT) between the client and the data node. It can also determine the data node closest to the client's network topology based on information such as the border gateway protocol routing table (BGP) and the autonomous system path length (AS). The specifics are not limited here.

[0127] For example, the client's Internet Protocol (IP) address and the data node's IP address can be converted into latitude and longitude or city coordinates to calculate the physical location between the client and the data node, thereby determining the data node that is physically closest to the client.

[0128] In this possible implementation, selecting data nodes based on physical location or network topology further reduces the latency of fault recovery. For example, in multinational banking systems, selecting data nodes based on physical location or network topology allows for rapid response to recovery requests from local clients, avoiding delays caused by long-distance network transmission. This improves user experience while reducing cross-node communication overhead.

[0129] In some embodiments of this application, the first data node may first obtain the first session state information from its internal storage space; if it does not obtain it from the internal storage space of the first data node, the first data node may then obtain it from the storage space of other data nodes in the database node cluster.

[0130] This possible implementation reduces the number of cross-node network requests and latency through a local caching priority strategy. This shortens fault recovery time, reduces network congestion risk, and improves system stability and response speed.

[0131] In some embodiments, step 308, where the first data node restores the session connection with the client based on the first session state information, may specifically include:

[0132] The first data node establishes a session connection with the client and restores the session context information based on the first session state information. The session context information includes at least one of the following: session state information, session parameters, and session cache.

[0133] Session context information refers to the collection of all runtime environment information required to maintain business continuity and consistency during the interaction session between the client and the data node. It enables the system to recover to the breakpoint state after a session interruption, avoiding re-login, duplicate calculations, or data inconsistencies.

[0134] Session state information can describe the current logical state of a session, and is typically immutable or controllable metadata. Examples include a unique session identifier, user identity, session creation time, last active time, whether the session is currently in a transaction, transaction snapshot timestamps, and network connection status.

[0135] Session parameters can be configurable variables set by the client or system that affect the execution behavior or result format of Structured Query Language (SQL).

[0136] Session caching temporarily stores intermediate results, metadata, or frequently accessed data copies during the session's lifecycle to improve performance or support continuous operations. Examples include cursor positions, breakpoints for pagination or streaming queries, and execution plans for prepared statements.

[0137] In this possible implementation, the continuity of business logic after a failover is ensured by restoring the transaction context information. For example, in financial trading scenarios, after uncommitted transactions and temporary variables are restored, users can continue operating without having to re-enter parameters, thus improving business continuity and user experience.

[0138] In this embodiment, a server-driven session state management mechanism solves the problem of service interruption caused by session state loss in existing technologies. A distributed caching mechanism for session identifiers and session state information ensures accurate recovery of session state after failover, preventing duplicate execution of business processes. Dynamic backup strategies reduce redundant data transmission, lowering network load and storage overhead. A direct query mechanism based on identifiers and a backup node pre-location strategy shorten fault recovery time.

[0139] Figure 5 This is a schematic diagram of the structure of a session recovery device provided in an embodiment of this application, as shown below. Figure 5 As shown, the transaction preprocessing apparatus 500 provided in this embodiment includes, in some embodiments:

[0140] The transceiver module 501 is used to receive a session connection request from the client, the session connection request including a first session identifier; and to obtain the corresponding first session status information based on the first session identifier. The first session status information is used to indicate the status information of the session connection previously established between the client and the second data node. The first session status information includes a first session identifier, first session node information, and first session status parameters.

[0141] Processing module 502 is used to restore the session connection with the client based on the first session state information.

[0142] In one possible implementation, the parameter modules for different transaction dimensions correspond to different transaction parameter items. The processing module 502 is specifically used to: determine the target parameter module from multiple parameter modules based on the transaction information; determine the target configuration parameter corresponding to the target parameter module based on the transaction information, and match the parameter items of the target configuration parameter with the configuration parameter items corresponding to the target parameter module.

[0143] In one possible implementation, the transceiver module 501 is further configured to: receive first session state information from the second data node and store it in the first storage space corresponding to the first data node; and retrieve the first session state information from the first storage space based on the first session identifier.

[0144] In one possible implementation, the first data node is an adjacent available data node of the second data node; or, the first data node is any data node in the database node cluster; or, the first node is a data node in the database node cluster determined by a hash algorithm based on the first session identifier and the database node cluster node status information, wherein the database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, and the data node availability information is used to indicate the available data nodes in the database node cluster; or, the first data node is the data node with the lowest load among the available nodes in the database node cluster.

[0145] In one possible implementation, the database node cluster also includes a third data node, and the transceiver module 501 is specifically used to: send a first session identifier to the third data node; and receive the first session status information sent by the third data node.

[0146] In one possible implementation, the third data node is the data node that is physically closest to the client, or the third data node is the data node that is closest to the client's network topology.

[0147] In one possible implementation, the processing module 502 is specifically used to: establish a session connection with the client and restore session context information based on the first session state information, wherein the session context information includes at least one of session state information, session parameters, and session cache.

[0148] The session recovery device provided in this embodiment can execute the method implemented by the first data node in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0149] In other embodiments, the session resumption device 500 includes:

[0150] The transceiver module 501 is used to send the first session identifier to the client and send the first session status information to at least one target data node.

[0151] The processing module 502 is used to generate first session state information after establishing a session connection with the client. The first session state information is used to instruct the first data node to establish a session connection with the client. The first session state information includes a target session identifier, session node information, and session state parameters; and to determine at least one target data node in the data nodes of the database node cluster.

[0152] In one possible implementation, the processing module 502 is specifically configured to: determine an available data node adjacent to the second data node as at least one target data node; or, determine all data nodes in the database node cluster as at least one target data node; or, determine at least one target data node by a hash algorithm based on the first session identifier and the database node cluster node status information, wherein the database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, and the data node availability information is used to indicate the available data nodes in the database node cluster; or, determine the data node with the lowest load among the available nodes in the database node cluster as at least one target data node.

[0153] The session recovery device provided in this embodiment can execute the method implemented by the second data node in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0154] In other embodiments, the session resumption device 500 includes:

[0155] The transceiver module 501 is used to establish a session connection with the second data node; receive a first session identifier from the second data node; and send a session connection request to the first data node after the session connection with the second data node fails, the session connection request including the first session identifier.

[0156] Processing module 502 is used to establish a session connection with the second data node.

[0157] The session recovery device provided in this embodiment can execute the method implemented by the client in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0158] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6As shown, the electronic device 60 may include a memory 601 and a processor 602. Optionally, the electronic device may also include a transceiver 603, wherein the memory 601 and the processor 602 communicate; for example, the memory 601, the processor 602 and the transceiver 603 may communicate via a communication bus 604, the memory 601 is used to store a computer program, and the processor 602 executes the computer program to implement the method of the above embodiments.

[0159] Optionally, the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps in the method embodiments disclosed in this application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0160] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the methods in any of the above method embodiments.

[0161] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the methods in any of the above method embodiments.

[0162] All or part of the steps in the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, it performs the steps of the above method embodiments; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disk, and any combination thereof.

[0163] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0164] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0165] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0166] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims of this application and their equivalents, this application also intends to include these modifications and variations.

[0167] In this application, the term "comprising" and its variations can refer to non-limiting inclusion; the term "or" and its variations can refer to "and / or". The terms "first", "second", etc., in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0168] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0169] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0170] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0171] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0172] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0173] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0174] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0175] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0176] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A session recovery method, characterized in that, Applied to the first data node, the database node cluster includes the first data node and the second data node, the method includes: Receive a session connection request from a client, the session connection request including a first session identifier; The first session status information is obtained according to the first session identifier. The first session status information is used to indicate the status information of the session connection previously established between the client and the second data node. The first session status information includes the first session identifier, the first session node information, and the first session status parameters. The session connection is restored with the client based on the first session state information.

2. The method according to claim 1, characterized in that, Before receiving the session connection request from the client, the method further includes: Receive first session state information from the second data node and store it in the first storage space corresponding to the first data node; The step of obtaining the corresponding first session status information based on the first session identifier includes: Based on the first session identifier, the first session state information is obtained from the first storage space.

3. The method according to claim 2, characterized in that, The first data node is an adjacent available data node of the second data node; or, The first data node is any data node in the database node cluster; or, The first node is a data node in the database node cluster determined by a hash algorithm based on the first session identifier and the database node cluster node status information. The database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, which indicates the available data nodes in the database node cluster; or, The first data node is the data node with the lowest load among the available nodes in the database node cluster.

4. The method according to claim 1, characterized in that, The database node cluster also includes a third data node, and the step of obtaining the corresponding first session state information based on the first session identifier includes: Send the first session identifier to the third data node; Receive the first session status information sent by the third data node.

5. The method according to claim 4, characterized in that, The third data node is the data node that is physically closest to the client, or the third data node is the data node that is closest to the client's network topology.

6. The method according to any one of claims 1-5, characterized in that, The step of restoring the session connection with the client based on the first session state information includes: A session connection is established with the client, and session context information is restored based on the first session state information. The session context information includes at least one of session state information, session parameters, and session cache.

7. A session recovery method, characterized in that, Applied to a second data node, the database node cluster includes a first data node, and the method includes: After establishing a session connection with the client, first session state information is generated. The first session state information is used to indicate that the first data node establishes a session connection with the client. The first session state information includes the target session identifier, session node information, and session state parameters. Send the first session identifier to the client; At least one target data node is identified among the data nodes of the database node cluster; Send the first session state information to the at least one target data node.

8. The method according to claim 7, characterized in that, Identifying at least one target data node among the data nodes in the database node cluster includes: Determine the available data node adjacent to the second data node as the at least one target data node; or, All data nodes in the database node cluster are identified as the at least one target data node; or, Based on the first session identifier and the database node cluster node status information, the at least one target data node is determined using a hash algorithm. The database node cluster node status information includes the number of data nodes in the database node cluster and data node availability information, whereby the data node availability information indicates the available data nodes in the database node cluster; or... The data node with the lowest load among the available nodes in the database node cluster is identified as the at least one target data node.

9. A session recovery method, characterized in that, Applied to the client, the database node cluster includes a first data node and a second data node, and the method includes: Establish a session connection with the second data node; Receive the first session identifier from the second data node; After the session connection with the second data node fails, a session connection request is sent to the first data node, the session connection request including the first session identifier; Establish a session connection with the first data node.

10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as claimed in any one of claims 1 to 6, or the method as claimed in any one of claims 7 to 8, or the method as claimed in claim 9.