Methods and apparatus for achieving session consistency
By obtaining the status information of the session management platform in the distributed system, the problem of session inconsistency during session synchronization is solved, strong consistency of session information and fault detection are achieved, and the efficiency and reliability of session synchronization are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING OCEANBASE TECHNOLOGY CO LTD
- Filing Date
- 2023-06-12
- Publication Date
- 2026-05-26
AI Technical Summary
In distributed systems, during session synchronization, errors in the session management platform or communication failures can lead to inconsistent session information. Existing technologies cannot effectively guarantee the consistency of session information on each node.
In response to a session switching command, the system obtains the status information stored in the session management platform, including the connection information of the first session, and obtains the target session information recorded in the first session based on the connection information, so as to ensure that the session information of the second session is consistent with that of the first session.
It enables direct acquisition of session information during session switching, ensuring strong consistency of session information, timely detection of faults, and improvement of the efficiency and reliability of session synchronization.
Smart Images

Figure CN116828032B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of computer technology, and more particularly to a method and apparatus for implementing session consistency. Background Technology
[0002] In distributed systems, sessions on each node ensure consistency of session information through session synchronization mechanisms. In related technologies, to guarantee synchronization efficiency, session information is often synchronized via forwarding by a session management platform. However, errors may occur during forwarding by the session management platform (e.g., incomplete forwarded data, system crashes during forwarding, etc.), and these errors are often imperceptible to individual nodes, posing a significant risk in practical applications. Summary of the Invention
[0003] In view of this, one or more embodiments of this specification provide a method and apparatus for achieving session consistency.
[0004] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0005] According to a first aspect of one or more embodiments of this specification, a method for implementing session consistency is proposed, comprising:
[0006] In response to a session switching command from the first session to the second session, the status information stored in the session management platform is obtained, wherein the status information includes the connection information of the first session;
[0007] Based on the connection information of the first session, obtain the target session information recorded in the first session to ensure consistency between the session information in the first session and the second session.
[0008] According to a second aspect of one or more embodiments of this specification, an apparatus for implementing session consistency is provided, comprising:
[0009] The first acquisition module is used to acquire status information stored in the session management platform in response to a session switching instruction from the first session to the second session, wherein the status information includes the connection information of the first session;
[0010] The second acquisition module is used to acquire the target session information recorded in the first session based on the connection information of the first session, so that the session information in the first session and the second session are consistent.
[0011] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, comprising:
[0012] processor;
[0013] Memory used to store processor-executable instructions;
[0014] The processor implements the method described in the first aspect by running executable instructions.
[0015] According to a fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method as described in the first aspect.
[0016] The session consistency implementation method provided in this specification enables a second session to respond to a session switching command from the first session to the second session and obtain state information stored in the session management platform. This state information includes the connection information of the first session. Furthermore, the second session can obtain the target session information recorded in the first session based on the connection information of the first session. The solution provided in this specification allows the second session to directly obtain the session information recorded in the first session, thereby ensuring the consistency of session information between the first and second sessions. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of a system architecture for an implementation method of session consistency provided in an exemplary embodiment.
[0018] Figure 2 This is a flowchart illustrating an exemplary embodiment of a method for implementing session consistency.
[0019] Figure 3 This is a flowchart illustrating a session consistency verification method provided in an exemplary embodiment.
[0020] Figure 4 This is a flowchart illustrating a session synchronization method provided in an exemplary embodiment.
[0021] Figure 5 This is a flowchart illustrating another session synchronization method provided in an exemplary embodiment.
[0022] Figure 6 This is a schematic diagram of the structure of a device provided in an exemplary embodiment.
[0023] Figure 7 This is a schematic diagram of the structure of an implementation device for session consistency provided in an exemplary embodiment. Detailed Implementation
[0024] 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 numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0025] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0026] To facilitate understanding, the terms used in this instruction manual will be explained first.
[0027] A session can be understood as a context between a client and a server from the start to the end of communication. When a user establishes a connection with a server through a client, a session corresponding to that connection is created on the server to record session information generated during the interaction. This session information is typically stateful; for example, it may include user login information to ensure the user is logged in.
[0028] Session consistency refers to the consistency between sessions across different nodes in a distributed system. Because the nodes in a distributed system are independent of each other, a user's session generated during a single connection is distributed across multiple nodes. Therefore, it is necessary to ensure the consistency of sessions across all nodes, thereby guaranteeing the reliability and correctness of the data.
[0029] In a standalone system, after a user establishes a connection with the server through a client, the server can create a session corresponding to that connection and use the session to store the user's session information. As long as the user does not close the connection, the session information can be retained for a period of time. For example, the session information may include the user's login information to ensure that the user is logged in.
[0030] With the development of computer technology and business, stand-alone systems are gradually being replaced by distributed systems. Although the system still appears as a whole to the client, from the server's perspective, business data is split and deployed on different nodes. Each node is independent of the others and can be connected via Remote Procedure Call (RPC).
[0031] Therefore, the session information that originally existed only once in a single-machine system should be synchronized to each node in a distributed system so that each node can be aware of the user's session information and thus have the ability to provide services to the user.
[0032] In related technologies, a session management platform can be configured to synchronize sessions on different nodes. However, during the synchronization process, there may be faults such as the session management platform going offline or incomplete synchronization of session information due to the communication method between the session management platform and the node. All of these faults may cause errors in the session synchronization process, resulting in inconsistencies in sessions on different nodes.
[0033] In view of this, the session consistency implementation method provided in this specification enables the second session to respond to a session switching command from the first session to the second session and obtain the status information stored in the session management platform, wherein the status information includes the connection information of the first session. This allows the second session to obtain the target session information recorded in the first session based on the connection information of the first session. The solution provided in this specification enables the second session to directly obtain the session information recorded in the first session, thereby ensuring the consistency of session information between the first and second sessions.
[0034] The following will describe the exemplary implementation method in detail with reference to the accompanying drawings and embodiments.
[0035] First, the application scenarios involved in the embodiments of this specification are introduced. The methods provided in this specification can be applied to any distributed system, such as a distributed database. The system architecture of the embodiments of this specification will be described below using a distributed database as an example.
[0036] Figure 1 An exemplary system architecture diagram is shown that can be applied to the implementation method or apparatus for session consistency in the embodiments of this specification.
[0037] like Figure 1 As shown, the system architecture 100 includes a terminal 101, a database management system 102, and a distributed database 103.
[0038] Terminal 101 may include mobile phones, smart TVs, tablets, laptops, or personal computers (PCs). A client may also be configured on terminal 101, which may be an application client or a browser client.
[0039] The database management system 102 can be deployed on a server and integrates a session management platform, which can provide session management capabilities to external users.
[0040] The distributed database 103 can consist of multiple independent nodes, which can be connected via Remote Procedure Call (RPC). The nodes in the distributed database can be independent physical machines or different virtual machines on the same physical machine; this specification does not limit this.
[0041] In some embodiments, the database management system 102 establishes a bridge between the terminal 101 and the distributed database 103 via a network, enabling the forwarding of requests sent by the terminal 101 to any node in the distributed database 103. The network can be a wide area network (WAN), a local area network (LAN), or a combination of both.
[0042] In some embodiments, when the data currently requested by a user is stored on different nodes in the distributed database 103 compared to the data requested in the previous query, the database management system 102 can forward the user's current query request to the corresponding node and issue a session switching instruction. At this time, the node corresponding to the user's current query request can execute the session consistency implementation method provided in the embodiments of this specification, thereby ensuring the consistency of session information before and after the session switching.
[0043] Those skilled in the art will know that Figure 1 The number of terminals, database management systems, and distributed databases shown is merely illustrative. Depending on actual needs, any number of terminals, database management systems, and distributed databases can be used, and this specification does not impose any limitations on this.
[0044] The following section will describe in detail, with reference to specific implementation methods, a method for achieving session consistency provided in the embodiments of this specification.
[0045] Figure 2 This is a flowchart illustrating an exemplary embodiment of a method for implementing session consistency. This method can be executed by any electronic device, for example, by a node in a distributed database. Figure 2 As shown in the embodiments of this specification, the method for implementing session consistency includes the following steps.
[0046] S201, in response to a session switching instruction from the first session to the second session, the second session obtains the status information stored in the session management platform, wherein the status information includes the connection information of the first session.
[0047] It should be noted that the session management platform can be used to manage sessions on various nodes in a distributed environment, such as creating, deleting or modifying sessions.
[0048] For example, in a distributed database application scenario, when a session management platform receives an initial access request from a client for the distributed database, it can create a session corresponding to that access request on various nodes of the distributed database. For instance, a first session can be created on the first node of the distributed database, and a second session can be created on the second node.
[0049] Once a session is created, a corresponding session ID can be returned to the client. When the client sends a request again, it can retrieve the corresponding session information from the node by including the session ID in the request header. When the client disconnects, the session management platform can delete the session corresponding to that client, thereby freeing up storage space on the node.
[0050] Furthermore, in distributed database applications, session management platforms can be integrated into the database management system. For example, for Oceanbase databases, the OceanBase Developer Center (ODC) can be used to manage sessions generated during database connections.
[0051] It should be noted that the session switching command allows users to switch between sessions on different nodes.
[0052] For example, suppose the first session is created on the first node and the second session is created on the second node. The first node and the second node are two different nodes in the same distributed system. In this case, if the user's previous access request was forwarded to the first node by the session management system, and the current access request is forwarded to the second node by the session management system, then when the current access request is executed, a session switching instruction will be generated to switch from the first session to the second session.
[0053] For example, in a distributed database application scenario, if the data requested by the user in the previous query is located on the first node, while the data requested in the current query is located on the second node, a switching instruction will be generated to switch from the first session to the second session when the current query request is executed.
[0054] It should be noted that the status information of the first session can be information generated during communication between the client and the node where the first session resides. In the embodiments of this specification, the status information may include the connection information of the first session, so that other sessions can establish a connection with the first session based on the connection information of the first session.
[0055] In some embodiments, the status information is sent from the first session to the session management platform before the second session obtains the status information stored in the session management platform.
[0056] For example, the status information can be fed back to the session management platform by the first session in real time, or by the first session when the status information changes, or by the session management platform actively obtaining it from the first session after receiving a session switching instruction. This specification does not limit this.
[0057] S202, the second session obtains the target session information recorded in the first session based on the connection information of the first session, so that the session information in the first session and the second session are consistent.
[0058] It should be noted that session information consistency refers to the requirement that the session information in the first session and the second session be completely identical. As mentioned earlier, session information is typically information with persistent state. For example, session information may include user login information. By ensuring that the session information containing user login information in the first session and the second session is consistent, the user can remain logged in when switching from the first session to the second session.
[0059] In the embodiments of this specification, since the second session can directly obtain the session information recorded in the first session, the session information recorded in the first session can be directly used as the session information of the second session, thereby ensuring the consistency of the session information in the first session and the second session.
[0060] In some embodiments, a connection can be established between the second session and the first session based on the connection information of the first session, and the target session information recorded in the first session can be obtained based on the established connection.
[0061] For example, the first session and the second session are created on different nodes. The connection information of the first session includes the node connection information and session identification information of the first session. The connection between the second session and the first session can be established as follows: based on the node connection information, the node corresponding to the first session is determined; based on the session identification information, the first session is located in the node corresponding to the first session, so that a connection is established between the second session and the first session. The node connection information can be the IP address and port number of the node where the first session resides.
[0062] In some embodiments, the connection established between the second session and the first session can be an RPC connection. Since the first session and the second session are deployed on different nodes, data between them cannot be directly accessed; the semantics of the call and the data to be called need to be expressed through the network.
[0063] In some embodiments, the status information in S201 further includes the initial session information of the first session. This initial session information is the session information of the first session stored in the session management platform. In other words, the initial session information is the session information that the first session pre-sent to the session management platform.
[0064] When the status information includes the initial session information, the second session can use the initial session information as the session information of the second session after receiving the status information, thereby enabling the client to quickly join the new session during the session switching process.
[0065] It should be noted that both the initial session information and the target session information are session information from the first session. The difference is that the initial session information is session information that the first session sends to the session management platform in advance and is then forwarded to the second session by the session management platform, while the target session information is session information that the first session sends directly to the second session.
[0066] Ideally, the initial session information and the target session information are identical, differing only in their transmission paths. However, in practice, errors may occur during transmission of the initial session information. Since the initial session information is sent from the session management platform to the second session, the first session cannot detect whether the platform successfully sent the initial session information to the second session, nor can it verify the correctness of the initial session information sent to the second session. Therefore, when errors occur during transmission, inconsistencies between the session information of the first and second sessions will result. To ensure consistency between the session information in the first and second sessions, the initial session information in the second session can be validated.
[0067] For example, the second session can further verify the initial session information by comparing its consistency with the target session information obtained in S202. If the target session information and the initial session information are inconsistent, the second session can send an alarm message to the session management platform to prompt relevant technical personnel to troubleshoot the problem in a timely manner.
[0068] In some embodiments, if the target session information and the initial session information are inconsistent, the second session may directly use the target session information as its session information. That is, the second session can use the target session information directly obtained from the first session to overwrite the initial session information obtained from the state information, thereby ensuring consistency.
[0069] In some embodiments, after obtaining the target session information recorded in the first session, the second session can return a session information confirmation message to the first session, thereby ensuring strong consistency of session information in the first and second sessions. That is, if the first session does not receive a session information confirmation message from the second session within a preset time period, it can be considered that the target session information was not sent successfully, and the session information in the second session has not yet been verified.
[0070] The solution provided in this specification ensures consistency between the session information of the first and second sessions because the second session can directly obtain the session information recorded in the first session. Furthermore, when an error occurs during the transmission of session information from the first session to the second session, the error can be detected by both parties due to the established communication connection, allowing for timely fault detection.
[0071] The above describes the basic concept of the session consistency implementation method provided in the embodiments of this specification. The following will combine... Figure 3 , Figure 4 and Figure 5 This specification details three specific implementation methods.
[0072] Figure 3 This is a flowchart illustrating a session consistency verification method provided in an exemplary embodiment. Figure 3 As shown in the embodiments of this specification, the session consistency verification method includes the following steps.
[0073] S301, the first session sends status information (including connection information and initial session information) to the session management platform.
[0074] Specifically, the connection information includes the IP address, port number, and session identifier of the node where the first session resides. The initial session information is the session information of the first session.
[0075] For example, the status information can be sent from the first session to the session management platform in real time, or it can be sent from the first session to the session management platform when the status information changes. This specification does not limit this embodiment.
[0076] S302, the session management platform synchronizes the status information to the second session.
[0077] Specifically, after receiving a session switching instruction from the first session to the second session, the session management platform can synchronize the received connection information and initial session information to the second session. Upon receiving the initial session information, the second session can then use it to provide services to the client.
[0078] S303, the second session establishes a connection with the first session.
[0079] Specifically, to prevent errors in the initial session information sent by the session management platform, the second session can establish a connection with the first session based on the received connection information to complete the verification of the initial session information.
[0080] S304, the first session sends target session information to the second session.
[0081] Specifically, the first session can send target session information to the second session through the established connection. The target session information is the session information that the first session directly sends to the second session.
[0082] S305, the second session verifies whether the target session information and the initial session information are consistent.
[0083] Specifically, after receiving the target session information, the second session can verify whether the initial session information and the target session information are consistent. If they are consistent, the initial session information is correct; otherwise, it can send a corresponding alarm message to the session management platform, which indicates that the initial session information used in the current second session may be incorrect.
[0084] Figure 4 This is a flowchart illustrating a session synchronization method provided in an exemplary embodiment. Figure 4 The provided embodiments and Figure 3 The difference in the provided embodiments is that, Figure 4 The provided embodiment does not have a verification step, but directly uses the target session information as the session information of the second session, thereby ensuring the consistency of session information in the first session and the second session.
[0085] Specifically, such as Figure 4 As shown in the embodiments of this specification, the session synchronization method includes the following steps.
[0086] S401, the first session sends status information (including connection information and initial session information) to the session management platform.
[0087] S402, the session management platform synchronizes the status information to the second session.
[0088] S403, the second session establishes a connection with the first session.
[0089] S404, the first session sends target session information to the second session.
[0090] S405, the second session uses the target session information as the session information of the second session.
[0091] Specifically, the purpose of the embodiments in this specification is to ensure the consistency of session information between the first session and the second session. Since the initial session information relayed through the session management platform may be sent incorrectly during synchronization to the second session, and this error cannot be detected, the target session information received from the first session can be directly used as the session information of the first session to ensure the consistency of session information.
[0092] The above focuses on describing Figure 4 The provided embodiments and Figure 3 The differences between the provided embodiments and other undescribed parts can be found in the following references. Figure 3 The descriptions in the provided embodiments are for the purpose of brevity, and will not be repeated in the embodiments of this specification.
[0093] Figure 5 This is a flowchart illustrating a session synchronization method provided in an exemplary embodiment. Figure 5 The provided embodiments and Figure 4 The difference in the provided embodiments is that, Figure 5 In the provided embodiment, the status information only includes the connection information of the first session, but not the initial session information, thereby avoiding redundant transmission of session information and improving session synchronization efficiency.
[0094] Specifically, such as Figure 5 As shown in the embodiments of this specification, the session synchronization method includes the following steps.
[0095] S501, the first session sends status information (including connection information) to the session management platform.
[0096] S502, the session management platform synchronizes the status information to the second session.
[0097] S503, the second session establishes a connection with the first session.
[0098] S504, the first session sends target session information to the second session.
[0099] S505, the second session uses the target session information as the session information of the second session.
[0100] Specifically, since the consistency of session information can be guaranteed by S504 and S505, in order to avoid the problem of slow session synchronization caused by redundant transmission of session information, the embodiments of this specification can carry only the connection information of the first session in the status information, and enable the second session to provide services to the client after obtaining the target session information from the first session according to the connection information.
[0101] For example, in order to ensure strong consistency between the session information of the second session and the first session, after receiving the target session information sent by the first session, the second session can return a session information confirmation message to the first session, thereby forming a closed loop in the session synchronization process, so that the first session can perceive the synchronization result and ensure strong consistency between the session information in the first session and the second session.
[0102] The above focuses on describing Figure 5 The provided embodiments and Figure 4 The differences between the provided embodiments and other undescribed parts can be found in the following references. Figure 4 The descriptions in the provided embodiments are for the purpose of brevity, and will not be repeated in the embodiments of this specification.
[0103] Figure 6 This is a schematic diagram of the structure of a device provided in an exemplary embodiment. Please refer to... Figure 6 At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, memory 608, and non-volatile memory 610, and may also include other hardware required for business operations. One or more embodiments of this specification can be implemented in software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into memory 608 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0104] Please refer to Figure 7 , Figure 7 A session consistency implementation device 700 is provided, which can be applied to, for example... Figure 6 The device shown implements the technical solution of this specification. The session consistency implementation device 700 may include:
[0105] The first acquisition module 701 is used to acquire status information stored in the session management platform in response to a session switching instruction from the first session to the second session, wherein the status information includes the connection information of the first session;
[0106] The second acquisition module 702 is used to acquire the target session information recorded in the first session based on the connection information of the first session, so that the session information in the first session and the second session are consistent.
[0107] In some embodiments, the status information further includes the initial session information of the first session. The first acquisition module 701 is further configured to use the initial session information as the session information of the second session. The second acquisition module 702 is further configured to verify the consistency between the target session information and the initial session information; if the target session information and the initial session information are inconsistent, an alarm message is sent to the session management platform.
[0108] In some embodiments, if the target session information and the initial session information are inconsistent, the second acquisition module 702 is further configured to use the target session information as the session information of the second session.
[0109] In some embodiments, the status information is sent from the first session to the session management platform before the status information stored in the session management platform is obtained.
[0110] In some embodiments, the second acquisition module 702 is further configured to: establish a connection between the second session and the first session based on the connection information of the first session; and acquire target session information recorded in the first session based on the established connection.
[0111] In some embodiments, the first session and the second session are created on different nodes, and the connection information includes the node connection information and session identification information of the first session. The second acquisition module 702 is further configured to: determine the node corresponding to the first session based on the node connection information; and locate the first session in the node corresponding to the first session based on the session identification information, so as to establish a connection between the second session and the first session.
[0112] In some embodiments, the connection established between the second session and the first session is a Remote Procedure Call (RPC) connection.
[0113] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0114] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0115] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0116] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0117] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0118] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0119] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” used in one or more embodiments of this specification and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0120] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."
[0121] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification.
Claims
1. A method for implementing session consistency, comprising: In response to a session switching instruction from a first session to a second session, the status information stored in the session management platform is obtained, wherein the status information includes connection information and initial session information of the first session; The initial session information is used as the session information of the second session. Based on the connection information of the first session, the target session information recorded in the first session is obtained to ensure that the session information of the first session and the second session are consistent. The consistency between the target session information and the initial session information is verified. If the target session information and the initial session information are inconsistent, an alarm message is sent to the session management platform.
2. The method according to claim 1, wherein if the target session information and the initial session information are inconsistent, the method further comprises: The target session information is used as the session information of the second session.
3. The method according to claim 1, wherein before obtaining the status information stored in the session management platform, the status information is sent from the first session to the session management platform.
4. The method according to claim 1, wherein obtaining the target session information recorded in the first session based on the connection information of the first session includes: Based on the connection information of the first session, a connection is established between the second session and the first session; Based on the established connection, obtain the target session information recorded in the first session.
5. The method according to claim 4, wherein the first session and the second session are created on different nodes, and the connection information includes node connection information and session identifier information of the first session; The step of establishing a connection between the second session and the first session based on the connection information of the first session includes: Based on the node connection information, determine the node corresponding to the first session; Based on the session identifier information, the first session is located in the node corresponding to the first session, so that a connection is established between the second session and the first session.
6. The method according to claim 4, wherein the connection established between the second session and the first session is a Remote Procedure Call (RPC) connection.
7. An apparatus for implementing session consistency, comprising: The first acquisition module is configured to, in response to a session switching instruction from a first session to a second session, acquire status information stored in the session management platform, wherein the status information includes connection information and initial session information of the first session, and uses the initial session information as the session information of the second session; The second acquisition module is used to acquire target session information recorded in the first session based on the connection information of the first session, so that the session information of the first session and the second session are consistent; and to verify the consistency between the target session information and the initial session information; if the target session information and the initial session information are inconsistent, an alarm message is sent to the session management platform.
8. An electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor implements the method as described in any one of claims 1 to 6 by executing the executable instructions.
9. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1 to 6.