Service connection establishment method and device, storage medium and electronic device
By maintaining and automatically restoring connections to cloud databases after changes through an intermediate service, the problem of complex connection restoration operations when cloud databases are changed is solved, achieving seamless automatic connection restoration and high availability.
Patent Information
- Application Number
- CN202210017890.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-07
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2042-01-07
AI Technical Summary
When changes occur in a cloud database, the process of restoring the connection between the user service and the cloud database service is highly complex, and existing technologies have not been able to effectively solve this problem.
The system maintains a connection with the user service through an intermediate service, saves the connection state on the intermediate service, and automatically establishes a set of connections with the changed database nodes, reducing user operations.
It enables automatic connection recovery without user awareness when cloud databases change, reducing operational complexity and improving service availability.
Smart Images

Figure CN116455954B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and more specifically, to a method, apparatus, storage medium, and electronic device for establishing a service connection. Background Technology
[0002] Cloud service providers offer a variety of cloud services, among which cloud database services are characterized by numerous instances, large data volumes, and high service availability requirements. Under normal operating conditions, instance nodes in cloud database services undergo changes such as restarts, migrations, and switches. In abnormal operating situations, such as system crashes, high-availability switches are performed. These scenarios can all lead to a disconnection between the user service and the cloud database service, preventing users from using the services provided by the cloud database.
[0003] Currently, there are generally two architectures for connecting user services and cloud database services. One is where the user service directly connects to the database node provided by the cloud database service. In this architecture, when the aforementioned situation occurs, the user service will detect the unavailability of the backend node. After the change is completed, the user service needs to re-establish the connection through complex operations such as editing code before it can continue using the services provided by the cloud database. The other architecture is where the user service connects to the database node provided by the cloud database service through middleware. In this architecture, when the aforementioned situation occurs, the middleware will return changes (such as error information from the operation request) to the user service. The user service will also detect the change in the backend node and needs to re-establish the connection through complex operations such as editing code.
[0004] In other words, if the database nodes provided by the cloud database service to users change, users need to manually restore the service connection through complex operations such as writing code in order to continue using the cloud database service normally. This results in a high level of operational complexity in the process of restoring the service connection when the cloud database changes.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This invention provides a method, apparatus, storage medium, and electronic device for establishing service connections, to at least address the technical problem of high operational complexity in the process of restoring service connections when cloud databases undergo changes.
[0007] According to one aspect of the present invention, a method for establishing a service connection is provided, comprising: obtaining first indication information sent by a management service to an intermediate service, wherein the first indication information is used to indicate that a first database node in a cloud database is a database node to be changed, the first database node is used to provide data services to a user service through a first set of connections established between the first database node and the intermediate service, and the management service is used to change the first database node; responding to the first indication information, maintaining a service connection between the intermediate service and the user service on the intermediate service, and saving the connection status of the service connections included in the first set of connections on the intermediate service; and, if it is determined that the first database node has been changed to a second database node in the cloud database, establishing a second set of connections between the intermediate service and the second database node on the intermediate service according to the connection status, wherein the second database node is used to provide data services to the user service in place of the first database node through the second set of connections.
[0008] According to another aspect of the present invention, a service connection establishment apparatus is also provided, comprising: a first acquisition module, configured to acquire first indication information sent by a management service to an intermediate service, wherein the first indication information is configured to indicate that a first database node in a cloud database is a database node to be changed, the first database node is configured to provide data services to a user service through a first connection set established between the first database node and the intermediate service, and the management service is configured to change the first database node; a processing module, configured to respond to the first indication information, maintain a service connection between the intermediate service and the user service on the intermediate service, and save the connection status of the service connections included in the first connection set on the intermediate service; and an establishment module, configured to, when it is determined that the first database node has been changed to a second database node in the cloud database, establish a second connection set between the intermediate service and the second database node on the intermediate service according to the connection status, wherein the second database node is configured to provide data services to the user service in place of the first database node through the second connection set.
[0009] As an optional solution, the processing module includes: a first acquisition unit, configured to acquire the first connection set from the service connections established between the intermediate service and the database nodes included in the cloud database; a second acquisition unit, configured to acquire the target connection status of each service connection included in the first connection set; and a storage unit, configured to store the service connections included in the first connection set and the target connection status with corresponding relationships on the intermediate service.
[0010] As an optional solution, the first acquisition unit is configured to: search for service connections established for the first database node as candidate service connections from the service connections established between the intermediate service and the database nodes included in the cloud database; search for candidate service connections from the candidate service connections whose execution state of the executed statement is the target execution state, and obtain the first connection set, wherein the target execution state is used to indicate that the executed statement has a unique execution result.
[0011] As an optional solution, the second acquisition unit is configured to: search for connection-level variables from the execution statements of each service connection included in the first connection set; and determine the found connection-level variables and variable values with corresponding relationships as the target connection state corresponding to each service connection.
[0012] As an optional solution, the first establishment module includes: an establishment unit, configured to establish a third service connection between the intermediate service and the second database node on the intermediate service, wherein the initial service connection included in the third service connection corresponds one-to-one with the service connection included in the first connection set; and a configuration unit, configured to configure the connection state of each initial service connection included in the third service connection to the connection state of the corresponding service connection included in the first connection set, thereby obtaining the second connection set.
[0013] As an optional solution, the apparatus further includes: a second acquisition module, configured to acquire second indication information sent by the management service to the intermediate service before establishing a second connection set between the intermediate service and the second database node based on the connection status, wherein the second indication information is used to indicate that the first database node has been changed to the second database node; and an extraction module, configured to extract node information of the second database node from the second indication information, wherein the node information is used to establish the second connection set between the intermediate service and the second database node.
[0014] As an optional solution, the apparatus further includes: a sending module, configured to send third indication information to the management service after saving the connection status of the service connections included in the first connection set on the intermediate service, wherein the third indication information is used to indicate that the management service is allowed to make changes to the first database node.
[0015] As an optional solution, the device further includes: a third acquisition module, configured to acquire a target operation request received on the intermediate service after the acquisition management service sends the first indication information to the intermediate service, wherein the target operation request is used to request the execution of a target operation on the first database node; and a forwarding module, configured to forward the target operation request according to the operation type of the target operation.
[0016] As an optional solution, the forwarding module includes: a third acquisition unit, configured to acquire from the target operation request a first operation request indicating that the operation type of the target operation is a read-only operation; and a forwarding unit, configured to forward the first operation request to the read-only database node corresponding to the first database node.
[0017] As an optional solution, the apparatus further includes: a creation module, configured to create the read-only database node corresponding to the first database node before forwarding the first operation request to the read-only database node corresponding to the first database node; a fourth acquisition module, configured to acquire service connections of read-only type from the first connection set to obtain a third connection set; and a second establishment module, configured to establish the third connection set between the intermediate service and the read-only database node.
[0018] As an optional solution, the device further includes: a suspension module, configured to suspend a second operation request other than the first operation request in the target operation request on the intermediate service after obtaining a first operation request from the target operation request indicating that the operation type of the target operation is read-only; and a forwarding module, configured to forward the second operation request to the second database node after establishing a second set of connections with the second database node on the intermediate service according to the connection state.
[0019] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the above-described service connection establishment method at runtime.
[0020] According to another aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the service connection establishment method as described above.
[0021] According to another aspect of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described service connection establishment method through the computer program.
[0022] In this embodiment of the invention, database nodes in the cloud database provide data services to corresponding user services through a set of connections established between them and intermediate services. One function of the management and control service in the cloud database can be to modify database nodes to be changed. When a database node (such as the first database node mentioned above) is a database node to be changed, the management and control service sends indication information (i.e., the first indication information mentioned above) to the intermediate service to indicate the database node to be changed. When the intermediate service obtains the indication information, on the one hand, it maintains the service connection between the intermediate service and the user service served by the database node to be changed, and on the other hand, it saves the connection status of the service connections included in the set of connections between the database node to be changed and the intermediate service (i.e., the first connection set mentioned above). When it is determined that the database node change is complete and the changed database node (such as the second database node mentioned above) is... When a database node is modified, the original connection state of the service connection before the change, stored in the intermediate service, can be used to directly establish a set of connections (such as a second connection set) between the intermediate service and the modified database node. This reduces the user's operation process on the service connection by maintaining the service connection between the intermediate service and the user service and transferring the connection state of the service connection between the intermediate service and the database node. Furthermore, by processing the service connection on the intermediate service, the data service provided to the user service can be automatically restored, and the service connection can be restored to its original state. The user service can directly use the restored service connection without being aware of the interruption of the service connection. This achieves the technical effect of reducing the operational complexity of restoring service connections when the cloud database changes, and thus solves the technical problem of high operational complexity in the process of restoring service connections when the cloud database changes. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0024] Figure 1 This is a schematic diagram of an application environment for an optional service connection establishment method according to an embodiment of the present invention;
[0025] Figure 2This is a schematic diagram of the flow of an optional service connection establishment method according to an embodiment of the present invention;
[0026] Figure 3 This is an illustration of an optional service connection establishment method according to an embodiment of the present invention. Figure 1 ;
[0027] Figure 4 This is an illustration of an optional service connection establishment method according to an embodiment of the present invention. Figure 2 ;
[0028] Figure 5 This is an illustration of an optional service connection establishment method according to an embodiment of the present invention. Figure 3 ;
[0029] Figure 6 This is an illustration of an optional service connection establishment method according to an embodiment of the present invention. Figure 4 ;
[0030] Figure 7 This is an illustration of an optional service connection establishment method according to an optional embodiment of the present invention. Figure 1 ;
[0031] Figure 8 This is an illustration of an optional service connection establishment method according to an optional embodiment of the present invention. Figure 2 ;
[0032] Figure 9 This is an illustration of an optional service connection establishment method according to an optional embodiment of the present invention. Figure 3 ;
[0033] Figure 10 This is an illustration of an optional service connection establishment method according to an embodiment of the present invention. Figure 5 ;
[0034] Figure 11 This is an illustration of an optional service connection establishment method according to an optional embodiment of the present invention. Figure 4 ;
[0035] Figure 12 This is an illustration of an optional service connection establishment method according to an optional embodiment of the present invention. Figure 5 ;
[0036] Figure 13 This is an illustration of an application scenario for an optional service connection establishment method according to an embodiment of the present invention. Figure 1 ;
[0037] Figure 14 This is an illustration of an application scenario for an optional service connection establishment method according to an embodiment of the present invention. Figure 2 ;
[0038] Figure 15 This is a schematic diagram of an optional service connection establishment apparatus according to an embodiment of the present invention;
[0039] Figure 16 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present invention;
[0040] Figure 17 This is a schematic diagram of the structure of an optional computer system according to an embodiment of the present invention. Detailed Implementation
[0041] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0042] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0043] First, to facilitate understanding of the embodiments of the present invention, some terms or nouns involved in the present invention will be explained below:
[0044] Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computing, storage, processing, and sharing.
[0045] Cloud technology, a collective term for network technology, information technology, integration technology, management platform technology, and application technology based on cloud computing business models, can form resource pools for on-demand, flexible, and convenient use. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0046] A database, simply put, can be viewed as an electronic filing cabinet—a place to store electronic files, where users can perform operations such as adding, querying, updating, and deleting data. A "database" is a collection of data stored together in a certain way, capable of being shared by multiple users, with minimal redundancy, and independent of application programs.
[0047] A Database Management System (DBMS) is a computer software system designed to manage databases, generally possessing basic functions such as storage, retrieval, security, and backup. DBMSs can be classified according to the database model they support, such as relational or XML (Extensible Markup Language); or according to the type of computer they support, such as server clusters or mobile devices; or according to the query language used, such as SQL (Structured Query Language) or XQuery; or according to performance priorities, such as maximum scale or maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages simultaneously.
[0048] Cloud databases, database services provided by cloud providers, offer high performance, high reliability, high availability, and high security, and also provide comprehensive functions such as disaster recovery, backup, restoration, monitoring, and migration.
[0049] Database service failover: For database services with one master and one slave or one master and multiple slaves, when the master node crashes, becomes unavailable due to network outages, or other reasons, a slave node is promoted to master to provide services, reducing the service downtime caused by the master node's unavailability.
[0050] Database migration is used for cloud database services. Customers may need to upgrade or downgrade instances due to business expansion or contraction, or if a node machine encounters a problem, they may need to restart the node or migrate it from the original node to another machine.
[0051] Database high availability is achieved through software management of the database cluster. When the cluster master node fails or the network becomes unavailable, a quick switch can be performed to resume normal service, reducing service downtime and improving service availability.
[0052] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be connected directly or indirectly through wired or wireless communication methods, which is not limited herein.
[0053] According to one aspect of the present invention, a method for establishing a service connection is provided. Optionally, as an alternative implementation, the above-described method for establishing a service connection may be applied to, but is not limited to, [examples of other methods]. Figure 1 The environment shown may include, but is not limited to, user service 102, intermediate service 104, first database node 106, second database node 108, and management service 110. The first database node 106 provides data services to user service 102 through a first set of connections established between it and intermediate service 104.
[0054] The specific process can be summarized as follows: Step S102, the management service 110 sends a first instruction message to the intermediate service 104, which indicates that the first database node 106 in the cloud database is the database node to be changed; Steps S104-S106, the intermediate service 104 maintains its service connection with the user service 102 and saves the connection status of the service connections included in the first connection set; Step S108, the management service 110 changes the first database node 106 to the second database node 108. Step S110, when the intermediate service 104 determines that the first database node 106 has been changed to the second database node 108, it establishes a second connection set between itself and the second database node 108 based on the saved connection status. The second database node 108 provides data services to the user service 102 in place of the first database node through the second connection set.
[0055] Alternatively, as an alternative implementation method, such as Figure 2 As shown, the methods for establishing a service connection include:
[0056] S202, Obtain the first instruction information sent by the management and control service to the intermediate service, wherein the first instruction information is used to indicate that the first database node in the cloud database is the database node to be changed, the first database node is used to provide data services to the user service through the first set of connections established between the first database node and the intermediate service, and the management and control service is used to make changes to the first database node.
[0057] Cloud databases provide data services to users through database nodes and manage and control these database nodes through management services. Database nodes provide data services to user services connected to intermediate services through a set of connections they establish with intermediate services. The service connection establishment function provided in this embodiment can be deployed on, but is not limited to, the intermediate service, or it can be deployed independently and the intermediate service controlled to achieve the automatic saving and reconstruction of service connections.
[0058] It should be noted that, in this embodiment, the service connection establishment function is deployed on an intermediate service as an example, and the intermediate service is responsible for the automatic recovery of the service connection. The service connection recovery process is similar in other deployment methods and will not be described in detail here.
[0059] There can be, but are not limited to, two connection architectures between the database node and the user service. One connection architecture is as follows: Figure 3As shown, the user service initially connects directly to the backend cloud database service. In this connection architecture, a change in the database node will cause the connection to that database node to break, leading to the unavailability of the upper-layer user service. For example, if the database node A that the user service connects to changes to database node B, the connection between the user service and database node A will be broken. The user service will be aware of the unavailability of database node A. After the change is completed, the user service needs to recreate the service connection and reconnect to database node B. If the connection modifies variables or character sets, the state of each connection also needs to be restored. This means that if the user service loses its connection to the database node, users will need to perform complex operations to regain service, resulting in a poor user experience. Through the service connection establishment process provided in this embodiment, in this connection architecture, an intermediate service (such as a middleware service Proxy) can be deployed between the user service and the backend database node. A service connection establishment module can be deployed on the Proxy. When database node A changes to database node B to provide data services to the user service, the Proxy can automatically restore the service connection, thereby reducing the operational burden on the user service.
[0060] Another connection architecture between database nodes and user services is as follows: Figure 4 As shown, the user service connects to the backend cloud database service through an intermediate service (which could be a middleware service, such as a proxy). In this connection architecture, if the database node changes, the user service's connection to that database node will also be lost, leading to the unavailability of the upper-layer user service. For example, if the database node A that the user service connects to through the proxy changes to database node B, the proxy will disconnect from database node A, and the user service will also disconnect from the proxy. The user service will be aware of the unavailability of database node A. After the change is completed, the user service needs to recreate the service connection with the proxy and the service connection between the proxy and database node B before it can reconnect to database node B. If the connection modifies variables or character sets, the state of each connection also needs to be restored. This means that if the user service loses its connection to the database node, users will need to perform more complex operations to regain service, resulting in a worse user experience. Through the service connection establishment process provided in this embodiment, under this connection architecture, a service connection establishment module can be deployed on the intermediate service Proxy deployed between the user service and the backend database node. When the database node A changes to database node B to provide data services to the user service, the service connection can be automatically restored by the Proxy, thereby reducing the operational pressure on the user service.
[0061] In this embodiment, changes to the database node may include, but are not limited to, the following types of changes: database service switching, database migration, database high availability, etc.
[0062] The management and control service can, but is not limited to, managing and controlling database clusters and database nodes. For example, processes such as restarting, migrating, and switching to high availability for cloud database clusters and nodes can all be managed and controlled by the management and control service. When a database node is about to undergo one of the aforementioned changes, the management and control service sends an indication message to an intermediate service to indicate the database node to be changed before controlling the change process. In this embodiment, the first indication message may, but is not limited to, carry the node address (host) of the first database node to indicate the first database node to be changed.
[0063] In this embodiment, the database node can be implemented as an instance node in the cloud database, but is not limited to that implemented as an instance node in the cloud database. When the instance node in the cloud database used to provide data services undergoes changes such as switching, migration, or high availability, the management service will indicate the changed instance node to the intermediate service.
[0064] S204, in response to the first instruction information, maintain the service connection between the intermediate service and the user service on the intermediate service, and save the connection status of the service connections included in the first connection set on the intermediate service.
[0065] In this embodiment, when database nodes in the cloud database undergo changes such as switching, migration, or high availability adjustments, the management service will indicate the changed database node to the intermediate service. By maintaining the service connections between the intermediate service and the user service, as well as the set of connections between the intermediate service and the database nodes (including maintaining service connections and saving their connection states), the user is able to remain unaware of and require no action from the user regarding changes to the database nodes. Alternatively, the user can be aware of the database node changes without needing to perform any operations on the service connections. For example, the intermediate service could simply notify the user of the database node changes, allowing the user to be promptly informed of the database node's operational status.
[0066] The intermediate service can maintain the service connection between itself and the user service by keeping the service connection open and continuing to receive operation requests from the user service to the first database node initiated by the user service using the service connection. During the process of changing the first database node, the intermediate service does not close its service connection with the user service. On the one hand, the user service can still use the service connection to initiate operation requests to the first database node. On the other hand, it does not need to re-establish the service connection between itself and the intermediate service after the database node changes. This avoids users performing complex reconnection operations, reduces the pressure on users, and enables rapid recovery of the service connection.
[0067] Because the service restart, migration, or high availability changes of the backend database node can lead to changes in the service connection environment, the service connection provided by the database node to the user service may be interrupted, causing the user service to perceive a momentary connection interruption. In this embodiment, when the backend database node service restarts, migrates, or becomes highly available, the original connection is saved or maintained. Then, after the backend database operation is completed, the connection is automatically restored, thus completing the process from connection interruption to connection maintenance and then to connection restoration.
[0068] Due to business growth or normal cloud database operation and maintenance needs, changes may be required to the database nodes providing data services in the cloud database. For example, database node migration, switching, and high availability changes can all lead to the unavailability of user services to the backend database nodes. To address this issue, this embodiment provides a service connection establishment function, also known as a fail-safe connection retention function. This fail-safe connection retention function can, but is not limited to, be provided to users of the cloud database service to control its activation and deactivation.
[0069] Taking high-availability failover between database nodes in a cloud database MySQL cluster as an example, such as Figure 5 As shown, if the user has not used the connection persistence feature, after a high-availability failover of a database node in the cloud database backend, the user needs to wait for the backend database node failover to complete before recreating the connection and restoring its state. In this case, the user needs to perform the following steps: First, retry the connection until it succeeds or the retry limit is exceeded. Then, if the connection succeeds, the user needs to reset the connection name setting variable (set names) to latin1 so that the connection state after reconnection is consistent with the connection state of the previous connection (connection name is latin1, i.e., names = latin1).
[0070] During the reconnection process described above, some users may lack the necessary technical skills and fail to retry within their own applications, leading to service unavailability. Other users may have retried the connection but failed to restore the connection state, potentially causing data anomalies and more serious incidents. Therefore, to address these issues, users can choose to use the anti-interruption connection retention feature.
[0071] After users enable the connection persistence feature, if a database node in the backend cloud database MySQL cluster experiences a high-availability switch, the intermediate service proxy will detect this and maintain the connection state. Once the backend service recovers, it will create a connection to the new node and restore the connection state. Throughout this process, users may only experience a temporary service interruption without any other awareness or intervention, significantly reducing user costs and improving service availability.
[0072] Users can enable or disable the connection retention feature on the front-end interface provided by the cloud database. For example, the front-end interface provided by the cloud database may include, but is not limited to, displays of data service information and settings. Figure 6 As shown, the display interface includes an option button to enable or disable the anti-interruption connection maintenance function. Users can control this button to choose whether to enable this function. If the user clicks or drags the option button to the "Yes" state, it indicates that the user has selected to enable the anti-interruption connection maintenance function. In this state, if a database node changes, the user will not be aware of the change in service connection; instead, the intermediate service will handle the connection maintenance and recovery process. If the user clicks or drags the option button to the "No" state, it indicates that the user has selected to disable the anti-interruption connection maintenance function. In this state, if a database node changes, the user will be aware of the change in service connection, and the user will handle the connection recovery process themselves.
[0073] During the maintenance and recovery of service connections, the intermediate service maintains its service connection with the user service to ensure that the user service is unaware of the service connection interruption. Furthermore, the intermediate service can maintain its service connection with the database node to be changed, saving not only the service connection itself but also the connection state of each service connection. This allows the rebuilt service connection after a database node change to restore to its original connection state.
[0074] As an optional approach, the connection states of the service connections included in the first connection set are stored on the intermediate service, including:
[0075] S11, Obtain the first connection set from the service connections established between the intermediate service and the database nodes included in the cloud database;
[0076] S12, obtain the target connection status of each service connection included in the first connection set;
[0077] S13, save the service connection and target connection states included in the first connection set with corresponding relationships on the intermediate service.
[0078] As middleware providing a connection bridge between user services and database nodes, the middleware service may simultaneously establish and maintain service connection sets with different database nodes. First, from all service connections established on the middleware service, the first set of connections established between the middleware service and the first database node to be modified is retrieved. During this retrieval process, the first set of connections can be formed by searching for the corresponding service connection based on the node identifier of the first database node. Alternatively, the service connections on the middleware service can be stored directly according to the mapping relationship between database nodes and connection sets, and the first set of connections can be directly retrieved from the mapping relationship based on the node identifier of the first database node.
[0079] In this embodiment, any information that can reflect or identify the state of the service connection can be used as the target connection state to be obtained. For example, connection state identifiers, statements in the connection execution statements that can reflect the connection state, etc.
[0080] In rare cases, the connection status of certain services may become unstable. For example, the execution result of statements executed on a service connection may be uncertain, potentially leading to connection instability. In such situations, service connections established on intermediate services and those to be modified can be filtered based on their connection stability. This ensures that stable service connections are automatically rebuilt and their status restored.
[0081] As an optional approach, a first set of connections is obtained from the service connections established between the intermediate service and the database nodes included in the cloud database, including:
[0082] S21, from the service connections established between the intermediate service and the database nodes included in the cloud database, find the service connection established for the first database node as a candidate service connection.
[0083] S22, search for candidate service connections from the candidate service connections whose execution state of the executed statement is the target execution state, and obtain the first connection set, wherein the target execution state is used to indicate that the executed statement has a unique execution result.
[0084] In obtaining the first set of connections, all service connections established on the intermediate service for the first database node to be changed can be used as candidate service connections for filtering. Then, further filtering is performed based on the stability of the connection state. The criteria for judging the stability of the connection state can include, but are not limited to, the execution state of the statements executed on the service connection. The execution state where the statement has a unique execution result is taken as the target execution state. Service connections whose execution state matches this target execution state are selected from the candidate service connections and used as the first set for connection state maintenance and recovery. This ensures that the recovered connection state is stable.
[0085] In the execution statement of a service connection, the execution result of the statement is considered to be not unique if at least one of the following conditions is met:
[0086] Scenario 1: The executed statement contains a transaction.
[0087] Scenario 2: The executed statement contains a Prepare statement that has not been deleted.
[0088] Scenario 3: The executed statement contains a lock, that is, a statement like flush table with read lock or locktable is executed.
[0089] Case 4: The executed statement contains a temporary table.
[0090] Case 5: The execution statement is waiting for the execution result.
[0091] Apart from the execution statements that fall under the above circumstances, all other service connections can be identified as service connections with stable connection states, that is, candidate service connections whose execution states are the target execution states.
[0092] For situations involving unstable connection states, a timeout period can be set to wait and confirm whether the service connection's state can transition from an unstable to a stable state, thereby automatically restoring the service connection state as much as possible. For example, a timeout period can be set to continuously monitor changes in the connection state of unstable service connections until the connection state becomes stable or the timeout period is reached.
[0093] The aforementioned timeout period can be, but is not limited to, starting from the receipt of the first indication information or counting down, or it can be, but is not limited to, starting from the detection of an unstable service connection and timing out the timeout period separately for each unstable service connection. In this embodiment, the timeout period can be, but is not limited to, sent by the management service to the intermediate service through the first indication information. That is, the first indication information can, but is not limited to, carry the node address (host) of the first database node and the timeout period (in seconds, abbreviated as S).
[0094] In one optional implementation, after receiving the first instruction information sent by the control service, the intermediate service begins counting down the timeout period and filters stable service connections. First, it acquires candidate service connections and then confirms the execution status of the statements executed by these connections. For candidate service connections whose execution status matches the target execution status, they are directly saved. For candidate service connections whose execution status does not match the target execution status, if timeout > 0, it continues to receive execution statements from these connections within the timeout period until the execution status changes to the target execution status or the timeout expires. If timeout = 0 or a timeout occurs, it can directly return an error to the candidate service connection whose execution status does not match the target execution status and disconnect this service connection.
[0095] In this embodiment, for candidate service connections whose execution state is not the target execution state, or candidate service connections whose connection state is unstable, an error can be reported to the user service, but is not limited to, so that the user service can rebuild such service connections on its own.
[0096] As an optional approach, the target connection state of each service connection included in the first connection set is obtained, including:
[0097] S31, Search for connection-level variables from the execution statements of each service connection included in the first connection set;
[0098] S32, determine the target connection state corresponding to each service connection by finding the corresponding connection-level variables and variable values.
[0099] In this embodiment, connection-level variables in the executed statements can be saved as the target connection state of the service connection, but are not limited to this. Saving can include, but is not limited to, saving connection-level variables and variable values with corresponding relationships.
[0100] Link-level variables in execution statements can include, but are not limited to, system-level link variables and user-defined link variables.
[0101] S206, if it is determined that the first database node has been changed to the second database node in the cloud database, a second connection set between the intermediate service and the second database node is established on the intermediate service according to the connection status, wherein the second database node is used to provide data services to users in place of the first database node through the second connection set.
[0102] In the technical solution provided in step S206 above, the saved connection state can be automatically restored by the intermediate service after the change is confirmed.
[0103] In the cloud database, the message that the first database node has been changed to the second database node can be, but is not limited to, instructed by the management service to the intermediate service, or it can also be, but is not limited to, instructed by the second database node to the intermediate service.
[0104] The second set of connections established between the intermediate service and the second database node based on the connection state not only enables the user service to use the data services provided by the second database node, but also enables the second database node to provide data services to the user service in place of the first database node through the second set of connections with the same connection state as the first connection set.
[0105] As an optional approach, a second set of connections is established between the intermediate service and the second database node based on the connection status, including:
[0106] S41, establish a third service connection between the intermediate service and the second database node on the intermediate service, wherein the initial service connection included in the third service connection corresponds one-to-one with the service connection included in the first connection set;
[0107] S42, configure the connection state of each initial service connection included in the third service connection to the connection state of the service connection included in the corresponding first connection set, to obtain the second connection set.
[0108] During the service connection recovery process, a third set of connections is first established on the intermediate service, comprising initial service connections that correspond one-to-one with the service connections included in the first set of connections. Then, the connection states of each initial service connection are configured using the saved connection states of each service connection, thereby obtaining new service connections with the same state as the previous service connections to provide users with the corresponding data services.
[0109] Through the embodiments provided in this application, database nodes in the cloud database provide data services to corresponding user services through the set of connections established between them and intermediate services. One function of the management and control service in the cloud database can be to modify database nodes to be changed. When a database node (such as the first database node mentioned above) is a database node to be changed, the management and control service sends indication information (i.e., the first indication information mentioned above) to the intermediate service to indicate the database node to be changed. When the intermediate service obtains the indication information, on the one hand, it maintains the service connection between the intermediate service and the user service served by the database node to be changed, and on the other hand, it saves the connection status of the service connections included in the set of connections between the database node to be changed and the intermediate service (i.e., the first connection set mentioned above). When it is determined that the database node change is completed and the changed database node (such as the first database node mentioned above) is... When a second database node is established, the original connection state of the service connection before the change, stored in the intermediate service, can be used to directly establish a set of connections (such as a second connection set) between the intermediate service and the changed database node. This reduces the user's operation process on the service connection by maintaining the service connection between the intermediate service and the user service and transferring the connection state of the service connection between the intermediate service and the database node. Furthermore, by processing the service connection in the intermediate service, the data service provided to the user service can be automatically restored, and the service connection can be restored to its original state. The user service can directly use the restored service connection without being aware of the interruption of the service connection. This achieves the technical effect of reducing the operational complexity of restoring the service connection when the cloud database changes, and thus solves the technical problem of high operational complexity in the process of restoring the service connection when the cloud database changes.
[0110] On the other hand, service connections between user services and database nodes are restored through processing on intermediate services, so the user server does not need to be aware of the service connection interruption and restoration process. This eliminates the need for users to maintain service connections during service use; the restoration process after a service connection interruption is handled by the service provider, reducing the difficulty of using database services and providing users with more efficient and convenient services.
[0111] As an optional approach, before establishing a second set of connections between the intermediate service and the second database node based on the connection state, the following steps are also included:
[0112] S51, Obtain the second instruction information sent by the management and control service to the intermediate service, wherein the second instruction information is used to indicate that the first database node has been changed to the second database node;
[0113] S52, extract the node information of the second database node from the second instruction information, wherein the node information is used to establish a second set of connections with the second database node on the intermediate service.
[0114] After the database node change is completed, the management service may, but is not limited to, notify the intermediate service of the changed second database node through the second instruction information. The intermediate service can extract the node information of the changed second database node from the second instruction information, and then complete the subsequent reconstruction and recovery process of the service connection on the second database node based on the node information.
[0115] In this embodiment, the node information of the second database node may include, but is not limited to, the node address of the second database node, and other information used to enable the intermediate service to find the second database node.
[0116] In an optional implementation, an intermediate service is provided to establish a process for changing service connections, such as... Figure 7 As shown, the method for establishing a service connection in this optional embodiment can mainly include the following steps S701 to S705.
[0117] The user service connects to database node A, which currently provides data services to it in the cloud database, through an intermediate service. A service connection is established between the user service and the intermediate service, and a first connection set is established between the intermediate service and database node A. When database node A needs to be changed to database node B, the management service sends a first indication message to indicate that database node A is about to be changed (S701). The intermediate service responds to the first indication message, maintaining its service connection with the user service and saving the connection status of the service connections included in the first connection set (S702). When it receives a second indication message from the management service (S703), it extracts the node information of database node B (S704) and uses this node information to locate database node B and establish a second connection set (S705). This restores the service connection between the user service and database node B, which will subsequently provide data services to it in the cloud database.
[0118] As an optional approach, after storing the connection states of the service connections included in the first connection set on the intermediate service, the following steps are also included:
[0119] S61, send a third instruction message to the management service, wherein the third instruction message is used to instruct the management service to make changes to the first database node.
[0120] After the intermediate service saves the connection states of the service connections included in the first connection set, the intermediate service may, but is not limited to, notify the management service that the service connections of the first database node have been saved and that the management service can begin making changes to the first database node by sending a third instruction message to the management service. The management service then begins controlling the changes to the first database node after receiving the third instruction message, thereby ensuring the accuracy of the saved connection states.
[0121] In the above optional implementations, such as Figure 8 As shown, in this optional embodiment, the method for establishing a service connection may further include the following steps S801 to S802. After the intermediate service responds to the first instruction information and saves the connection status of the service connections included in the first connection set, it sends a third instruction information to the management service (S801). Upon receiving the third instruction information, the management service begins to modify the database node (S802). After completing the modification of database node A to database node B, the management service sends a second instruction information to the intermediate service to indicate the modified database node B.
[0122] As an optional solution, after obtaining the first instruction information sent by the management service to the intermediate service, it also includes:
[0123] S71, Obtain the target operation request received from the intermediate service, wherein the target operation request is used to request the execution of a target operation on the first database node;
[0124] S72, forward the target operation request according to the operation type of the target operation.
[0125] During the process of re-establishing the service connection, the service connection between the user service and the intermediate service is maintained. The user service may, but is not limited to, continue to send operation requests to the intermediate service to request the database node that provides data services to continue to perform the corresponding operations.
[0126] If an intermediate service receives a target operation request sent by a user service, it may, but is not limited to, forward the target operation request accordingly based on the operation type of the requested target operation.
[0127] In this embodiment, the operation type requested by the operation request can be classified in various ways, including but not limited to: based on data direction, it can be divided into read operations and write operations; read operations can include, but are not limited to, query operations; write operations can include, but are not limited to, edit, delete, and modify operations. Based on changes to the database nodes, it can be divided into operations with changed connections and operations without changed connections.
[0128] For different types of target operations, forwarding may be performed as appropriate, but not limited to, based on the current service connection status and changes in database nodes. For example, only forward target operation requests that are read operations or operations where the connection has not changed. The forwarding process can be executed according to the original forwarding strategy.
[0129] As an optional approach, the target operation request can be forwarded based on the operation type of the target operation, including:
[0130] S81, Obtain from the target operation request the first operation request that indicates the target operation type as a read-only operation;
[0131] S82, forward the first operation request to the read-only database node corresponding to the first database node.
[0132] The target operation can be further divided into read-only operations and non-read-only operations. The operation request of the indicated target operation type is read-only operation. The operation request can be forwarded as the first operation request to the read-only database node corresponding to the first database node for response. In this way, during the reconstruction of service connection and database node change, some operation requests of users can be responded to in a timely manner.
[0133] In an optional implementation, a process is provided to continue responding to user service operation requests during the service connection reconstruction process, such as... Figure 9 As shown, the method for establishing a service connection in this optional implementation mainly includes the following steps S901 to S905. The user service connects to database node A, which currently provides data services to it in the cloud database, through an intermediate service. A service connection is established between the user service and the intermediate service, and a first connection set is established between the intermediate service and database node A. When database node A needs to be changed to database node B, the management service sends a first indication message to indicate that database node A is about to be changed (S901). The intermediate service responds to the first indication message and executes the service connection establishment process (S902). During the service connection establishment process, the user service can continue to use the service connection maintained by the intermediate service to send target operation requests to the intermediate service to request database node A to perform the corresponding target operation (S903). The intermediate service filters out the first operation request from the received target operation requests, identifying the first operation request whose operation type is read-only (S904), and forwards the first operation request to the read-only database node corresponding to database node A for processing (S905), thereby ensuring that some operation requests of the user service can receive timely responses.
[0134] In the architecture of cloud databases, read-only database nodes are also provided to promptly respond to read-only operation requests initiated by user services. For example... Figure 10 As shown, the database nodes in the cloud database connected to the middleware Proxy include the Master node, which provides read and write data services; one or more Read-Only Nodes (ROs), which provide read-only data services; and Slave nodes, which do not provide external services and are mainly used for high-availability failover of user services. In this embodiment, the Proxy provides read-write separation functionality. For example, when the Master node is switching, if an operation request is sent, the Proxy can route the operation request to the RO node for processing according to routing rules. The request will not be blocked, and service will continue. Only operation requests that need to be routed to the Master node may be blocked, waiting for the switchover to complete before resuming service.
[0135] As an optional approach, before forwarding the first operation request to the read-only database node corresponding to the first database node, the following steps are also included:
[0136] S91, Create a read-only database node corresponding to the first database node;
[0137] S92, Obtain service connections with read-only connection type from the first connection set to obtain the third connection set;
[0138] S93 establishes a third set of connections between the intermediate service and the read-only database node.
[0139] The read-only database node corresponding to the first database node mentioned above may be, but is not limited to, created by the intermediate service for the first database node, so as to cooperate with the timely response to the target operation request initiated by the user service during the change of the first database node.
[0140] On the read-only database node, the intermediate service can find the service connection with the connection type of read-only connection from the first connection set it saves as the third connection set, and establish the third connection set with the read-only database node to ensure the forwarding of read-only operation requests.
[0141] The creation of a read-only database node can occur, but is not limited to, upon receiving the first instruction information, or when a read-only operation request is received during the service connection establishment process.
[0142] In the above optional implementations, a process is provided for creating a read-only database node while continuing to respond to user service operation requests, such as... Figure 11As shown, in this optional embodiment, the method for establishing a service connection may further include the following steps S1101 to S1102. The intermediate service filters out a first operation request from the received target operation requests, identifying the target operation type as a read-only operation. In response to this first operation request, the service creates a read-only database node for database node A (S1101) and establishes a third connection set with the read-only database node (S1102). Then, the first operation request is forwarded to the read-only database node corresponding to database node A for processing, thereby ensuring that some operation requests of the user service can receive timely responses.
[0143] As an optional solution, the above-mentioned service connection establishment method also includes:
[0144] S1001, after obtaining the first operation request whose operation type is read-only from the target operation request, the second operation request other than the first operation request in the target operation request is suspended on the intermediate service.
[0145] S1002, after establishing a second set of connections with the second database node on the intermediate service according to the connection status, the second operation request is forwarded to the second database node.
[0146] For the second operation request, which is a non-read-only operation other than the first operation request, it can be temporarily suspended on the intermediate service. After the second connection set is established, the second operation request will be forwarded to the second database node for processing.
[0147] In the above optional implementations, such as Figure 12As shown, in this optional implementation, the method for establishing a service connection may further include the following steps S1201 to S1202. The user service connects to database node A, which currently provides data services to it in the cloud database, through an intermediate service. A service connection is established between the user service and the intermediate service, and a first connection set is established between the intermediate service and database node A. When database node A needs to be changed to database node B, the management service sends a first indication message to indicate that database node A is about to be changed (S901). The intermediate service responds to the first indication message and executes the service connection establishment process (S902). During the service connection establishment process, the user service can continue to use the service connection maintained by the intermediate service to send target operation requests to the intermediate service to request database node A to perform the corresponding target operation (S903). The intermediate service filters out the first operation request from the received target operation requests, selecting the first operation request whose operation type is read-only (S904), and suspends the second operation request (S1201). The first operation request is forwarded to the read-only database node corresponding to database node A for processing (S905), thereby ensuring that some operation requests of the user service can receive timely responses. Then, after the service connection is established, the pending second operation request is forwarded to database node B for processing (S1202).
[0148] Figure 13 The illustration schematically shows the principle of the service connection establishment method in an application scenario according to an embodiment of this application. For example... Figure 13As shown, the method for establishing a service connection in this application scenario mainly includes the following steps S1301 to S1306. In this application scenario, the cloud database provides data services to the user service through instance nodes in the MySQL cluster and manages and controls the MySQL cluster through the management service. The middleware Proxy is used to realize the service connection from the user service to the MySQL cluster through its service connection with the user service and its service connection with the MySQL cluster. S1301, when a node in the MySQL cluster needs to be switched, the management service notifies the Proxy of the node switching information, and carries the set timeout and the information of the switching node (i.e., the first database node mentioned above) (node address host) in the information. S1302, the Proxy maintains the service connection with the user service and begins to process the service connection with the switching node. The processing includes: determining whether the service connection meets the migration conditions (i.e., whether the service connection is stable). For connections that meet the conditions, the information used to indicate the connection status in the execution statement of the service connection is retained in the Proxy (i.e., the first connection set is obtained). For service connections that do not meet the conditions, check if the timeout has expired. If timeout > 0, continue accepting execution statements for the ineligible service connection within the specified time until the condition is met and it is added to the first connection set, or until the timeout expires. If timeout = 0 or the timeout has expired, the ineligible service connection is directly determined as an unmigrateable connection, and an error is returned to the user service.
[0149] S1303, After processing, the Proxy will notify the management service of the completion information. S1304, The management module begins node switching and other operations. S1305, After the switch is complete, the management module informs the Proxy that the switch is complete and provides the switched node (i.e., the second database node mentioned above). S1306, Based on the notification from the management module, the Proxy rebuilds the service connection with the switched node and restores the rebuilt connection state. Afterwards, the user service can be restored, and the user service can connect to and use the MySQL cluster normally.
[0150] To determine the conditions for connection switching, a service connection can be deemed ineligible if the execution statement of the service connection includes the following states: contains a transaction; contains an undeleted Prepare statement; contains a lock, i.e., executes statements such as flushtable with read lock or lock table; contains a temporary table; or is waiting for execution results, etc.
[0151] In this application scenario, a process for handling operation requests during Master node switching is also provided, such as... Figure 14 As shown, the method for establishing service connections in this application scenario mainly includes the following steps S1401 to S1406. In the aforementioned MySQL cluster, the original Master of the user service will be switched to the new Master. S1401, the management service notifies the Proxy to begin the switch. S1402, the Proxy maintains the service connection with the user service and begins processing the service connection with the switching node. S1403, after processing, the Proxy notifies the management service of the completion information. S1404, the management module first probes the status of the original Master; if all connections are idle, the switch begins. S1405, during the switch, the intermediate service receives an SQL request sent by the user service. S1406, the read-only RO request is forwarded to the read-only database node (RO) corresponding to the original Master for processing.
[0152] S1407 After the original Master switchover is complete, the management module promotes the new Master to the primary node. S1408 Configure the new Master on the Proxy. S1409 The Proxy rebuilds the service connection based on the notification from the management module and restores the rebuilt connection status.
[0153] 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 the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.
[0154] According to another aspect of the present invention, an apparatus for establishing a service connection for implementing the above-described service connection establishment method is also provided. For example... Figure 15 As shown, the device includes:
[0155] The first acquisition module 1502 is used to acquire the first instruction information sent by the management and control service to the intermediate service. The first instruction information is used to indicate that the first database node in the cloud database is the database node to be changed. The first database node is used to provide data services to the user service through the first set of connections established between the first database node and the intermediate service. The management and control service is used to make changes to the first database node.
[0156] The processing module 1504 is used to respond to the first indication information, maintain the service connection between the intermediate service and the user service on the intermediate service, and save the connection status of the service connections included in the first connection set on the intermediate service.
[0157] The first establishment module 1506 is used to establish a second connection set between the intermediate service and the second database node on the intermediate service according to the connection status when it is determined that the first database node has been changed to the second database node in the cloud database. The second database node is used to provide data services to users in place of the first database node through the second connection set.
[0158] Through the embodiments provided in this application, database nodes in the cloud database provide data services to corresponding user services through the set of connections established between them and intermediate services. One function of the management and control service in the cloud database can be to modify database nodes to be changed. When a database node (such as the first database node mentioned above) is a database node to be changed, the management and control service sends indication information (i.e., the first indication information mentioned above) to the intermediate service to indicate the database node to be changed. When the intermediate service obtains the indication information, the processing module maintains the service connection between the intermediate service and the user service served by the database node to be changed, and saves the connection status of the service connections included in the set of connections between the database node to be changed and the intermediate service (i.e., the first connection set mentioned above). When it is determined that the database node change is complete and the changed database node (such as the first database node mentioned above) is... When establishing a second database node, the module can use the original connection state of the service connection before the change stored in the intermediate service to directly establish a set of connections (such as the second connection set) between the intermediate service and the changed database node. This reduces the user's operation process on the service connection by maintaining the service connection with the user service and transferring the connection state of the service connection with the database node in the intermediate service. Furthermore, by processing the service connection in the intermediate service, the data service provided to the user service can be automatically restored, and the service connection can be restored to its original state. The user service can directly use the restored service connection without being aware of the interruption of the service connection. This achieves the technical effect of reducing the operational complexity of restoring the service connection when the cloud database changes, and thus solves the technical problem of high operational complexity in the process of restoring the service connection when the cloud database changes.
[0159] On the other hand, service connections between user services and database nodes are restored through processing on intermediate services, so the user server does not need to be aware of the service connection interruption and restoration process. This eliminates the need for users to maintain service connections during service use; the restoration process after a service connection interruption is handled by the service provider, reducing the difficulty of using database services and providing users with more efficient and convenient services.
[0160] As an alternative solution, such as Figure 15 As shown, the above-mentioned processing module 1504 includes:
[0161] The first acquisition unit 1504-1 is used to acquire a first connection set from the service connections between the intermediate service and the database nodes included in the cloud database established on the intermediate service.
[0162] The second acquisition unit 1504-2 is used to acquire the target connection status of each service connection included in the first connection set;
[0163] Storage unit 1504-3 is used to store the service connection and target connection states included in the first connection set with corresponding relationships on the intermediate service.
[0164] As an optional solution, the first acquisition unit is used for:
[0165] From the service connections established between the intermediate service and the database nodes included in the cloud database, the service connection established for the first database node is searched as a candidate service connection.
[0166] Search for candidate service connections from the candidate service connections whose execution state of the executed statement is the target execution state to obtain the first set of connections, where the target execution state is used to indicate that the executed statement has a unique execution result.
[0167] As an optional solution, the second acquisition unit is used for:
[0168] Look up the connection-level variables from the execution statements of each service connection included in the first set of connections;
[0169] The variables and variable values at the corresponding connection levels are identified to determine the target connection state for each service connection.
[0170] As an alternative solution, such as Figure 15 As shown, the first establishment module 1506 mentioned above includes:
[0171] Establishment unit 1506-1 is used to establish a third service connection between the intermediate service and the second database node on the intermediate service, wherein the initial service connection included in the third service connection corresponds one-to-one with the service connection included in the first connection set;
[0172] Configuration unit 1506-2 is used to configure the connection state of each initial service connection included in the third service connection to the connection state of the service connection included in the corresponding first connection set, so as to obtain the second connection set.
[0173] As an alternative solution, such as Figure 15 As shown, the above-mentioned device also includes:
[0174] The second acquisition module 1508 is used to acquire second indication information sent by the management service to the intermediate service before establishing a second set of connections between the intermediate service and the second database node based on the connection status. The second indication information is used to indicate that the first database node has been changed to the second database node.
[0175] Extraction module 1510 is used to extract node information of the second database node from the second instruction information, wherein the node information is used to establish a second set of connections with the second database node on the intermediate service.
[0176] As an alternative solution, such as Figure 15 As shown, the above-mentioned device also includes:
[0177] The sending module 1512 is used to send third indication information to the management service after saving the connection status of the service connections included in the first connection set on the intermediate service. The third indication information is used to indicate that the management service is allowed to make changes to the first database node.
[0178] As an alternative solution, such as Figure 15 As shown, the above-mentioned device also includes:
[0179] The third acquisition module 1514 is used to acquire the target operation request received on the intermediate service after acquiring the first instruction information sent by the control service to the intermediate service, wherein the target operation request is used to request the execution of a target operation on the first database node.
[0180] Forwarding module 1516 is used to forward target operation requests based on the operation type of the target operation.
[0181] As an alternative solution, such as Figure 15 As shown, the aforementioned forwarding module 1516 includes:
[0182] The third acquisition unit 1516-1 is used to acquire from the target operation request a first operation request in which the operation type of the indicated target operation is a read-only operation;
[0183] Forwarding unit 1516-2 is used to forward the first operation request to the read-only database node corresponding to the first database node.
[0184] As an alternative solution, such as Figure 15 As shown, the above-mentioned device also includes:
[0185] Create module 1518, which is used to create a read-only database node corresponding to the first database node before forwarding the first operation request to the read-only database node corresponding to the first database node.
[0186] The fourth acquisition module 1520 is used to acquire service connections with read-only connection type from the first connection set to obtain the third connection set;
[0187] The second establishment module 1522 is used to establish a third set of connections between the intermediate service and the read-only database node.
[0188] As an alternative solution, such as Figure 15 As shown, the above-mentioned device also includes:
[0189] The suspension module 1524 is used to suspend the second operation request other than the first operation request in the target operation request on the intermediate service after obtaining the first operation request in the target operation request, which indicates that the operation type of the target operation is read-only.
[0190] The forwarding module 1526 is used to forward the second operation request to the second database node after establishing a second set of connections with the second database node on the intermediate service according to the connection status.
[0191] For specific implementation examples, please refer to the example shown in the above service connection establishment method, which will not be repeated here.
[0192] According to another aspect of the present invention, an electronic device for implementing the above-described service connection establishment method is also provided, such as... Figure 16 As shown, the electronic device includes a memory 1602 and a processor 1604. The memory 1602 stores a computer program, and the processor 1604 is configured to execute the steps of any of the above method embodiments via the computer program.
[0193] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0194] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0195] S1, obtain the first instruction information sent by the management and control service to the intermediate service, wherein the first instruction information is used to indicate that the first database node in the cloud database is the database node to be changed, the first database node is used to provide data services to the user service through the first connection set established between the first database node and the intermediate service, and the management and control service is used to change the first database node;
[0196] S2, responding to the first instruction information, maintaining the service connection between the intermediate service and the user service on the intermediate service, and saving the connection status of the service connections included in the first connection set on the intermediate service;
[0197] S3, if it is determined that the first database node has been changed to the second database node in the cloud database, a second connection set between the intermediate service and the second database node is established on the intermediate service according to the connection status. The second database node is used to provide data services to users in place of the first database node through the second connection set.
[0198] Alternatively, as those skilled in the art will understand, Figure 16 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 16 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 16 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 16 The different configurations shown.
[0199] The memory 1602 can be used to store software programs and modules, such as the program instructions / modules corresponding to the service connection establishment method and apparatus in this embodiment of the invention. The processor 1604 executes various functional applications and data processing by running the software programs and modules stored in the memory 1602, thereby realizing the aforementioned service connection establishment method. The memory 1602 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1602 may further include memory remotely located relative to the processor 1604, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1602 may be used, but is not limited to, to store information such as accidental touch signals, touch positions, and detection areas. As an example, such as... Figure 16 As shown, the memory 1602 may include, but is not limited to, the first acquisition module 1502, processing module 1504, and establishment module 1506 from the service connection establishment apparatus. Furthermore, it may include, but is not limited to, other module units from the service connection establishment apparatus, which will not be elaborated upon in this example.
[0200] Optionally, the transmission device 1606 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1606 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 1606 is a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0201] In addition, the aforementioned electronic device also includes: a display 1608 for displaying the aforementioned first indication information, connection status, second connection set, etc.; and a connection bus 1610 for connecting the various module components in the aforementioned electronic device.
[0202] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this peer-to-peer network.
[0203] Figure 17 A schematic block diagram of a computer system architecture for implementing an electronic device according to embodiments of the present application is shown.
[0204] It should be noted that, Figure 17 The computer system 1700 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0205] like Figure 17As shown, the computer system 1700 includes a central processing unit (CPU) 1701, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1702 or programs loaded from storage section 1708 into random access memory (RAM) 1703. The RAM 1703 also stores various programs and data required for system operation. The CPU 1701, ROM 1702, and RAM 1703 are interconnected via a bus 1704. An input / output interface 1705 (I / O interface) is also connected to the bus 1704.
[0206] The following components are connected to the input / output interface 1705: an input section 1706 including a keyboard, mouse, etc.; an output section 1707 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1708 including a hard disk, etc.; and a communication section 1709 including a network interface card such as a local area network card, modem, etc. The communication section 1709 performs communication processing via a network such as the Internet. A drive 1710 is also connected to the input / output interface 1705 as needed. Removable media 1711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on the drive 1710 as needed so that computer programs read from them can be installed into the storage section 1708 as needed.
[0207] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1709, and / or installed from removable medium 1711. When the computer program is executed by central processing unit 1701, it performs various functions defined in the system of this application.
[0208] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions to cause the computer device to perform the aforementioned service connection establishment method, wherein the computer program is configured to perform the steps of any of the above method embodiments at runtime.
[0209] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the following steps:
[0210] S1, obtain the first instruction information sent by the management and control service to the intermediate service, wherein the first instruction information is used to indicate that the first database node in the cloud database is the database node to be changed, the first database node is used to provide data services to the user service through the first connection set established between the first database node and the intermediate service, and the management and control service is used to change the first database node;
[0211] S2, responding to the first instruction information, maintaining the service connection between the intermediate service and the user service on the intermediate service, and saving the connection status of the service connections included in the first connection set on the intermediate service;
[0212] S3, if it is determined that the first database node has been changed to the second database node in the cloud database, a second connection set between the intermediate service and the second database node is established on the intermediate service according to the connection status. The second database node is used to provide data services to users in place of the first database node through the second connection set.
[0213] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0214] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0215] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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 storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention.
[0216] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0217] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or the indirect coupling or communication connection of units or modules may be electrical or other forms.
[0218] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0219] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0220] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for establishing a service connection, characterized in that, include: The first instruction information sent by the management and control service to the intermediate service is obtained. The first instruction information is used to indicate that the first database node in the cloud database is a database node to be changed. The first database node is used to provide data services to the user service through the first set of connections established between the first database node and the intermediate service. The management and control service is used to make changes to the first database node. In response to the first indication information, the service connection between the intermediate service and the user service is maintained on the intermediate service, and the connection status of the service connections included in the first connection set is saved on the intermediate service, wherein the intermediate service stores the first connection set; A third instruction message is sent to the management service to instruct the management service to make changes to the first database node, so that the management service makes changes to the first database node; Upon receiving a second indication message from the management service indicating that the first database node has been changed to a second database node in the cloud database, a second connection set between the intermediate service and the second database node is established on the intermediate service according to the connection status. The second database node is used to provide data services to the user service in place of the first database node through the second connection set.
2. The method according to claim 1, characterized in that, The step of storing the connection status of the service connections included in the first connection set on the intermediate service includes: The first connection set is obtained from the service connections established between the intermediate service and the database nodes included in the cloud database. Obtain the target connection status of each service connection included in the first connection set; The intermediate service stores the service connections included in the first connection set with corresponding relationships and the target connection status.
3. The method according to claim 2, characterized in that, Obtaining the first connection set from the service connections established between the intermediate service and the database nodes included in the cloud database includes: From the service connections established between the intermediate service and the database nodes included in the cloud database, the service connection established for the first database node is searched as a candidate service connection. The first set of connections is obtained by searching the candidate service connections for the execution state of the executed statement to be the target execution state. The target execution state is used to indicate that the executed statement has a unique execution result.
4. The method according to claim 2, characterized in that, The step of obtaining the target connection status of each service connection included in the first connection set includes: Look up connection-level variables from the execution statements of each service connection included in the first connection set; The variables and variable values at the corresponding connection levels are determined as the target connection state for each service connection.
5. The method according to claim 1, characterized in that, The step of establishing a second set of connections between the intermediate service and the second database node based on the connection status includes: A third service connection is established between the intermediate service and the second database node on the intermediate service, wherein the initial service connection included in the third service connection corresponds one-to-one with the service connection included in the first connection set; Configure the connection state of each initial service connection included in the third service connection to the connection state of the corresponding service connection included in the first connection set to obtain the second connection set.
6. The method according to claim 1, characterized in that, Before establishing a second set of connections between the intermediate service and the second database node based on the connection state, the method further includes: Extract the node information of the second database node from the second indication information, wherein the node information is used to establish the second set of connections with the second database node on the intermediate service.
7. The method according to claim 1, characterized in that, After obtaining the first instruction information sent by the control service to the intermediate service, the method further includes: Obtain the target operation request received on the intermediate service, wherein the target operation request is used to request the execution of a target operation on the first database node; Forward the target operation request according to the operation type of the target operation.
8. The method according to claim 7, characterized in that, The step of forwarding the target operation request according to the operation type of the target operation includes: Obtain from the target operation request a first operation request indicating that the operation type of the target operation is a read-only operation; The first operation request is forwarded to the read-only database node corresponding to the first database node.
9. The method according to claim 8, characterized in that, Before forwarding the first operation request to the read-only database node corresponding to the first database node, the method further includes: Create the read-only database node corresponding to the first database node; Obtain service connections with read-only connection type from the first connection set to obtain the third connection set; The third set of connections is established between the intermediate service and the read-only database node.
10. The method according to claim 8, characterized in that, After obtaining a first operation request from the target operation request indicating that the operation type of the target operation is read-only, the method further includes: suspending a second operation request in the target operation request other than the first operation request on the intermediate service; After establishing a second set of connections with the second database node on the intermediate service based on the connection status, the method further includes: forwarding the second operation request to the second database node.
11. A service connection establishment apparatus, characterized in that, include: The first acquisition module is used to acquire first instruction information sent by the management and control service to the intermediate service. The first instruction information is used to indicate that the first database node in the cloud database is a database node to be changed. The first database node is used to provide data services to the user service through the first set of connections established between the first database node and the intermediate service. The management and control service is used to make changes to the first database node. A processing module is configured to respond to the first indication information, maintain the service connection between the intermediate service and the user service on the intermediate service, and save the connection status of the service connections included in the first connection set on the intermediate service, wherein the intermediate service stores the first connection set. The first establishment module is configured to, upon receiving second indication information sent by the management service indicating that the first database node has been changed to a second database node in the cloud database, establish a second connection set between the intermediate service and the second database node on the intermediate service according to the connection status, wherein the second database node is used to provide data services to the user service in place of the first database node through the second connection set; the above device is further configured to: send third indication information indicating that the management service is allowed to change the first database node to the management service, so that the management service changes the first database node.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 10.
13. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1 to 10.
14. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 10 through the computer program.
Citation Information
Patent Citations
Database switching method, device, apparatus and system
CN109471902A