Request processing method and system for database, and server, product and storage medium
By introducing proxy components and relay log mechanisms into the database cluster, automatically resend read requests and synchronous write requests, the request processing delay problem caused by master node failure is solved, and high availability and consistency in the early stage of the failure is achieved.
Patent Information
- Application Number
- PCT/IB2025/050053
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-26
- Filing Date
- 2025-01-03
- Publication Date
- 2025-09-04
AI Technical Summary
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.
By introducing proxy components into the database node cluster, receiving client requests and not receiving the primary node response within the delay threshold, it will automatically resend read requests to the secondary node, and synchronous write requests using relay logs to ensure consistency between the secondary node and the primary node, and switch the secondary node as the primary node when necessary.
In the early stage of a master node failure, reduce the risk of read request failure, ensure that client requests can respond in a timely manner, reduce service interruptions, and improve system availability.
Smart Images

Figure IB2025050053_04092025_PF_FP_ABST
Abstract
Description
[0001] TECHNICAL FIELD The present disclosure relates to the field of computer technology, and more particularly to a database request processing method, system, server, product, and storage medium. Background: Active-standby database deployment is a high-availability technology used to ensure data reliability and service continuity. Active-standby deployment typically employs a one-master-one-standby or one-master-multiple-standby architecture, namely, 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 database. When the primary database fails, the standby database can quickly switch to become the primary database, ensuring service continuity. However, in practice, when the primary database fails, fault detection and active-standby switchover 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 Various aspects of the present disclosure provide a database request processing method, system, server, product, and storage medium to reduce the impact on client data read requests when a database master node fails. An embodiment of the present disclosure 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 to the data read request is not received within a latency threshold, sending the data read request to a target slave node among the at least one slave node, so that the target slave node processes the data read request and returns a processing result; wherein the latency threshold is determined based on the response time of the master node within a historical time period. Optionally, before sending the data read request to the target standby node, the method further 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 a 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.Optionally, 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 in response to the data read request is received, sending the first response message to the client; or, if a second response message returned by the master node in response to the data read request is received before the first response message is received, sending the second response message to the client and discarding the first response message. Optionally, the method further includes: if the 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; switching 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, using a management and control component. Optionally, the method further includes: initializing a specified duration threshold as a latency threshold for 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; and determining a latency threshold for the new master node based on the response duration of the at least one data read request. An embodiment of the present disclosure 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 configured to send a data read request; the proxy component is configured to: receive the 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 to 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 the response time of the master node within a historical period; the master node and any standby node are configured to process the data read request sent by the proxy component and return a processing result. Optionally, the standby node is further configured to: receive the data write request sent by the proxy component; record the data write request in a relay log, and, upon completion of recording, return a recording success message to the proxy component. Optionally, 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 an apply operation of the relay log; and after the relay log has been completely applied, process the data read request and return a response message to the proxy component. An embodiment of the present disclosure also provides a server comprising: a memory and a processor; the memory being configured to store one or more computer instructions; and the processor being configured to execute the one or more computer instructions to perform the steps of the method provided in an embodiment of the present disclosure.Embodiments of the present disclosure also provide a computer-readable storage medium storing a computer program. When executed by a processor, the computer program can implement the steps of the method provided in the embodiments of the present disclosure. Embodiments of the present disclosure also provide a computer program product, including a computer program / instructions. When executed by a processor, the computer program / instructions can implement the steps of the method provided in the embodiments of the present disclosure. In the database request processing method provided in the embodiments of the present disclosure, after receiving a data read request from a client, the proxy component can send the data read request to a primary node in a database node cluster deployed in a master-standby mode. If no response message to the data read request is received from the primary node within a latency threshold, the proxy component can send the data read request to a target standby node in the database node cluster, so that the target standby node processes the data read request and returns a result. In this embodiment, the latency threshold is determined based on the response time of the primary node within a historical period and can be used to reflect the responsiveness of the primary node. Furthermore, when no primary node failure is detected, the proxy component can use the latency threshold to preliminarily determine whether the primary node is abnormal. If a preliminarily determined primary node abnormality is present, the proxy component can automatically resend the read request to the standby node. In this embodiment, the read request retransmission operation is performed by the proxy component, which can reduce the risk of read request failure in the early stages of a master node failure without the client being aware of it. BRIEF DESCRIPTION OF THE DRAWINGS The drawings described herein are intended to provide a further understanding of the present disclosure and constitute a part of this disclosure. The exemplary embodiments of this disclosure and their descriptions are intended to explain the disclosure and do not constitute undue limitations of the disclosure. In the drawings: Figure 1 is a flowchart of a conventional database request processing method; Figure 2 is a schematic diagram of the structure of a database request processing system provided in an exemplary embodiment of the present disclosure; Figure 3 is a schematic diagram of the interaction between components in the request processing system provided in an exemplary embodiment of the present disclosure; Figure 4 is a flowchart of the database request processing method provided in an exemplary embodiment of the present disclosure; and Figure 5 is a schematic diagram of the structure of a server provided in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION To further clarify the objectives, technical solutions, and advantages of this disclosure, the technical solutions of this disclosure will be described clearly and completely below in conjunction with the specific embodiments of this disclosure and the corresponding drawings. Obviously, the described embodiments are only some of the embodiments of this disclosure, and not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure. The terms used in the embodiments of this disclosure are for the sole purpose of describing specific embodiments and are not intended to limit the disclosure.As used in the embodiments of the present invention and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the 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. It should be understood that the term "and / or" as used herein merely describes an associative relationship between associated objects, indicating that three relationships can exist. For example, "A and / or B" can represent: A alone, A and B simultaneously, or B alone. Furthermore, the character " / " herein generally indicates that the associated objects are in an "or" relationship. It should also be noted that the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or system comprising a list of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such product or system. Without further limitation, the elements specified by the phrase "comprising a..." do not exclude the presence of additional identical elements in the product or system comprising the elements. In a database deployment architecture with one master and one standby, or one master and multiple standby nodes, 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, not write operations. When a data read or write request is received, the client can directly request the master node, or the client can request a proxy node, which then requests the master node. Figure 1 illustrates how a client directly requests the master node. When the master database fails, fault detection and master-slave failover take time. As shown in Figure 1, the client can request either the master or standby node. When the master node fails, the control component, or the control program, detects the master node failure after a detection period T1 (i.e., the duration T1 required to detect the master node failure) and triggers a master-slave failover. The active / standby switchover takes T2, which is the duration T2o that triggers the active / standby switchover. After the active / standby switchover, the client or proxy needs T3 to obtain the latest routing table, which is the post-switch routing table T3o. Only after the client or proxy obtains the latest routing table will it forward the request to the standby node for service restoration. During this process, the service is unavailable for a total of T1 + T2 + T3o. During this unavailable period, client requests cannot be processed promptly, resulting in request failures. To address the above technical issues, some embodiments of the present disclosure provide a solution. The following details the technical solutions provided by various embodiments of the present disclosure, with reference to the accompanying figures.Figure 2 is a schematic diagram of the structure of a database request processing system provided by an exemplary embodiment of the present disclosure. As shown in Figure 2, request processing system 200 primarily includes a client 201, a proxy component 202, and a database node cluster 203. Database node cluster 203 includes a master node 203a, at least one slave node 203b, and a management and control component 203c. The master node 203a and the at least one slave node 203b are deployed in a master-slave mode. Management and control component 203c is used to manage, control, and coordinate database node cluster 203. In this embodiment, management and control component 203c can run on any node in database node cluster 203, primarily monitoring whether the master node experiences anomalies and executing a master-slave switchover when the master node experiences anomalies. Proxy component 202 can be deployed on client 201 or on a communication forwarding device between the client and the master node 203a and the at least one slave node 203b, without limitation in this embodiment. The master node 203a and any standby node 203b can be implemented as physical servers, virtual servers, or elastic computing instances 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. The client 201 is primarily configured to issue data read requests based on user data access operations or data access operations of upstream applications. The proxy component 202 is configured to receive data read requests from the client 201 and send the data read requests to the master node 203a. If no response message is received from the master node 203a for the data read request within a latency threshold, the proxy component 202 may send the data read request to a target standby node among the at least one standby node. Specifically, if the master node 203a times out and fails to 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 proxy component 202, without client 201 noticing. In other words, the read request exceeds a latency threshold, and the read request is resent. The latency threshold can be determined based on the response time of master node 203a over a historical period. If the response time of master node 203a is not obtained, proxy component 202 can initialize a set value as the latency threshold for master node 203a. This set value can be a relatively large value. For example, in some embodiments, proxy component 202 can set the latency threshold for master node 203a to 5 seconds.After communicating with master node 203a, proxy component 202 can count the response time of master node 203a to data read requests within a time window of a set length and determine a 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 for master node 203a. In other embodiments, the average response time counted within the time window can be used as the latency threshold for master node 203a. Optionally, the response time count operation can be performed continuously, and the latency threshold can be dynamically updated based on the statistical results to better reflect the actual response capability of master node 203a. For example, at each moment, the maximum response time within the most recent time window before that moment can be used as the latency threshold for master node 203a at that moment. Based on this embodiment, the latency threshold can be used to reflect the response capability 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. In some optional embodiments, during the communication interaction between client 201 and master node 203a, at least one backup node 203b may synchronize operations performed by client 201 on master node 203a to maintain a consistent storage environment with master node 203a. This facilitates performing some operations on behalf of master node 203a when master node 203a experiences an abnormality. The following description will continue using the target backup node as an example. Optionally, before sending the data read request to the target backup node, proxy component 202 may synchronize the acquired data write request for master node 203a to the target backup node. For example, after acquiring any data write request for master node 203a, proxy component 202 may send the data write request to master node 203a for processing. Proxy component 202 may synchronize the data write request to the target backup node. The target standby node can receive the data write request sent by proxy component 202, record the data write request in a relay log, and return a record success message to proxy component 202 after recording is complete. A relay log is a logging mechanism in a database that synchronizes data changes on the primary node with the standby node, implementing master-slave replication. When a standby node connects to a primary node, it reads the primary node's binary log and writes the data change events recorded therein to its own relay log. After recording the relay log, the standby node executes the events in the relay log to apply the data changes made on the primary node to its own database. In this embodiment, the relay log is used to synchronize the target standby node with the data write operations of primary node 203a.Optionally, after the target standby node records the relay log and returns a record success message, it can apply the relay log to asynchronously perform the same write operation as the primary node 203a. The proxy component 202 can receive the record success message returned by the target standby node and, based on the record success message, return a write success notification message corresponding to the data write request to the client 201. Based on the above embodiment, the proxy component 202 can synchronize write operations between the primary node 203a and the target standby node, thereby ensuring that the target standby node and the primary node 203a maintain a consistent storage environment. In some optional embodiments, after receiving a data read request sent by the proxy component 202, the target standby node can determine whether the recorded relay log has been fully applied. If not, the target standby node can perform the apply operation on the relay log and, after the relay log has been fully 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 fully applying the relay log, ensuring that the read data is the latest data, thereby ensuring strong data consistency. Optionally, after sending the data read request to the target standby node, if 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 client 201. Optionally, if the proxy component 202 receives a second response message returned by 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 client 201 and discards the first response message. That is, if proxy component 202 receives response messages from master node 203a and the target standby node successively, the proxy component 202 passes the response message returned earlier to client 201 and discards the response message returned later. 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, the proxy component 202 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, when the proxy component 202 determines that the master node 203a has failed, it may notify the control component 203c to perform a master-slave switchover operation, thereby enabling the new master node to execute the data write request of the client 201 and reducing the impact on the client 201. It should be noted that in some optional embodiments, after the control component 203c performs the master-slave switchover, the proxy component 202 may use the latency threshold of the master node 203a as the latency threshold of the new master node, or may determine the latency 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 can initialize a specified duration threshold as the latency threshold for the new master node. Proxy component 202 can 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 latency threshold for the new master node based on the response duration of the at least one data read request. Furthermore, during subsequent communications with the new master node, the latency threshold for the new master node can be used to determine whether read requests sent to the new master node have timed out. This will not be discussed further. Based on this embodiment, if master node 203a has failed but not been identified, proxy component 202 can use the target backup node to execute read requests from client 201, ensuring that read requests from client 201 receive accurate responses before a master-slave switchover occurs. After determining that master node 203a has failed, a master-slave switchover is executed, allowing read requests from client 201 received after the failure to be processed by the new master node, thereby reducing the impact on client 201. The request processing system will be further illustrated below with reference to FIG3. As shown in FIG3, when executing the request processing method, the request processing system may perform the following steps:
[0002] 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.
[0003] 2. The master node synchronizes the data write request to the target standby node, i.e., synchronizes the data write request.
[0004] 3. The target standby node records the data write request in the relay log and returns a record success message to the proxy component after recording the relay log. After receiving the record success message, the proxy component returns a write success message to the client.
[0005] 4. The client sends a data read request.
[0006] 5. The master node fails, and the failure has not yet been detected by the management and control components.
[0007] 6. After receiving the read request from the client, the proxy component sends the data read request to the master node.
[0008] 7. When the data read request exceeds the latency threshold, the proxy component automatically resends the data read request to the target standby node.
[0009] 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. That is, it applies the relay logs and processes the data read request.
[0010] 9. The proxy component receives the read request success message and the read data from the standby node, and returns the data read request success message and the read data to the client.
[0011] 10. The control component executes a master-slave switchover, which includes detecting a master node failure for a duration T1, triggering a master-slave switchover for a duration T2, and pushing the post-switch routing table T3. Based on this implementation, while the control component detects a master node failure (i.e., within duration T1), the proxy component can use the target slave node to execute client read requests. This allows for timely responses to client read requests before the master-slave switchover occurs, thereby minimizing the impact on the client. Figure 4 is a flowchart of a database request processing method provided by an exemplary embodiment of the present disclosure. The method may include the following steps: Step 401: Receive a data read request from a client. Step 402: Send the data read request to a master node in a database node cluster; the database node cluster includes at least one slave node. Step 403: If no response message is received from the master node to the data read request within a latency threshold, the data read request is sent to a target backup node among the at least one backup node, so that the target backup node processes the data read request and returns a result. The latency threshold is determined based on the response time of the master node within a historical period. This embodiment can be performed by a proxy component of the client. Alternatively, in some optional embodiments, when the client is a rich client, this embodiment can be performed by certain functional modules within the rich client, which is not limited in this embodiment. In some exemplary embodiments, before sending the data read request to the target standby node, the method further 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 data write request in a relay log; the relay log is used to synchronize the target standby node with the primary node's data write operation; 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 based on the record success message. In some exemplary embodiments, after sending the data read request to the target standby node, the method further includes: if a first response message is received from the target standby node in response to the data read request, sending the first response message to the client; or, if a second response message is received from the primary node in response to the data read request before receiving the first response message, sending the second response message to the client and discarding the first response message.In some exemplary embodiments, the method further includes: if no second response message is received from the master node in response to the data read request, determining that the master node is in a faulty state; and using the management and control component to switch the target standby node to the new master node, or selecting any standby node from the at least one standby node as the new master node. In some exemplary embodiments, the method further includes: initializing a specified duration threshold as a latency threshold for 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 latency threshold for the new master node based on the response duration of the at least one data read request. In this embodiment, after receiving a data read request from a client, the proxy component may send the data read request to a master node in a database node cluster deployed in a master-standby mode. If no response message is received from the master node in response to the data read request within the latency threshold, the proxy component may send the data read request to a target standby node in the database node cluster, so that the target standby node processes the data read request and returns a result. In this embodiment, the latency threshold is determined based on the primary node's response time over a historical period. This can be used to reflect the primary node's responsiveness. Furthermore, when no primary node failure is detected, the latency threshold can be used to preliminarily determine whether the primary node is abnormal. If a primary node failure is preliminarily determined, the read request is automatically resent to the backup node. In this embodiment, the read request resend operation is performed by a proxy component, which reduces the risk of read request failure in the early stages of a primary node failure without the client's awareness. 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, steps 401 to 404 can be executed by device A; in another example, steps 401 and 402 can be executed by device A, and step 403 can be executed by device B; and so on. Furthermore, some of the processes described in the above embodiments and accompanying drawings include multiple operations that appear in a specific order. However, it should be understood that these operations may be executed in a different order than the order in which they appear herein or in parallel. Operation sequence numbers, such as 401 and 402, are merely used to distinguish between different operations and do not represent any specific execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that terms such as "first" and "second" herein are used to distinguish between different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.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, storage, and display, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. The collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or deny. Figure 5 illustrates a schematic diagram of the server provided in an exemplary embodiment of the present disclosure. As shown in Figure 5, the server includes: memory 501, processor 502, and communication component 503. Memory 501 is used to store computer programs and can be configured to store various other data to support operations on the server. Examples of such data include instructions for any application or method operating on the server. A processor 502 is coupled to the memory 501 and is configured to execute a computer program in the memory 501, configured to: receive a data read request from a client; send the data read request to the master node; and if no response message is received from the master node to 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, so that the target standby node processes the data read request and returns a processing result; wherein the latency threshold is determined based on a response time of the master node within a historical period. Optionally, before sending the data read request to the target standby node, the processor 502 is further configured 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 a relay log based on the data write request; the relay log is used to synchronize the target standby node with the primary node's data write operation; 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 based on the record success message. Optionally, after sending the data read request to the target standby node, the processor 502 is further configured to: if a first response message returned by the target standby node in response to the data read request is received, send the first response message to the client; or, if a second response message returned by the primary node in response to the data read request is received before the first response message is received, send the second response message to the client and discard the first response message.Optionally, the processor 502 is further configured to: if the second response message returned by the master node in response to the data read request is not received, determine that the master node is in a faulty state; and, using the management and control component, switch the target backup node to a new master node, or select any backup node from the at least one backup node as the new master node. Optionally, the processor 502 is further configured to: initialize a specified duration threshold as a latency threshold for the new master node; obtain a response duration of at least one data read request sent to the new master node within a specified time window; and determine the latency threshold for the new master node based on the response duration of the at least one data read request. An embodiment of the present disclosure 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 configured to send a data read request; the proxy component is configured to: receive the 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 to 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 the response time of the master node within a historical period; the master node and any standby node are configured to process the data read request sent by the proxy component and return a processing result. Optionally, the standby node is further configured to: receive the data write request sent by the proxy component; record the data write request in a relay log, and, upon completion of recording, return a recording success message to the proxy component. Optionally, 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 apply operation of the relay log; and after the relay log has been completely applied, process the data read request and return a response message to the proxy component. Furthermore, as shown in FIG5 , the server also includes other components, such as a power supply component 504, a display component 505, and an audio component 506. FIG5 schematically illustrates only some components and does not imply that the server includes only the components shown in FIG5 .The memory 501 may be implemented by any type of volatile or non-volatile memory 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 storage, flash memory, magnetic disk, or optical disk. The communication component 503 is configured to facilitate wired or wireless communication between the device in which 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 LTE-Advanced (LTE-A)), or 5G (Fifth Generation Mobile Communication Technology), or a combination thereof. In an exemplary embodiment, the communication component receives broadcast signals 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.The power supply assembly 504 is configured to provide power to various components of the device in which the power supply assembly resides. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly resides. The display assembly 505 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). OIf 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 touches, slides, and gestures on the touch panel. The touch sensors can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action. The audio component 506 can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC). When the device containing the audio component 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 transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting the audio signal. In this embodiment, after receiving a data read request from a client, the data read request can be sent to the master node in a database node cluster deployed in active-standby mode. If no response message is received from the primary node to the data read request within the latency threshold, the data read request may be sent to a target standby node in the database node cluster, enabling the target standby node to process the data read request and return a result. In this embodiment, the latency threshold is determined based on the primary node's response time over a historical period and can be used to reflect the primary node's responsiveness. Furthermore, when no primary node failure is detected, the latency threshold can be used to preliminarily determine whether the primary node is abnormal. If so, the read request can be automatically resent to the standby node. In this embodiment, the client does not need to resend the read request, reducing the risk of read request failure in the early stages of a primary node failure without the client's awareness. Accordingly, embodiments of the present disclosure also provide a computer-readable storage medium storing a computer program. When executed, the computer program can implement the steps that can be performed by the server in the above-described method embodiments. Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. 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. 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, such that the instructions, when executed by the processor of the computer or other programmable data processing device, produce a device for implementing the functions specified in one or more processes in the flowcharts and / or one or more blocks in the block diagrams. These computer program instructions can also be stored in a computer-readable memory capable of directing the computer or other programmable data processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device that implements the functions specified in one or more processes in the flowcharts and / or one or more blocks in the block diagrams. These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing the computer or other programmable device to execute a series of operational steps to produce a computer-implemented process. The instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more flow charts and / or one or more blocks in the block diagrams. In a typical configuration, a computing device includes one or more processors (Central Processing Units, CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-volatile memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory. Memory is an example of computer-readable media. Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can implement information storage 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 technologies, 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 media such as modulated data signals and carrier waves. It should also be noted that the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, product, or device comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, product, or device. Without further limitation, the phrase "comprising a..." does not preclude the presence of other identical elements in the process, method, product, or device comprising the elements. The foregoing description is merely an embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that the present disclosure is susceptible to various modifications and variations. Any modifications, equivalent substitutions, improvements, and the like made within the spirit and principles of the present disclosure are intended to be encompassed by the claims of the present disclosure. Industrial Applicability: In the database request processing method provided in the embodiments of the present disclosure, after receiving a data read request from a client, the proxy component can send the data read request to the master node in a database node cluster deployed in active-standby mode. If no response message is received from the master node to the data read request within the latency threshold, the data read request may be sent to a target standby node in the database node cluster, causing the target standby node to process the data read request and return a result. In this embodiment, the latency threshold is determined based on the master node's response time over a historical period and can be used to reflect the master node's responsiveness. Furthermore, if no master node failure is detected, the latency threshold can be used to preliminarily determine whether the master node is abnormal. If so, the read request can be automatically resent to the standby node.In this embodiment, the retransmission 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 being aware of it.
Claims
Claims 1. A database request processing method, 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 comprises: Receive data read requests from clients; Sending the data read request to the master node; If a response message returned by the master node to 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, wherein: 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.
3. The method according to claim 1, wherein: 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, sending 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, sending the second response message to the client and discarding the first response message.
4. The method according to claim 3, wherein: 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, wherein: 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 according to a response duration of the at least one data read request.
6. A database request processing system, comprising: 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 used to: receive a data read request from the client; Sending the data read request to the master node; if the response message returned by the master node for the data read request is not received within the delay threshold, sending the data read request to the target standby node in the at least one standby node; wherein the delay threshold is based on the master node in The response time within the historical period is determined; the master node and any standby node are used to process the data read request sent by the proxy component and return a processing result.
7. The system according to claim 6, wherein: 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, wherein: The standby node is further configured to: upon receiving the data read request, determine whether the recorded relay log is completely applied; if not, execute the apply 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, comprising: 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, wherein when the computer program is executed by a processor, the method for processing database requests according to any one of claims 1 to 5 can be implemented.
11. A computer program product, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the method for processing a database request according to any one of claims 1 to 5 can be implemented.
Citation Information
Patent Citations
Message scheduling method and device
CN108769242A
A method and a terminal for improving the availability of a DNS
CN109922120A
System fault processing method and device, computer equipment and storage medium
CN112328421A
Client in distributed computing system that monitors request time and operation time in order to detect performance problems and automatically issue alerts
US20170026495A1
Data storage system with redundant internal networks
US20200404055A1