Database request processing method and system, server, product and storage medium

By forwarding the request to the standby node when the primary node fails, and maintaining the storage consistency of the standby node, the request failure caused by the primary node failure is solved, and fast response and data consistency before the primary and secondary handover is achieved.

CN120540908APending Publication Date: 2025-08-26ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410210759.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-26
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

When the database master node fails, the fault detection and master-standby switching in the prior art take time, resulting in the client request being unable to be processed in time, resulting in the request failure.

Method used

Receive client requests through the proxy component. If the master node does not respond within the delay threshold, it will automatically forward the request to the backup node for processing, and maintain the storage consistency between the backup node and the master node before the master node fails, dynamically adjust the delay threshold to judge the master node abnormality, and realize automatic resend of read requests.

Benefits of technology

Reduce the risk of read request failure in the early stages of a master node failure, ensure that client requests are responded in a timely manner before the master-stop switch, and reduce service interruption time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540908A_ABST
    Figure CN120540908A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database request processing method and system, a server, a product and a storage medium. In the request processing method, after an agent component receives a data reading request of a client, the data reading request can be sent to a main node in a database node cluster deployed in a main-standby mode. And if a response message returned by the main node for the data reading request is not received within the time delay threshold, the data reading request can be sent to a target standby node in a database node cluster, so that the target standby node processes the data reading request and returns a processing result. In the implementation mode, the time delay threshold value is determined according to the response duration of the main node in the historical time period and can be used for reflecting the response capability of the main node, so that whether the main node is abnormal or not can be preliminarily judged according to the time delay threshold value when the fault of the main node is not monitored; and when the main node is preliminarily judged to be abnormal, the read request is automatically retransmitted to the standby node. In the implementation mode, the retransmission operation of the read request is executed by the proxy component, so that the failure risk of the read request at the initial stage of the fault of the main node can be reduced under the condition that the client does not perceive.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a database request processing method, system, server, product, and storage medium. Background Art

[0002] Active / standby database deployment is a high-availability technology used to ensure data reliability and service continuity. Active / standby deployment typically employs a one-active-one-standby or one-active-multiple-standby configuration, with one primary database and one or more standby databases. In this architecture, the primary database handles all data write requests, while the standby databases serve as backups of the primary. If the primary database fails, the standby database can quickly switch to primary, ensuring service continuity. However, in practice, when a primary database fails, fault detection and active / standby failover take time. During this time, client requests cannot be processed promptly, resulting in request failures. Therefore, a new solution is needed. Summary of the Invention

[0003] Multiple aspects of the present application provide a database request processing method, system, server, product, and storage medium, which are used to reduce the impact of client data read requests when the database master node fails.

[0004] An embodiment of the present application provides a database request processing method, which is applied to a database node cluster deployed in a master-slave mode; the database node cluster includes a master node and at least one slave node; the method includes: receiving a data read request from a client; sending the data read request to the master node; if a response message returned by the master node for the data read request is not received within a delay threshold, sending the data read request to a target standby node among the at least one standby node, so that the target standby node processes the data read request and returns a processing result; wherein the delay threshold is determined based on the response time of the master node within a historical period.

[0005] Optionally, before sending the data read request to the target standby node, it also includes: obtaining a data write request for the primary node; sending the data write request to the primary node for processing; synchronizing the data write request to the target standby node so that the target standby node records the relay log according to the data write request; the relay log is used to synchronize the target standby node with the write data operation of the primary node; receiving a record success message returned by the target standby node, and returning a write success notification message corresponding to the data write request to the client according to the record success message.

[0006] Optionally, after sending the data read request to the target standby node, it also includes: if a first response message returned by the target standby node according to the data read request is received, the first response message is sent to the client; or, if a second response message returned by the master node according to the data read request is received before the first response message is received, the second response message is sent to the client and the first response message is discarded.

[0007] Optionally, it also includes: if the second response message returned by the master node according to the data read request is not received, determining that the master node is in a faulty state; using the management and control component to switch the target standby node to a new master node, or selecting any standby node from the at least one standby node as the new master node.

[0008] Optionally, it also includes: initializing a specified duration threshold as the delay threshold of the new master node; obtaining the response duration of at least one data read request sent to the new master node within a specified time window; and determining the delay threshold of the new master node based on the response duration of the at least one data read request.

[0009] An embodiment of the present application also provides a database request processing system, comprising: a client, a proxy component, a master node and at least one standby node; wherein the client is used to send a data read request; the proxy component is used to: receive the data read request from the client; send the data read request to the master node; if a response message returned by the master node for the data read request is not received within a delay threshold, send the data read request to a target standby node among the at least one standby node; wherein the delay threshold is determined based on the response time of the master node within a historical period; the master node and any standby node are used to process the data read request sent by the proxy component and return the processing result.

[0010] Optionally, the standby node is further configured to: receive the data write request sent by the proxy component; record a relay log according to the data write request, and return a record success message to the proxy component after recording is completed.

[0011] Optionally, the standby node is further used to: after receiving the data read request, determine whether the recorded relay log is completely applied; if not, execute the application operation of the relay log, and after the relay log is completely executed, process the data read request and return a response message to the proxy component.

[0012] An embodiment of the present application also provides a server, comprising: a memory and a processor; the memory is used to store one or more computer instructions; the processor is used to execute the one or more computer instructions to: execute the steps in the method provided in the embodiment of the present application.

[0013] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps of the method provided in the embodiment of the present application.

[0014] An embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, can implement the steps in the method provided in the embodiment of the present application.

[0015] In the database request processing method provided by the embodiment of the present application, after the proxy component receives the data read request from the client, the data read request can be sent to the master node in the database node cluster deployed in the master-slave mode. If the response message returned by the master node for the data read request is not received within the delay threshold, the data read request can be sent to the target standby node in the database node cluster, so that the target standby node processes the data read request and returns the processing result. In this embodiment, the delay threshold is determined based on the response time of the master node in the historical period, which can be used to reflect the response capability of the master node, and then when the master node failure is not detected, it can be preliminarily judged whether the master node has an abnormality based on the delay threshold, and automatically resend the read request to the standby node when it is preliminarily judged that the master node has an abnormality. In this embodiment, the resending operation of the read request is performed by the proxy component, which can reduce the failure risk of the read request in the early stage of the master node failure without the client's perception. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0017] Figure 1 A flowchart of an existing database request processing method;

[0018] Figure 2 A schematic diagram of the structure of a database request processing system provided by an exemplary embodiment of the present application;

[0019] Figure 3 A schematic diagram of the interaction between components in a request processing system provided by an exemplary embodiment of the present application;

[0020] Figure 4 A flowchart of a method for processing database requests provided by an exemplary embodiment of the present application;

[0021] Figure 5 A schematic diagram of the structure of a server provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0022] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0023] The terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The singular forms "a," "the," and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise. "A plurality" generally includes at least two, but does not exclude the inclusion of at least one.

[0024] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.

[0025] It should also be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or system. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the product or system comprising the element.

[0026] In a single-master / single-standby or single-master / multiple-standby database deployment architecture, the database master node (hereinafter referred to as the master node) primarily executes read and write operations from clients, while the database standby node (hereinafter referred to as the standby node) primarily executes client read operations, but not write operations. When there is a data read or write request, the client can directly request the master node, or the client can request a proxy node, which then requests the master node. Figure 1 The client directly requests the master node. When the master database fails, it takes a certain amount of time to detect the failure and switch between the master and the standby. Figure 1As shown in the figure, when the primary node fails, the control component needs to detect the primary node failure after a detection period of T1 and trigger a master-slave switch. The master-slave switch takes T2. After the master-slave switch, the client or agent needs T3 to obtain the latest routing table. Only after obtaining the latest routing table will the client or agent forward the request to the backup node for service recovery. During this process, the service is unavailable for a total of T1 + T2 + T3. During this unavailable period, client requests cannot be processed in a timely manner, resulting in request failures.

[0027] In response to the above technical problems, a solution is provided in some embodiments of the present application. The technical solutions provided in each embodiment of the present application are described in detail below with reference to the accompanying drawings.

[0028] Figure 2 A schematic diagram of a database request processing system provided by an exemplary embodiment of the present application is shown in FIG. Figure 2 As shown, the request processing system 200 mainly includes: a client 201, a proxy component 202 and a database node cluster 203; wherein, the database node cluster 203 includes: a master node 203a, at least one backup node 203b and a management component 203c.

[0029] The master node 203a and at least one backup node 203b are deployed in a master-slave mode. The management and control component 203c is used to manage, control, and coordinate the database node cluster 203. In this embodiment, the management and control component 203c can run on any node in the database node cluster 203. Its primary function is to monitor whether the master node has an anomaly and initiate a master-slave switch if the master node experiences an anomaly.

[0030] The proxy component 202 may be deployed on the client 201 or on a communication forwarding device between the client and the master node 203a and at least one backup node 203b, which is not limited in this embodiment.

[0031] The master node 203a and any standby node 203b can be implemented as a physical server, a virtual server, or an elastic computing instance on the cloud, without limitation in this embodiment. The master node 203a and any standby node 203b are primarily configured to receive data read requests sent by the proxy component 202, process the data read requests sent by the proxy component 202, and return the processing results to the proxy component 202.

[0032] Among them, the client 201 is mainly used to: issue a data read request based on the user's data access operation or the data access operation of the upstream application. Among them, the proxy component 202 is used to: receive the data read request of the client 201, and send the data read request to the master node 203a; if the response message returned by the master node 203a for the data read request is not received within the delay threshold, the proxy component 202 may send the data read request to the target standby node in the at least one standby node. That is, when the master node 203a times out and does not respond, the proxy component 202 may resend the data read request to the target standby node. The operation of resending the data read request is performed by the proxy component 202, and the client 201 is unaware.

[0033] The latency threshold can be determined based on the response time of the master node 203a within a historical period. If the response time of the master node 203a is not obtained, the proxy component 202 can initialize a set value as the latency threshold of the master node 203a. The set value can be a larger value. For example, in some embodiments, the proxy component 202 can set the latency threshold of the master node 203a to 5 seconds. After communicating with the master node 203a, the proxy component 202 can count the response time of the master node 203a to data read requests within a time window of a set length and determine the latency threshold based on the response time within the time window. For example, in some embodiments, the maximum response time counted within the time window can be used as the latency threshold of the master node 203a. For example, in other embodiments, the average response time counted within the time window can be used as the latency threshold of the master node 203a. Optionally, the operation of counting response times can be performed continuously, and the latency threshold can be dynamically updated based on the statistical results to more closely reflect the actual response capability of the master node 203a. For example, at each moment, the maximum response time within the most recent time window preceding that moment can be used as the latency threshold for master node 203a at that moment. Based on this implementation, the latency threshold can be used to reflect the responsiveness of the master node. Furthermore, when no master node failure is detected, the latency threshold can be used to preliminarily determine whether the master node is abnormal.

[0034] In some optional embodiments, during the communication interaction between the client 201 and the master node 203a, at least one standby node 203b can synchronize the client 201's operations on the master node 203a to maintain a consistent storage environment with the master node 203a, thereby facilitating the execution of some operations on behalf of the master node 203a when an abnormality occurs in the master node 203a. The following will continue to use the target standby node as an example for exemplary explanation. Optionally, before sending the data read request to the target standby node, the proxy component 202 can synchronize the acquired data write request for the master node 203a to the target standby node. Taking any data write request as an example, after the proxy component 202 acquires the data write request for the master node 203a, it can send the data write request to the master node 203a for processing. The proxy component 202 can synchronize the data write request to the target standby node.

[0035] The target standby node can receive the data write request sent by the proxy component 202, record the relay log according to the data write request, and return a record success message to the proxy component 202 after the recording is completed. The relay log is a log recording mechanism in the database, which is used to synchronize data changes on the master node to the standby node to implement the master-slave replication function. When the standby node is connected to the master node, the standby node can read the binary log on the master node and write the data change events recorded therein to its own relay log. After recording the relay log, the standby node can execute the events in the relay log to apply the data changes that occurred on the master node to its own database.

[0036] In this embodiment, the relay log is used to synchronize the target standby node with the write operation of the primary node 203a. Optionally, after the target standby node records the relay log and returns a record success message, the relay log can be applied to asynchronously perform the same write operation as the primary node 203a.

[0037] The proxy component 202 may receive a record success message returned by the target standby node, and return a write success notification message corresponding to the data write request to the client 201 according to the record success message.

[0038] Based on the above implementation, the proxy component 202 can synchronize write operations between the primary node 203a and the target standby node, so that the target standby node maintains a consistent storage environment with the primary node 203a.

[0039] In some optional embodiments, after receiving a data read request sent by the proxy component 202, the target standby node may determine whether the recorded relay log has been completely applied. If not, the target standby node may execute the apply operation of the relay log, and after the relay log is completely applied, process the data read request and return a response message to the proxy component 202. Based on this embodiment, the target standby node processes the data read request after completely applying the relay log, ensuring that the read data is the latest data, thereby ensuring strong data consistency.

[0040] Optionally, after sending the data read request to the target standby node, if the proxy component 202 receives a first response message returned by the target standby node in response to the data read request, the proxy component 202 sends the first response message to the client 201. Optionally, if the proxy component 202 receives a second response message returned by the master node 203a in response to the data read request before receiving the first response message, the proxy component 202 sends the second response message to the client 201 and discards the first response message. That is, if the proxy component 202 receives response messages from the master node 203a and the target standby node in sequence, the proxy component 202 passes the response message returned first to the client 201 and discards the response message returned later.

[0041] In some optional embodiments, if proxy component 202 does not receive the second response message returned by master node 203a in response to the data read request, it may determine that master node 203a is in a faulty state. In this case, proxy component 202 may switch the target standby node to the new master node, or select any standby node from the at least one standby node as the new master node. That is, upon determining that master node 203a has failed, proxy component 202 may notify control component 203c to perform a master-standby switchover operation, thereby enabling the new master node to execute the data write request from client 201 and reducing the impact on client 201.

[0042] It should be noted that, in some optional embodiments, after the management and control component 203c performs the master-slave switch, the proxy component 202 may use the delay threshold of the master node 203a as the delay threshold of the new master node, or may determine the delay threshold of the new master node based on the response time of the new master node to the data read request. Optionally, the proxy component may initialize a specified time threshold as the delay threshold of the new master node. The proxy component 202 may obtain the response time of at least one data read request sent to the new master node within a specified time window, and determine the delay threshold of the new master node based on the response time of the at least one data read request. Furthermore, in the subsequent communication process of the new master node, it may be determined whether the read request sent to the new master node has timed out based on the delay threshold of the new master node, which will not be described further.

[0043] Based on this embodiment, when the failure of primary node 203a is not recognized, proxy component 202 can use the target backup node to execute the read request of client 201, so that the read request of client 201 can be accurately responded to before the active-standby switchover. After the failure of primary node 203a is determined, the active-standby switchover is performed, so that the read request received from client 201 after the failure can be processed by the new primary node, thereby reducing the impact on the client 201 side.

[0044] The following will be combined Figure 3 , further exemplifies the request processing system.

[0045] like Figure 3 As shown, when executing the request processing method, the request processing system may perform the following steps:

[0046] 1. The client issues a data write request. After receiving the data write request from the client, the proxy component can send the data write request to the master node. The master node executes the data write request.

[0047] 2. The primary node synchronizes the data write request to the target standby node.

[0048] 3. The target standby node can record the data write request in the relay log and return a record success message to the proxy component after recording the relay log. After receiving the record success message, the proxy component can return a write success message to the client.

[0049] 4. The client issues a read request.

[0050] 5. The master node fails, but the failure has not yet been detected by the management and control components.

[0051] 6. After receiving the read request from the client, the proxy component sends the read request to the master node.

[0052] 7. When the read request exceeds the latency threshold, the proxy component automatically resends the read request to the target standby node.

[0053] 8. After the target standby node receives the read request, if there are unapplied relay logs, it applies all relay logs and executes the read request.

[0054] 9. The proxy component receives the read request success message and the read data from the standby node, and returns the read request success message and the read data to the client.

[0055] 10. The control component performs active / standby switching.

[0056] Based on this implementation method, during the period when the management and control component detects the failure of the primary node (i.e., within the duration T1), the proxy component can use the target backup node to execute the client's read request, so that the client's read request can be responded to in a timely manner before the primary-backup switch, thereby reducing the impact on the client side.

[0057] Figure 4 This is a flow chart of a method for processing a database request provided by an exemplary embodiment of the present application. The method may include: Figure 4 Steps shown:

[0058] Step 401: Receive a data read request from a client.

[0059] Step 402: Send the data read request to a master node in a database node cluster; the database node cluster includes at least one standby node.

[0060] Step 403: If a response message returned by the master node for the data read request is not received within a delay threshold, the data read request is sent to a target standby node among the at least one standby node, so that the target standby node processes the data read request and returns a processing result; wherein the delay threshold is determined based on the response time of the master node within a historical period.

[0061] This embodiment can be executed by the proxy component of the client. Alternatively, in some optional embodiments, when the client is a rich client, this embodiment can be executed by some functional modules in the rich client, which is not limited in this embodiment.

[0062] In some exemplary embodiments, before sending the data read request to the target standby node, it also includes: obtaining a data write request for the primary node; sending the data write request to the primary node for processing; synchronizing the data write request to the target standby node so that the target standby node records the relay log according to the data write request; the relay log is used to synchronize the target standby node with the write data operation of the primary node; receiving a record success message returned by the target standby node, and returning a write success notification message corresponding to the data write request to the client according to the record success message.

[0063] In some exemplary embodiments, after sending the data read request to the target standby node, it also includes: if a first response message returned by the target standby node according to the data read request is received, the first response message is sent to the client; or, if a second response message returned by the master node according to the data read request is received before the first response message is received, the second response message is sent to the client and the first response message is discarded.

[0064] In some exemplary embodiments, the method further includes: if a second response message returned by the master node in response to the data read request is not received, determining that the master node is in a faulty state; using a management and control component to switch the target standby node to a new master node, or selecting any standby node from the at least one standby node as a new master node.

[0065] In some exemplary embodiments, the method further includes: initializing a specified duration threshold as a delay threshold of the new master node; obtaining the response duration of at least one data read request sent to the new master node within a specified time window; and determining the delay threshold of the new master node based on the response duration of the at least one data read request.

[0066] In this embodiment, after the proxy component receives the data read request from the client, it can send the data read request to the master node in the database node cluster deployed in the master-slave mode. If the response message returned by the master node for the data read request is not received within the delay threshold, the data read request can be sent to the target standby node in the database node cluster, so that the target standby node processes the data read request and returns the processing result. In this embodiment, the delay threshold is determined based on the response time of the master node in a historical period, which can be used to reflect the response capability of the master node, and then when the master node failure is not detected, it can be preliminarily judged whether the master node has an abnormality based on the delay threshold, and automatically resend the read request to the standby node when it is preliminarily judged that the master node has an abnormality. In this embodiment, the resending operation of the read request is performed by the proxy component, which can reduce the failure risk of the read request in the early stage of the master node failure without the client's perception.

[0067] It should be noted that the execution entity of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution entity of steps 401 to 404 can be device A; for another example, the execution entity of steps 401 and 402 can be device A, and the execution entity of step 403 can be device B; and so on.

[0068] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The sequence numbers of the operations, such as 401, 402, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to being different types.

[0069] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0070] Figure 5 A schematic diagram of the structure of a server provided by an exemplary embodiment of the present application is shown in FIG. Figure 5 As shown, the server includes: a memory 501 , a processor 502 and a communication component 503 .

[0071] The memory 501 is used to store computer programs and can be configured to store various other data to support operations on the server, such as instructions for any application or method used to operate on the server.

[0072] The processor 502 is coupled to the memory 501 and is used to execute the computer program in the memory 501, so as to: receive a data read request from a client; send the data read request to the master node; if a response message returned by the master node for the data read request is not received within a delay threshold, send the data read request to a target standby node among the at least one standby node, so that the target standby node processes the data read request and returns a processing result; wherein the delay threshold is determined based on the response time of the master node within a historical period.

[0073] Optionally, before sending the data read request to the target standby node, the processor 502 is also used to: obtain a data write request for the primary node; send the data write request to the primary node for processing; synchronize the data write request to the target standby node so that the target standby node records the relay log according to the data write request; the relay log is used to synchronize the target standby node with the write data operation of the primary node; receive a record success message returned by the target standby node, and return a write success notification message corresponding to the data write request to the client according to the record success message.

[0074] Optionally, after sending the data read request to the target standby node, the processor 502 is also used to: if a first response message returned by the target standby node according to the data read request is received, send the first response message to the client; or, if a second response message returned by the master node according to the data read request is received before receiving the first response message, send the second response message to the client and discard the first response message.

[0075] Optionally, the processor 502 is also used to: determine that the master node is in a faulty state if the second response message returned by the master node according to the data read request is not received; use the management and control component to switch the target standby node to a new master node, or select any standby node from the at least one standby node as the new master node.

[0076] Optionally, the processor 502 is also used to: initialize a specified duration threshold as the delay threshold of the new master node; obtain the response duration of at least one data read request sent to the new master node within a specified time window; and determine the delay threshold of the new master node based on the response duration of the at least one data read request.

[0077] An embodiment of the present application also provides a database request processing system, comprising: a client, a proxy component, a master node and at least one standby node; wherein the client is used to send a data read request; the proxy component is used to: receive the data read request from the client; send the data read request to the master node; if a response message returned by the master node for the data read request is not received within a delay threshold, send the data read request to a target standby node among the at least one standby node; wherein the delay threshold is determined based on the response time of the master node within a historical period; the master node and any standby node are used to process the data read request sent by the proxy component and return the processing result.

[0078] Optionally, the standby node is further configured to: receive the data write request sent by the proxy component; record a relay log according to the data write request, and return a record success message to the proxy component after recording is completed.

[0079] Optionally, the standby node is further used to: after receiving the data read request, determine whether the recorded relay log is completely applied; if not, execute the application operation of the relay log, and after the relay log is completely executed, process the data read request and return a response message to the proxy component.

[0080] Further, if Figure 5As shown, the server also includes other components such as a power supply component 504 , a display component 505 , and an audio component 506 . Figure 5 Only some components are shown schematically, which does not mean that the server only includes Figure 5 Components shown.

[0081] Among them, the memory 501 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0082] The communication component 503 is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as Wi-Fi (wireless network communication technology), 2G (such as Global System for Mobile Communications (GSM)), 3G (such as Wideband Code Division Multiple Access (WCDMA), 4G (such as Long Term Evolution (LTE)), 4G+ (such as upgraded Long Term Evolution (LTE-Advanced, LTE-A)), or 5G (5th Generation Mobile Communication Technology), or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component can be implemented based on Near Field Communication (NFC) technology, Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0083] The power supply component 504 is used to provide power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.

[0084] Among them, the display component 505 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundary of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0085] Among them, the audio component 506 can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive external audio signals. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0086] In this embodiment, after receiving the data read request from the client, the data read request can be sent to the master node in the database node cluster deployed in the master-slave mode. If the response message returned by the master node for the data read request is not received within the delay threshold, the data read request can be sent to the target standby node in the database node cluster, so that the target standby node processes the data read request and returns the processing result. In this embodiment, the delay threshold is determined based on the response time of the master node in a historical period, which can be used to reflect the response capability of the master node, and then when the master node failure is not detected, it can be preliminarily judged whether the master node has an abnormality based on the delay threshold, and the read request can be automatically resent to the standby node when it is preliminarily judged that the master node has an abnormality. In this embodiment, there is no need for the client to perform a resend operation on the read request, which can reduce the failure risk of the read request in the early stage of the master node failure without the client being aware of it.

[0087] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be executed by the server in the above method embodiment.

[0088] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM (Compact Disc Read-Only Memory), optical storage, etc.) containing computer-usable program code.

[0089] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0090] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0091] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0092] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.

[0093] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0094] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, Parallel Random Access Machine (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of random access memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0095] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0096] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for processing a database request, characterized in that: Applicable to database node clusters deployed in active-standby mode; The database node cluster includes a master node and at least one standby node; the method includes: Receive data read requests from clients; Sending the data read request to the master node; If a response message returned by the master node for the data read request is not received within a delay threshold, the data read request is sent to a target standby node among the at least one standby node, so that the target standby node processes the data read request and returns a processing result; wherein the delay threshold is determined based on the response time of the master node within a historical period.

2. The method according to claim 1, characterized in that Before sending the data read request to the target standby node, the method further includes: Obtaining a data write request for the master node; Sending the data write request to the master node for processing; Synchronize the data write request to the target standby node, so that the target standby node records a relay log according to the data write request; the relay log is used to synchronize the data write operation of the primary node with the target standby node; Receive a record success message returned by the target standby node, and return a write success notification message corresponding to the data write request to the client according to the record success message.

3. The method according to claim 1, characterized in that After sending the data read request to the target standby node, the method further includes: If a first response message returned by the target standby node according to the data read request is received, the first response message is sent to the client; or If a second response message returned by the master node according to the data read request is received before the first response message is received, the second response message is sent to the client and the first response message is discarded.

4. The method according to claim 3, characterized in that Also includes: If the second response message returned by the master node according to the data read request is not received, it is determined that the master node is in a fault state; The target standby node is switched to a new master node by using a management and control component, or any standby node is selected from the at least one standby node as a new master node.

5. The method according to claim 4, characterized in that Also includes: Initialize a specified duration threshold as the delay threshold of the new master node; Obtaining a response duration of at least one data read request sent to the new master node within a specified time window; Determine a latency threshold of the new master node based on a response duration of the at least one data read request.

6. A database request processing system, characterized in that: include: Client, proxy component, master node and at least one standby node; Wherein, the client is used to send a data read request; The proxy component is configured to: receive a data read request from the client; send the data read request to the master node; and if no response message is received from the master node for the data read request within a latency threshold, send the data read request to a target standby node among the at least one standby node; wherein the latency threshold is determined based on a response time of the master node within a historical period; The master node and any standby node are used to process the data read request sent by the proxy component and return the processing result.

7. The system according to claim 6, characterized in that The standby node is further configured to: receive the data write request sent by the proxy component; record a relay log according to the data write request, and return a record success message to the proxy component after recording is completed.

8. The system according to claim 6 or 7, characterized in that The standby node is further configured to: upon receiving the data read request, determine whether the recorded relay log has been completely applied; if not, execute the application operation of the relay log, and after the relay log is completely executed, process the data read request and return a response message to the proxy component.

9. A server, characterized in that: include: memory and processor; The memory is used to store one or more computer instructions; The processor is configured to execute the one or more computer instructions to perform the steps of the method according to any one of claims 1 to 5.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it can implement the database request processing method described in any one of claims 1 to 5.

11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the database request processing method according to any one of claims 1 to 5 can be implemented.

Citation Information

Cited By

  • Write request response method and electronic equipment

    CN122240035A