CN-121996639-A - Data query method, device, electronic equipment, storage medium and program product
Abstract
The embodiment of the application provides a data query method, a data query device, electronic equipment, a storage medium and a program product. The method comprises the steps of periodically synchronizing data from a data source to a local cache, responding to a data query request of each client based on the local cache under the condition that synchronization is not suspended, suspending the synchronization after the data source is subjected to a preset type of change, responding to a data query request of a second client based on the data source under the condition that synchronization is suspended, carrying out gray verification on the data source based on the data query request of the first client, gradually setting the first client as the second client under the condition that the second client can work normally based on target data acquired from the data source until all the first clients are set as the second client, and recovering the synchronization when each client can work normally based on the target data acquired from the data source, so that the reliability of the acquired data can be improved.
Inventors
- LI XUDONG
- WANG RUN
- ZHU QIN
- WANG KEZUN
Assignees
- 网联清算有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20241101
Claims (10)
- 1. A data query method, characterized in that it is applied to a server, the method comprising: periodically synchronizing data from the data source to the local cache; responding to the data query request of each client based on the local cache under the condition that the synchronization is not suspended; Suspending the synchronization after a predetermined type of change occurs to the data source; Under the condition of suspending the synchronization, responding to a data query request of a first client based on the local cache, responding to a data query request of a second client based on the data source, and performing gray verification on the data source; under the condition that the second client can work normally based on the target data acquired from the data source, gradually setting the first client as the second client until all the first clients are set as the second client; And when each client can work normally based on the target data acquired from the data source, the synchronization is restored.
- 2. The method of claim 1, wherein in the event that the second client is capable of operating properly based on the target data obtained from the data source, progressively placing the first client as the second client until all of the first clients are placed as the second client, comprising: dividing the clients into a plurality of groups, each group comprising at least one first client, and sequentially performing the following gray scale verification operation on each of the plurality of groups until all the first clients are set as second clients; wherein the gray scale verification operation includes: setting each first client corresponding to the current group as a second client; Respectively confirming whether each second client can normally work based on the target data received from the data source; when each second client is confirmed to work normally based on the target data received from the data source, taking the group of the next round as the current group; The method further comprises the steps of: and if any second client cannot work normally based on the target data acquired from the data source, responding to the data query request of each client based on the local cache.
- 3. The method of claim 1, wherein partitioning each client into a plurality of groups comprises: Determining weights corresponding to the clients respectively; Dividing the clients into a plurality of groups according to the weights corresponding to the clients respectively, wherein the weights of the clients corresponding to each group are the same; accordingly, the following gray scale verification operations are sequentially performed for each of the plurality of groups, including: For each of the plurality of groups, the following gradation verification operations are sequentially performed in order of low to high weights.
- 4. A method according to any of claims 1-3, wherein suspending the synchronization after a predetermined type of change has occurred to the data source comprises: after the data source is changed in a preset type, acquiring the total data after the change in the data source, and suspending the synchronization after the acquisition is finished; The method further comprises the steps of: consistency comparison is carried out on the modified full data and the full data before modification in the local cache; And if the comparison result is data abnormality, responding to the data query request of each client based on the local cache.
- 5. The method of claim 1, wherein the server comprises a primary hub server and a plurality of non-primary hub servers, the method being applied to the primary hub server, the periodically synchronizing data from a data source to a local cache comprising: periodically synchronizing data from a data source to a local cache, and synchronizing the data in the local cache to the local caches respectively corresponding to the non-main center servers, so that when any non-main center server is switched to a main center server, the local cache based on the non-main center server responds to the data query request of each client; the responding to the data query request of each client comprises the following steps: and receiving a data query request sent by any target server through an internal interface, wherein the data query request is acquired by an external interface of the target server.
- 6. The method of claim 1, wherein the data query request includes identification information of the client, the identification information stored in a remote procedure call context object; Under the condition of suspending the synchronization, responding to the data query request of the first client based on the local cache, responding to the data query request of the second client based on the data source, and comprising: And determining whether the client is a first client or a second client according to the identification information.
- 7. The method of claim 1, wherein the server is provided with a cache refresh switch to periodically synchronize data from the data source to the local cache, comprising: when the cache refreshing switch is started, periodically synchronizing data from a data source to a local cache; accordingly, after the data source is changed in a predetermined type, suspending the synchronization includes: And after the data source is changed in a preset type, closing the cache refreshing switch to pause the synchronization.
- 8. A data query device, applied to a server, the device comprising: The synchronization module is used for periodically synchronizing data from the data source to the local cache; The response module is used for responding to the data query requests of the clients based on the local cache under the condition that the synchronization is not suspended; A pause module for pausing the synchronization after a predetermined type of change occurs to the data source; The verification module is used for responding to the data query request of the first client based on the local cache under the condition of suspending the synchronization, responding to the data query request of the second client based on the data source so as to carry out gray verification on the data source; and the recovery module is used for recovering the synchronization when each client can work normally based on the target data acquired from the data source.
- 9. An electronic device is characterized by comprising a memory and a processor; The memory stores computer-executable instructions; The processor executing computer-executable instructions stored in the memory, causing the processor to perform the method of any one of claims 1-7.
- 10. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1-7.
Description
Data query method, device, electronic equipment, storage medium and program product Technical Field The present application relates to the field of computer communications technologies, and in particular, to a data query method, a data query device, an electronic device, a storage medium, and a program product. Background In the scenario that the client acquires data through the server, a cache can be set at the server, the server periodically pulls and updates the cached data from the data source, and when a query request sent by the client is acquired, the server returns the data in the cache to the client. The common data source takes a database as an example, when the database is subjected to major changes, such as database active-standby switching, database change, SQL (Structured Query Language ) change and the like, the risk that data in the data source is unavailable exists, so that the reliability of the data acquired by a client is lower, the cache of a server is still updated periodically on the premise of data errors in the data source, and the data is provided for the client in full quantity, and the client can receive the erroneous data during query, thereby possibly causing erroneous business decisions, data display or other operations depending on the data. Disclosure of Invention The embodiment of the application provides a data query method, a data query device, electronic equipment, a storage medium and a program product, which are used for improving the reliability of data acquired by a client. In a first aspect, an embodiment of the present application provides a data query method, applied to a server, where the method includes: periodically synchronizing data from the data source to the local cache; responding to the data query request of each client based on the local cache under the condition that the synchronization is not suspended; Suspending the synchronization after a predetermined type of change occurs to the data source; Under the condition of suspending the synchronization, responding to a data query request of a first client based on the local cache, responding to a data query request of a second client based on the data source, and performing gray verification on the data source; under the condition that the second client can work normally based on the target data acquired from the data source, gradually setting the first client as the second client until all the first clients are set as the second client; And when each client can work normally based on the target data acquired from the data source, the synchronization is restored. In one possible implementation, in a case where the second client is able to operate normally based on the target data acquired from the data source, gradually setting the first clients as the second clients until all the first clients are set as the second clients, including: dividing the clients into a plurality of groups, each group comprising at least one first client, and sequentially performing the following gray scale verification operation on each of the plurality of groups until all the first clients are set as second clients; wherein the gray scale verification operation includes: setting each first client corresponding to the current group as a second client; Respectively confirming whether each second client can normally work based on the target data received from the data source; when each second client is confirmed to work normally based on the target data received from the data source, taking the group of the next round as the current group; The method further comprises the steps of: and if any second client cannot work normally based on the target data acquired from the data source, responding to the data query request of each client based on the local cache. In one possible implementation, dividing each client into a plurality of groups includes: Determining weights corresponding to the clients respectively; Dividing the clients into a plurality of groups according to the weights corresponding to the clients respectively, wherein the weights of the clients corresponding to each group are the same; accordingly, the following gray scale verification operations are sequentially performed for each of the plurality of groups, including: For each of the plurality of groups, the following gradation verification operations are sequentially performed in order of low to high weights. In one possible implementation, suspending the synchronization after a predetermined type of change has occurred to the data source includes: after the data source is changed in a preset type, acquiring the total data after the change in the data source, and suspending the synchronization after the acquisition is finished; The method further comprises the steps of: consistency comparison is carried out on the modified full data and the full data before modification in the local cache; And if the comparison result is data abnormality, responding to the data que