WO2022068660A1 - 保持不同存储系统的数据一致的方法以及装置 - Google Patents
保持不同存储系统的数据一致的方法以及装置 Download PDFInfo
- Publication number
- WO2022068660A1 WO2022068660A1 PCT/CN2021/119791 CN2021119791W WO2022068660A1 WO 2022068660 A1 WO2022068660 A1 WO 2022068660A1 CN 2021119791 W CN2021119791 W CN 2021119791W WO 2022068660 A1 WO2022068660 A1 WO 2022068660A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- storage system
- primary key
- version number
- read
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 65
- 238000012545 processing Methods 0.000 claims abstract description 18
- 230000008569 process Effects 0.000 claims description 19
- 230000002085 persistent effect Effects 0.000 claims description 10
- 238000010586 diagram Methods 0.000 description 6
- 230000009471 action Effects 0.000 description 4
- 230000007246 mechanism Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 2
- 230000000717 retained effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000001413 cellular effect Effects 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Definitions
- the embodiments of this specification relate to the field of computer technology, and in particular, to a method for keeping data consistent in different storage systems.
- One or more embodiments of the present specification simultaneously relate to an apparatus for maintaining data consistency in different storage systems, a computing device, and a computer-readable storage medium.
- a storage system such as a persistent data source
- an application service often need to use another storage system (such as a cache system) to obtain data.
- another storage system such as a cache system
- the data of the other storage system also needs to be updated. For example, in order to keep the latest data in the B storage system stored in the A storage system, currently, the A storage system is updated during the write operation, and then the data corresponding to the B storage system is deleted. During the read operation, the B storage system is read first. Return if the data exists, otherwise read the data of the A storage system and update the B storage system.
- the embodiments of the present specification provide a method for keeping data of different storage systems consistent.
- One or more embodiments of this specification simultaneously relate to an apparatus for maintaining data consistency in different storage systems, a computing device, and a computer-readable storage medium, so as to solve the technical defects existing in the prior art.
- a method for maintaining data consistency in different storage systems including: in the case of updating a first storage system by a write operation, processing the first data as a read-incompatible operation with an atomic operation to, and generate or update the corresponding version number for the first primary key in the atomic operation, wherein the first data is the data corresponding to the first primary key targeted by the write operation in the second storage system; in the read operation If the first data cannot be read from the second storage system, the latest version number of the first primary key is obtained, and the second data is read from the first storage system.
- the data is the data corresponding to the first primary key in the first storage system; if they are consistent, the second data is updated to the second storage system by an atomic operation, and in the atomic operation, the The version number corresponding to the first primary key update; if inconsistent, re-enter the step of acquiring the latest version number of the first primary key and reading the second data from the first storage system.
- the first storage system is a persistent data source
- the second storage system is a cache system
- the method further includes: if the latest version number of the first primary key cannot be obtained, generating a corresponding initial value of the version number for the first primary key with an atomic operation.
- acquiring the latest version number of the first primary key includes: sending the second storage system the A request for reading data by a read operation; receiving a message that the data fed back by the second storage system for the request cannot be read, the message carrying the latest version number of the first primary key; obtaining according to the message The latest version number of the first primary key.
- the second storage system provides a hidden acquisition interface, and the hidden acquisition interface is used to acquire the latest version number of the first primary key.
- acquiring the latest version number of the first primary key includes: sending the read operation to the second storage system request for data; receive a message that the data fed back by the second storage system for the request cannot be read; obtain the latest version of the first primary key through the hidden acquisition interface of the second storage system according to the message No.
- the second storage system provides a hidden interface, the hidden interface is used to mark the data as hidden so that it cannot be read by an atomic operation, and in the atomic operation, a corresponding primary key of the data is generated or updated. version number.
- processing the first data as unreadable by an atomic operation, and generating or updating a corresponding version number for the first primary key in the atomic operation includes:
- the operation to update the first storage system by calling the hidden interface, the first data is marked as hidden so that it cannot be read by an atomic operation, and in the atomic operation, the corresponding data is generated or updated for the first primary key. version number.
- processing the first data to be unreadable by an atomic operation includes: in the case of updating the first storage system by a write operation, performing an atomic operation on all data. The data corresponding to the first primary key targeted by the write operation is deleted in the second storage system.
- an apparatus for maintaining data consistency in different storage systems comprising: a writing module configured to, in the case of updating the first storage system by a writing operation, perform atomic operations on the first storage system The data processing cannot be read, and the corresponding version number is generated or updated for the first primary key in the atomic operation, wherein the first data is the first primary key for which the write operation is in the second storage system corresponding data.
- a read module configured to obtain the latest version number of the first primary key in the case that the read operation cannot read the first data from the second storage system, and read the first data from the first storage system Second data, where the second data is data corresponding to the first primary key in the first storage system.
- the comparison module is configured to compare the acquired version number with the latest version number of the first primary key, and if it is inconsistent, trigger the reading module to re-enter the acquisition of the latest version number of the first primary key, and from the first primary key A step of reading out the second data from the storage system.
- a data update module is configured to update the second data to the second storage system with an atomic operation if the comparison module determines that they are consistent, and update the corresponding first primary key in the atomic operation version number.
- a computing device including: a memory and a processor; the memory is used for storing computer-executable instructions, and the processor is used for executing the computer-executable instructions: in writing In the case of operating to update the first storage system, an atomic operation is used to process the first data as unreadable, and in the atomic operation, a corresponding version number is generated or updated for the first primary key, wherein the first data The data corresponding to the first primary key for the write operation in the second storage system; in the case that the read operation cannot read the first data from the second storage system, obtain the latest data of the first primary key.
- the second data is the data corresponding to the first primary key in the first storage system; compare the obtained version number with the first Compare the latest version numbers of a primary key; if they are consistent, update the second data to the second storage system with an atomic operation, and update the corresponding version number for the first primary key in the atomic operation; If not, re-enter the step of acquiring the latest version number of the first primary key and reading the second data from the first storage system.
- a computer-readable storage medium which stores computer-executable instructions, and when the instructions are executed by a processor, implements any one of the methods for maintaining data consistency in different storage systems A step of.
- An embodiment of the present specification provides a method for keeping data in different storage systems consistent, because in the case of updating the first storage system by a write operation, the method uses an atomic operation to process the first data as unreadable and for the first storage system.
- a primary key generates or updates the corresponding version number
- the first data is the data corresponding to the first primary key targeted by the write operation in the second storage system, so that the update of the data and the version number as a whole through the atomic operation is stored in the second storage system.
- Pre-occupancy is implemented in the second storage system to effectively prevent inconsistencies caused by concurrent updates.
- the latest version number of the first primary key is obtained, and the second data is read from the first storage system , and compare the obtained version number with the latest version number of the first primary key. If the version numbers are the same, it means that after the read operation reads the second data from the first storage system, the read data is not updated, and the read second data can be updated to the second storage system by atomic operation
- the system also updates the corresponding version number for the first primary key in the atomic operation, which can effectively prevent inconsistency caused by concurrent reads.
- the version numbers are inconsistent, it means that after the read operation reads the second data from the first storage system, the second data in the first storage system has been updated, and the corresponding version numbers need to be re-obtained for comparison, so as to compare the latest The second data is updated to the second storage system, thereby keeping the data of the first storage system and the second storage system consistent. It can be seen that the method provided by the embodiments of this specification uses the update of the data and the version number as an atomic operation in the second storage system to achieve data consistency between the first storage system and the second storage system by pre-occupying.
- FIG. 1 is a flowchart of a method for maintaining data consistency in different storage systems provided by an embodiment of the present specification
- FIG. 2 is a flow chart of a write processing process of a method for maintaining data consistency in different storage systems provided by an embodiment of the present specification
- FIG. 3 is a flow chart of a read processing process of a method for maintaining data consistency in different storage systems provided by an embodiment of the present specification
- FIG. 4 is a schematic structural diagram of an apparatus for maintaining data consistency in different storage systems provided by an embodiment of the present specification
- FIG. 5 is a schematic structural diagram of an apparatus for maintaining data consistency in different storage systems provided by another embodiment of the present specification.
- FIG. 6 is a structural block diagram of a computing device provided by an embodiment of the present specification.
- Primary key The representation of data stored in the storage system, which is used to obtain the corresponding data (value).
- Version number The version information of the data, which can be updated by means of atomic auto-increment when it is modified in the storage system.
- Atomic operation refers to an operation that will not be interrupted by the thread scheduling mechanism. Once the atomic operation starts, it will run until the end of the atomic operation, without switching to another thread in the middle.
- the data update in the cache and the atomic auto-increment of the version number are a complete whole, updated together in one atomic operation without being interrupted by the thread scheduling mechanism.
- a method for maintaining data consistency in different storage systems is provided, and this specification also relates to a device for maintaining data consistency in different storage systems, a computing device, and a computer-readable storage medium. Detailed descriptions are given in the following examples one by one.
- FIG. 1 shows a flowchart of a method for maintaining data consistency in different storage systems according to an embodiment of the present specification, including steps 102 to 108 .
- Step 102 In the case of updating the first storage system by a write operation, the first data is processed as unreadable by an atomic operation, and a corresponding version number is generated or updated for the first primary key in the atomic operation, wherein, The first data is data corresponding to the first primary key targeted by the write operation in the second storage system.
- Step 104 In the case that the read operation cannot read the first data from the second storage system, obtain the latest version number of the first primary key, and read the second data from the first storage system , and the second data is the data corresponding to the first primary key in the first storage system.
- Step 106 Compare the acquired version number with the latest version number of the first primary key.
- step 104 If not, then re-enter the step of obtaining the latest version number of the first primary key in step 104 and reading the second data from the first storage system.
- Step 108 If they are consistent, update the second data to the second storage system in an atomic operation, and update the corresponding version number for the first primary key in the atomic operation.
- the method processes the first data to be unreadable with an atomic operation and generates or updates the corresponding version number for the first primary key, while the first data is
- the data corresponding to the first primary key of the write operation is in the second storage system, so that the update of the data and the version number through the atomic operation as a whole realizes pre-occupancy in the second storage system, effectively preventing concurrent updates from causing of inconsistency.
- the first data needs to be read, if it cannot be read from the second storage system, the latest version number of the first primary key is obtained, and the second data is read from the first storage system , and compare the obtained version number with the latest version number of the first primary key.
- the version numbers are the same, it means that after the read operation reads the second data from the first storage system, the read data is not updated, and the read second data can be updated to the second storage system by atomic operation
- the system also updates the corresponding version number for the first primary key in the atomic operation, which can effectively prevent inconsistency caused by concurrent reads.
- the version numbers are inconsistent, it means that after the read operation reads the second data from the first storage system, the second data in the first storage system has been updated, and the corresponding version numbers need to be re-obtained for comparison, so as to compare the latest
- the second data is updated to the second storage system, thereby keeping the data of the first storage system and the second storage system consistent. It can be seen that the method provided by the embodiments of this specification uses the update of the data and the version number as an atomic operation in the second storage system to achieve data consistency between the first storage system and the second storage system by pre-occupying.
- the method performs the update of the data and the version number as a whole in an atomic operation, thereby ensuring that the data of the first storage system and the second storage system are consistent.
- the methods provided by the embodiments of this specification can be applied to an application scenario in which a persistent data source (eg, a database) is kept consistent with cached data.
- a persistent data source eg, a database
- the first storage system may be a persistent data source
- the second storage system may be a cache system.
- the methods provided in the embodiments of the present specification can be applied inside a cache system, so that data update and version update can be updated together in an atomic manner in an atomic operation as a complete whole within the cache system.
- the method provided by the embodiments of the present specification by pre-occupying the entire data and the update of the version number as an atomic operation in the cache system, the consistency of the data of the persistent data source and the cache system is realized.
- one or more embodiments of this specification further include: if the latest version number of the first primary key cannot be obtained, performing an atomic operation on The first primary key generates a corresponding initial value of the version number.
- the reading process is further improved, which can effectively ensure that the data corresponding to the primary key is not updated, and the initial version number can still be used to maintain the different storage systems. Data consistency purpose.
- the specific implementation manner of acquiring the latest version number of the primary key is not limited.
- a message fed back by the second storage system may carry a version number.
- acquiring the latest version number of the first primary key includes: sending the data to the second storage system. the request for reading data by the read operation; receive a message that the data fed back by the second storage system for the request cannot be read, and the message carries the latest version number of the first primary key; according to the message Obtain the latest version number of the first primary key.
- the version number carried in the message can be directly extracted from the message returned by the second storage system, the process is clear, and the amount of data transmission is small.
- the second storage system provides a hidden acquisition interface, and the hidden acquisition interface is used to acquire the latest version number of the first primary key.
- acquiring the latest version number of the first primary key includes: sending the read operation to the second storage system request for data; receive a message that the data fed back by the second storage system for the request cannot be read; obtain the latest version of the first primary key through the hidden acquisition interface of the second storage system according to the message No.
- the version number can be obtained through the hidden acquisition interface.
- the second storage system does not need to return additional information and attributes, which can reduce the need for necessary data transfer.
- the specific implementation manner in which the data processing cannot be read is not limited.
- the data can be identified as hidden, and for another example, the data can be deleted so that it cannot be read.
- the second storage system provides a hidden interface, and the hidden interface is used to identify data as hidden so that it cannot be read by an atomic operation, and in the Generate or update the corresponding version number for the primary key of the data in the atomic operation.
- processing the first data as unreadable by an atomic operation, and generating or updating a corresponding version number for the first primary key in the atomic operation includes:
- the operation to update the first storage system by calling the hidden interface, the first data corresponding to the first primary key in the second storage system is marked as hidden so that it cannot be read by an atomic operation, and the atomic operation is performed.
- processing the first data to be unreadable by an atomic operation includes: updating the first storage system by a write operation
- the first data corresponding to the first primary key targeted by the write operation in the second storage system is deleted by an atomic operation.
- the primary key when the data corresponding to the primary key in the second storage system is deleted, the primary key can be retained, and its corresponding value can be set to null, which facilitates setting the corresponding version number and improves the processing efficiency of write logic.
- the method for maintaining data consistency of different storage systems provided by the embodiments of this specification is used as an example to maintain the consistency between persistent data sources and caches.
- the data-consistent method is further described.
- a version number management mechanism is added to the cache system, and a data read and write interface is provided externally.
- a set of protocols supports the special attributes of the identification data, that is, the identification data exists but the ordinary data access interface cannot read it. , which can only be accessed by a special interface, and supports atomically incremental version numbers of data, which can support consistent updates of persistent data and caches.
- the cache system provides a protocol to support the existence of identification data, but ordinary data access interfaces such as “get” interface cannot be read, while the hidden access interface such as “getHidden” described in the embodiments of this specification can be accessed, and supports atomic data Increment the version number. Therefore, the cache system of this embodiment additionally provides a set of interfaces such as "hide/getHidden” to support hidden identification of data.
- FIG. 2 shows a flow chart of a write processing process of a method for maintaining data consistency in different storage systems provided by an embodiment of the present specification, and the specific steps include steps 202 to 204 .
- Step 202 Write the update data to the persistent data source.
- Step 204 Use the "hide” interface to hide the data corresponding to the primary key of the updated data in the cache system, and at the same time increment the version number corresponding to the primary key.
- Version number When data is being written, the version number corresponding to the primary key is incremented.
- FIG. 3 shows a flow chart of a read processing process of a method for keeping data in different storage systems consistent according to an embodiment of the present specification, and the specific steps include steps 302 to 318 .
- Step 302 Read the data corresponding to the key in the cache system through the "get" interface.
- Step 304 Determine whether the "get" interface returns the data corresponding to the key.
- step 306 If not returned, go to step 306 .
- Step 306 Use the "getHidden” interface to obtain the version number corresponding to the key.
- Step 308 Determine whether the "getHidden” interface returns the version number corresponding to the key.
- Step 310 If not, hide the data corresponding to the key by using the "hide" interface with atomic operations, so that the data corresponding to the key in the cache system is initialized to be empty and the corresponding version number is initialized to "1".
- Re-enter step 306 If not, hide the data corresponding to the key by using the "hide" interface with atomic operations, so that the data corresponding to the key in the cache system is initialized to be empty and the corresponding version number is initialized to "1".
- Step 312 If yes, obtain the data corresponding to the key from the persistent data source.
- Step 314 Use the version number and the data obtained in Step 306 to call the "put" interface to write the cache, "put": used to perform the write operation of the cache, if the input version number is equal to the current latest version of the data in the cache system number, it is allowed to write to the cache while the version number of the data in the cache system is atomically incremented, and the write succeeds, otherwise the write fails.
- Step 316 Determine whether the writing is successful.
- step 306 If not, return to step 306 . If yes, go to step 318.
- Step 318 end the process.
- step 314 the "put" interface is called in step 314, and the "put" operation will compare the version number obtained in step 306 with the latest version number of the key in the cache system. If it is inconsistent, the writing fails and returns to step 306 , if they are consistent, the writing is successful, and the process goes to step 318 to end the process.
- FIG. 4 shows the structure of an apparatus for keeping data in different storage systems consistent according to an embodiment of this specification. Schematic. As shown in FIG. 4 , the apparatus includes: a writing module 402 , a reading module 404 , a comparing module 406 and a data updating module 408 .
- the writing module 402 can be configured to process the first data as unreadable by an atomic operation when the first storage system is updated by a write operation, and generate or update the corresponding first primary key in the atomic operation , where the first data is the data corresponding to the first primary key targeted by the write operation in the second storage system.
- the read module 404 can be configured to obtain the latest version number of the first primary key in the case that the read operation cannot read the first data from the second storage system, and obtain the latest version number of the first primary key from the first storage system Second data is read out, where the second data is data corresponding to the first primary key in the first storage system.
- the comparison module 406 can be configured to compare the acquired version number with the latest version number of the first primary key, and if they are inconsistent, trigger the reading module 404 to re-enter the acquisition of the latest version number of the first primary key, and the step of reading the second data from the first storage system.
- the data update module 408 can be configured to update the second data to the second storage system in an atomic operation if the comparison module 406 determines that they are consistent, and in the atomic operation for the first The version number corresponding to the primary key update.
- the device processes the first data as unreadable by atomic operations and generates or updates the corresponding version number for the first primary key, while the first data is
- the data corresponding to the first primary key of the write operation is in the second storage system, so that the update of the data and the version number through the atomic operation as a whole realizes pre-occupancy in the second storage system, effectively preventing concurrent updates from causing of inconsistency.
- the first data needs to be read, if it cannot be read from the second storage system, the latest version number of the first primary key is obtained, and the second data is read from the first storage system , and compare the obtained version number with the latest version number of the first primary key.
- the version numbers are the same, it means that after the read operation reads the second data from the first storage system, the read data is not updated, and the read second data can be updated to the second storage system by atomic operation
- the system also updates the corresponding version number for the first primary key in the atomic operation, which can effectively prevent inconsistency caused by concurrent reads.
- the version numbers are inconsistent, it means that after the read operation reads the second data from the first storage system, the second data in the first storage system has been updated, and the corresponding version numbers need to be re-obtained for comparison, so as to compare the latest
- the second data is updated to the second storage system, thereby keeping the data of the first storage system and the second storage system consistent. It can be seen that the apparatus provided in the embodiments of this specification uses the update of the data and the version number as an atomic operation in the second storage system to achieve data consistency between the first storage system and the second storage system by pre-occupying.
- FIG. 5 shows a schematic structural diagram of an apparatus for maintaining data consistency in different storage systems according to another embodiment of the present specification.
- the apparatus may further include: a version initialization module 412, which may be configured to perform an atomic operation on the first primary key if the reading module 404 cannot obtain the latest version number of the first primary key Generate the corresponding version number initial value.
- a version initialization module 412 which may be configured to perform an atomic operation on the first primary key if the reading module 404 cannot obtain the latest version number of the first primary key Generate the corresponding version number initial value.
- the reading process is further improved, which can effectively ensure that the data corresponding to the primary key is not updated, and the initial version number can still be used to maintain the different storage systems. Data consistency purpose.
- the reading module 404 may include: a request sending submodule 4042 , a message receiving submodule 4044 , a version obtaining submodule 4046 and a data obtaining submodule 4048 .
- the request sending sub-module 4042 may be configured to send a request for reading data by the read operation to the second storage system.
- the message receiving sub-module 4044 may be configured to receive a message that the data fed back by the second storage system for the request cannot be read, and the message carries the latest version number of the first primary key.
- the version obtaining sub-module 4046 may be configured to obtain the latest version number of the first primary key according to the message.
- the data acquisition sub-module 4048 may be configured to read data corresponding to the first primary key from the first storage system.
- the version number carried in the message can be directly extracted from the message returned by the second storage system, the process is clear, and the amount of data transmission is small.
- the second storage system provides a hidden acquisition interface, and the hidden acquisition interface is used to acquire the latest version number of the first primary key.
- the request sending sub-module 4042 may be configured to send a request for reading data by the read operation to the second storage system.
- the message receiving sub-module 4044 may be configured to receive a message that the data fed back by the second storage system for the request cannot be read.
- the version obtaining sub-module 4046 may be configured to obtain the latest version number of the first primary key through a hidden obtaining interface of the second storage system according to the message.
- the version number can be obtained through the hidden acquisition interface.
- the second storage system does not need to return additional information and attributes, which can reduce the need for necessary data transfer.
- the second storage system provides a hidden interface
- the hidden interface is used to identify data as hidden so that it cannot be read in an atomic operation, and in the atomic operation, the data is targeted
- the primary key for generating or updating the corresponding version number.
- the writing module 402 can be configured to, in the case of updating the first storage system by a writing operation, by calling the hidden interface, to mark the first data as hidden so that it cannot be read by an atomic operation, and in the atomic operation. In the operation, a corresponding version number is generated or updated for the first primary key.
- marking the data as hidden the existence of the primary key in the second storage system can be maintained, so that the corresponding version number can be directly set for the primary key, and the processing efficiency of the write logic can be improved.
- the writing module 402 may be configured to, in the case that the writing operation updates the first storage system, use an atomic operation to store the first primary key targeted by the writing operation in the second storage system Delete the corresponding data in .
- the primary key when the first data corresponding to the primary key in the second storage system is deleted, the primary key can be retained, and its corresponding value can be set to null, which facilitates setting the corresponding version number and improves the processing efficiency of write logic .
- the above is a schematic solution of an apparatus for maintaining data consistency of different storage systems according to this embodiment. It should be noted that the technical solution of the device for maintaining data consistency in different storage systems and the technical solution of the above-mentioned method for maintaining data consistency in different storage systems belong to the same concept, and the technical solution of the device for maintaining data consistency in different storage systems is not the same. For details of the detailed description, reference may be made to the description of the technical solution of the method for maintaining data consistency in different storage systems above.
- FIG. 6 shows a structural block diagram of a computing device 600 provided according to an embodiment of the present specification.
- Components of the computing device 600 include, but are not limited to, memory 610 and processor 620 .
- the processor 620 is connected with the memory 610 through the bus 630, and the database 650 is used for saving data.
- Computing device 600 also includes access device 640 that enables computing device 600 to communicate via one or more networks 660 .
- networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet.
- Access device 640 may include one or more of any type of network interface (eg, network interface card (NIC)), wired or wireless, such as IEEE 802.11 wireless local area network (WLAN) wireless interface, World Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and the like.
- NIC network interface card
- computing device 600 may also be connected to each other, such as through a bus.
- bus may also be connected to each other, such as through a bus.
- FIG. 6 the structural block diagram of the computing device shown in FIG. 6 is only for the purpose of example, rather than limiting the scope of this specification. Those skilled in the art can add or replace other components as required.
- Computing device 600 may be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (eg, tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (eg, smart phones) ), wearable computing devices (eg, smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs.
- Computing device 600 may also be a mobile or stationary server.
- the processor 620 is configured to execute the following computer-executable instructions:
- the first data is processed as unreadable by an atomic operation, and a corresponding version number is generated or updated for the first primary key in the atomic operation, wherein the first data
- One piece of data is the data corresponding to the first primary key targeted by the write operation in the second storage system
- the read operation cannot read the first data from the second storage system, obtain the latest version number of the first primary key, and read the second data from the first storage system, and the The second data is the data corresponding to the first primary key in the first storage system;
- the above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned method for maintaining data consistency in different storage systems belong to the same concept, and the details that are not described in detail in the technical solution of the computing device can be referred to above. A description of the technical scheme of the data-consistent method.
- An embodiment of the present specification further provides a computer-readable storage medium, which stores computer instructions, which, when executed by a processor, are used for:
- the first data is processed as unreadable by an atomic operation, and a corresponding version number is generated or updated for the first primary key in the atomic operation, wherein the first data
- One piece of data is the data corresponding to the first primary key targeted by the write operation in the second storage system
- the read operation cannot read the first data from the second storage system, obtain the latest version number of the first primary key, and read the second data from the first storage system, and the The second data is the data corresponding to the first primary key in the first storage system;
- the computer instructions include computer program code, which may be in source code form, object code form, an executable file, some intermediate form, or the like.
- the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable media may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer-readable media Electric carrier signals and telecommunication signals are not included.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computational Linguistics (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
Claims (10)
- 一种保持不同存储系统的数据一致的方法,包括:在写操作更新第一存储系统的情况下,以原子操作将第一数据处理为读取不到,且在所述原子操作中针对第一主键生成或更新对应的版本号,其中,所述第一数据为所述写操作针对的第一主键在第二存储系统中对应的数据;在读操作从所述第二存储系统读取不到所述第一数据的情况下,获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据,所述第二数据为所述第一主键在所述第一存储系统中对应的数据;将获取的版本号与所述第一主键最新的版本号进行比较;如果一致,则以原子操作将所述第二数据更新到所述第二存储系统,且在所述原子操作中针对所述第一主键更新对应的版本号;如果不一致,则重新进入所述获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据的步骤。
- 根据权利要求1所述的方法,所述第一存储系统为持久化数据源,所述第二存储系统为缓存系统。
- 根据权利要求1所述的方法,还包括:如果获取不到所述第一主键最新的版本号,则以原子操作针对所述第一主键生成对应的版本号初始值。
- 根据权利要求1所述的方法,所述在读操作从所述第二存储系统读取不到所述第一数据的情况下,获取所述第一主键最新的版本号包括:向所述第二存储系统发送所述读操作读取数据的请求;接收所述第二存储系统针对所述请求反馈的数据无法被读取到的消息,所述消息携带了所述第一主键最新的版本号;根据所述消息获取所述第一主键最新的版本号。
- 根据权利要求1所述的方法,所述第二存储系统提供了隐藏获取接口,所述隐藏获取接口用于获取所述第一主键最新的版本号;所述在读操作从所述第二存储系统读取不到所述第一数据的情况下,获取所述第一主键最新的版本号包括:向所述第二存储系统发送所述读操作读取数据的请求;接收所述第二存储系统针对所述请求反馈的数据无法被读取到的消息;根据所述消息通过所述第二存储系统的隐藏获取接口获取所述第一主键最新的版本号。
- 根据权利要求1所述的方法,所述第二存储系统提供了隐藏接口,所述隐藏接口用于以原子操作将数据标识为隐藏以无法被读取,且在所述原子操作中针对数据的主键生成或更新对应的版本号;所述在写操作更新第一存储系统的情况下,以原子操作将第一数据处理为读取不到,且在所述原子操作中针对第一主键生成或更新对应的版本号包括:在写操作更新第一存储系统的情况下,通过调用所述隐藏接口,以原子操作将第一数据标识为隐藏以无法被读取,且在所述原子操作中针对所述第一主键生成或更新对应的版本号。
- 根据权利要求1所述的方法,所述在写操作更新第一存储系统的情况下,以原子操作将第一数据处理为读取不到包括:在写操作更新第一存储系统的情况下,以原子操作将所述写操作针对的第一主键在第二存储系统中对应的第一数据删除。
- 一种保持不同存储系统的数据一致的装置,包括:写模块,被配置为在写操作更新第一存储系统的情况下,以原子操作将第一数据处理为读取不到,且在所述原子操作中针对第一主键生成或更新对应的版本号,其中,所述第一数据为所述写操作针对的第一主键在第二存储系统中对应的数据;读模块,被配置为在读操作从所述第二存储系统读取不到所述第一数据的情况下,获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据,所述第二数据为所述第一主键在所述第一存储系统中对应的数据;比较模块,被配置为将获取的版本号与所述第一主键最新的版本号进行比较,如果不一致,触发读模块重新进入所述获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据的步骤;数据更新模块,被配置为如果所述比较模块判定一致,则以原子操作将所述第二数据更新到所述第二存储系统,且在所述原子操作中针对所述第一主键更新对应的版本号。
- 一种计算设备,包括:存储器和处理器;所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:在写操作更新第一存储系统的情况下,以原子操作将第一数据处理为读取不到,且在所述原子操作中针对第一主键生成或更新对应的版本号,其中,所述第一数据为所述写操作针对的第一主键在第二存储系统中对应的数据;在读操作从所述第二存储系统读取不到所述第一数据的情况下,获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据,所述第二数据为所述第一主键在所述第一存储系统中对应的数据;将获取的版本号与所述第一主键最新的版本号进行比较;如果一致,则以原子操作将所述第二数据更新到所述第二存储系统,且在所述原子操作中针对所述第一主键更新对应的版本号;如果不一致,则重新进入所述获取所述第一主键最新的版本号,且从所述第一存储系统读取出第二数据的步骤。
- 一种计算机可读存储介质,其存储有计算机指令,该指令被处理器执行时实现权利要求1至7任意一项所述保持不同存储系统的数据一致的方法的步骤。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/246,666 US20230281187A1 (en) | 2020-09-29 | 2021-09-23 | Method for keeping data consistent across different storage systems, computing device, and storage medium |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011052190.3A CN112286947B (zh) | 2020-09-29 | 2020-09-29 | 保持不同存储系统的数据一致的方法以及装置 |
CN202011052190.3 | 2020-09-29 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022068660A1 true WO2022068660A1 (zh) | 2022-04-07 |
Family
ID=74422294
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/119791 WO2022068660A1 (zh) | 2020-09-29 | 2021-09-23 | 保持不同存储系统的数据一致的方法以及装置 |
Country Status (3)
Country | Link |
---|---|
US (1) | US20230281187A1 (zh) |
CN (1) | CN112286947B (zh) |
WO (1) | WO2022068660A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112286947B (zh) * | 2020-09-29 | 2022-10-04 | 阿里云计算有限公司 | 保持不同存储系统的数据一致的方法以及装置 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170054802A1 (en) * | 2015-08-19 | 2017-02-23 | Facebook, Inc. | Read-after-write consistency in data replication |
CN109862102A (zh) * | 2019-02-25 | 2019-06-07 | 交通银行股份有限公司 | 一种分布式数据多副本并发控制系统、服务器及方法 |
CN110955719A (zh) * | 2018-09-27 | 2020-04-03 | 阿里巴巴集团控股有限公司 | 一种数据存取处理设备、系统和方法 |
CN112286947A (zh) * | 2020-09-29 | 2021-01-29 | 阿里云计算有限公司 | 保持不同存储系统的数据一致的方法以及装置 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7636814B1 (en) * | 2005-04-28 | 2009-12-22 | Symantec Operating Corporation | System and method for asynchronous reads of old data blocks updated through a write-back cache |
CN102073494B (zh) * | 2010-12-30 | 2014-05-07 | 用友软件股份有限公司 | 缓存数据管理方法和装置 |
JP6199808B2 (ja) * | 2014-06-06 | 2017-09-20 | 株式会社東芝 | データベース装置およびデータアクセス方法 |
CN106557278A (zh) * | 2015-09-30 | 2017-04-05 | 腾讯科技(深圳)有限公司 | 一种缓存数据持久化的方法 |
-
2020
- 2020-09-29 CN CN202011052190.3A patent/CN112286947B/zh active Active
-
2021
- 2021-09-23 US US18/246,666 patent/US20230281187A1/en active Pending
- 2021-09-23 WO PCT/CN2021/119791 patent/WO2022068660A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170054802A1 (en) * | 2015-08-19 | 2017-02-23 | Facebook, Inc. | Read-after-write consistency in data replication |
CN110955719A (zh) * | 2018-09-27 | 2020-04-03 | 阿里巴巴集团控股有限公司 | 一种数据存取处理设备、系统和方法 |
CN109862102A (zh) * | 2019-02-25 | 2019-06-07 | 交通银行股份有限公司 | 一种分布式数据多副本并发控制系统、服务器及方法 |
CN112286947A (zh) * | 2020-09-29 | 2021-01-29 | 阿里云计算有限公司 | 保持不同存储系统的数据一致的方法以及装置 |
Also Published As
Publication number | Publication date |
---|---|
CN112286947B (zh) | 2022-10-04 |
CN112286947A (zh) | 2021-01-29 |
US20230281187A1 (en) | 2023-09-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110399356B (zh) | 一种在线数据迁移方法、装置、计算设备及存储介质 | |
US8719845B2 (en) | Sharing and synchronization of objects | |
CN110096334B (zh) | 缓存处理方法、装置、设备及计算机可读存储介质 | |
JP2005222533A (ja) | 挿入されたメッセージ修正を使用した、コード作成のため受信したメッセージディスパッチの調整 | |
CN114661248B (zh) | 数据处理方法及装置 | |
CN113204435B (zh) | 数据处理方法以及系统 | |
CN111737002B (zh) | 一种链式存储请求的处理方法、装置、设备及可读介质 | |
CN113297320A (zh) | 分布式数据库系统及数据处理方法 | |
CN112306993B (zh) | 基于Redis的数据读取方法、装置、设备及可读存储介质 | |
WO2022068660A1 (zh) | 保持不同存储系统的数据一致的方法以及装置 | |
CN107451070B (zh) | 一种数据的处理方法和服务器 | |
WO2021259188A1 (zh) | 路由读请求、反馈报文的方法以及各自装置、数据库 | |
CN114328626A (zh) | 多数据源动态切换方法、系统及存储介质 | |
CN113297231A (zh) | 数据库处理方法及装置 | |
US10467143B1 (en) | Event-driven cache | |
CN110955719A (zh) | 一种数据存取处理设备、系统和方法 | |
CN116483556A (zh) | 数据处理方法及加速器系统 | |
CN109445966B (zh) | 事件处理方法、装置、介质和计算设备 | |
CN112546617B (zh) | 任务处理方法及装置 | |
CN114217986A (zh) | 数据处理方法、装置、设备、存储介质及产品 | |
US20140149463A1 (en) | Method, apparatus, system and computer program product for managing data in database | |
CN113342270A (zh) | 卷卸载方法、装置和电子设备 | |
CN111078632A (zh) | 一种文件数据的管理方法及装置 | |
CN115361435B (zh) | 数据处理方法 | |
CN116028677B (zh) | 数据操作方法以及系统 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21874321 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21874321 Country of ref document: EP Kind code of ref document: A1 |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 13.11.2023) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21874321 Country of ref document: EP Kind code of ref document: A1 |