A read cache method and system based on log writing

Through the read caching method based on log writing, logical sharding and data index are used to store and read data in HDD disks, which solves the problems of low efficiency and data inconsistency in frequent reading of data in HDD disk components, and achieves efficient and safe Read cache enables fast recovery of cached indexes after process failures.

CN117348809BActive Publication Date: 2024-09-10CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311293481.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-08
Publication Date
2024-09-10
Estimated Expiration
2043-10-08

AI Technical Summary

Technical Problem

In existing technology, in storage clusters using HDD disk components, when data is frequently read, the read cache efficiency is low and there is a risk of data inconsistency. Especially when the data is modified after being read, the processing flow is complex, affecting efficiency and security. sex.

Method used

Adopt a read cache method based on log writing, write user data logs to the data hard disk pool through logical sharding, create data indexes, and record cache metadata to quickly restore the cache when reading, avoid data modification and improve reading efficiency.

Benefits of technology

An efficient and safe read cache is implemented. The data will not be modified. The logic is simple. It can read recently frequently accessed data and quickly restore the cache index after a process failure to avoid re-identification of hot data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117348809B
    Figure CN117348809B
Patent Text Reader

Abstract

The present invention relates to the field of cache reading technology, and provides a log-writing-based read cache method and system, the method of the present invention comprising: writing a user's data log to a data hard disk pool through logical sharding; when writing the data log to the data hard disk pool, caching the data and creating a data index; reading corresponding data from the data hard disk pool according to the data index; recording cache metadata, and when a read cache process fails, restoring cache reading through the recorded cache metadata. The log-writing-based read cache method and system of the present invention can improve the efficiency and security of read cache.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cache reading technology, and in particular to a log writing-based read cache method and system. Background Art

[0002] HDDs have slow read and write performance, especially during random reads and writes, where performance is even lower due to the reciprocating motion of the robotic arm. Therefore, in storage clusters using HDDs, SSDs are often used as accelerators. On the one hand, data must first be written to the SSDs and then returned to the backend, which then writes the data in large blocks to the HDDs to accelerate storage writes. On the other hand, frequently read data must be written to an SSD cache disk and then read directly from the SSD.

[0003] In practical applications, technologies that cache frequently read data in SSDs must account for situations where data is modified after being read into the cache. For example, when writing data, the system checks whether the data is in the cache and, if so, modifies the cached data. Alternatively, when reading data, the system first reads from the write cache and, if the data cannot be read from the write cache, reads from main memory. These complex processes not only affect read efficiency but also increase the risk of data inconsistency.

[0004] Therefore, how to provide a more efficient and secure read cache method has become a technical problem that needs to be solved urgently. Summary of the Invention

[0005] In view of this, in order to overcome the deficiencies of the prior art, the present invention aims to provide a read cache method and system based on log writing.

[0006] According to a first aspect of the present invention, a log-write-based read cache method is provided, comprising:

[0007] Write user data logs to the data hard disk pool through logical sharding;

[0008] When writing data logs to the data hard disk pool, cache the data and create a data index;

[0009] Read the corresponding data from the data hard disk pool according to the data index;

[0010] Record cache metadata. When a cache read process fails, cache reads can be restored using the recorded cache metadata.

[0011] Preferably, in the read cache method based on log writing of the present invention, the user's data log is written to the data hard disk pool through logical sharding, including: obtaining the user's data from the client, scattering the obtained data onto logical shards according to the user's logical address space, allocating space from the data hard disk pool for the logical shards, and appending the data on the logical shards to the corresponding space of the data hard disk pool in the form of logs.

[0012] Preferably, in the log-writing-based read cache method of the present invention, when writing data logs to a data hard disk pool, caching the data and creating a data index include:

[0013] When data is appended from a logical shard to the data disk pool in the form of logs, the data is cached in the form of key-value pairs locally on the node where the logical shard is located. A cache hash table is built in memory based on the key-value pairs of the cached data.

[0014] Create a data index and record the data log write address in the created data index.

[0015] Preferably, in the log write-based read cache method of the present invention, data is cached in the form of key-value pairs locally at the node where the logical shard is located, and a cache hash table is constructed in the memory according to the key-value pairs of the cached data, including: using the log write address of the data as the key and the data as the value, caching the data locally at the node where the logical shard is located, and constructing a cache hash table in the memory according to the key-value pairs of the cached data.

[0016] Preferably, in the read cache method based on log writing of the present invention, the data is cached and a data index is created, including: using the object name and offset written in the log as the key of the data, recording the key of the data in the data index created in the memory, and pointing the key of the data to the corresponding cached data.

[0017] Preferably, in the log write-based read cache method of the present invention, corresponding data is read from the data hard disk pool according to the data index, including: when reading data, first reading the data index, and reading the corresponding data from the data hard disk pool according to the log write address recorded in the data index.

[0018] Preferably, in the log write-based read cache method of the present invention, corresponding data is read from the data hard disk pool according to the data index, including: querying and obtaining the log write address corresponding to the data to be read from the data index, and querying the cache address of the data to be read through the cache hash table.

[0019] Preferably, in the log-writing-based read cache method of the present invention, cache metadata is recorded. When a failure occurs in the read cache process, cache reading is restored using the recorded cache metadata, including:

[0020] The cache metadata of the data is recorded in the memory in the form of a log. The cache metadata log is obtained and a cache metadata threshold is set. When the obtained cache metadata is greater than the set cache metadata threshold, the cache metadata is persisted.

[0021] When a failure occurs in the cache read process, the cache metadata log is scanned, and the key-value pairs in the corresponding cache metadata log are reinserted into the cache hash table in memory to restore the cache information of the cached data.

[0022] According to a second aspect of the present invention, a read cache system based on log writing is provided, which includes a cache read server, which is used to write the user's data log to the data hard disk pool through logical sharding; when writing the data log to the data hard disk pool, cache the data and create a data index; read the corresponding data from the data hard disk pool according to the data index; record cache metadata, and when the read cache process fails, restore the cache read through the recorded cache metadata.

[0023] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present invention when executing the program.

[0024] The log-writing-based read cache method and system of the present invention have the following beneficial technical effects:

[0025] 1. Cache data using the end log write address. The cached data will not be modified and is all newly written, making the cache logic simple.

[0026] 2. Use bitmaps and time to record cache reads, enabling reading of recently accessed data. For sequential reads, data to be read can be pre-fetched in advance.

[0027] 3. Cache data records the cache key value information. After a process failure, the cache metadata can be scanned to rebuild the cache index, eliminating the need to re-identify hot data and regenerate the cache. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0029] Figure 1 This is an example diagram of the technical principle of the present invention;

[0030] Figure 2 An example diagram of the reading process of cached data in the prior art;

[0031] Figure 3 This is an example diagram of the process of reading cache data in the method of the present invention;

[0032] Figure 4 Schematic diagram of a system for a log-write-based read cache method applicable to an embodiment of the present invention;

[0033] Figure 5 A flowchart of a log-write-based read cache method according to an embodiment of the present invention;

[0034] Figure 6 This is an example diagram of the read cache memory index format in the method of this embodiment;

[0035] Figure 7 This is an example diagram of the storage format of cache metadata in the method of an embodiment of the present invention;

[0036] Figure 8 This is an example diagram of maintaining cache metadata in the method according to an embodiment of the present invention;

[0037] Figure 9 This is an example diagram of the principle of reading cache when cache fails in the prior art;

[0038] Figure 10 This is an example diagram of the principle of reading the cache when a cache failure occurs in the method of this embodiment;

[0039] Figure 11 This is a schematic structural diagram of the device provided by the present invention. DETAILED DESCRIPTION

[0040] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0041] It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments may be combined with each other; and, based on the embodiments in this disclosure, all other embodiments obtained by persons of ordinary skill in the art without creative work are within the scope of protection of this disclosure.

[0042] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on this disclosure, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement an apparatus and / or practice a method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this apparatus and / or practice this method.

[0043] The technical principles of the present invention are as follows:

[0044] Figure 1 This is an example diagram of the technical principle of the present invention, as shown in FIG. Figure 1 As shown, the present invention distributes data from the client onto logical shards based on user-visible logical addresses. The logical shards allocate space from the data disk pool and append data to the data disk pool in the form of logs. The data index records the address where the data was appended to the data disk pool. When reading data, the data index is first read, and then the data is read from the data disk pool using the address within the data disk pool recorded in the data index. Figure 2 The following is an example diagram of the reading process of cached data in the prior art, such as Figure 2 As shown, the client's logical address is used as the key value to cache data. When reading data, the data is first read from the cache through the logical address. If there is no data in the cache, the data index pool is read to the data hard disk pool to read the data. Figure 3 This is an example diagram of the process of reading cache data in the method of the present invention, such as Figure 3 As shown, the main improvement of the present invention is that the user's logical address is not used as the key value to cache data, but the data hard disk pool address recorded in the data index is recorded as the key in the cache data index.

[0045] Figure 4 An exemplary system of a log-write-based read cache method applicable to an embodiment of the present invention is shown. Figure 4 As shown, the system may include a cache reading server 101, a communication network 102 and / or one or more cache reading clients 103. Figure 4 The example in FIG. 1 is a plurality of cache read clients 103 .

[0046] The cache read server 101 can be any appropriate server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the cache read server 101 can perform appropriate functions. For example, in some embodiments, the cache read server 101 can be used to read cache based on log writes. As an optional example, in some embodiments, the cache read server 101 can be used to implement read cache by creating data indexes based on log writes. For example, the cache read server 101 can be used to write the user's data log to the data hard disk pool through logical sharding; when writing the data log to the data hard disk pool, cache the data and create a data index; read the corresponding data from the data hard disk pool according to the data index; record cache metadata, and when the read cache process fails, restore the cache read through the recorded cache metadata.

[0047] As another example, in some embodiments, the cache reading server 101 may send a log write-based read cache method to the cache reading client 103 for user use based on a request of the cache reading client 103 .

[0048] As an optional example, in some embodiments, the cache read client 103 is used to provide a visual interface, which is used to receive a user's selection input operation for the read cache based on log writes, and, in response to the selection input operation, obtain an interface corresponding to the option selected by the selection input operation from the cache read server 101 and display the interface, wherein the interface at least displays information about the read cache based on log writes and operation options for the information about the read cache based on log writes.

[0049] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The cache read client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the cache read server 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the cache read client 103 and the cache read server 101, such as a network link, a dial-up link, a wireless link, a hardwired link, any other suitable communication link, or any suitable combination of such links.

[0050] The cache read client 103 may include any one or more clients that present an interface related to the log-write-based read cache in an appropriate form for user use and operation. In some embodiments, the cache read client 103 may include any suitable type of device. For example, in some embodiments, the cache read client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.

[0051] Although cache read server 101 is illustrated as a single device, in some embodiments, any suitable number of devices may be used to perform the functions performed by cache read server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by cache read server 101. Alternatively, the functions of cache read server 101 may be implemented using a cloud service.

[0052] Based on the above system, an embodiment of the present application provides a read cache method based on log writing, which is described below through the following embodiments.

[0053] Reference Figure 5 , shows a flowchart of the steps of a log-write-based read cache method according to an embodiment of the present invention.

[0054] The log-write-based read cache method of this embodiment can be executed on a cache read server. The log-write-based read cache method includes the following steps:

[0055] Step S201: Write the user's data log to the data hard disk pool through logical sharding.

[0056] As an optional example, in the method of this embodiment, the user's data is obtained from the client, and the obtained data is scattered onto logical shards according to the user's logical address space. The logical shards allocate space from the data hard disk pool, and the data on the logical shards is appended to the space corresponding to the data hard disk pool in the form of logs.

[0057] Step S202: When writing the data log to the data hard disk pool, cache the data and create a data index.

[0058] In the method of this embodiment, when data is appended to the data hard disk pool from the logical shard in the form of a log, the data is cached in the form of a key-value pair locally at the node where the logical shard is located, and a cache hash table is constructed in the memory based on the key-value pair of the cached data; at the same time, this embodiment also needs to create a data index, and record the log write address of the data in the created data index. As an optional example, the method of this embodiment uses the log write address of the data as the key and the data as the value, caches the data locally at the node where the logical shard is located, and constructs a cache hash table in the memory based on the key-value pair of the cached data. As an optional example, the method of this embodiment uses the object name and offset of the log write as the key of the data, records the key of the data in the data index created in the memory, and points the key of the data to the corresponding cached data.

[0059] Step S203: Read corresponding data from the data hard disk pool according to the data index.

[0060] When reading data, the method of this embodiment first reads the data index and then reads the corresponding data from the data hard disk pool based on the log write address recorded in the data index. As an optional example, the method of this embodiment can query the data index to obtain the log write address corresponding to the data to be read, and then query the cache address of the data to be read through the cache hash table.

[0061] It should be noted that in the method of this embodiment, a hash table is established in memory in a key-value format with the backend log write address as the key and the data cache as the value. After querying the data index and obtaining the backend log address, the data cache address can be quickly queried through the cache hash table. The cache address includes but is not limited to the local SSD disk address, and also includes other addresses that can be used to read data, which is not limited by the method of this embodiment. Figure 6 This is an example diagram of the read cache memory index format in the method of this embodiment.

[0062] It should be noted that in the method of this embodiment, the cache reading status can also be recorded in bitmap and time, so that the most recently frequently accessed data can be read. For sequential reading, the data to be read can be pre-fetched in advance.

[0063] Step S204: Record cache metadata. When a failure occurs in the cache reading process, restore cache reading through the recorded cache metadata.

[0064] After data is written to the cache SSD (including other high-speed media), to ensure that the memory cache data of each logical shard remains available after a process failure, the method in this embodiment also records cache metadata. Because the key of the cache metadata is the log write address, it will not be repeated. The cache metadata is also recorded in the form of a log. Figure 7 This is an example diagram of the storage format of cache metadata in the method of an embodiment of the present invention.

[0065] As an optional example, the method of this embodiment records the cache metadata of the data in the form of a log in the memory, obtains the cache metadata log, sets the cache metadata threshold, and when the obtained cache metadata is greater than the set cache metadata threshold, the cache metadata is persisted. Figure 8 This diagram illustrates an example of maintaining cache metadata in a method according to an embodiment of the present invention. For example, by reserving 16KB of memory, cache metadata is recorded in the reserved 16KB of memory. When the 1MB cache metadata log is full, the 16KB of memory is flushed to persistent high-speed media. Alternatively, if the log is not persisted for more than 5 minutes, the cache metadata log is persisted once.

[0066] When a failure occurs in the cache read process, the cache metadata log is scanned, and the key-value pairs in the corresponding cache metadata log are reinserted into the cache hash table in memory to restore the cache information of the cached data. Figure 9 This is an example diagram of the principle of reading cache when cache fails in the prior art; Figure 10 This is an example diagram of the principle of reading cache when cache fails in the method of this embodiment. Figure 10 As shown in the figure, after a failure occurs, by scanning the cache metadata log and reinserting the key-v key-value pairs into the cache hash table in memory, the original cache information can be quickly restored. This prevents cache loss and prolonged data read performance drops caused by process restarts due to upgrades or software failures.

[0067] The method of the embodiment of the present invention has the following beneficial technical effects:

[0068] 1. Cache data using the end log write address. The cached data will not be modified and is all newly written, making the cache logic simple.

[0069] 2. Use bitmaps and time to record cache reads, enabling reading of recently accessed data. For sequential reads, data to be read can be pre-fetched in advance.

[0070] 3. Cache data records the cache key value information. After a process failure, the cache metadata can be scanned to rebuild the cache index, eliminating the need to re-identify hot data and regenerate the cache.

[0071] like Figure 11As shown, the present invention further provides a device including a processor 310, a communication interface 320, a memory 330 for storing a computer program executable by the processor, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 implements the aforementioned log-write-based read cache method by running the executable computer program.

[0072] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0073] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0074] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or certain parts of the embodiment.

[0075] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. A read cache method based on log writing, characterized in that: The method comprises: Write user data logs to the data hard disk pool through logical sharding; When writing the data log to the data hard disk pool, cache the data and create a data index; Read the corresponding data from the data hard disk pool according to the data index; Record cache metadata. When a cache read process fails, cache reads can be restored using the recorded cache metadata. When writing data logs to the data disk pool, the data is cached and a data index is created, including: When data is appended from the logical shard to the data disk pool in the form of logs, the data is cached in the form of key-value pairs in the local node where the logical shard is located, and a cache hash table is built in memory based on the key-value pairs of the cached data; Create a data index and record the data log write address in the created data index; Among them, the data is cached in the form of key-value pairs locally at the node where the logical shard is located, and a cache hash table is built in the memory according to the key-value pairs of the cached data, including: using the log write address of the data as the key and the data as the value, caching the data locally at the node where the logical shard is located, and building a cache hash table in the memory according to the key-value pairs of the cached data.

2. The log-writing based read cache method according to claim 1, characterized in that: The user's data log is written to the data hard disk pool through logical sharding, including: obtaining the user's data from the client, scattering the obtained data to the logical sharding according to the user's logical address space, allocating space from the data hard disk pool for the logical sharding, and appending the data on the logical sharding to the corresponding space in the data hard disk pool in the form of logs.

3. The log-writing based read cache method according to claim 1, characterized in that: The data is cached and a data index is created, including: using the object name and offset written in the log as the key of the data, recording the key of the data in the data index created in the memory, and pointing the key of the data to the corresponding cached data.

4. The log-writing based read cache method according to claim 1, characterized in that: Reading corresponding data from the data hard disk pool according to the data index includes: when reading data, first reading the data index, and reading corresponding data from the data hard disk pool according to the log write address recorded in the data index.

5. The log-writing based read cache method according to claim 1, characterized in that: Reading corresponding data from the data hard disk pool according to the data index includes: querying and obtaining the log write address corresponding to the data to be read from the data index, and querying the cache address of the data to be read through the cache hash table.

6. The log-writing based read cache method according to claim 1, characterized in that: Record cache metadata. When the cache read process fails, cache reads are restored through the recorded cache metadata, including: The cache metadata of the data is recorded in the memory in the form of logs, the cache metadata log is obtained, and the cache metadata threshold is set. When the obtained cache metadata is greater than the set cache metadata threshold, the cache metadata is persisted; When a failure occurs in the cache read process, the cache metadata log is scanned, and the key-value pairs in the corresponding cache metadata log are reinserted into the cache hash table in the memory to restore the cache message of the cache data.

7. A read cache system based on log writing, characterized in that: The system includes a cache read server, which is used to write the user's data log to the data hard disk pool through logical sharding; when writing the data log to the data hard disk pool, cache the data and create a data index; read the corresponding data from the data hard disk pool according to the data index; record cache metadata, and when a cache read process fails, restore cache reading through the recorded cache metadata; When writing data logs to a data hard disk pool, the data is cached and a data index is created, including: when appending data from a logical shard to the data hard disk pool in the form of a log, the data is cached in the form of a key-value pair locally at the node where the logical shard is located, and a cache hash table is built in memory according to the key-value pair of the cached data; a data index is created, and the log write address of the data is recorded in the created data index; wherein, the data is cached in the form of a key-value pair locally at the node where the logical shard is located, and a cache hash table is built in memory according to the key-value pair of the cached data, including: using the log write address of the data as a key and the data as a value, caching the data locally at the node where the logical shard is located, and building a cache hash table in memory according to the key-value pair of the cached data.

8. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 6 when executing the program.