Data query optimization method and system
By configuring a mechanism for compatible identification and recording failed data node information in a distributed data storage system, the data query failure caused by data node failure is solved, and the fault tolerance and availability of the system are improved.
Patent Information
- Application Number
- CN202411614708.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-21
AI Technical Summary
In distributed data storage systems, data node failure or request timeout will cause data query failure, affecting system stability and reliability.
By configuring the failed compatibility identifier in the client data query request, the server records the faulty data node information during the data query and skips the faulty node, and continues to access the next data node to ensure the successful completion of the data query.
This method improves the fault tolerance and availability of the system, reduces the negative impact caused by faulty nodes or request timeouts, and ensures the success rate of data queries and the stability of the system.
Smart Images

Figure CN119669273A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a data query optimization method and system. Background Art
[0002] In modern information systems, in order to support high concurrency and high throughput scenario requirements, a distributed architecture is usually used to deploy various applications, and data storage is also carried out using multiple data nodes. When a client needs to obtain data, it first accesses the central node, which then obtains data from multiple data nodes, and returns it to the client after filtering and assembling. If any data node fails or access is abnormal during this process, not only will the current data query fail, but any subsequent requests involving the node will also be affected, resulting in reduced stability and reliability of the system as a whole. Therefore, there is an urgent need for an optimization method and system for data query that can solve the above problems. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a data query optimization method and system, which can reduce the negative impact caused by faulty nodes or request timeouts, and further improve the overall stability and availability of the system.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: A data query optimization method comprises the following steps: S1. The server responds to a client data query request and detects whether the client data query request is configured with a failure compatibility flag; S2. When the server queries data, if the client data query request is configured with a failed compatible identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node, accesses the next data node, obtains the query data, and returns the information of the failed data node and all the query data obtained from the access to the client; S3. The client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful; otherwise, the data query is determined to be failed.
[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: A data query optimization system includes a client and a server, wherein the client and the server execute each step of the above-mentioned data query optimization method.
[0006] The beneficial effects of the present invention are as follows: the present invention provides an optimization method and system for data query, which allows subsequent data processing to be performed when a data node fails or a request times out, and responds to client data query requests, thereby improving the overall fault tolerance and availability of the system; the client determines whether the received data is available based on business rules, and if so, the data query is determined to be successful, otherwise the data query is determined to have failed, and data problems are fed back immediately. When the data is unavailable, it is convenient to quickly initiate a data query request again, thereby increasing system flexibility and meeting client business needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 A flowchart of a data query optimization method according to an embodiment of the present invention; Figure 2 A schematic diagram of a data query optimization system according to an embodiment of the present invention; Description of labels: 1. A data query optimization system; 2. Client; 3. Server. DETAILED DESCRIPTION
[0008] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0009] Please refer to Figure 1 The embodiment of the present invention provides a method for optimizing data query, comprising the steps of: S1. The server responds to a client data query request and detects whether the client data query request is configured with a failure compatibility flag; S2. When the server queries data, if the client data query request is configured with a failed compatible identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node, accesses the next data node, obtains the query data, and returns the information of the failed data node and all the query data obtained from the access to the client; S3. The client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful; otherwise, the data query is determined to be failed.
[0010] From the above description, it can be seen that the beneficial effects of the present invention are: by introducing a failure-compatible identifier and a faulty data node information recording mechanism, subsequent data processing can still be performed when a data node fails or a request times out, and client data query requests can be responded to, thereby improving the overall fault tolerance and availability of the system; the client determines whether the received data is available based on business rules. If available, the data query is determined to be successful, otherwise the data query is determined to have failed, and data problems are fed back immediately. When the data is unavailable, it is convenient to quickly initiate a data query request again, thereby increasing system flexibility and meeting client business needs.
[0011] Furthermore, the step S2 further includes: When the server queries data, if the client data query request is not configured with a failure compatible identifier, then when there is a data node failure, the central node directly returns a query error message to the client, and determines that the data query has failed.
[0012] From the above description, it can be seen that when the client data query request is not configured with a failure compatible identifier and there is a data node failure, the central node directly returns the query error information to the client. Through this direct error return design, the data query status is promptly fed back so that the client can take corresponding measures in time, initiate the data query request again, and obtain the required data.
[0013] Furthermore, the method for determining the data node failure includes: The central node records the number of failures of each data node in the cache. If a data node fails continuously for a preset number of times, the data node is set to a fault state and its corresponding data node identifier is set to unavailable.
[0014] From the above description, it can be seen that by recording the number of failures of the data node in real time, when the number of failures reaches a preset number, the data node is set to a fault state, and its corresponding data node identifier is set to unavailable, thereby avoiding resource loss caused by continued querying of the faulty data node and improving data query efficiency and system stability.
[0015] Furthermore, the method for determining the data node failure also includes: The central node regularly monitors the network access status of each data node. When access to a data node is interrupted, the corresponding data node is set to a fault state and its corresponding data node identifier is set to unavailable.
[0016] From the above description, it can be seen that through regular monitoring of the central node, network access problems of the data node are discovered, and the data node corresponding to the interruption is set to a fault state in time so that the faulty data node can be processed, which helps to reduce the delay in fault detection and improve the response speed of the system. The data node identifier corresponding to the faulty data node is set to unavailable to prevent the faulty data node from continuing to participate in data query, thereby improving system reliability.
[0017] Furthermore, after step S3, the method further includes: The server sets an asynchronous thread to regularly monitor each data node and the access status of the central node to each data node. When the failed data node returns to normal, the corresponding data node in the central node is marked as available.
[0018] From the above description, it can be seen that by regularly monitoring the status of data nodes and promptly restoring failed data nodes, the stable operation of the system is ensured, and the corresponding data node markers in the central node are set as available to improve system availability. In addition, asynchronous threads are used for monitoring to improve system operation efficiency and avoid unnecessary resource consumption.
[0019] Please refer to Figure 2 Another embodiment of the present invention provides a data query optimization system, including a client and a server, wherein the client and the server execute the various steps of the above-mentioned data query optimization method.
[0020] The above-mentioned data query optimization method and system of the present invention are suitable for reducing the negative impact caused by faulty nodes or request timeouts during data query and improving the overall stability and availability of the system. The following is an explanation through specific implementation methods: Please refer to Figure 1 , Embodiment 1 of the present invention is: a method for optimizing data query, comprising the steps of: S1. The server responds to a client data query request and detects whether the client data query request is configured with a failure compatibility flag.
[0021] In this embodiment, the failure compatibility flag can be set to false or true, false indicates incompatibility, and true indicates compatibility. By responding to and detecting the failure compatibility flag in the client data query request, the server can better handle possible errors or abnormal situations, which helps to reduce data query failures caused by data node failures and improve the stability and reliability of the entire system.
[0022] S2. When the server queries data, if the client data query request configuration fails with a compatible identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node and accesses the next data node to obtain the query data, and returns the information of the failed data node and all query data obtained from the access to the client.
[0023] In this embodiment, by recording and skipping the faulty data nodes, the system can continue to run without interrupting the data query service due to the failure of a single data node, thereby improving the system's fault tolerance, improving the overall stability of the system, and avoiding invalid access to faulty data nodes, optimizing resource utilization efficiency, and improving data query efficiency.
[0024] Furthermore, in this embodiment, step S2 also includes: when the server is querying data, if the client data query request is not configured with a failure compatible identifier, then when there is a data node failure, the central node directly returns the query error information to the client and determines that the query has failed. Through this direct error return design, the data query status is fed back in time, so that the client can take corresponding measures in time, initiate the data query request again, and obtain the required data.
[0025] Furthermore, in the present embodiment, the method for determining data node failure includes: the central node records the number of failures of each data node in the cache. If a data node fails continuously for a preset number of times, for example, the preset number is set to 2, then when a data node fails continuously for 2 times, the data node is set to a faulty state, and its corresponding data node identifier is set to unavailable. The number of failures of the data node is recorded in real time, and corresponding processing is performed according to the number of failures to avoid resource loss caused by continued querying of the faulty data node, thereby improving data query efficiency and system stability.
[0026] Furthermore, in the present embodiment, the method for determining data node failure also includes: the central node periodically monitors the network access status of each data node. When access to a data node is interrupted, the data node corresponding to the interruption is set to a faulty state, and its corresponding data node identifier is set to unavailable. Through the regular monitoring of the central node, network access problems of data nodes are discovered, and the data node corresponding to the interruption is set to a faulty state in a timely manner so that the faulty data node can be processed, which helps to reduce the delay in fault detection and improve the response speed of the system. The data node identifier corresponding to the faulty data node is set to unavailable to prevent the faulty data node from continuing to participate in data query, thereby improving system reliability.
[0027] S3. The client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful; otherwise, the data query is determined to be failed.
[0028] In this embodiment, data availability is determined through the business rules of the client. For example, a page needs to display 10 pieces of data, and the failed interface has returned 20 pieces of data, which has met the business needs of the client. Therefore, the query can be determined to be successful. The client can promptly feedback data problems to ensure data validity and applicability. When data is unavailable, it is easy to quickly initiate a data query request again, increase system flexibility, and meet client business needs.
[0029] Furthermore, in this embodiment, after step S3, it also includes: the server sets an asynchronous thread to regularly monitor each data node and the access status of the central node to each data node, and promptly restores the faulty data node to ensure stable operation of the system. When the faulty data node returns to normal, the corresponding data node in the central node is set to be available to improve system availability, and asynchronous threads are used for monitoring to improve system operation efficiency and avoid unnecessary resource consumption.
[0030] Please refer to Figure 2 , Embodiment 2 of the present invention is: a data query optimization system 1, comprising a client 2 and a server 3, wherein the client 2 and the server 3 execute each step of a data query optimization method of Embodiment 1.
[0031] In summary, the present invention provides a data query optimization method and system, through the server responding to the client data query request, detecting whether the client data query request is configured with a failure compatibility identifier, so that the server can better handle possible errors or abnormal situations, which helps to reduce data query failures caused by data node failures and improve the stability and reliability of the entire system; when the server queries data, if the client data query request is configured with a failure compatibility identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node to access the next data node, obtains the query data, and returns the information of the failed data node and all the query data obtained by the access to the client; if the client data query request is not configured with a failure compatibility identifier, then when there is a data node failure, the central node directly returns the query error information to the client, determines that the query fails, and performs corresponding processing according to the failure compatibility identifier and the data node access situation, avoids invalid access to the failed data node, improves data query efficiency, and also improves the fault tolerance and overall stability of the system; the method for determining the data node failure includes: the central node records the number of failures of each data node in the cache, and if there is a data node failure, the central node directly returns the query error information to the client, determines that the query fails, and performs corresponding processing according to the failure compatibility identifier and the data node access situation, so as to avoid invalid access to the failed data node, improve data query efficiency, and also improve ... When the number of consecutive failures of a data node reaches a preset number, the data node is set to a fault state, and its corresponding data node identifier is set to unavailable; the central node regularly monitors the network access of each data node. When the access to the data node is interrupted, the data node corresponding to the interruption is set to a fault state, and its corresponding data node identifier is set to unavailable. The central node makes a fault determination based on the data node access situation so as to process the faulty data node, avoid resource loss caused by continuing to query the faulty data node, and improve data query efficiency and system stability; the client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful, otherwise the data query is determined to be failed. The client promptly feedbacks data problems to ensure data validity and applicability. When the data is unavailable, it is convenient to quickly initiate a data query request again, increase system flexibility, and meet client business needs; the server sets an asynchronous thread to regularly monitor each data node and the access situation of the central node to each data node, promptly restore the faulty data node, ensure stable operation of the system, and when the faulty data node returns to normal, set the corresponding data node identifier in the central node to be available to improve system availability.
[0032] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A data query optimization method, characterized in that: Includes steps: S1. The server responds to a client data query request and detects whether the client data query request is configured with a failure compatibility flag; S2. When the server queries data, if the client data query request is configured with a failed compatible identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node, accesses the next data node, obtains the query data, and returns the information of the failed data node and all the query data obtained from the access to the client; S3. The client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful; otherwise, the data query is determined to be failed.
2. The data query optimization method according to claim 1, characterized in that: The step S2 further includes: When the server queries data, if the client data query request is not configured with a failure compatible identifier, then when there is a data node failure, the central node directly returns a query error message to the client, and determines that the data query has failed.
3. The data query optimization method according to claim 1, characterized in that: The method for determining the data node failure includes: The central node records the number of failures of each data node in the cache. If a data node fails continuously for a preset number of times, the data node is set to a fault state and its corresponding data node identifier is set to unavailable.
4. The data query optimization method according to claim 3, characterized in that: The method for determining the data node failure also includes: The central node regularly monitors the network access status of each data node. When access to a data node is interrupted, the corresponding data node is set to a fault state and its corresponding data node identifier is set to unavailable.
5. The data query optimization method according to claim 1, characterized in that: After step S3, the method further includes: The server sets an asynchronous thread to regularly monitor each data node and the access status of the central node to each data node. When the failed data node returns to normal, the corresponding data node in the central node is marked as available.
6. A data query optimization system, comprising a client and a server, characterized in that: The client and the server perform the following steps: S1. The server responds to a client data query request and detects whether the client data query request is configured with a failure compatibility flag; S2. When the server queries data, if the client data query request is configured with a failed compatible identifier, then when there is a data node failure, the central node records the information of the failed data node, skips the failed data node, accesses the next data node, obtains the query data, and returns the information of the failed data node and all the query data obtained from the access to the client; S3. The client determines whether the received data is available according to the business rules. If it is available, the data query is determined to be successful; otherwise, the data query is determined to be failed.
7. A data query optimization system according to claim 6, characterized in that: The step S2 further includes: When the server queries data, if the client data query request is not configured with a failure compatible identifier, then when there is a data node failure, the central node directly returns a query error message to the client, and determines that the data query has failed.
8. The data query optimization system according to claim 6, characterized in that: The method for determining the data node failure includes: The central node records the number of failures of each data node in the cache. If a data node fails continuously for a preset number of times, the data node is set to a fault state and its corresponding data node identifier is set to unavailable.
9. The data query optimization system according to claim 8, characterized in that: The method for determining the data node failure also includes: The central node regularly monitors the network access status of each data node. When access to a data node is interrupted, the corresponding data node is set to a fault state and its corresponding data node identifier is set to unavailable.
10. The data query optimization system according to claim 6, characterized in that: After step S3, the method further includes: The server sets an asynchronous thread to regularly monitor each data node and the access status of the central node to each data node. When the failed data node returns to normal, the corresponding data node in the central node is marked as available.