CN110858204A - Query request processing method, device and medium - Google Patents

Query request processing method, device and medium Download PDF

Info

Publication number
CN110858204A
CN110858204A CN201810936221.8A CN201810936221A CN110858204A CN 110858204 A CN110858204 A CN 110858204A CN 201810936221 A CN201810936221 A CN 201810936221A CN 110858204 A CN110858204 A CN 110858204A
Authority
CN
China
Prior art keywords
data object
changed
state
variable
query request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810936221.8A
Other languages
Chinese (zh)
Other versions
CN110858204B (en
Inventor
王凡
龙凤
陈乐君
唐堂
谭正
颜理
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Group Chongqing Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Group Chongqing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Group Chongqing Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201810936221.8A priority Critical patent/CN110858204B/en
Publication of CN110858204A publication Critical patent/CN110858204A/en
Application granted granted Critical
Publication of CN110858204B publication Critical patent/CN110858204B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method, equipment and medium for processing a query request. The method comprises the following steps: setting a first variable to be in a first state, wherein the first state is used for representing that a data object in a database system needs to be changed; according to the first state, the query request related to the data object to be changed is placed into a cache queue; changing the data object to be changed; and if the data object to be changed is successfully changed, sending the query request in the cache queue to the database system. The query request processing method disclosed by the invention can cache the query request related to the data object to be changed during the data object changing period, so that the changed data object in the database system can be accessed after the data object is changed, the data object is prevented from being changed in a mode of interrupting service access, and the use experience of a user is improved.

Description

Query request processing method, device and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method for processing a query request, an apparatus for processing a query request, and a computer-readable storage medium.
Background
If the data object is changed, for example, the data object is changed on a large scale when the version of the application program is released, the service access can be interrupted, the data object is changed during the interruption of the service access, and the service access is recovered after the data object is changed, which belongs to the method of off-line change.
However, since a Structured Query Language (SQL) request cannot be received during a change to a data object, business access to the database system is not possible, and if the update frequency of the data object is relatively high, the business access needs to be frequently interrupted, and particularly when the access to the enterprise key business is frequently interrupted, the enterprise may experience bad use experience.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, and a medium for processing a query request, which can change a data object without interrupting service access.
In a first aspect, an embodiment of the present invention provides a method for processing a query request, including:
setting a first variable to be in a first state, wherein the first state is used for representing that a data object in a database system needs to be changed;
according to the first state, the query request related to the data object to be changed is placed into a cache queue;
changing the data object to be changed;
and if the data object to be changed is successfully changed, sending the query request in the cache queue to the database system.
In a second aspect, an embodiment of the present invention provides an apparatus for processing a query request, including:
the first setting module is used for setting a first variable into a first state, and the first state is used for representing the change requirement of a data object in the database system;
the first storage module is used for placing the query request related to the data object to be changed into a cache queue according to the first state;
the change module is used for changing the data object to be changed;
and the first sending module is used for sending the query request in the cache queue to the database system if the data object to be changed is successfully changed.
In a third aspect, an embodiment of the present invention provides an apparatus for processing a query request, including: at least one processor, at least one memory, and computer program instructions stored in the memory that, when executed by the processor, implement the method as described above.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the above-described method.
Compared with the prior art, according to the query request processing method, the query request processing device and the query request processing medium provided by the embodiment of the application, if the data object needs to be changed, the query request related to the data object to be changed is placed into the cache queue for caching, and after the data object is changed, the query request in the cache queue is sent to the database system. It can be seen that query requests associated with a data object to be changed can be cached during a data object change, and the changed data object in the database system can be accessed after the data object has been changed. In the related technical scheme, the query request cannot be received during the data object changing period, and the service access to the database system cannot be performed, so that compared with the scheme in the related art, the embodiment of the invention does not interrupt the service access to the database system, and the use experience of a user is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments of the present invention will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram illustrating a method of processing a query request in accordance with one embodiment of the present invention;
FIG. 2 is a schematic logical block diagram illustrating a method of processing a query request according to another embodiment of the invention;
FIG. 3 shows a schematic flow chart diagram of an object change method of an embodiment of the invention;
FIG. 4 is a schematic flow chart diagram illustrating a method of depositing a query request in accordance with one embodiment of the present invention;
FIG. 5 is a schematic flow chart diagram illustrating a method of processing a query request in a cache queue according to one embodiment of the invention;
FIG. 6 is a schematic flow chart diagram illustrating a method of processing query requests in a pass-through queue in accordance with one embodiment of the present invention;
FIG. 7 is a schematic block diagram of an apparatus for processing a query request in accordance with an embodiment of the present invention;
fig. 8 is a schematic structural diagram showing an apparatus for processing a query request according to another embodiment of the present invention.
Detailed Description
Features and exemplary embodiments of various aspects of the present invention will be described in detail below. In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The embodiments will be described in detail below with reference to the accompanying drawings.
FIG. 1 shows a schematic flow chart of a method 100 for processing a query request according to an embodiment of the invention. The method comprises the following steps: s101 to S104.
S101, setting a first variable to be in a first state, wherein the first state is used for indicating that a data object in a database system needs to be changed.
As one example, a first variable is set to a first state by assigning a value to the first variable.
For example, the value of the first variable is set to 1, and when the value of the first variable is 1, it indicates that there is a data object change requirement in the database system.
It should be noted that, when the first variable is set to the first state is not limited herein.
For example, when the name of the data object to be changed is received from the user, it is described that there is a need for changing the data object, and the first variable may be set to the first state.
For another example, the first variable may be set to the first state when a change instruction is received from the user.
S102, according to the first state, the query request related to the data object to be changed is placed into a cache queue.
As an example, the query request may be an SQL request, and the query request may also be another query request, and the query request is not specifically limited herein.
As an example, after setting the first variable to the first state, a predefined data object name variable is set to the name of the data object to be changed, and a query request received from an application is divided into two classes according to the data object name variable, which are a query request related to the data object to be changed and a query request unrelated to the data object to be changed, respectively.
For example, the data object to be changed is table a, and the data object name variable is set as the name of table a; receiving a query request from an application; if the query request contains the information of the data object name variable, the query request is a query request related to the data object to be changed; if the query request does not contain the information of the data object name variable, the query request is a query request unrelated to the data object to be changed.
S103, changing the data object to be changed.
It should be noted that the order of starting execution of S102 and S103 is not limited herein, and S102 may be started first, and S103 may be started again; or S102 and S103 start to execute simultaneously; or S103 and S102 may be started first.
And S104, if the data object to be changed is successfully changed, sending the query request in the cache queue to the database system.
As an example, the query requests in the cache queue are stored in the transparent transmission queue, and then the query requests in the transparent transmission queue are sent to the database system, so that the query requests in the cache queue are sent to the database system.
As another example, query requests in the cache queue are sent directly to the database system without going through the pass-through queue.
According to the query request processing method 100 of the embodiment of the present invention, if a data object needs to be changed, a query request related to the data object to be changed is placed in a cache queue for caching, and after the data object is changed, the query request in the cache queue is sent to a database system. It can be seen that query requests associated with a data object to be changed can be cached during a data object change, and the changed data object in the database system can be accessed after the data object has been changed. In the related technical scheme, the query request cannot be received during the data object changing period, and the service access to the database system cannot be performed, so that compared with the scheme in the related art, the service access to the database system cannot be interrupted, and the use experience of a user is improved.
In one embodiment of the present invention, S103 includes:
and when the data object to be changed and the copy of the data object to be changed meet the preset data object synchronization condition, changing the data object to be changed by using the copy of the data object to be changed.
It should be noted that, a copy of the data object to be changed may be established in advance, for example, a copy of the data object to be changed may be established in advance by a user. The name of the copy of the data object to be changed may be the name of the data object to be changed + tmp, and tmp is used to indicate the copy. Mapping transformations may be established between the data object to be changed and the copy of the data object to be changed. The object structure between the data object to be changed and the copy of the data object to be changed is consistent or inconsistent. And adding data to the copy of the data object to be changed according to the data object to be changed so as to keep the data object to be changed and the copy of the data object to be changed synchronous.
For example, the copy of the data object includes data generated before time point a, and when the data object is updated, the data generated after time point a in the data object is written into the copy of the data object, so as to maintain synchronization between the data object and the copy of the data object.
As an example, the data object synchronization condition includes: the generation time point of the latest data in the data object to be changed is the same as the generation time point of the latest data in the copy of the data object to be changed.
For example, the data object to be changed is data object a, the copy of the data object to be changed is data object a1, the time of generation of the latest data in data object a is 3 pm of the day, the time of generation of the latest data in copy a1 of the data object is 0 min 1 sec of 3 pm of the day, and the data object a and the copy a1 of the data object are not synchronized.
As an example, the data object synchronization condition includes: the interval between the generation time point of the latest data in the data object to be changed and the generation time point of the latest data in the copy of the data object to be changed is less than first preset time.
For example, the data object to be changed is the data object B, the copy of the data object to be changed is the data object B1, the first preset time is 5 seconds, the generation time of the latest data in the data object B is 3 o 'clock every afternoon of the day, the generation time of the latest data in the copy B1 of the data object is 3 o' clock 0 min 7 seconds every afternoon of the day, and the difference between the data object B and the copy B1 of the data object by 7 seconds is greater than the first preset time, so that the data object B and the copy B1 of the data object are asynchronous.
As one example, a change instruction based on a Data Definition Language (DDL) for changing a data object to be changed is transmitted to a database system.
It should be noted that, after receiving the change instruction based on the DDL, the database system changes the name of the data object to be changed to another name, and changes the name of the copy of the data object to be changed to the original name of the data object to be changed.
For example, the name of the data object to be changed is M, the name of the copy of the data object to be changed is M1, the name of the data object to be changed is changed from M to M + old, and the name of the copy of the data object to be changed is changed to M.
According to the query request processing method provided by the embodiment of the invention, when the data object to be changed and the copy of the data object to be changed meet the preset data object synchronization condition, the data in the data object to be changed and the data in the copy of the data object to be changed are the same or basically the same, and the data object to be changed is changed, so that the data in the data object after being changed and the data in the data object before being changed are the same or basically the same, and the difference between the front and the back of the data object is avoided being large.
In an embodiment of the present invention, the method for processing the query request further includes:
and if the data object to be changed and the copy of the data object to be changed do not meet the data object synchronization condition and the length of the query request in the cache queue is greater than the preset length, ending the change of the data object.
It should be noted that, after the first variable is set in the first state, when the data object to be changed and the copy of the data object to be changed do not satisfy the data object synchronization condition, it is necessary to wait until the data object to be changed and the copy of the data object to be changed change the data object to be changed when the data object to be changed and the copy of the data object to be changed satisfy the data object synchronization condition. In the waiting process, more and more query requests are available in the cache queue, and if the length of the query requests in the cache queue is greater than the preset length, which indicates that the cache queue is about to overflow, the data object to be changed fails to be changed, and the change of the data object is finished.
Or, if the data object to be changed and the copy of the data object to be changed do not satisfy the data object synchronization condition, and the duration of the first variable in the first state reaches the preset time, ending the change of the data object.
It should be noted that, after the first variable is set in the first state, if the data object to be changed and the copy of the data object to be changed satisfy the data object synchronization condition, the data object to be changed may be changed; if the data object to be changed and the copy of the data object to be changed do not satisfy the data object synchronization condition, waiting is needed until the data object to be changed and the copy of the data object to be changed change the data object to be changed when the data object to be changed and the copy of the data object to be changed satisfy the data object synchronization condition. If the first variable is set in the first state, starting to time the duration of the first variable in the first state, wherein the time is the waiting time, and if the waiting time reaches the preset time and indicates that the waiting time is long, the data object to be changed and the copy of the data object to be changed still do not meet the data object synchronization condition, ending the change of the data object.
According to the query request processing method provided by the embodiment of the invention, when the cache queue is about to overflow, it is indicated that all query requests related to the data object to be changed cannot be stored in the cache queue completely, and thus all query requests related to the data object to be changed cannot be sent to the database system, so that the change of the data object is finished, and the influence on service access caused by that part of query requests related to the data object to be changed are not cached is avoided. When the duration of the first variable in the first state reaches the preset time, it is described that the time for waiting for synchronization of the data object to be changed and the copy of the data object to be changed is relatively long, the change of the data object is finished, and a long time for accessing the data object to be changed is avoided, so that the use experience of a user is guaranteed.
In an embodiment of the present invention, after finishing the change of the data object, the method for processing the query request further includes:
and setting the first variable to be in a second state, wherein the second state is used for indicating that no data object in the database system needs to be changed.
As one example, the first variable is set to the second state by assigning a value to the first variable.
For example, the value of the first variable is set to 0, and when the value of the first variable is 0, it indicates that there is no data object change requirement in the database system.
According to the processing method of the query request, when the data object is failed to change and the change of the data object is finished, the first variable is set to be in the second state, so that the condition that no data object change requirement exists in the database system is obtained in the second state according to the first variable, and the next processing is convenient to carry out.
In an embodiment of the present invention, the method for processing the query request further includes:
and if the length of the query request in the cache queue is greater than the preset length, setting the first variable in a sixth state, wherein the sixth state is used for indicating that the cache queue overflows or indicating that the cache queue is about to overflow.
As an example, the first variable is set in the sixth state by assigning a value to the first variable.
For example, the value of the first variable is set to 2, and when the value of the first variable is 2, the buffer queue is over or about to overflow.
In an embodiment of the present invention, after S104, the method for processing the query request further includes:
and setting the first variable to be in a second state, wherein the second state is used for indicating that no data object in the database system needs to be changed.
According to the processing method of the query request, when the data object is successfully changed and the query request in the cache queue is sent to the database system, the first variable is in the second state, namely the first variable is set to be in the initial state, so that the data object can be changed next time.
In one embodiment of the present invention, S101 includes:
and after the data object to be changed and the copy of the data object to be changed meet the preset data change condition, setting the first variable into a first state.
As an example, the data change condition includes: and the interval between the generation time point of the latest data in the data object to be changed and the generation time point of the latest data in the copy of the data object to be changed is less than second preset time.
For example, the data object to be changed is data object a, the copy of the data object to be changed is data object a1, the second preset time is 10 seconds, the time point of generating the latest data in data object a is 3 pm on the day, the time point of generating the latest data in copy a1 of the data object is 3 pm 0 min 9 seconds on the day, and the data change condition is satisfied between data object a and copy a1 of the data object.
According to the processing method of the query request, when the difference between the data object to be changed and the copy of the data object to be changed is small, the time for waiting for synchronization between the data object to be changed and the copy of the data object to be changed is short, so that the first variable is set to be in the first state, the process of changing the data object is started, and the success rate of updating the data object is high.
In an embodiment of the present invention, after S101, the method for processing the query request further includes:
and if the second variable is in the third state, setting the second variable to be in a fourth state, wherein the third state is used for indicating that the cache queue is empty, and the fourth state is used for indicating that the cache queue comprises the query request.
It should be noted that, after S101, it is described that the query request related to the data object to be changed enters the buffer queue, and before the data object to be changed is successfully changed, the second variable is set to the fourth state to indicate that the buffer queue includes the query request, and the buffer queue is not empty.
In an embodiment of the present invention, the method for processing the query request further includes:
and if the data object to be changed is successfully changed, setting the second variable to be in a fifth state, wherein the fifth state is used for indicating that the data object is changed.
After S104, the method further includes:
the second variable is set to a third state.
It should be noted that, if the data object to be changed is successfully changed, the second variable is immediately set from the fourth state to the fifth state. The order of setting the second variable to the fifth state and starting to execute S104 is not limited, and it should be noted that the time taken to set the second variable to the fifth state is short, and a plurality of query requests generally need to be sent to the database system in S104, so that S104 has not been executed yet, and the setting of the second variable to the fifth state has been completed.
In one embodiment of the present invention, setting the second variable to the third state comprises:
stopping putting the query requests into the cache queue, and putting all the received query requests into a transparent transmission queue; setting the second variable to a third state; and if the transparent transmission queue comprises the query request related to the data object to be changed, after the second variable is set to be in the third state, the query request related to the data object to be changed in the transparent transmission queue is sent to the database system.
According to the query request processing method provided by the embodiment of the invention, after all the query requests in the cache queue are respectively sent to the database system, the normal access to the database system is recovered, the query requests are stopped from being put into the cache queue, and all the received query requests are put into the transparent transmission queue. The second variable may include a query request associated with the changed data object in the pass-through queue while in the fifth state. It will be understood that since the data object to be changed is changed, the changed data object is used herein for illustration rather than the data object to be changed, i.e., the changed data object appearing herein is the data object to be changed as described above. If the transparent transmission queue comprises the query request related to the changed data object, the query request related to the changed data object in the transparent transmission queue is not sent to the database system, and the query request related to the changed data object in the transparent transmission queue is sent to the database system after the second variable is set to be in the third state, namely the normal access to the database system is recovered.
In an embodiment of the present invention, after S101, the method for processing the query request further includes:
according to the first state, putting the query request irrelevant to the data object to be changed into a transparent transmission queue; and sending the query request which is not related to the data object to be changed in the transparent transmission queue to the database system.
It should be noted that, when the first variable is in the first state, the received query requests include a query request related to the data object to be changed and a query request unrelated to the data object to be changed, the query request related to the data object to be changed is placed in the cache queue, and the query request unrelated to the data object to be changed is placed in the pass-through queue. The query requests irrelevant to the data objects to be changed in the transparent transmission queue are sent to the database system, so that the data objects which are not changed in the database system can be accessed during the change of the data objects, the access to the data objects which are not changed in the database system cannot be influenced by the change of the data objects, and the user experience is further improved.
Fig. 2 is a schematic logical structure diagram illustrating a processing method of an SQL request according to another embodiment of the present invention. The method is realized by a data synchronization program, an SQL interception and analysis program, an object change program, a cache forwarding program and a transparent transmission program. In this embodiment, the query request is an SQL request.
Synchronization between the data object to be changed and the copy of the data object to be changed is achieved by a data synchronization program.
And intercepting the SQL request from an external application through an SQL interception analysis program, and putting the SQL request into a cache queue and a transparent transmission queue according to a first variable and a second variable.
And changing the data object to be changed by the object changing program.
And forwarding the SQL request in the cache queue to the database system through a cache forwarding program.
And forwarding the SQL request in the transparent transmission queue to the database system through the transparent transmission program.
The first variable is 0, which indicates that no data object in the database system needs to be changed; a first variable is 1, which indicates that a data object in the database system needs to be changed; the first variable is 2 indicating that the buffer queue overflows.
A second variable of 0 indicates that the cache queue is empty; the second variable is 1, which indicates that the cache queue comprises SQL requests; a second variable of 2 indicates that the data object has been changed.
Based on fig. 2, fig. 3 shows a schematic flowchart of an object changing method according to an embodiment of the present invention. The method may be implemented by an object modification program. The method includes S301 to S308.
S301, the name of the data object to be changed input by the user is obtained.
S302 judges whether or not the first variable is 2, and if yes, indicates that the buffer queue overflows when the data object is changed last time, step S303 is executed, and if no, step 304 is executed.
S303, setting the first variable to 0, i.e. initializing the first variable.
S304, judging whether the synchronization delay gap between the data object and the copy of the data object meets the data change condition, if so, executing the step 305, and if not, returning to the step S302. The synchronization delay gap refers to an interval of a generation time point of the latest data in the data object to be changed from a generation time point of the latest data in the copy of the data object to be changed.
S305, setting the first variable to be 1, setting the data object variable to be the name of the data object to be changed, and distinguishing the SQL request related to the data object to be changed and the SQL request unrelated to the data object to be changed according to the data object variable.
S306, judging whether the synchronization delay gap between the data object and the data object copy is 0, if yes, executing step S307, if no, indicating that the data object and the data object copy need to wait for synchronization, and executing step S308.
S307, the data object to be changed is changed.
S308, judging whether the first variable is 2, if so, explaining that a buffer queue overflows due to overlong time for waiting synchronization in the process of waiting for synchronizing the data object and the copies of the data object, failing to change the data object to be changed, finishing the change of the data object to be changed, returning to the step S303, and if not, returning to the step S306.
Based on fig. 2, fig. 4 is a schematic flow chart of a method for depositing an SQL request according to an embodiment of the present invention. The method can be realized by an SQL interception parser. The method includes S401 to S411.
S401 determines whether the first variable is 1, and if the determination result is yes, step S402 is executed, and if the determination result is no, step S409 is executed, indicating that there is no need to change the data object.
S402 determines whether the second variable is 2, and if the determination result is yes, step S403 is executed, and if the determination result is no, step S404 is executed.
And S403, when the data object is successfully changed, putting all SQL requests in the cache queue into the transparent transmission queue, and then sending the SQL requests in the transparent transmission queue to the database system, thereby realizing that all SQL requests in the cache queue are respectively sent to the database system. It will be appreciated that all SQL requests in the cache queue may be sent directly to the database system without going through the pass-through queue.
S404 judges whether or not the second variable is 1, and if the judgment result is yes, step S405 is executed, and if the judgment result is no, step S406 is executed so that the second variable is 1.
S405, judging whether the length of the SQL request in the cache queue is over-long, namely judging whether the length of the SQL request in the cache queue is larger than a preset length, if so, executing a step S407, and if not, executing a step S408.
S406, the second variable is set to 1.
S407, when the length of the SQL request in the cache queue is too long, the first variable is set to be 2, the second variable is set to be 2, and the data object change failure is explained.
S408, the SQL requests related to the data objects to be changed in the received SQL requests from the applications are put into a cache queue, and the SQL requests unrelated to the data objects to be changed in the received SQL requests from the applications are put into a transparent transmission queue.
S409, when no data object change requirement exists in the database system, all the received SQL requests are put into a transparent transmission queue.
S410 judges whether or not the second variable is 0, and if yes, returns to step S401, and if no, executes step S411.
S411, setting the second variable to 0, where it needs to be noted that if the second variable is 1, the second variable is first set to 2, and then the second variable is set to 0; if the second variable is 2, the second variable is directly set to 0.
Based on fig. 2, fig. 5 is a schematic flow chart of a method for processing an SQL request in a cache queue according to an embodiment of the present invention. The method may be implemented by a cache forwarding program. The method includes S501 and S502.
S501 determines whether the second variable is 2, if yes, executes step S502, and if no, returns to step S501.
S502, all SQL requests in the cache queue are sent to the database system, and until the cache queue is empty, the second variable is set to be 0.
Based on fig. 2, fig. 6 is a schematic flow chart of a method for processing an SQL request in an unvarnished transmission queue according to an embodiment of the present invention. The method may be implemented by a passthrough program. The method includes S601 to S603.
S601 judges whether or not the second variable is 2, and if the judgment result is yes, step S602 is executed, and if the judgment result is no, step S603 is executed.
S602, sending the SQL request which is not related to the changed data object in the transparent transmission queue to the database system, and temporarily not processing the SQL request which is related to the changed data object in the transparent transmission queue.
S603, sending the SQL request related to the changed data object in the transparent transmission queue to the database system.
It should be noted that, when the second variable is 2, the SQL request is stopped being placed in the cache queue, and all the received SQL requests are placed in the pass-through queue, so the pass-through queue may include SQL requests related to the changed data object. When the transparent transmission queue comprises the SQL request related to the changed data object, the SQL request related to the changed data object in the transparent transmission queue is not processed for the moment, and when the second variable is 0, namely the second variable is restored to the initial value, the SQL request related to the changed data object in the transparent transmission queue is sent to the database system.
FIG. 7 is a schematic block diagram of an apparatus for processing a query request according to an embodiment of the present invention. The apparatus 700 comprises: a first setup module 701, a first storage module 702, a change module 703 and a first sending module 704.
The first setting module 701 is configured to set a first variable to a first state, where the first state is used to indicate that there is a data object change requirement in the database system.
A first storing module 702, configured to place, according to the first state, the query request related to the data object to be changed into the cache queue.
A changing module 703, configured to change the data object to be changed.
A first sending module 704, configured to send the query request in the cache queue to the database system if the data object to be changed is successfully changed.
In one embodiment of the invention, the change module 703 is used to,
and when the data object to be changed and the copy of the data object to be changed meet the preset data object synchronization condition, changing the data object to be changed by using the copy of the data object to be changed.
In one embodiment of the invention, the change module 703 is further operable to,
and if the data object to be changed and the copy of the data object to be changed do not meet the data object synchronization condition and the length of the query request in the cache queue is greater than the preset length, ending the change of the data object.
Or,
and if the data object to be changed and the copy of the data object to be changed do not meet the data object synchronization condition, and the duration of the first variable in the first state reaches the preset time, ending the change of the data object.
In one embodiment of the invention, the apparatus 700 further comprises:
and the second setting module is used for setting the first variable into a second state, and the second state is used for indicating that no data object change requirement exists in the database system.
In one embodiment of the present invention, the first setup module 701 is configured to,
and after the data object to be changed and the copy of the data object to be changed meet the preset data change condition, setting the first variable into a first state.
In one embodiment of the invention, the apparatus 700 further comprises:
and the third setting module is used for setting the second variable to be in a fourth state when the second variable is in a third state, wherein the third state is used for indicating that the cache queue is empty, and the fourth state is used for indicating that the query request enters the cache queue.
In one embodiment of the invention, the apparatus 700 further comprises:
and the fourth setting module is used for setting the second variable to be in a fifth state if the data object to be changed is successfully changed, and the fifth state is used for indicating that the data object is changed.
And the fifth setting module is used for setting the second variable into a third state.
In one embodiment of the present invention, the fifth setting module includes:
and the sending unit is used for stopping the query requests from being put into the cache queue and putting all the received query requests into the transparent transmission queue.
A setting unit configured to set the second variable to a third state;
the sending unit is further configured to send the query request related to the data object to be changed in the transparent transmission queue to the database system after the setting unit sets the second variable to the third state if the transparent transmission queue includes the query request related to the data object to be changed.
In one embodiment of the invention, the apparatus 700 further comprises:
the second storage module is used for placing the query requests irrelevant to the data objects to be changed into the transparent transmission queue according to the first state;
and the second sending module is used for sending the query request which is not related to the data object to be changed in the transparent transmission queue to the database system.
Fig. 8 is a schematic structural diagram showing an apparatus for processing a query request according to another embodiment of the present invention. The apparatus 800 comprises: an input device 801, an input interface 802, a processor 803, a memory 804, an output interface 805, and an output device 806.
The input interface 802, the processor 803, the memory 804, and the output interface 805 are connected to each other via a bus 810, and the input device 801 and the output device 806 are connected to the bus 810 via the input interface 802 and the output interface 805, respectively, and further connected to other components of the computing device 800.
Specifically, the input device 801 receives input information from the outside and transmits the input information to the processor 803 through the input interface 802; the processor 803 processes input information based on computer-executable instructions stored in the memory 804 to generate output information, stores the output information in the memory 804 temporarily or permanently, and then transmits the output information to the output device 806 via the output interface 805; output device 806 outputs output information external to computing device 800 for use by a user.
The computing device 800 may perform the steps of the methods described herein.
The processor 803 may be one or more Central Processing Units (CPUs). When the processor 601 or the processor 701 is one CPU, the CPU may be a single-core CPU or a multi-core CPU.
The Memory 804 may be, but is not limited to, one or more of a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable programmable Read-Only Memory (EPROM), a Compact Disc Read-Only Memory (CD-ROM), a hard disk, and the like. The memory 504 is used for storing program codes.
It is understood that in the embodiment of the present application, the functions of any one or all of the modules provided in fig. 7 may be implemented by the central processing unit 803 shown in fig. 8.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When used in whole or in part, can be implemented in a computer program product that includes one or more computer instructions. When loaded or executed on a computer, cause the flow or functions according to embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL), or wireless (e.g., infrared, wireless, microwave, etc.)). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
According to an embodiment of the present invention, an apparatus for processing a query request is provided, which includes: at least one processor, at least one memory, and computer program instructions stored in the memory that, when executed by the processor, implement the method described above.
According to an embodiment of the invention, a computer-readable storage medium is provided, on which computer program instructions are stored, which when executed by a processor implement the above-mentioned method.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (13)

1. A method for processing a query request, comprising:
setting a first variable to be in a first state, wherein the first state is used for representing that a data object in a database system needs to be changed;
according to the first state, the query request related to the data object to be changed is placed into a cache queue;
changing the data object to be changed;
and if the data object to be changed is successfully changed, sending the query request in the cache queue to the database system.
2. The method of claim 1, wherein said changing the data object to be changed comprises:
and when the data object to be changed and the copy of the data object to be changed meet a preset data object synchronization condition, changing the data object to be changed by using the copy of the data object to be changed.
3. The method of claim 2, further comprising:
if the data object to be changed and the copy of the data object to be changed do not meet the data object synchronization condition, and the length of the query request in the cache queue is greater than a preset length, ending the change of the data object;
or,
and if the data object to be changed and the copy of the data object to be changed do not meet the data object synchronization condition, and the duration of the first variable in the first state reaches a preset time, ending the change of the data object.
4. The method of claim 3, wherein after the ending of the change of the data object, further comprising:
and setting the first variable to be in a second state, wherein the second state is used for indicating that no data object in the database system needs to be changed.
5. The method of claim 1, wherein after sending the query request in the cache queue to the database system, further comprising:
and setting the first variable to be in a second state, wherein the second state is used for indicating that no data object in the database system needs to be changed.
6. The method of claim 2, wherein setting the first variable to the first state comprises:
and setting the first variable to be in the first state after the data object to be changed and the copy of the data object to be changed meet a preset data change condition.
7. The method of claim 1, further comprising:
and if the second variable is in a third state, setting the second variable to be in a fourth state, wherein the third state is used for indicating that the cache queue is empty, and the fourth state is used for indicating that the cache queue comprises the query request.
8. The method of claim 7, further comprising:
if the data object to be changed is successfully changed, setting the second variable to be a fifth state, wherein the fifth state is used for indicating that the data object is changed;
after the query request in the cache queue is sent to the database system, the method further includes:
setting the second variable to the third state.
9. The method of claim 8, wherein setting the second variable to the third state comprises:
stopping putting the query requests into the cache queue, and putting all the received query requests into a transparent transmission queue;
setting the second variable to the third state;
and if the transparent transmission queue comprises the query request related to the data object to be changed, setting the second variable to be in the third state, and then sending the query request related to the data object to be changed in the transparent transmission queue to the database system.
10. The method of claim 1, wherein setting the first variable after the first state further comprises:
according to the first state, putting the query request irrelevant to the data object to be changed into a transparent transmission queue;
and sending the query request which is not related to the data object to be changed in the transparent transmission queue to the database system.
11. An apparatus for processing a query request, comprising:
the first setting module is used for setting a first variable into a first state, and the first state is used for representing the change requirement of a data object in the database system;
the first storage module is used for placing the query request related to the data object to be changed into a cache queue according to the first state;
the change module is used for changing the data object to be changed;
and the first sending module is used for sending the query request in the cache queue to the database system if the data object to be changed is successfully changed.
12. An apparatus for processing a query request, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory that, when executed by the processor, implement the method of any of claims 1-10.
13. A computer-readable storage medium having computer program instructions stored thereon, which when executed by a processor implement the method of any one of claims 1-10.
CN201810936221.8A 2018-08-16 2018-08-16 Query request processing method, device and medium Active CN110858204B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810936221.8A CN110858204B (en) 2018-08-16 2018-08-16 Query request processing method, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810936221.8A CN110858204B (en) 2018-08-16 2018-08-16 Query request processing method, device and medium

Publications (2)

Publication Number Publication Date
CN110858204A true CN110858204A (en) 2020-03-03
CN110858204B CN110858204B (en) 2023-09-19

Family

ID=69634820

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810936221.8A Active CN110858204B (en) 2018-08-16 2018-08-16 Query request processing method, device and medium

Country Status (1)

Country Link
CN (1) CN110858204B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1462958A2 (en) * 2003-03-28 2004-09-29 Microsoft Corporation Systems and methods for requesting and receiving database change notifications
US20050210125A1 (en) * 2000-10-06 2005-09-22 Verizon Laboratories Inc. Mobile cache for dynamically composing user-specific information
CN101329686A (en) * 2008-07-31 2008-12-24 中国科学院计算技术研究所 System for implementing network search caching and search method
CN103390041A (en) * 2013-07-18 2013-11-13 杭州东信北邮信息技术有限公司 Method and system for providing data service based on middleware
CN104407926A (en) * 2014-12-15 2015-03-11 成都英力拓信息技术有限公司 Scheduling method of cloud computing resources
CN104471573A (en) * 2012-08-14 2015-03-25 艾玛迪斯简易股份公司 Updating cached database query results
CN107391764A (en) * 2017-08-31 2017-11-24 江西博瑞彤芸科技有限公司 Business datum querying method
CN107807816A (en) * 2016-09-08 2018-03-16 阿里巴巴集团控股有限公司 The upgrade method of serve end program and database, device and equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050210125A1 (en) * 2000-10-06 2005-09-22 Verizon Laboratories Inc. Mobile cache for dynamically composing user-specific information
EP1462958A2 (en) * 2003-03-28 2004-09-29 Microsoft Corporation Systems and methods for requesting and receiving database change notifications
CN101329686A (en) * 2008-07-31 2008-12-24 中国科学院计算技术研究所 System for implementing network search caching and search method
CN104471573A (en) * 2012-08-14 2015-03-25 艾玛迪斯简易股份公司 Updating cached database query results
CN103390041A (en) * 2013-07-18 2013-11-13 杭州东信北邮信息技术有限公司 Method and system for providing data service based on middleware
CN104407926A (en) * 2014-12-15 2015-03-11 成都英力拓信息技术有限公司 Scheduling method of cloud computing resources
CN107807816A (en) * 2016-09-08 2018-03-16 阿里巴巴集团控股有限公司 The upgrade method of serve end program and database, device and equipment
CN107391764A (en) * 2017-08-31 2017-11-24 江西博瑞彤芸科技有限公司 Business datum querying method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王彦士;王伟;刘朝辉;魏峻;黄涛;: "支持透明集成的数据缓存机制" *

Also Published As

Publication number Publication date
CN110858204B (en) 2023-09-19

Similar Documents

Publication Publication Date Title
CN109032796B (en) Data processing method and device
US20230106118A1 (en) Distributed processing of transactions in a network using timestamps
JP6405255B2 (en) COMMUNICATION SYSTEM, QUEUE MANAGEMENT SERVER, AND COMMUNICATION METHOD
US9026493B1 (en) Multi-master RDBMS improvements for distributed computing environment
CN113094430B (en) Data processing method, device, equipment and storage medium
CN111666134A (en) Method and system for scheduling distributed tasks
CN113742376A (en) Data synchronization method, first server and data synchronization system
WO2018010603A1 (en) Storage mode upgrade method, apparatus and system based on video cloud storage system
CN113094431A (en) Read-write separation method and device and server
CN109284177B (en) Data updating method and device
CN112084254A (en) Data synchronization method and system
CN110858204A (en) Query request processing method, device and medium
CN115914393A (en) Communication method, device, equipment and medium
CN111008202A (en) Distributed transaction processing method and framework
CN113486116A (en) Data synchronization method and device, electronic equipment and computer readable medium
US20190303193A1 (en) Computing system including enhanced application performance based on last completed operation sequence value
CN113761075A (en) Method, device, equipment and computer readable medium for switching databases
CN113138975A (en) Data migration method and device
JP5598089B2 (en) Program, information processing apparatus and information processing method
CN114531394A (en) Data synchronization method and device
CN112182003A (en) Data synchronization method and device
US10310921B2 (en) Computing system including PLSO command to maintain equivalency between independent coupling facilities
CN116401317B (en) Cache data synchronization method and device, electronic equipment and medium
CN110784532B (en) Bidirectional data synchronization method and system
CN113760860B (en) Data reading method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant