WO2022174705A1 - 数据处理方法、计算机系统和中间设备 - Google Patents
数据处理方法、计算机系统和中间设备 Download PDFInfo
- Publication number
- WO2022174705A1 WO2022174705A1 PCT/CN2022/072422 CN2022072422W WO2022174705A1 WO 2022174705 A1 WO2022174705 A1 WO 2022174705A1 CN 2022072422 W CN2022072422 W CN 2022072422W WO 2022174705 A1 WO2022174705 A1 WO 2022174705A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- server
- information
- version
- intermediate device
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5055—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering software capabilities, i.e. software resources associated or available to the machine
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/182—Distributed file systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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 OR CALCULATING; 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
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
Definitions
- the present application relates to the field of storage technologies, and in particular, to a data processing method, a computer system and an intermediate device.
- a shared storage system such as a storage system with global memory that can be shared by multiple servers or a distributed shared file system
- metadata of the data is recorded in the home server of the data, and the metadata includes information of the server that caches the latest version of the data.
- the home server needs to update the metadata.
- the home server needs to forward the data access request, which increases the burden of the home server.
- the embodiments of the present application aim to provide a data processing solution, in which the information of the server where the latest version of the data is stored is stored by the intermediate device connected to multiple servers, and the latest version of the data is obtained through the intermediate device, thereby reducing the burden on the server and improving the system performance.
- a first aspect of the present application provides a computer system, including an intermediate device, a first server and a second server, the first server and the second server are connected through the intermediate device, and the second server is The first version of the data is stored, the first version is the latest version of the data, the information of the server storing the latest version of the data is recorded in the intermediate device, and the first server is used to pass the The intermediary device obtains the first version of the data from the second server.
- the intermediate device By recording the information of the second server that stores the latest version of the data by the intermediate device, other servers can forward the data acquisition request and the latest version of the data through the intermediate device, so that the latest version of the data can be obtained from the second server, reducing the home server of the data. the burden and improve the system performance.
- the second server is further configured to, after acquiring the first version of the data, instruct the intermediate device to record that the second server stores the data the latest version of the server.
- the middle device By recording the information of the server after the server obtains the latest version of the data by the middle device, other servers can obtain the latest version of the data through the middle device according to the recorded information.
- the server can obtain the latest version of the data in any of the following ways: newly writing data, rewriting data after obtaining data from other servers or locally, or reading data from other servers.
- the intermediate device stores metadata of the data, and the intermediate device is configured to record the information of the second server in the metadata of the data .
- the first server when the first server obtains the first version of the data from the second server through the intermediary device, the first server is specifically configured to request the intermediary device to Sending an acquisition request for the data, and the intermediate device is further configured to: receive the acquisition request for the data from the first server, and forward the acquisition request according to the information of the server that stores the latest version of the data to the second server; receiving a first version of the data from the second server and forwarding to the first server.
- the first server is configured to send the data when receiving a rewriting request for the data and the first version of the data is not hit locally
- the obtaining request is sent to the intermediate device; after obtaining the first version of the data, the first server is further configured to rewrite the first version of the data into a second version.
- the first server is further configured to send rewriting completion information to the intermediate device after rewriting the first version of the data to the second version;
- the intermediate device is further configured to receive the rewriting completion information from the first server, and based on the rewriting completion information, modify the information of the server storing the latest version of the data to the information of the first server.
- the acquisition request carries a rewrite identifier
- the second server is configured to The rewrite flag in the obtaining request deletes the stored first version of the data after obtaining the first version of the data.
- write lock information on the data is recorded in the intermediate device, and the intermediate device is further configured to: After the acquisition request of the data, the write lock information is modified according to the rewrite identifier in the acquisition request to lock the data, and based on the rewrite completion information, the information of the server that stores the latest version of the data is stored. After being modified to the information of the first server, modify the write lock information of the metadata to unlock the data.
- the data is hotspot data.
- the system further includes a third server, the third server is connected to the intermediate device, and the third server also stores a third server of the data.
- the third server after the second server receives the rewriting request for the data and hits the first version of the data locally, it is further configured to send a deletion request for the data to the intermediate device, so The intermediate device is further configured to: receive a deletion request for the data from the second server, and forward the deletion request to the third server according to the information of the server storing the latest version of the data, The third server is instructed to delete the first version of the data; the second server is further configured to rewrite the first version of the data into the second version.
- the intermediate device is a network switching device.
- the intermediate device includes a first intermediate device and a second intermediate device that are connected to each other, wherein the first intermediate device stores data belonging to the first intermediate device.
- the metadata of the data of the server, the metadata of the data belonging to the second server is stored in the second intermediate device.
- the computer system is a global memory system or a distributed shared file system.
- a second aspect of the present application provides a data processing method, characterized in that the method is performed by an intermediate device, the intermediate device is respectively connected to a first server and a second server, and the second server stores the first version of the data,
- the first version is the latest version of the data
- the intermediate device records information of a server that stores the latest version of the data
- the method includes: receiving an acquisition of the data from the first server request; forward the acquisition request to the second server according to the information of the server storing the latest version of the data; receive the first version of the data from the second server; The first version is forwarded to the first server.
- the method further includes: receiving rewriting completion information for the data from the first server; based on the rewriting completion information, storing the data The information of the server of the latest version of the data is modified to the information of the first server.
- the acquisition request carries a rewrite identifier
- the method further includes, after forwarding the acquisition request to the second server, from the first server
- the second server receives the information that the first version of the data is deleted.
- write lock information on the data is recorded in the intermediate device, and the method further includes: after receiving from the first server the write lock information on the data After the acquisition request, modify the write lock information according to the rewrite identifier in the acquisition request to lock the data, and based on the rewrite completion information, modify the information of the server that stores the latest version of the data as After the information of the first server, modify the write lock information to unlock the data.
- the data is hotspot data.
- a third aspect of the present application provides an intermediate device, the intermediate device is respectively connected to a first server and a second server, the second server stores a first version of data, and the first version is the data of the data.
- the latest version, the information of the server storing the latest version of the data is recorded in the intermediate device, and the intermediate device includes: a receiving unit for receiving an acquisition request for the data from the first server; a forwarding unit , for forwarding the obtaining request to the second server according to the information of the server storing the latest version of the data; the receiving unit is further configured to receive the first version of the data from the second server a version; the forwarding unit is further configured to forward the first version of the data to the first server.
- the receiving unit is further configured to receive rewriting completion information for the data from the first server;
- the intermediate device further includes a modifying unit, configured to based on In the rewriting completion information, the information of the server storing the latest version of the data is modified to the information of the first server.
- the acquisition request carries a rewrite identifier
- the receiving unit is further configured to, after forwarding the acquisition request to the second server, retrieve the data from the The second server receives information that the first version of the data is deleted.
- write lock information on the data is recorded in the intermediate device, and the modification unit is further configured to: After the acquisition request of the data, the write lock information is modified according to the rewrite identifier in the acquisition request to lock the data, and based on the rewrite completion information, the information of the server that stores the latest version of the data is stored. After being modified to the information of the first server, modify the write lock information to unlock the data.
- the data is hotspot data.
- a fourth aspect of the present application provides an intermediate device, including a processing unit and a storage unit, where executable code is stored in the storage unit, and the processing unit executes the executable code to implement the method described in the second aspect of the present application .
- a fifth aspect of the present application provides an intermediate device, comprising: a communication interface for performing data transmission with a server; and a processing unit for processing data received by the communication interface, so as to execute the process described in the second aspect of the present application. method.
- FIG. 1 is an architectural diagram of a shared storage system provided by an embodiment of the present application
- FIG. 2 is a flowchart of a method for writing data in a shared storage system provided by an embodiment of the present application
- FIG. 3 is a flowchart of a method for rewriting data in a shared storage system provided by an embodiment of the present application
- Fig. 4 is the flow chart of the process A that is executed when data is not cached in the first server in Fig. 3;
- FIG. 5 is a schematic diagram of a data rewriting process when the data state is an unshared state
- FIG. 6 is a schematic diagram of a data rewriting process when the data state is a shared state
- FIG. 7 is a schematic diagram of a data rewriting process when the data state is a modified state
- Fig. 8 is the schematic diagram of the change of the state of the data along with the operation to the data;
- Fig. 9 is a flow chart of the process B executed when data is cached in the first server in Fig. 3 and the state of the data is a shared state;
- FIG. 10 is a schematic diagram of a data rewriting process when the data access request is a data deletion request
- FIG. 11 is a flowchart of a method for reading data in a shared storage system provided by an embodiment of the present application.
- FIG. 12 is a schematic diagram of a data reading process when the data state is a shared or modified state
- FIG. 13 is an architectural diagram of a shared disk system provided by an embodiment of the present application.
- FIG. 14 is an architecture diagram of an intermediate device provided by an embodiment of the present application.
- 15 is a structural diagram of an intermediate device provided by an embodiment of the application.
- FIG. 16 is a structural diagram of an intermediate device provided by an embodiment of the present application.
- FIG. 1 is an architectural diagram of a shared storage system provided by an embodiment of the present application, the system includes multiple servers forming a server cluster and at least one intermediate device, wherein each intermediate device is connected to at least one server, and the intermediate device may Connecting a device for a programmable network, such as a switch, will be described below with a switch as an example of an intermediate device.
- FIG. 1 schematically shows that the switch 1 is connected to the server S1 to the server Si, and the switch 2 is connected to the server Sj to the server Sn.
- each server divides its own memory (eg, Dynamic Random Access Memory (DRAM)) into two parts: shared memory and a private local cache (ie, write-back cache).
- DRAM Dynamic Random Access Memory
- the shared memory of all servers in the server cluster constitutes a memory pool (hereinafter referred to as global memory), and any server in the server cluster can access the global memory.
- the address of the data stored in the global memory can be represented by a 16-bit node number plus a 48-bit intra-node address, and the data in the global memory can use the address as the data identifier (or data number), and the node number is the shared data.
- the number of the server that stores the data in the memory, and the address in the node is the address offset where the data is stored in the shared memory provided by the server. In each server, when the server reads and writes data, it will first access the local cache.
- the local cache stores the hot data of the application (Application, APP) in the server, such as the data newly written by the application or the frequently read data.
- the data in the local cache can be eliminated to the shared memory of the server.
- the accessed data is not hit in the local cache, the data is read from the global memory to the local memory, and then the data is read from the local memory.
- the server may be a physical server, or may also be a virtual entity abstracted based on general hardware resources, such as a virtual machine and a container.
- the switches are connected to their corresponding servers, and the switches are connected to each other to forward data with respect to the multiple servers.
- the server Sn will read the data A from the local cache instead of the latest version of the data A1, so that the application cannot read the latest version of the data A1. data.
- the server that stores the data in the shared memory is used as the home server of the data, and the home server generates and stores metadata of the data, and the metadata includes caching the data.
- Information about the latest version of the server After the data is modified by other servers other than the home server, the home server needs to update the information of the server that caches the latest version of the data in the metadata.
- the home server needs to send the cache to the data. The data server forwards the data access request to obtain the latest version of the data, thereby increasing the burden on the home server.
- the switch stores the metadata of the data in the global memory, and the information of the server storing the latest version of each data is recorded in the metadata.
- the server can send a data access request to the switch, and through the data-based metadata processing of the switch, obtain the latest version of the data from the server storing the latest version of the data.
- the information of the server that caches the latest version of the data in the metadata of the data is updated by the switch, and when other servers access the latest version of the data, the switch forwards the data access request to the cache of the data.
- the server thereby reducing the processing and network traffic of the server, reduces the burden on the server.
- each switch can be connected to some servers in the server cluster, so that multiple switches can cooperatively process data access requests of each server.
- the correspondence between the data in the global memory and each switch can be determined.
- the data in the global memory may be divided into corresponding to multiple switches according to the storage address range in the global memory.
- the connection between the switch and the server can be established according to the corresponding relationship between the data stored in the shared memory of each server and each switch.
- each switch can store the data corresponding to the switch in the shared memory. server connection.
- Each switch can store metadata of each data corresponding to it to perform cache coherent processing on each data corresponding to it, or each switch can only store metadata of hotspot data in its corresponding data to only Cache coherency processing is performed on the hotspot data.
- the metadata of the data can be migrated between the switch and the server according to the access heat of the data. For example, for frequently accessed data, the home server of the data can send the metadata of the data to the switch to which it is connected, so that the switch performs cache coherency processing on the data.
- the switch can send the metadata of the data to the home server of the data, thereby restoring the cache consistency processing of the data by the home server. In this way, the switch only processes the cache coherence processing of the hot data, which reduces the storage requirement for the switch.
- the metadata of the data includes, for example, a list of servers that cache the data.
- the format of the server list can be, for example, a bitmap, and each server corresponds to a bit in the bitmap. If the data is cached in the server, the bit corresponding to the server in the server list of the data is 1. Indicates that the server is in the server list.
- the metadata of the data may also include the state of the data.
- the state of the data includes the following three states: unshared, that is, in the server cluster, no server stores the data in the local cache; shared (shared), that is, the data is stored in the local cache of at least one server in the server cluster The data exists, and the at least one server only has the read permission for the data; for modification, that is, the data is stored in the local cache of a server in the server cluster, and the server has the write permission for the data.
- the server sends a data access request to the corresponding switch in the following three situations: the data that you want to read and write is not stored in the local cache, that is, the cache misses; The data stored in the shared state is rewritten, that is, write sharing; the data stored in the local cache is deleted, that is, data eviction.
- the server can send the following five data access requests to the switch according to the storage conditions of the data in the local cache: when the data is not cached in the local cache and the server wishes to rewrite the data, the server sends the data access indicating the write miss operation.
- the server when the data is not cached in the local cache and the server wishes to read the data, the server sends a data acquisition request indicating a read miss operation; when the data is cached in the local cache, the data recorded in the server When the status is shared and the server wishes to rewrite the data, the server sends a data deletion request indicating the write sharing operation; when the data is cached in the local cache, the status of the data recorded in the server is the modified status, And in the case that the server wishes to delete the data, the server sends a data write request indicating the eviction modification operation; when the data is cached in the local cache, the state of the data recorded in the server is the shared state, and the server wishes to delete the data.
- the server sends a processing request indicating an eviction share operation.
- the write missing operation, the read missing operation, the write sharing operation, the eviction modification operation and the eviction sharing operation are five types of operations performed by the server on the data.
- the switch After the switch receives the data access request from the server, it can perform corresponding processing according to the type of the data access request, the server list of cached data recorded in the metadata, and the status of the data, so as to ensure the local cache of each server. Coherence of cached data, which is described in detail below.
- FIG. 2 is a flowchart of a method for writing data in a shared storage system provided by an embodiment of the present application. The method is jointly executed by the servers and switches in the server cluster in FIG. 1 .
- the first server may be any server in the server cluster, and the following description takes the first server as the server S1 for example description.
- step S201 is executed to generate a metadata creation request.
- the server S1 determines the address at which data is written in the global memory.
- the address includes the server node number and the server's in-node address, and the determined address is used as the data number (hereinafter referred to as number d1), And generate the metadata creation request accordingly.
- the metadata creation request includes, for example, information such as the data number d1.
- the metadata creation request may also include the serial number of the requesting server (ie, the server S1).
- the server S1 executes step S202, and sends the metadata creation request to the switch.
- the switch is the switch corresponding to the data A numbered d1.
- the switch is the switch corresponding to the address of the data. Assuming that the address of the data indicates that the switch corresponding to the data is the switch 2 in FIG. 1 , the server S1 can forward the metadata creation request to the switch 2 through the switch 1 .
- the switch 2 After receiving the metadata creation request from the server S1, the switch 2 creates metadata of the data, and the metadata includes, for example, the number d1 of the data A, the server list of the data A and other information.
- the initial server list is an empty list, that is, it does not include any server information.
- the metadata may also include a read-write lock table.
- the switch 2 can avoid conflicts between multiple data access requests for the data numbered 1 received at the same time through the read lock or write lock in the metadata.
- the read-write lock is, for example, a 16-bit lock, and the highest bit is a write lock. If the value is 1, it means that the data is subject to a write lock, and other servers will not be able to perform other data operations on the data (such as read operations, write operations,
- the last 15 bits of the read-write lock are read locks, indicating the number of servers that read the data. Each time a read lock is added, the value of the last 15 bits of the read-write lock is increased by 1. The value of the last 15 bits of the write lock is decremented by 1.
- the switch 2 After the switch 2 creates the metadata of the data, it can add a write lock to the data numbered d1 through the read-write lock. As mentioned above, during the write lock period, other servers will not be able to perform any other operations on the data through switch 2. When the switch 2 subsequently receives other data access requests for the data numbered d1, if the received data access request is the above-mentioned data acquisition request indicating a read missing operation, the switch 2 determines that the write lock is not added.
- the switch 2 adds a write lock to the metadata in the case of determining that the write lock is not added, if the switch 2 determines that the data has been added with a write lock or a read lock The number of times is already 2 15 -1 times, then the locking fails this time, and switch 2 returns a processing failure message.
- step S204 after the switch 2 has created the metadata of the data, it returns the creation completion information to the server S1.
- the creation completion information includes, for example, information on adding a write lock to the data.
- step S205 after determining that the switch 2 has created the metadata of the data A, the server S1 writes the data A in the local cache.
- the state in which the data with the number d1 can be recorded locally is the modified state.
- the server S1 wishes to modify the data numbered d1 again, it can directly modify the data A in the local cache based on the modification status, that is, the modification status indicates that the server S1 has the right to modify the data numbered d1.
- the server S1 may record the correspondence between the number d1 and the address (virtual address or physical address) where the data A is stored in the local cache, so that the data A can be read from the local cache according to the correspondence.
- step S206 the server S1 sends the data writing completion information to the switch 2.
- the data writing completion information includes, for example, the state of data A (modified state).
- the data writing completion information may further include a server list, and the server list includes, for example, the information of the server S1.
- step S207 after receiving the data writing completion information from the server S1, the switch 2 updates the metadata of the data numbered d1 based on the data writing completion information. Specifically, the switch 2 can modify the server list in the metadata to include the information of the server S1, and record the status of the data A as the modified status in the metadata. After this update, the switch 2 can unlock the data numbered d1 in the metadata.
- the server S1 After the server S1 writes the data A in the local cache through the above steps, according to the predetermined eviction rule, for example, when the data A is no longer the hot data of the application, or when the data A is written for more than a predetermined time, the server S1 will Data A in the modified state is evicted from the local cache. To this end, the server S1 needs to store the latest version of the data (ie, data A) in its home server through the switch 2 . Therefore, the server S1 can perform step S208 to generate a data write request indicating the eviction modification, so as to store the data A in the home server. Since the state of the data A is in the modified state at this time, the data write request is specifically the data write request indicating the eviction modification operation.
- the data write request includes, for example, the request type (the data write request type indicating the eviction modification operation), the data number d1, the data A, and the number of the requesting server (ie, the server S1).
- step S209 the server S1 sends a data write request to the switch 2.
- step S210 after receiving the data write request from the server S1, the switch 2 forwards the data write request to the home server of the data A (shown as the second server in FIG. 2 ) according to the data address corresponding to the number d1, for example
- the home server is the server Sn.
- step S211 after receiving the data write request, the server Sn writes the data A into the address corresponding to the number d1 in the shared memory.
- step S212 the server Sn returns data writing completion information to the switch 2 after completing the writing of the data A.
- the switch 2 After receiving the data writing completion information from the server Sn, the switch 2 returns the data writing completion information to the server S1 in step S213.
- step S214 after receiving the data writing completion information, the server S1 deletes the data A in the local cache, and sends the data eviction completion information to the switch 2 in step S215.
- the switch 2 can update the metadata of the data A, specifically, can delete the information of the server S1 in the server list in the metadata, and modify the data state to the unshared state.
- the embodiment of the present application is not limited to this.
- the switch after receiving the data write request, can send the metadata creation request to the server Sn according to the number of the data home server in the data number, and the server Sn creates the metadata of the data, and After the access frequency of the data increases and becomes hot data, the metadata is moved to the switch 2 by the server Sn.
- the process of creating data metadata and the process of storing data in the shared memory are performed through the server and the switch.
- the switch 2 can record the information of the server of the latest version of the data of the cache number d1 in the metadata according to the write operation or eviction operation of the data by the server S1, so that other servers can pass the switch 2 Get the latest version of the data.
- the switch creates and updates the metadata, and the switch forwards the data access request, which reduces the burden on the server.
- FIG. 3 is a flowchart of a method for rewriting data in a shared storage system according to an embodiment of the present application.
- the first server in FIG. 3 is any server in the server cluster that wishes to rewrite the data (for example, the data numbered d1 ), and the following description takes the server S1 as the first server for example.
- step S301 it is determined whether the data numbered d1 is stored in the local cache.
- the server S1 can determine whether the number d1 is included in the correspondence table between the locally recorded data number and the address in the local cache. If the number d1 is not included, it can be determined that the data numbered d1 is not stored in the local cache, so that the process can be executed. A. If the number d1 is included, it can be determined that the data of the number d1 is stored in the local cache.
- the server S1 can execute step S302, and determine whether the data is in the modified state based on the data state of the number d1 recorded locally, and if it is in the modified state, the server S1 can execute the step S303 , directly rewrite the data of the number d1 in the local cache, if it is not in the modified state, it can be determined that the state of the data is the shared state, and the server S1 executes the process B.
- FIG. 4 is a flowchart of the process A executed when no data is cached in the first server in FIG. 3 .
- the server S1 generates a data acquisition request.
- the data acquisition request is the above-mentioned data acquisition request indicating the write missing operation.
- the data acquisition request includes a request type (a data acquisition request indicating a write-miss operation), a data number (eg, number d1 ) to be rewritten, and the number of the requesting server (eg, the number of server S1 ).
- step S402 the server S1 sends the data acquisition request to the switch 2.
- the server S1 After the server S1 generates the data acquisition request, it can determine that the data corresponds to the switch 2 according to the corresponding relationship between the data number d1 and the switch 2 , and can send the data acquisition request to the switch 2 through the switch 1 .
- the switch 2 can determine whether the metadata of the data numbered d1 is stored locally, and in the case of determining that the metadata of the data is stored locally, the subsequent steps of the flow shown in FIG. 4 are performed. In the case of determining that the metadata of the data is not stored locally, the switch 2 forwards the data acquisition request to the server Sn according to the number of the server Sn in the data number of the data d1, so that the server Sn can cache the data acquisition request consistently sexual processing. It is assumed that the metadata of the data numbered d1 is stored in the switch 2, that is, the switch 2 performs cache coherency processing on the request after receiving the above data acquisition request.
- the switch 2 may add a write lock to the data in the metadata.
- the switch 2 After each time the switch 2 receives a data access request, it can check the validity of the data access request, including: checking whether there is a conflict between the data access request and the data state in the switch metadata; and checking the requesting server in the data access request Whether there is a conflict between the number and the server list for that data in the metadata. In the event of a conflict, the switch may return a processing failure message to the requesting server.
- the processing failure message may include a reason for the failure, and the requesting server may retry the data processing operation after receiving the processing failure message.
- the conflict between the data processing request and the data status in the switch metadata includes, for example, the following conflicts: the request type is a request indicating write sharing or eviction sharing, and the data status is not shared; the request type is a request indicating eviction modification request, the status of the data is not modified.
- Conflicts between the request server number and the server list include, for example, the following conflicts: the request type is a request indicating a read miss or a write miss, but the number of the requesting server is already in the server list of the cache block; the request type is a request indicating write sharing, eviction When sharing or evicting a modified request, the requesting server is not in the server list.
- the switch 2 may forward the data acquisition request to the second server according to the metadata of the data.
- the data state recorded in the metadata is an unshared state, and/or the metadata records that the server list does not include any server information, that is, no server in the server cluster is cached in the local cache Data numbered d1.
- the switch 2 determines that the home server of the data is the server Sn according to the number d1, and forwards the data acquisition request to the server Sn, in this case, the server Sn is the second server.
- FIG. 5 is a schematic diagram of a data rewriting process when the data state is an unshared state.
- the server S1 sends the data acquisition request to the switch 2, it pulls the data A numbered d1 from the shared memory of the server Sn through the switch 2, and the server S1 modifies the data A to the data A1, and in the The modified data A1 is stored in the local cache, and finally the switch 2 updates the metadata of the data numbered d1 after the modification of the server S1 to indicate that the latest version of the data numbered d1 is stored in the server S1.
- the data state recorded in the metadata is a shared state
- the switch sends the data acquisition request to each server recorded in the server list according to the server list in the metadata.
- the switch can also designate one of the servers to return its cached data.
- the switch may send a data packet to each server including a data fetch request indicating a write miss operation and a "return data" field, which instructs one of the servers (eg, server Si) to return its cached data.
- the data packet may also include other fields, such as the status of the data d1, the server list of the data d1, and whether the metadata is in the switch 2 and other fields.
- FIG. 6 is a schematic diagram of a data rewriting process when the data state is a shared state.
- the server S1 sends the data acquisition request to the switch 2
- the data acquisition request is forwarded to each server (for example, the server Si and the server Sj) that cache the data through the switch 2, and the data is retrieved from the local cache of the server Sj.
- the server S1 modifies the data A to the data A1, and stores the modified data A1 in the local cache.
- the switch 2 updates the metadata of the data with the number d1 after the modification of the server S1 is completed to Indicates that the latest version of the data numbered d1 is stored in the server S1. That is, in this case, the server Sj is the second server in FIG. 4 .
- the state of the data recorded in the metadata is a modified state
- the switch sends the data acquisition request to a server recorded in the server list (for example, the server according to the server list in the metadata) Si), ie, in this case, the server Si is the second server in FIG. 4 .
- FIG. 7 is a schematic diagram of a data rewriting process when the data state is a modified state.
- the server S1 sends the data acquisition request to the switch 2
- the data A with the number d1 is pulled from the local cache of the server Si through the switch 2.
- the modified data A1 is stored in the cache, and finally the switch 2 updates the metadata of the data numbered d1 after the modification of the server S1 to indicate that the latest version of the data numbered d1 is stored in the server S1.
- step S404 the second server reads the data after receiving the data acquisition request.
- the second server is the server Sn, and the server Sn reads the data A from the shared memory after receiving the data acquisition request.
- the second server is the server Sj
- the server Sj reads the data A from the local cache according to the “whether to return data” field in the data packet for return.
- the server Sj deletes the data A in the local cache according to the request type of the data acquisition request, so as to ensure the cache consistency of the data.
- the server Si in FIG. 6 also deletes the data A in the local cache, so as to ensure the cache consistency of the data.
- the second server is the server Si, and after receiving the data acquisition request, the server Si reads the latest version of the data numbered d1 (assumed to be data A) from the local cache, and stores the local The data A in the cache is deleted to ensure the cache consistency of the data.
- step S405 after reading the data A, the second server returns the read data A to the switch 2 .
- step S406 after receiving the data A from the second server, the switch 2 returns the data A to the server S1. While returning the data A to the server S1, the switch 2 may also send at least one of the data status of the data numbered d1 in the metadata and the server list to the server S1.
- step S407 after receiving the returned data A, the server S1 rewrites the data A into the data A1.
- the server S1 in the case where the server S1 also receives the server list of the data numbered d1 from the switch 2, it can be determined based on the server list that it only needs to receive the reply information from the server Sn, so that the server S1 only needs to receive the reply information from the server Sn. After it is determined that the data A returned by the server Sn is received, the data A is rewritten. In the case that the state of the received data is the unshared state, the server S1 may determine, based on the state, that it only needs to receive the reply information from the home server of the data (ie, the server Sn).
- the server S1 modifies the data A to the data A1 as the latest version of the data numbered d1, and stores the data A1 in the local cache, wherein the modification to the data A includes the modification of at least one of the data A Modification of some data.
- the server S1 may determine the latest state of the data d1 according to the state of the received data d1 (ie, the unshared state) and the type of operation on the data.
- FIG. 8 is a schematic diagram of the state of data changing with the operation on the data.
- the nodes in FIG. 8 are the current state of the data, and the edges between the nodes are the data operation types.
- the server S1 may determine that the state of the data d1 has changed to the modified state according to the current unshared state of the data d1 and the write missing operation.
- the server S1 also modifies the received server list accordingly, and the updated server list only includes the server S1.
- the server S1 in the case that the server S1 also receives the server list of data numbered d1 from the switch 2, assuming that the server list includes the information of the server Si and the server Sj, the server S1 can be based on the server S1.
- the list determines that the reply information needs to be received from the servers Si and Sj, so that after it is determined that the reply information from the servers Si and Sj is received, the data A is rewritten, wherein the reply information of the server Si includes the information of deleting the data A, and the server Sj
- the reply information includes data A and the information of deleting data A.
- the server S1 can determine that, after the write-miss operation is performed on the data in the shared state, the state of the data becomes the modified state, and sends the updated data state to the switch 2 .
- the server S1 determines, according to the server list, that after receiving the data A sent by the server Si, the data A can be rewritten. According to FIG. 8 , the server S1 can determine that, after the write-miss operation is performed on the data in the modified state, the state of the data is still in the modified state, and the data state can be sent to the switch 2 .
- step S408 the server S1 sends data rewriting completion information to the switch 2.
- the data rewriting completion information includes, for example, the state of the data d1 after the write miss operation and the server list of the data d1.
- the data rewriting completion information when the switch 2 writes a lock on the data d1 after receiving the data acquisition request indicating the write-missing operation, the data rewriting completion information further includes write-lock unlocking information.
- Step S409 after receiving the data rewriting completion information, the switch 2 updates the metadata of the data according to the data rewriting completion information.
- the switch 2 After receiving the data rewriting completion information, the switch 2 updates the metadata of the data numbered d1 according to the state of the data d1 and the server list of the data d1 in the data rewriting completion information. Specifically, referring to FIGS. 5-7 , after the update of the metadata, the state of the data d1 recorded in the metadata is a modified state, and the server list in the metadata includes the server S1. By recording that the state of the data in the metadata is the modified state and the server list of the data includes the server S1, it means that the server S1 can modify the data d1 in the local cache, and instructs other servers: the local cache of the server S1 stores a serial number The latest version of the data for d1. Therefore, when other servers want to read and write the data numbered d1, the switch 2 can read the latest version of the data numbered d1 from the server S1, thereby ensuring the cache consistency of the data d1 in each server.
- the switch 2 In the case where the switch 2 has already write-locked the data d1 according to the data acquisition request indicating the write-missing operation, after the metadata update is completed, the switch 2 will write-lock the data d1 according to the write-lock unlocking information in the data processing completion information Unlocking, that is, restoring the value of the most significant bit of the read-write lock of the data d1 to 0, as described above.
- FIG. 9 is a flowchart of a process B executed when data is cached in the first server in FIG. 3 and the state of the data is a shared state.
- the server S1 executes step S901 to generate an instruction
- the data deletion request of the write sharing operation includes the request type (indicating the data deletion request type of the write sharing operation), the data number (number d1) to be rewritten and the number of the requesting server (the number of the server S1).
- step S902 the server S1 sends a data deletion request to the switch 2.
- step S402 the description of step S402 above, which will not be repeated here.
- step S903 the switch 2 forwards the data deletion request to the second server according to the metadata of the data.
- the switch 2 may determine at least one server that caches data except the server S1 according to the server list in the metadata, and forwards the data deletion request to each server that caches the data. That is to say, the second server in FIG. 9 may be any server other than server S1 that caches the data, such as server Si.
- FIG. 10 is a schematic diagram of a data rewriting process when the data access request is a data deletion request.
- the switch 2 forwards the data deletion request to the server Si, so that the server Si deletes the data A in the local cache, so as to ensure the cache consistency of the data . That is, in this case, the server Si is the second server in FIG. 9 .
- step S904 the server Si deletes the data after receiving the data deletion request.
- the server Si deletes the data A in the local cache.
- step S905 the server Si returns deletion completion information to the switch 2.
- step S906 the switch 2 forwards the received deletion completion information to the server S1. While forwarding the deletion completion information, the switch can also send the status of the data in the metadata and the server list of the data to the server S1.
- step S907 after receiving the deletion completion information from the server Si, the server S1 rewrites the data A in the local cache.
- the server S1 may determine that only deletion completion information needs to be received from the server Si according to the server list of data received from the switch 2, and rewrite the data A after determining that the deletion completion information has been received from the server Si.
- the server S1 reads the data A from the local cache, modifies the data A to the data A1 as the latest version of the data numbered d1 , and stores the data A1 in the local cache.
- FIG. 10 the server S1 reads the data A from the local cache, modifies the data A to the data A1 as the latest version of the data numbered d1 , and stores the data A1 in the local cache.
- the server S1 may update the state of the data d1 to a modified state according to the state of the data d1 received from the switch 2 (ie, the shared state) and the type of write sharing operation. At the same time, the server S1 can also modify the server list received from the switch 2, and the updated server list only includes the server S1.
- step S908 the server S1 sends data rewriting completion information to the switch 2.
- the data rewriting completion information includes, for example, the status of the updated data and the server list of the data.
- step S909 the switch 2 updates the metadata of the data according to the rewriting completion information.
- the switch 2 After receiving the rewriting completion information, the switch 2 updates the metadata of the data numbered d1 according to the state of the data in the rewriting completion information and the server list of the data. Specifically, as shown in FIG. 10 , after the update of the metadata, the state of the data d1 recorded in the metadata is a modified state, and the server list in the metadata only includes the server S1.
- FIG. 11 is a flowchart of a method for reading data in a shared storage system provided by an embodiment of the present application.
- the first server in FIG. 11 is any server in the server cluster that wishes to read data, and the following description takes the server S1 as the first server for example.
- step S1101 when the application in the server S1 wishes to read the data numbered d1 , first, in step S1101 , it is determined whether the data numbered d1 is cached in the local cache. For the determination process, reference may be made to the description of step S301 above, which will not be repeated here. In the case where it is determined that there is data cached in the local cache, the data in the local cache can be directly read and returned to the application.
- the server S1 executes step S1102 to generate a data acquisition request indicating a read miss operation.
- the data acquisition request includes information such as a request type (a data acquisition request type indicating a read missing operation), a requested data number (number d1), and the number of the requesting server.
- step S1103 the server S1 sends the generated data acquisition request to the switch 2 corresponding to the data.
- step S1104 after receiving the data acquisition request, the switch 2 may forward the data acquisition request to the second server according to the metadata of the data.
- the data state recorded in the metadata is an unshared state, and/or the metadata records that the server list does not include any server information, that is, no server in the server cluster is cached in the local cache Data numbered d1.
- the switch 2 determines that the home server of the data is the server Sn according to the number d1, and forwards the data acquisition request to the server Sn, in this case, the server Sn is the second server in FIG. 11 .
- the data state recorded in the metadata is a shared state
- the switch sends the data acquisition request to any server recorded in the server list according to the server list in the metadata (for example, the server Si), that is, in this case, the server Si is the second server in FIG. 11 .
- the state of the data recorded in the metadata is a modified state
- the switch sends the data acquisition request to a server recorded in the server list (for example, the server according to the server list in the metadata) Si), that is, in this case, the server Si is the second server in FIG. 11 .
- FIG. 12 is a schematic diagram of a data reading process when the data state is a shared or modified state.
- the server S1 sends a data acquisition request indicating a read miss operation to the server Si through the switch 2, so that the data A is pulled from the local cache of the server Si through the switch 2, stored in the local cache, and returned to the Application, the switch 2 updates the metadata of the data numbered d1 after the server S1 is finished reading, to indicate that the server S1 and the server Si both have the data A cached.
- step S1105 the second server reads the data.
- the switch 2 may send the data status recorded in the data metadata to the second server together with the data acquisition request.
- the second server is the server Sn
- the server Sn can read the data A from the shared memory according to the data number d1.
- the server Si can cache the data from the local cache Read data A in.
- the server Si can read the data A from the local cache, and after the reading , the state of recording data A locally is the shared state. , to indicate that you no longer currently have permission to modify data A.
- step S1106 the second server returns the read data A to the switch 2 after reading the data.
- step S1107 the switch 2 returns the data A received from the second server to the server S1. While returning the data A to the server S1, the switch 2 can also send the status of the data in the metadata together with the server list of the data to the server S1.
- step S1108 after receiving the data A from the switch 2, the server S1 stores the data A in the local cache, and returns the data A to the application.
- the server S1 may determine whether to update the state of the data A according to the state of the data A received from the switch 2 and the read miss operation type. For example, if the initial state of data A is the unshared state, according to FIG. 8 , after the read miss operation, the state of the data becomes the shared state, so that the server S1 changes the state of the data A to the shared state. If the initial state of the data A is the modified state, referring to FIG. 8 , similarly, the server S1 changes the state of the data A to the shared state.
- the server S1 also modifies the server list received from the switch 2 accordingly, and the server S1 is added to the updated server list. For example, in the case where the initial state of data A is a shared state or a modified state, after the read operation, the updated server list includes S1 and Si.
- step S1109 the server S1 sends data read completion information to the switch 2.
- the data read completion information includes, for example, the status of the updated data and the server list of the data.
- the data processing completion information may further include read lock unlocking information.
- Step S1110 the switch 2 updates the metadata of the data according to the data read completion information.
- the switch 2 After receiving the above-mentioned data reading completion information, the switch 2 updates the metadata of the data numbered d1 according to the data status and the data server list in the data reading completion information. For example, in the case where the initial state of the data is a shared or modified state, as shown in FIG. 12 , after the update of the metadata, the state of the data recorded in the metadata is a shared state, and the server list in the metadata It includes server S1 and server Si, and the content recorded in the metadata indicates that data A is cached in both server S1 and Si, and other servers can read data A from server S1 or Si. In addition, after completing the update of the metadata of the data numbered d1, the switch 2 decodes the read-write lock of the data, that is, decrements the value of the last 15 bits of the read-write lock by 1.
- the server S1 After the server S1 writes the data A in the local cache through the above steps, according to the predetermined eviction rule, for example, when the data A is no longer the hot data of the application, or when the data A is written for more than a predetermined time, the server S1 can execute the In step S1111, a processing request indicating an eviction sharing operation of the data is generated, so as to evict the data A from the local cache.
- the processing request includes, for example, the request type (processing request type indicating the eviction sharing operation), the data number d1, and the number of the requesting server (ie, the server S1).
- step S1112 the server S1 sends the processing request to the switch 2.
- step S1113 the switch 2 returns reply information to the processing request.
- the switch 2 may perform operations such as adding a write lock to the data in the metadata.
- the switch 2 Since the eviction sharing operation will not affect the cache coherency of other servers on the data, the switch 2 does not need to forward the processing request indicating the eviction sharing operation to other servers, so that the switch 2 can directly send the request indicating the eviction to the server S1.
- the reply information of the processing request of the sharing operation may include the status and the server list in the metadata of the data numbered d1.
- the server S1 deletes the data A in the local cache after receiving the reply information. Specifically, the server S1 deletes the data A in the local cache, and determines the state of the data A according to the server list of the data A. If the server list only includes the information of the server S1, after the deletion, the state of the data A should become unshared Therefore, the server S1 modifies the state of the data A. If the server list also includes information of other servers, after the deletion, the state of the data A is still in the shared state. Meanwhile, after this deletion, the server S1 modifies the received server list, that is, deletes the information of the server S1 in the server list.
- step S1115 after deleting the data A, the server S1 sends the eviction sharing completion information to the switch 2, and the eviction sharing completion information may include the status of the data and the server list.
- step S1116 after receiving the eviction sharing completion information, the switch 2 updates the metadata of the data numbered d1, specifically, deletes the information of the server S1 in the server list of the metadata.
- the switch 2 can, for example, update the server list of the data in the metadata according to the server list of the data received from the server S1, if the state of the data received from the server changes, update the state of the data in the metadata, and release after completing the update. Write lock.
- the information of the server that caches the latest version of the data in the metadata of the data is updated by the switch, when other servers access the latest version of the data , the data access request is forwarded to the server that caches the data through the switch, thereby reducing the processing and network traffic of the server, and reducing the burden on the server.
- FIG. 13 shows an architecture diagram of a shared disk system provided by an embodiment of the present application. Similar to FIG. 1 , a plurality of servers and at least one switch are included in the shared disk system. Some of its own disks in each server are used as shared disks, and the shared disks of all servers constitute a global disk, and any server in the server cluster can access the data stored in the global disk.
- the shared disk system can be used, for example, as a distributed shared file system in which any server can access the shared files by storing them in the global disk.
- the address of the data in the global disk can be formed by the node number of the server and the address offset in the shared disk provided by the server.
- a local cache is also set. When the server reads and writes data, it will first access the local cache.
- the local cache stores the hot data of the application (Application, APP) in the server, such as the data newly written by the application. Or for frequently read data, when the storage space in the local cache is insufficient, the data in the local cache can be eliminated to the shared disk of the server.
- the accessed data is not hit in the local cache, the data is read from the global disk to the local cache, and then the data is read from the local cache.
- FIG. 14 is an architectural diagram of an intermediate device provided by an embodiment of the present application.
- the intermediate device is respectively connected to a first server and a second server, the second server stores a first version of data, and the first server stores a first version of data.
- the version is the latest version of the data, the information of the server storing the latest version of the data is recorded in the intermediate device, and the intermediate device includes:
- a receiving unit 141 configured to receive an acquisition request for the data from the first server
- a forwarding unit 142 configured to forward the obtaining request to the second server according to the information of the server storing the latest version of the data
- the receiving unit 141 is further configured to receive the first version of the data from the second server;
- the forwarding unit 142 is further configured to forward the first version of the data to the first server.
- the receiving unit 141 is further configured to receive rewriting completion information for the data from the first server; the intermediate device further includes a modifying unit 143, configured to complete the rewriting based on the rewriting completion information information, and modify the information of the server storing the latest version of the data to the information of the first server.
- the obtaining request carries a rewrite identifier
- the receiving unit 141 is further configured to receive the obtained data from the second server after forwarding the obtaining request to the second server. information that the first version of the data was deleted.
- write lock information for the data is recorded in the intermediate device, and the modification unit 143 is further configured to: after receiving a request for acquiring the data from the first server After that, modify the write lock information according to the rewrite identifier in the acquisition request to lock the data, and based on the rewrite completion information, modify the information of the server storing the latest version of the data to the first After the information of a server, the write lock information is modified to unlock the data.
- the data is hotspot data.
- FIG. 15 is a structural diagram of an intermediate device provided by an embodiment of the present application, including a processing unit 151 and a storage unit 152.
- the storage unit 152 stores executable codes, and the processing unit 151 executes the executable codes to Implement the method shown in Figure 2- Figure 12.
- FIG. 16 is a structural diagram of an intermediate device provided by an embodiment of the present application, including: a communication interface 161 for performing data transmission with a server; a processing unit 162 for processing data received by the communication interface to execute the following The method shown in Figures 2-12.
- ROM read-only memory
- RAM random-access memory
- the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware or any combination thereof.
- software it can be implemented in whole or in part in the form of a computer program product.
- the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated.
- the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
- the computer instructions may be stored in or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line, or wireless (eg, infrared, wireless, microwave, etc.) means.
- the computer-readable storage medium may be a computer Any available medium that can be accessed or a data storage device that contains one or more of the available media integration servers, data centers, etc.
- the available media may be magnetic media, (eg, floppy disks, hard disks, tapes), optical media, or Semiconductor media (such as Solid State Disk (SSD), etc.).
- the disclosed apparatus and method may be implemented in other manners without exceeding the scope of the present application.
- the above-described embodiments are only illustrative.
- the division of the modules or units is only a logical function division.
- multiple units or components may be combined. Either it can be integrated into another system, or some features can be omitted, or not implemented.
- the unit described as a separate component may or may not be physically separated, and the component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units .
- Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
提供一种数据处理方法、计算机系统和中间设备,计算机系统包括中间设备、第一服务器和第二服务器,第一服务器和第二服务器通过中间设备连接,第二服务器中存储有数据的第一版本,第一版本为数据的最新版本,中间设备中记录有存储数据的最新版本的服务器的信息,第一服务器用于通过中间设备从第二服务器获取数据的第一版本。从而减少了服务器的负担,提高了系统性能。
Description
本申请涉及存储技术领域,具体涉及一种数据处理方法、计算机系统和中间设备。
在共享存储系统中,例如在具有可以被多个服务器共享的全局内存的存储系统或者分布式共享文件系统中,需要保证多个服务器中所缓存数据的一致性,即保证每个服务器都可以访问到最新版本的数据。在一种保证缓存一致性的方法中,对于共享存储系统中的每份数据,在该数据的归属服务器中记录该数据的元数据,元数据中包括缓存该数据最新版本的服务器的信息。在数据被归属服务器之外的其他服务器修改之后,归属服务器需要更新元数据,另外,当其他服务器访问数据的最新版本时,需要由归属服务器转发数据访问请求,从而增加了归属服务器的负担。
发明内容
本申请实施例旨在提供一种数据处理方案,通过由连接多个服务器的中间设备存储数据的最新版本所在的服务器的信息,通过中间设备获取数据的最新版本,从而减少了服务器的负担,提高了系统性能。
为实现上述目的,本申请第一方面提供一种计算机系统,包括中间设备、第一服务器和第二服务器,所述第一服务器和第二服务器通过所述中间设备连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述第一服务器用于通过所述中间设备从所述第二服务器获取所述数据的第一版本。
通过由中间设备记录存储数据最新版本的第二服务器的信息,其它服务器可通过中间设备转发数据获取请求和数据最新版本,从而可从第二服务器获取数据的最新版本,减少了该数据的归属服务器的负担,提高了系统性能。
在本申请第一方面的一种可能的实现方式中,所述第二服务器还用于在获取所述数据的第一版本后,指示所述中间设备记录所述第二服务器为存储所述数据的最新版本的服务器。通过由中间设备在服务器获取数据的最新版本之后记录该服务器的信息,从而其它服务器可通过中间设备根据记录的信息获取数据的最新版本。其中,服务器可通过以下任一方式获取数据的最新版本:新写数据、从其他服务器或本地获取数据之后改写数据、从其他服务器读取数据。
在本申请第一方面的一种可能的实现方式中,所述中间设备存储有所述数据的元数据,所述中间设备用于在所述数据的元数据中记录所述第二服务器的信息。
在本申请第一方面的一种可能的实现方式中,所述第一服务器在通过所述中间设备从所述第二服务器获取所述数据的第一版本时,具体用于向所述中间设备发送对所述数据的获取请求,所述中间设备还用于:从所述第一服务器接收对所述数据的获取请求,根据存储所述数据的最新版本的服务器的信息将所述获取请求转发给所述第二服务器;从所述第二服务器接收所述数据的第一版本并转发给所述第一服务器。
通过由中间设备基于所记录的存储最新版本的服务器的信息将从第一服务器接收的数据获取请求转发给第二服务器,并将从第二服务器接收的数据的最新版本转发给第一服务器,减少了数据的归属服务器的负担。
在本申请第一方面的一种可能的实现方式中,所述第一服务器用于在接收到对所述数据的改写请求,并在本地没有命中所述数据的第一版本时,发送所述获取请求至所述中间设备;所述第一服务器在获取所述数据的第一版本之后,还用于将所述数据的第一版本改写为第二版本。
在本申请第一方面的一种可能的实现方式中,所述第一服务器还用于在将所述数据的第一版本改写为第二版本之后,向所述中间设备发送改写完成信息;所述中间设备还用于从所述第一服务器接收所述改写完成信息,基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
通过由中间设备在数据被改写之后接收改写完成信息并修改存储最新版本的服务器的信息,减少了数据的归属服务器的负担。
在本申请第一方面的一种可能的实现方式中,所述获取请求中携带有改写标识,在中间设备将所述获取请求转发给所述第二服务器之后,所述第二服务器用于根据所述获取请求中的改写标识在获取所述数据的第一版本之后删除所存储的所述数据的第一版本。
通过由第二服务器在获取数据的最新版本之后删除本地存储的数据的最新版本,保证了数据的缓存一致性,同时也减轻了服务器的负担。
在本申请第一方面的一种可能的实现方式中,所述中间设备中记录有对所述数据的写锁信息,所述中间设备还用于:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述元数据的写锁信息以对所述数据解锁。
通过由中间设备记录写锁信息并在接收到指示改写的获取请求之后通过写锁信息对数据进行锁定,保证了数据的缓存一致性,同时减轻了数据的归属服务器的负担。
在本申请第一方面的一种可能的实现方式中,所述数据为热点数据。通过使得中间设备只存储热点数据的元数据,减少了对中间设备的存储空间的需求。
在本申请第一方面的一种可能的实现方式中,所述系统还包括第三服务器,所述第三服务器与所述中间设备连接,所述第三服务器中也存储有所述数据的第一版本,所述第二服务器在接收到对所述数据的改写请求,并在本地命中所述数据的第一版本后,还用于向所述中间设备发送对所述数据的删除请求,所述中间设备还用于:从所述第二服务器接收对所述数据的删除请求,根据所述存储所述数据的最新版本的服务器的信息,将所述删除请求转发给所述第三服务器,指示所述第三服务器删除所述数据的第一版本;所述第二服务器还用于将所述数据的第一版本改写为第二版本。
在本申请第一方面的一种可能的实现方式中,所述中间设备为网络交换设备。
在本申请第一方面的一种可能的实现方式中,所述中间设备包括相互连接的第一中间设备和第二中间设备,其中,所述第一中间设备中存储有归属于所述第一服务器的数据的元数据,所述第二中间设备中存储有归属于所述第二服务器的数据的元数据。
在本申请第一方面的一种可能的实现方式中,所述计算机系统为全局内存系统或者分布式共享文件系统。
本申请第二方面提供一种数据处理方法,其特征在于,由中间设备执行,所述中间设备分别与第一服务器和第二服务器连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述方法包括:从所述第一服务器接收对所述数据的获取请求;根据所述存储所述数据的最新版本的服务器的信息,将所述获取请求转发给所述第二服务器;从所述第二服务器接收所述数据的第一版本;将所述数据的第一版本转发给所述第一服务器。
在本申请第二方面的一种可能的实现方式中,所述方法还包括:从所述第一服务器接收对所述数据的改写完成信息;基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
在本申请第二方面的一种可能的实现方式中,所述获取请求中携带有改写标识,所述方法还包括,在将所述获取请求转发给所述第二服务器之后,从所述第二服务器接收所述数据的第一版本被删除的信息。
在本申请第二方面的一种可能的实现方式中,所述中间设备中记录有对所述数据的写锁信息,所述方法还包括:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述写锁信息以对所述数据解锁。
在本申请第二方面的一种可能的实现方式中,所述数据为热点数据。
本申请第三方面提供一种中间设备,所述中间设备分别与第一服务器和第二服务器连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述中间设备包括:接收单元,用于从所述第一服务器接收对所述数据的获取请求;转发单元,用于根据所述存储所述数据的最新版本的服务器的信息,将所述获取请求转发给所述第二服务器;所述接收单元还用于从所述第二服务器接收所述数据的第一版本;所述转发单元还用于将所述数据的第一版本转发给所述第一服务器。
在本申请第三方面的一种可能的实现方式中,所述接收单元还用于从所述第一服务器接收对所述数据的改写完成信息;所述中间设备还包括修改单元,用于基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
在本申请第三方面的一种可能的实现方式中,所述获取请求中携带有改写标识,所述接收单元还用于在将所述获取请求转发给所述第二服务器之后,从所述第二服务器接收所述数据的第一版本被删除的信息。
在本申请第三方面的一种可能的实现方式中,所述中间设备中记录有对所述数据的写锁信息,所述修改单元还用于:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述写锁信息以对所述数据解锁。
在本申请第三方面的一种可能的实现方式中,所述数据为热点数据。
本申请第四方面提供一种中间设备,包括处理单元和存储单元,所述存储单元中存储有可执行代码,所述处理单元执行所述可执行代码以实现本申请第二方面所述的方法。
本申请第五方面提供一种中间设备,包括:通信接口,用于与服务器进行数据传输;处理单元,用于对所述通信接口接收的数据进行处理,以执行本申请第二方面所述的方法。
通过结合附图描述本申请实施例,可以使得本申请实施例更加清楚:
图1为本申请实施例提供的共享存储系统的架构图;
图2为本申请实施例提供的在共享存储系统中写数据的方法流程图;
图3为本申请实施例提供的在共享存储系统中改写数据的方法流程图;
图4为图3中的第一服务器中未缓存数据时所执行的流程A的流程图;
图5为在数据状态为未共享状态的情况下的数据改写过程示意图;
图6为在数据状态为共享状态的情况下的数据改写过程示意图;
图7为在数据状态为修改状态的情况下的数据改写过程示意图;
图8为数据的状态随对数据的操作的变化示意图;
图9为图3中的第一服务器中缓存有数据且数据的状态为共享状态时所执行的流程B的流程图;
图10为在数据访问请求为数据删除请求情况下的数据改写过程示意图;
图11为本申请实施例提供的在共享存储系统中读取数据的方法流程图;
图12为在数据状态为共享或修改状态的情况下的数据读取过程示意图;
图13为本申请实施例提供的共享磁盘系统的架构图;
图14为本申请实施例提供的一种中间设备的架构图;
图15为本申请实施例提供的一种中间设备的结构图;
图16本申请实施例提供的一种中间设备的结构图。
下面将结合附图,对本申请实施例中的技术方案进行描述。
图1为本申请实施例提供的共享存储系统的架构图,所述系统包括构成服务器集群的多个服务器和至少一台中间设备,其中每台中间设备与至少一个服务器连接,所述中间设备可以为可编程网络连接设备,例如交换机,下文中将以交换机作为中间设备的示例进行描述。图1中示意示出了,交换机1与服务器S1~服务器Si连接,交换机2与服务器Sj~服务器Sn连接。如图1中所示,每个服务器将自己的内存(例如动态随机存取存储器(Dynamic Random Access Memory,DRAM))分为两部分:共享内存和私有的本地缓存(即回写缓存)。服务器集群中的全部服务器的共享内存构成了一个内存池(下文称为全局内存),服务器集群中的任一服务器可以访问所述全局内存。其中,存储在全局内存中的数据的地址可以用16位的节点编号加48位的节点内地址表示,全局内存中的数据可以以地址作为数据标识(或数据编号),节点编号即为在共享内存中存储该数据的服务器的编号,节点内地址即为数据存储在服务器所提供的共享内存中的地址偏移。在各个服务器中,在服务器读写数据时,会首先访问本地缓存,本地缓存中存储有服务器中的应用程序(Application,APP)热数据,例如应用程序新写入的数据或者经常被读取的数据,当本地缓存中的存储空间不够时,可将本地缓存中的数据淘汰至服务器的共享内存中。当在本地缓存没有命中所访问的数据时,则从全局内存中将数据读取至本地内存,再从本地内存中读取数据。所述服务器可以为物理服务器,或者也可以为虚拟机、容器等基于通用硬件资源抽象的虚拟实体。交换机连接各自对应的服务器,并且交换机之间相互连接,以相对于所述多个服务器进行数据的转发。
在图1所示的共享存储系统中,需要保证多个服务器中的本地缓存中所缓存的数据的一 致性。即,当一份数据被多个服务器缓存在本地缓存时,保证多个服务器中的本地缓存中所缓存的该份数据的一致性,具体地,当一个服务器对该份数据进行修改之后,保证其他服务器可以访问到该份数据的最新版本。例如,假设服务器S1和服务器Sn在其各自的本地缓存中都缓存有编号为d1的数据A,服务器S1先对本地缓存中的数据A进行了改写操作,将数据A更新为数据A1。假设此时服务器Sn运行的应用程序对编号d1对应的数据进行读取操作,服务器Sn将从本地缓存中读取数据A,而不是最新版本的数据A1,从而导致应用程序不能读取到最新的数据。
在相关技术中,为了保证数据A被服务器S1修改为数据A1后,其他服务器仍然能读到最新版本的数据A1,需要在数据修改后,进行缓存一致性处理。具体是,对于全局内存中的数据,例如由在共享内存中存储该数据的服务器作为该数据的归属服务器,并由该归属服务器中生成并存储数据的元数据,该元数据中包括缓存该数据最新版本的服务器的信息。在数据被归属服务器之外的其他服务器修改之后,归属服务器需要更新元数据中的缓存该数据最新版本的服务器的信息,另外,当其他服务器访问数据的最新版本时,需要由归属服务器向缓存该数据的服务器转发数据访问请求,以获取数据的最新版本,从而增加了归属服务器的负担。
在本申请实施例提供的数据处理方案中,如图1所示,由交换机存储全局内存中的数据的元数据,在该元数据中会记录存储每个数据的最新版本的服务器的信息。这样,在服务器访问该数据时,服务器可将数据访问请求发送给交换机,通过交换机的基于数据的元数据的处理,从存储数据的最新版本的服务器获取数据的最新版本。通过如此,在数据被服务器修改之后,由交换机更新数据的元数据中的缓存该数据最新版本的服务器的信息,当其他服务器访问数据的最新版本时,通过交换机将数据访问请求转发给缓存该数据的服务器,从而减少了服务器的处理和网络流量,减少了服务器的负担。
如图1所示,在本申请实施例中,每台交换机可与服务器集群中的部分服务器连接,从而可由多台交换机协同处理各个服务器的数据访问请求。在一种实施方式中,可确定全局内存中的数据与各台交换机之间的对应关系。例如,可按照全局内存中的存储地址范围将全局内存中的数据划分为与多台交换机分别对应。之后,可根据各台服务器的共享内存中存储的数据与各台交换机的对应关系建立交换机与服务器之间的连接,具体是,使得每台交换机与在共享内存中存储与该台交换机对应的数据的服务器连接。每台交换机可以存储其对应的每个数据的元数据以对其对应的每个数据进行缓存一致性处理,或者,每台交换机可以仅存储其对应的数据中的热点数据的元数据,以仅对该热点数据进行缓存一致性处理。在后一情况中,交换机和服务器之间可根据数据的访问热度对数据的元数据进行迁移。例如,对于被频繁访问的数据,该数据的归属服务器可将该数据的元数据发送给其连接的交换机,从而由交换机进行对该数据的缓存一致性处理。反之,如果当前由交换机进行缓存一致性处理的数据的访问频次降低,交换机可将该数据的元数据发送给该数据的归属服务器,从而恢复由归属服务器进行对该数据的缓存一致性处理。如此使得交换机仅处理热点数据的缓存一致性处理,减少了对交换机的存储需求。
其中,数据的元数据中例如包括缓存该数据的服务器列表。服务器列表的格式例如可以是一个位图(bitmap),每个服务器对应于位图中的一位,若服务器中缓存了该数据,则数据的服务器列表中与该服务器对应的位为1,以表示该服务器在该服务器列表中。
数据的元数据中还可以包括数据的状态。数据的状态包括以下三种状态:未共享(unshared),即在服务器集群中,没有服务器在本地缓存中存储有该数据;共享(shared), 即服务器集群中的至少一个服务器的本地缓存中存储有该数据,并且该至少一个服务器仅具有对该数据的读权限;修改(modified),即服务器集群中的一个服务器的本地缓存中存储有该数据,并且该服务器具有对该数据的写权限。
在交换机中存储了数据的元数据的情况中,服务器在以下三种情况下向相应的交换机发送数据访问请求:本地缓存中未存储希望读写的数据,即缓存不命中;将要对本地缓存中存储的共享状态的数据进行改写,即写共享;删除本地缓存中存储的数据,即数据逐出。服务器根据数据在本地缓存中的存储情况可向交换机发送以下五种数据访问请求:当本地缓存中未缓存数据,并且服务器希望对该数据进行改写的情况中,服务器发送指示写缺失操作的数据获取请求;当本地缓存中未缓存数据,并且服务器希望对该数据进行读取的情况中,服务器发送指示读缺失操作的数据获取请求;当本地缓存中缓存了数据,在服务器中记录的该数据的状态为共享状态,并且该服务器希望对该数据进行改写的情况中,服务器发送指示写共享操作的数据删除请求;当本地缓存中缓存了数据,在服务器中记录的该数据的状态为修改状态,并且该服务器希望删除该数据的情况中,服务器发送指示逐出修改操作的数据写请求;当本地缓存中缓存了数据,在服务器中记录的该数据的状态为共享状态,并且该服务器希望删除该数据的情况中,服务器发送指示逐出共享操作的处理请求。其中,写缺失操作、读缺失操作、写共享操作、逐出修改操作和逐出共享操作为服务器对数据进行的五种操作类型。
交换机在从服务器接收到数据访问请求之后,可根据数据访问请求的类型、元数据中记录的缓存数据的服务器列表和数据的状态,进行相对应的处理,以用于保证各个服务器的本地缓存中所缓存的数据的一致性,这将在下文进行详细描述。
图2为本申请实施例提供的在共享存储系统中写数据的方法流程图。该方法由图1中的服务器集群中的服务器和交换机共同执行。其中,第一服务器可以为服务器集群中的任一服务器,下文中以第一服务器为服务器S1进行示例描述。
当服务器S1中的应用希望向全局内存新写入数据(例如数据A)时,执行步骤S201,生成元数据创建请求。具体是,服务器S1确定全局内存中写入数据的地址,如上文所述,该地址包括服务器节点编号和服务器的节点内地址,将该确定的地址作为数据的编号(下文表示为编号d1),并据此生成元数据创建请求。该元数据创建请求中例如包括数据编号d1等信息。该元数据创建请求中还可以包括请求服务器(即服务器S1)的编号。
服务器S1在生成元数据创建请求之后执行步骤S202,向交换机发送元数据创建请求。该交换机为编号为d1的数据A所对应的交换机,例如,如上文所述,该交换机为与数据的地址相对应的交换机。假设数据的地址指示该数据对应的交换机为图1中的交换机2,则服务器S1可通过交换机1将该元数据创建请求转发给交换机2。
交换机2在从服务器S1接收到元数据创建请求之后,创建数据的元数据,该元数据中例如包括数据A的编号d1、数据A的服务器列表等信息。其中,在创建该元数据之后,由于此时还没有任一服务器在其本地缓存中缓存有数据A,因此初始的服务器列表为空列表,即其中不包括任何服务器的信息。
所述元数据中还可以包括读写锁表。交换机2可通过元数据中的读锁或写锁,避免同时接收的对编号d1的数据的多个数据访问请求之间的冲突。该读写锁例如为16位锁,最高位为写锁,如果值为1,表示该数据被加上写锁,其他服务器将不能对该数据进行其他数据操作(如读操作、写操作、逐出操作等);读写锁的后15位为读锁,表示读该数据的服务器的数量,每加一次读锁,读写锁的后15位的值加1,每解一次读锁,读写锁的后15位的值减1,通过如此设置,如果读写锁的后15位的值不为0,表示该数据被加上读锁,其他服务器将不 能对该数据进行写操作,并且可控制读该数据的服务器的最大数目为2
15-1。
交换机2在创建数据的元数据之后,可通过该读写锁对编号d1的数据加写锁。如上文所述,在加写锁期间,其他服务器将不能通过交换机2对该数据进行其他任何操作。交换机2在后续接收到其他对编号d1的数据的数据访问请求时,如果接收的数据访问请求为上述指示读缺失操作的数据获取请求,交换机2在确定未加写锁的情况中,在元数据中加读锁,如果是上述五种数据访问请求中的其他请求,则交换机2在确定未加写锁的情况中在元数据中加写锁,如果交换机2确定数据已经加写锁或者读锁的数量已经为2
15-1次,则本次加锁失败,交换机2返回处理失败消息。
在步骤S204,交换机2在创建好数据的元数据之后,对服务器S1返回创建完成信息。该创建完成信息中例如包括对数据加写锁的信息。
在步骤S205,服务器S1在确定交换机2已经创建好数据A的元数据之后,在本地缓存中写入数据A。服务器S1在写入数据A之后,可在本地记录编号为d1的数据的状态为修改状态。当服务器S1希望再次修改编号为d1的数据时,基于该修改状态可直接对本地缓存中的数据A进行修改,即该修改状态指示服务器S1具有对编号为d1的数据的修改权限。另外,服务器S1可记录编号d1与本地缓存中存储数据A的地址(虚拟地址或物理地址)的对应关系,从而可根据该对应关系从本地缓存中读取到数据A。
在步骤S206,服务器S1向交换机2发送数据写完成信息。该数据写完成信息中例如包括数据A的状态(修改状态)。另外,该数据写完成信息中还可以包括服务器列表,该服务器列表中例如包括服务器S1的信息。
在步骤S207,交换机2在从服务器S1接收到数据写完成信息之后,基于数据写完成信息更新编号为d1的数据的元数据。具体是,交换机2可将元数据中的服务器列表修改为包括服务器S1的信息,并在元数据中记录数据A的状态为修改状态。在进行该更新之后,交换机2可在元数据中对编号为d1的数据解写锁。
服务器S1在通过上述步骤在本地缓存中写入数据A之后,根据预定逐出规则,例如当数据A不再是应用的热数据时,或者当数据A写入超过预定时间之后,服务器S1将从本地缓存中逐出修改状态的数据A。为此,服务器S1需要通过交换机2将数据的最新版本(即数据A)存储到其归属服务器中。从而,服务器S1可执行步骤S208,生成指示逐出修改的数据写请求,以将数据A存入归属服务器。由于此时数据A的状态为修改状态,该数据写请求具体为上述指示逐出修改操作的数据写请求。该数据写请求中例如包括请求类型(指示逐出修改操作的数据写请求类型)、数据编号d1、数据A和请求服务器(即服务器S1)的编号。
在步骤S209,服务器S1将数据写请求发送给交换机2。
在步骤S210,交换机2在从服务器S1接收到数据写请求之后,根据编号d1对应的数据地址,将该数据写请求转发给数据A的归属服务器(图2中以第二服务器示出),例如该归属服务器为服务器Sn。
在步骤S211,服务器Sn在接收到数据写请求之后,将数据A写入共享内存中的编号d1对应的地址中。
在步骤S212,服务器Sn在完成对数据A的写入之后,向交换机2返回数据写完成信息。交换机2在从服务器Sn接收到数据写完成信息之后,在步骤S213向服务器S1返回数据写完成信息。
在步骤S214,服务器S1在接收到数据写完成信息之后,在本地缓存中删除数据A,并在步骤S215向交换机2发送数据逐出完成信息。交换机2在接收到逐出完成信息之后,可更新 数据A的元数据,具体是,可将元数据中的服务器列表中的服务器S1的信息删除,并将数据状态修改为未共享状态。
在图2所示的流程中虽然示出了通过交换机创建数据的元数据,本申请实施例不限于此。在另一种实施方式中,交换机在接收到数据写请求之后,可根据数据编号中的数据归属服务器的编号,将该元数据创建请求发送给服务器Sn,由服务器Sn创建数据的元数据,并在该数据的访问频次增大成为热点数据之后,由服务器Sn将该元数据移至交换机2中。
在图2所示流程中,通过服务器和交换机进行了创建数据元数据的过程,以及在共享内存中存入数据的过程。在创建了数据的元数据之后,交换机2可根据服务器S1对数据的写操作或逐出操作在元数据中记录缓存编号d1的数据的最新版本的服务器的信息,从而使得其他服务器可通过交换机2获取到数据的最新版本。在该过程中,由交换机进行对元数据的创建和更新,并由交换机进行对数据访问请求的转发,减轻了服务器的负担。
图3为本申请实施例提供的在共享存储系统中改写数据的方法流程图。
图3中的第一服务器为服务器集群中希望对数据(例如编号为d1的数据)进行改写的任意服务器,下文中以服务器S1作为第一服务器进行示例描述。
如图3所示,当服务器S1中的应用希望对编号为d1的数据进行改写时,首先在步骤S301,确定本地缓存中是否存储有编号为d1的数据。服务器S1可确定在本地记录的数据编号与本地缓存中的地址的对应关系表中是否包括编号d1,如果不包括编号d1,则可确定本地缓存中没有存储编号为d1的数据,从而可执行流程A。如果包括编号d1,则可确定本地缓存中存储有编号d1的数据。
在确定本地缓存中存储有编号d1的数据的情况下,服务器S1可执行步骤S302,基于本地记录的编号d1的数据状态确定该数据是否为修改状态,如果为修改状态,服务器S1可执行步骤S303,直接对本地缓存中的编号d1的数据进行改写,如果不是修改状态,可确定该数据的状态为共享状态,则服务器S1执行流程B。
图4为图3中的第一服务器中未缓存数据时所执行的流程A的流程图。
如图4所示,在步骤S401,服务器S1生成数据获取请求。该数据获取请求为上述指示写缺失操作的数据获取请求。该数据获取请求中包括请求类型(指示写缺失操作的数据获取请求)、请求改写的数据编号(例如编号d1)和请求服务器的编号(例如服务器S1的编号)。
在步骤S402,服务器S1将数据获取请求发送给交换机2。
服务器S1在生成数据获取请求之后,根据数据的编号d1与交换机2的对应关系可确定该数据与交换机2相对应,并可通过交换机1将该数据获取请求发送给交换机2。
交换机2可确定本地是否存储有编号d1的数据的元数据,在确定本地存储有数据的元数据的情况中,进行图4所示流程的后续步骤。在确定本地未存储数据的元数据的情况中,交换机2根据数据d1的数据编号中的服务器Sn的编号,将该数据获取请求转发给服务器Sn,以由服务器Sn对该数据获取请求进行缓存一致性处理。假设交换机2中存储有编号为d1的数据的元数据,即交换机2在接收到上述数据获取请求之后进行对该请求的缓存一致性处理。
如上文所述,交换机2在接收到数据获取请求之后,可以在元数据中对数据加写锁。
交换机2在每次接收到数据访问请求之后,可以检查该数据访问请求的有效性,包括:检查数据访问请求与交换机元数据中的数据状态是否存在冲突;以及检查该数据访问请求中的请求服务器编号和元数据中该数据的服务器列表是否冲突。若发生冲突,交换机可向请求服务器返回处理失败消息。该处理失败消息中可包括失败的原因,请求服务器在接收到处理失败消息之后,可以重新尝试数据处理操作。其中,数据处理请求与交换机元数据中的数据 状态之间的冲突例如包括以下冲突:请求类型为指示写共享或者逐出共享的请求,数据的状态为不共享;请求类型为指示逐出修改的请求,数据的状态不为修改。请求服务器编号和服务器列表之间的冲突例如包括以下冲突:请求类型为指示读缺失或者写缺失的请求,但请求服务器的编号已经在缓存块的服务器列表中;请求类型为指示写共享、逐出共享或者逐出修改的请求时,请求服务器不在服务器列表中。
在步骤S403,交换机2在接收到数据获取请求之后可根据数据的元数据将数据获取请求转发给第二服务器。
在一种情况中,元数据中记录的数据状态为未共享状态,和/或元数据中记录了服务器列表中不包括任何服务器的信息,也即,服务器集群中没有服务器在本地缓存中缓存了编号为d1的数据。在该情况中,交换机2根据编号d1确定数据的归属服务器为服务器Sn,并将该数据获取请求转发给服务器Sn,在该情况中,服务器Sn为第二服务器。
图5为在数据状态为未共享状态的情况下的数据改写过程示意图。如图5所示,服务器S1在将数据获取请求发送给交换机2之后,通过交换机2从服务器Sn的共享内存中拉取编号为d1的数据A,服务器S1将数据A修改为数据A1,并在本地缓存中存储修改后的数据A1,最后交换机2在服务器S1修改完成之后更新编号为d1的数据的元数据,以指示服务器S1中存储有编号为d1的数据的最新版本。
在另一种情况中,元数据中记录的数据状态为共享状态,在该情况中,交换机根据元数据中的服务器列表,将该数据获取请求发送给服务器列表中记录的各个服务器。交换机在向各个服务器转发数据获取请求的同时,还可以指定其中一个服务器返回其缓存的数据。例如,交换机可向各个服务器发送数据包,该数据包中包括指示写缺失操作的数据获取请求和“是否返回数据”字段,通过该字段指示其中一个服务器(例如服务器Si)返回其缓存的数据。此外,该数据包中还可以包括其他字段,如数据d1的状态、数据d1的服务器列表、以及元数据是否在交换机2中等字段。
图6为在数据状态为共享状态的情况下的数据改写过程示意图。如图6所示,服务器S1在将数据获取请求发送给交换机2之后,通过交换机2将数据获取请求转发给缓存数据的各个服务器(例如服务器Si和服务器Sj),并从服务器Sj的本地缓存中拉取编号d1的数据A,服务器S1将数据A修改为数据A1,并在本地缓存中存储修改后的数据A1,最后交换机2在服务器S1修改完成之后更新编号为d1的数据的元数据,以指示服务器S1中存储有编号为d1的数据的最新版本。也就是说,在该情况中,服务器Sj为图4中的第二服务器。
在又一种情况中,元数据中记录的数据的状态为修改状态,在该情况中,交换机根据元数据中的服务器列表,将该数据获取请求发送给服务器列表中记录的一个服务器(例如服务器Si),即,在该情况中,服务器Si为图4中的第二服务器。
图7为在数据状态为修改状态的情况下的数据改写过程示意图。如图7所示,服务器S1在将数据获取请求发送给交换机2之后,通过交换机2从服务器Si的本地缓存中拉取编号d1的数据A,服务器S1将数据A修改为数据A1,并在本地缓存中存储修改后的数据A1,最后交换机2在服务器S1修改完成之后更新编号为d1的数据的元数据,以指示服务器S1中存储有编号为d1的数据的最新版本。
在步骤S404,第二服务器在接收到数据获取请求之后读取数据。
具体是,在图5所示的情况中,第二服务器为服务器Sn,服务器Sn在接收到数据获取请求之后,从共享内存中读取数据A。
在图6所示的情况中,第二服务器为服务器Sj,服务器Sj在接收到包括数据获取请求 的数据包之后,根据数据包中的“是否返回数据”字段,从本地缓存中读取数据A以用于返回。在读取数据A之后,服务器Sj根据数据获取请求的请求类型,将本地缓存中的数据A删除,以用于保证数据的缓存一致性。同样地,图6中的服务器Si在接收到交换机转发的数据获取请求之后,也将本地缓存中的数据A删除,以用于保证数据的缓存一致性。
在图7所示的情况中,第二服务器为服务器Si,服务器Si在接收到数据获取请求之后,从本地缓存中读取编号为d1的数据的最新版本(假设为数据A),并将本地缓存中的数据A删除,以保证数据的缓存一致性。
在步骤S405,第二服务器在读取数据A之后,将读取的数据A返回给交换机2。
在步骤S406,交换机2在从第二服务器接收到数据A之后,将该数据A返回给服务器S1。交换机2在将数据A返回给服务器S1的同时,还可以把元数据中编号为d1的数据的数据状态和服务器列表中的至少一个发送给服务器S1。
在步骤S407,服务器S1在接收到返回的数据A之后,将数据A改写为数据A1。
具体是,在图5所示的情况中,服务器S1在还从交换机2接收到编号为d1的数据的服务器列表的情况中,可基于该服务器列表确定只需要从服务器Sn接收回复信息,从而在确定接收到服务器Sn返回的数据A之后进行对数据A的改写。服务器S1在接收到数据的状态为未共享状态的情况中,可基于该状态确定只需要从数据的归属服务器(即服务器Sn)接收回复信息。服务器S1在接收到数据A之后,将数据A修改为数据A1作为编号为d1的数据的最新版本,并将数据A1存储到本地缓存中,其中,对数据A的修改包括对数据A中的至少部分数据的修改。
此外,服务器S1可根据接收的数据d1的状态(即未共享状态)和对数据的操作类型确定数据d1的最新状态。图8为数据的状态随对数据的操作的变化示意图,图8中的节点为数据的当前状态,节点之间的边为数据操作类型。如图8所示,服务器S1根据数据d1的当前未共享状态和写缺失操作可确定数据d1的状态变为修改状态。同时,服务器S1还相应地修改其接收的服务器列表,更新后的服务器列表中仅包括服务器S1。
在图6所示的情况中,服务器S1在还从交换机2接收到编号为d1的数据的服务器列表的情况中,假设该服务器列表中包括服务器Si和服务器Sj的信息,服务器S1可基于该服务器列表确定需要从服务器Si和Sj接收回复信息,从而在确定接收到服务器Si和Sj的回复信息之后,进行对数据A的改写,其中,服务器Si的回复信息中包括删除数据A的信息,服务器Sj的回复信息中包括数据A和删除数据A的信息。服务器S1根据图8可确定,在对共享状态的数据进行写缺失操作之后,数据的状态变为修改状态,并将该更新的数据状态发送给交换机2。
在图7所示的情况中,与图5所示情况类似地,服务器S1根据服务器列表确定在接收到服务器Si发送的数据A之后,可进行对数据A的改写。服务器S1根据图8可确定,在对修改状态的数据进行写缺失操作之后,数据的状态仍为修改状态,并可将该数据状态发送给交换机2。
在步骤S408,服务器S1向交换机2发送数据改写完成信息。
该数据改写完成信息例如包括在进行写缺失操作之后的数据d1的状态和数据d1的服务器列表。在一种实施方式中,在交换机2在接收到指示写缺失操作的数据获取请求之后对数据d1上写锁的情况中,在该数据改写完成信息中还包括写锁解锁信息。
步骤S409,交换机2在接收到数据改写完成信息之后,根据数据改写完成信息更新数据的元数据。
交换机2在接收到上述数据改写完成信息之后,根据数据改写完成信息中的数据d1的状态和数据d1的服务器列表更新编号为d1的数据的元数据。具体是,参考图5-图7,在该对元数据的更新之后,元数据中记录的数据d1的状态为修改状态,并且,元数据中的服务器列表中包括服务器S1。通过在元数据中记录数据的状态为修改状态以及数据的服务器列表中包括服务器S1,表示服务器S1可在本地缓存中对数据d1进行修改,并指示其他服务器:服务器S1的本地缓存中存储有编号为d1的数据的最新版本。从而,当其他服务器希望读写编号为d1的数据时,可通过交换机2从服务器S1读取编号为d1的数据的最新版本,从而保证了数据d1在各个服务器的缓存一致性。
在交换机2已经根据指示写缺失操作的数据获取请求对数据d1上写锁的情况中,在对元数据更新完成之后,交换机2根据数据处理完成信息中的写锁解锁信息对数据d1的写锁解锁,即,如上文所述,将数据d1的读写锁的最高位的值恢复为0。
图9为图3中的第一服务器中缓存有数据且数据的状态为共享状态时所执行的流程B的流程图。
如图9所示,假设第一服务器为服务器S1,服务器S1在确定本地缓存中缓存有编号为d1的数据且本地记录了数据的状态为共享状态的情况中,服务器S1执行步骤S901,生成指示写共享操作的数据删除请求,该数据删除请求中包括请求类型(指示写共享操作的数据删除请求类型)、请求改写的数据编号(编号d1)和请求服务器的编号(服务器S1的编号)。
在步骤S902,服务器S1将数据删除请求发送给交换机2。该步骤可参考上文对步骤S402的描述,在此不再赘述。
在步骤S903,交换机2根据数据的元数据向第二服务器转发数据删除请求。
交换机2可根据元数据中的服务器列表,确定除服务器S1之外的缓存数据的至少一个服务器,并将该数据删除请求转发给每个缓存该数据的服务器。也就是说,图9中的第二服务器可以是除服务器S1之外的缓存该数据的任一服务器,例如服务器Si。
图10为在数据访问请求为数据删除请求情况下的数据改写过程示意图。在数据元数据的服务器列表中包括服务器S1和服务器Si的信息的情况中,交换机2将数据删除请求转发给服务器Si,从而使得服务器Si删除本地缓存中的数据A,以保证数据的缓存一致性。即,在该情况中,服务器Si为图9中的第二服务器。
在步骤S904,服务器Si在接收到数据删除请求之后删除数据。
如图10所示,服务器Si在接收到上述数据删除请求之后,删除本地缓存中的数据A。
在步骤S905,服务器Si向交换机2返回删除完成信息。
在步骤S906,交换机2将接收的删除完成信息转发给服务器S1。交换机在转发删除完成信息的同时,还可以把元数据中数据的状态和数据的服务器列表一起发送给服务器S1。
在步骤S907,服务器S1在接收到来自服务器Si的删除完成信息之后,对本地缓存中的数据A进行改写。服务器S1根据从交换机2接收的数据的服务器列表可确定仅需要从服务器Si接收删除完成信息,并在确定已经从服务器Si接收到删除完成信息之后进行对数据A的改写。具体是,如图10所示,服务器S1从本地缓存中读取数据A,将数据A修改为数据A1作为编号为d1的数据的最新版本,并将数据A1存储到本地缓存中。此外,参考图8,服务器S1可根据从交换机2接收的数据d1的状态(即共享状态)和写共享操作类型将数据d1的状态更新为修改状态。同时,服务器S1还可以修改从交换机2接收的服务器列表,更新后的服务器列表中仅包括服务器S1。
在步骤S908,服务器S1向交换机2发送数据改写完成信息。
该数据改写完成信息例如包括更新的数据的状态和数据的服务器列表。
步骤S909,交换机2根据改写完成信息更新数据的元数据。
交换机2在接收到上述改写完成信息之后,根据改写完成信息中的数据的状态和数据的服务器列表更新编号为d1的数据的元数据。具体是,如图10所示,在该对元数据的更新之后,元数据中记录的数据d1的状态为修改状态,并且,元数据中的服务器列表仅包括服务器S1。
图11为本申请实施例提供的在共享存储系统中读取数据的方法流程图。
图11中的第一服务器为服务器集群中希望读取数据的任一服务器,下文中以服务器S1作为第一服务器进行示例描述。
如图11所示,当服务器S1中的应用希望读取编号为d1的数据时,首先在步骤S1101,确定本地缓存中是否缓存有编号为d1的数据。该确定的过程可参考上文对步骤S301的描述,在此不再赘述。在确定本地缓存中缓存有数据的情况中,可直接读取本地缓存中的数据返回给应用。
在确定本地缓存中未缓存数据的情况中,服务器S1执行步骤S1102,生成指示读缺失操作的数据获取请求。该数据获取请求中包括请求类型(指示读缺失操作的数据获取请求类型)、请求获取的数据编号(编号d1)和请求服务器的编号等信息。
在步骤S1103,服务器S1将生成的数据获取请求发送给数据对应的交换机2。
在步骤S1104,交换机2在接收到数据获取请求之后可根据数据的元数据将数据获取请求转发给第二服务器。
在一种情况中,元数据中记录的数据状态为未共享状态,和/或元数据中记录了服务器列表中不包括任何服务器的信息,也即,服务器集群中没有服务器在本地缓存中缓存了编号为d1的数据。在该情况中,交换机2根据编号d1确定数据的归属服务器为服务器Sn,并将该数据获取请求转发给服务器Sn,在该情况中,服务器Sn为图11中的第二服务器。
在另一种情况中,元数据中记录的数据状态为共享状态,在该情况中,交换机根据元数据中的服务器列表,将该数据获取请求发送给服务器列表中记录的任一服务器(例如服务器Si),即,在该情况中,服务器Si为图11中的第二服务器。
在又一种情况中,元数据中记录的数据的状态为修改状态,在该情况中,交换机根据元数据中的服务器列表,将该数据获取请求发送给服务器列表中记录的一个服务器(例如服务器Si),即,在该情况中,服务器Si为图11中的第二服务器。
图12为在数据状态为共享或修改状态的情况下的数据读取过程示意图。如图12所示,服务器S1通过交换机2将指示读缺失操作的数据获取请求发送给服务器Si,以通过交换机2从服务器Si的本地缓存中拉取数据A,存储到本地缓存中,并返回给应用,交换机2在服务器S1读取完成之后更新编号为d1的数据的元数据,以指示服务器S1和服务器Si中都缓存有数据A。
在步骤S1105,第二服务器读取数据。
交换机2可随数据获取请求一起将数据元数据中记录的数据状态一起发送给第二服务器。在上述第二服务器为服务器Sn的情况中,如果服务器Sn接收的数据状态为未共享状态,则服务器Sn可以根据数据的编号d1,从共享内存中读取数据A。在上述第二服务器为服务器Si的情况中,如果服务器Si接收的数据状态为共享状态,或者服务器Si可从本地记录的数据A的状态中确定数据A为共享状态,则服务器Si可从本地缓存中读取数据A。如果服务器Si接收的数据状态为修改状态,或者服务器Si可从本地记录的数据A的状态中确定数 据A为修改状态,则服务器Si可从本地缓存中读取数据A,并在该读取之后,在本地记录数据A的状态为共享状态。,以指示当前不再具有对数据A的修改权限。
在步骤S1106,第二服务器在读取数据之后向交换机2返回读取的数据A。
在步骤S1107,交换机2将从第二服务器接收的数据A返回给服务器S1。交换机2在向服务器S1返回数据A的同时,还可以把元数据中数据的状态和数据的服务器列表一起发送给服务器S1。
在步骤S1108,服务器S1在从交换机2接收到数据A之后,将数据A存储到本地缓存中,并向应用返回数据A。此外,参考图8,服务器S1可根据从交换机2接收的数据A的状态和读缺失操作类型确定是否更新数据A的状态。例如,如果数据A的初始状态为未共享状态,根据图8,在经过读缺失操作之后,数据的状态变为共享状态,从而服务器S1将数据A的状态更改为共享状态。如果数据A的初始状态为修改状态,参考图8,同样地,服务器S1将数据A的状态更改为共享状态。如果数据A的初始状态为共享状态,参考图8,在经过该读取之后,数据A的状态仍然为共享状态,不需要更改。同时,服务器S1还相应地修改从交换机2接收的服务器列表,更新后的服务器列表中添加了服务器S1。例如,在数据A的初始状态为共享状态或修改状态的情况中,在该读取操作之后,更新的服务器列表中包括S1和Si。
在步骤S1109,服务器S1向交换机2发送数据读取完成信息。
该数据读取完成信息例如包括更新的数据的状态和数据的服务器列表。在交换机2在接收到指示读缺失操作的数据获取请求之后对数据d1上读锁的情况中,该数据处理完成信息中还可以包括读锁解锁信息。
步骤S1110,交换机2根据数据读取完成信息更新数据的元数据。
交换机2在接收到上述数据读取完成信息之后,根据数据读取完成信息中的数据的状态和数据的服务器列表更新编号为d1的数据的元数据。例如,在数据初始状态为共享或修改状态的情况中,如图12所示,在该对元数据的更新之后,元数据中记录的数据的状态为共享状态,并且,元数据中的服务器列表中包括服务器S1和服务器Si,该元数据中记录的内容表示,服务器S1和Si中都缓存了数据A,其他服务器可从服务器S1或者Si读取数据A。另外,交换机2在完成对编号为d1的数据的元数据的更新之后,对数据的读写锁解读锁,即将读写锁的后15位的值减1。
服务器S1在通过上述步骤在本地缓存中写入数据A之后,根据预定逐出规则,例如当数据A不再是应用的热数据时,或者当数据A写入超过预定时间之后,服务器S1可执行步骤S1111,生成数据的指示逐出共享操作的处理请求,以将数据A从本地缓存中逐出。该处理请求中例如包括请求类型(指示逐出共享操作的处理请求类型)、数据编号d1、和请求服务器(即服务器S1)的编号。
在步骤S1112,服务器S1将处理请求发送给交换机2。
在步骤S1113,交换机2返回对处理请求的回复信息。
交换机2在接收到处理请求之后可进行在元数据中对数据加写锁等操作。
由于该逐出共享操作不会影响其它服务器对数据的缓存一致性,因此,交换机2不需要将该指示逐出共享操作的处理请求转发给其它服务器,从而可直接向服务器S1发送对指示逐出共享操作的处理请求的回复信息,该回复信息中可包括编号为d1的数据的元数据中的状态和服务器列表。
在步骤S1114,服务器S1在接收到回复信息之后在本地缓存中删除数据A。具体是,服务器S1删除本地缓存中的数据A,根据数据A的服务器列表确定数据A的状态,如果服务器 列表中只包括服务器S1的信息,则在该删除之后,数据A的状态应变为未共享状态,从而服务器S1修改数据A的状态,如果服务器列表中还包括其他服务器的信息,则在该删除之后,数据A的状态仍为共享状态。同时,在进行该删除之后,服务器S1修改接收的服务器列表,即,在服务器列表中删除服务器S1的信息。
在步骤S1115,服务器S1在删除数据A之后将逐出共享完成信息发送给交换机2,该逐出共享完成信息中可包括数据的状态和服务器列表。
在步骤S1116,交换机2在接收到逐出共享完成信息之后,更新编号为d1的数据的元数据,具体是,在元数据的服务器列表中删除服务器S1的信息。交换机2例如可根据从服务器S1接收的数据的服务器列表更新元数据中数据的服务器列表,如果从服务器接收的数据的状态发生变化,则在元数据中更新数据的状态,并在完成更新之后释放写锁。
在上述参考图2-图12描述的数据处理方案中,在数据被服务器修改之后,由交换机更新数据的元数据中的缓存该数据最新版本的服务器的信息,当其他服务器访问数据的最新版本时,通过交换机将数据访问请求转发给缓存该数据的服务器,从而减少了服务器的处理和网络流量,减少了服务器的负担。
可以理解,上文中虽然以全局内存为例描述基于共享存储系统的数据处理方案,本申请实施例提供的数据处理方案不限于用于包括全局内存的共享存储系统,而是还适用于其它带缓存的共享存储系统。图13示出本申请实施例提供的共享磁盘系统的架构图。与图1类似地,在该共享磁盘系统中包括多个服务器和至少一个交换机。每个服务器中自己的部分磁盘用作为共享磁盘,全部服务器的共享磁盘构成全局磁盘,服务器集群中的任一服务器可以访问该全局磁盘中存储的数据。该共享磁盘系统例如可用作为分布式共享文件系统,在分布式共享文件系统中,通过将共享文件存储在全局磁盘中,任一服务器都可以访问这些共享文件。全局磁盘中的数据的地址可通过服务器的节点编号和服务器所提供的共享磁盘中的地址偏移构成。在各个服务器中,还设置有本地缓存,在服务器读写数据时,会首先访问本地缓存,本地缓存中存储有服务器中的应用程序(Application,APP)热数据,例如应用程序新写入的数据或者经常被读取的数据,当本地缓存中的存储空间不够时,可将本地缓存中的数据淘汰至服务器的共享磁盘中。当在本地缓存没有命中所访问的数据时,则从全局磁盘中将数据读取至本地缓存,再从本地缓存中读取数据。
在图13所示的共享磁盘系统中,同样需要保证多个服务器中的本地缓存中所缓存的数据的一致性,本申请图2-图12所示的数据处理方法同样适用于在共享磁盘系统中保证各个服务器的数据的缓存一致性。
图14为本申请实施例提供的一种中间设备的架构图,所述中间设备分别与第一服务器和第二服务器连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述中间设备包括:
接收单元141,用于从所述第一服务器接收对所述数据的获取请求;
转发单元142,用于根据所述存储所述数据的最新版本的服务器的信息,将所述获取请求转发给所述第二服务器;
所述接收单元141还用于从所述第二服务器接收所述数据的第一版本;
所述转发单元142还用于将所述数据的第一版本转发给所述第一服务器。
在一种可能的实现方式中,所述接收单元141还用于从所述第一服务器接收对所述数据 的改写完成信息;所述中间设备还包括修改单元143,用于基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
在一种可能的实现方式中,所述获取请求中携带有改写标识,所述接收单元141还用于在将所述获取请求转发给所述第二服务器之后,从所述第二服务器接收所述数据的第一版本被删除的信息。
在一种可能的实现方式中,所述中间设备中记录有对所述数据的写锁信息,所述修改单元143还用于:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述写锁信息以对所述数据解锁。
在一种可能的实现方式中,所述数据为热点数据。
图15为本申请实施例提供的一种中间设备的结构图,包括处理单元151和存储单元152,所述存储单元152中存储有可执行代码,所述处理单元151执行所述可执行代码以实现如图2-图12所示的方法。
图16本申请实施例提供的一种中间设备的结构图,包括:通信接口161,用于与服务器进行数据传输;处理单元162,用于对所述通信接口接收的数据进行处理,以执行如图2-图12所示的方法。
需要理解,本文中的“第一”,“第二”等描述,仅仅为了描述的简单而对相似概念进行区分,并不具有其他限定作用。
本领域的技术人员可以清楚地了解到,本申请提供的各实施例的描述可以相互参照,为描述的方便和简洁,例如关于本申请实施例提供的各装置、设备的功能以及执行的步骤可以参照本申请方法实施例的相关描述,各方法实施例之间、各装置实施例之间也可以互相参照。
本领域技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的全部或部分步骤;而前述的存储介质包括:只读存储器(read-only memory,ROM)、随机存取存储器(random-access memory,RAM)、磁盘或者光盘等各种可以存储程序代码的介质。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质、或者半导体介质(例如固态硬盘(Solid State Disk,SSD)等。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,在没有超过本申请的范围内,可以通过其他的方式实现。例如,以上所描述的实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例 如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
另外,所描述装置和方法以及不同实施例的示意图,在不超出本申请的范围内,可以与其它系统,模块,技术或方法结合或集成。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电子、机械或其它的形式。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应所述以权利要求的保护范围为准。
Claims (25)
- 一种计算机系统,其特征在于,包括中间设备、第一服务器和第二服务器,所述第一服务器和第二服务器通过所述中间设备连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述第一服务器用于通过所述中间设备从所述第二服务器获取所述数据的第一版本。
- 根据权利要求1所述的系统,其特征在于,所述第二服务器还用于在获取所述数据的第一版本后,指示所述中间设备记录所述第二服务器为存储所述数据的最新版本的服务器。
- 根据权利要求2所述的系统,其特征在于,所述中间设备存储有所述数据的元数据,所述中间设备用于在所述数据的元数据中记录所述第二服务器的信息。
- 根据权利要求1-3任一项所述的系统,其特征在于,所述第一服务器在通过所述中间设备从所述第二服务器获取所述数据的第一版本时,具体用于向所述中间设备发送对所述数据的获取请求,所述中间设备还用于:从所述第一服务器接收所述获取请求,根据存储所述数据的最新版本的服务器的信息将所述获取请求转发给所述第二服务器;从所述第二服务器接收所述数据的第一版本并转发给所述第一服务器。
- 根据权利要求4所述的系统,其特征在于,所述第一服务器用于在接收到对所述数据的改写请求,并在本地没有命中所述数据的第一版本时,发送所述获取请求至所述中间设备;所述第一服务器在获取所述数据的第一版本之后,还用于将所述数据的第一版本改写为第二版本。
- 根据权利要求5所述的系统,所述第一服务器还用于在将所述数据的第一版本改写为第二版本之后,向所述中间设备发送改写完成信息;所述中间设备还用于从所述第一服务器接收所述改写完成信息,基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
- 根据权利要求5或6所述的系统,其特征在于,所述获取请求中携带有改写标识,在中间设备将所述获取请求转发给所述第二服务器之后,所述第二服务器用于根据所述获取请求中的改写标识在获取所述数据的第一版本之后删除所存储的所述数据的第一版本。
- 根据权利要求7所述的系统,其特征在于,所述中间设备中记录有对所述数据的写锁信息,所述中间设备还用于:在从所述第一服务器接收到对所述获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述元数据的写锁信息以对所述数据解锁。
- 根据权利要求1-8任一项所述的系统,其特征在于,所述数据为热点数据。
- 根据权利要求1-9任一项所述的系统,其特征在于,还包括第三服务器,所述第三服务器与所述中间设备连接,所述第三服务器中也存储有所述数据的第一版本,所述第二服务器在接收到对所述数据的改写请求,并在本地命中所述数据的第一版本后,还用于向所述中 间设备发送对所述数据的删除请求,所述中间设备还用于:从所述第二服务器接收对所述数据的删除请求,根据所述存储所述数据的最新版本的服务器的信息,将所述删除请求转发给所述第三服务器,指示所述第三服务器删除所述数据的第一版本;所述第二服务器还用于将所述数据的第一版本改写为第二版本。
- 根据权利要求1-10任一项所述的系统,其特征在于,所述中间设备为网络交换设备。
- 根据权利要求3-11任一项所述的系统,其特征在于,所述中间设备包括相互连接的第一中间设备和第二中间设备,其中,所述第一中间设备中存储有归属于所述第一服务器的数据的元数据,所述第二中间设备中存储有归属于所述第二服务器的数据的元数据。
- 根据权利要求1-12任一项所述的系统,其特征在于,所述计算机系统为全局内存系统或者分布式共享文件系统。
- 一种数据处理方法,其特征在于,由中间设备执行,所述中间设备分别与第一服务器和第二服务器连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述方法包括:从所述第一服务器接收对所述数据的获取请求;根据所述存储所述数据的最新版本的服务器的信息,将所述获取请求转发给所述第二服务器;从所述第二服务器接收所述数据的第一版本;将所述数据的第一版本转发给所述第一服务器。
- 根据权利要求14所述的方法,其特征在于,所述方法还包括:从所述第一服务器接收对所述数据的改写完成信息;基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
- 根据权利要求15所述的方法,其特征在于,所述获取请求中携带有改写标识,所述方法还包括,在将所述获取请求转发给所述第二服务器之后,从所述第二服务器接收所述数据的第一版本被删除的信息。
- 根据权利要求16所述的方法,其特征在于,所述中间设备中记录有对所述数据的写锁信息,所述方法还包括:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述写锁信息以对所述数据解锁。
- 根据权利要求14-17任一所述的方法,其特征在于,所述数据为热点数据。
- 一种中间设备,所述中间设备分别与第一服务器和第二服务器连接,所述第二服务器中存储有数据的第一版本,所述第一版本为所述数据的最新版本,所述中间设备中记录有存储所述数据的最新版本的服务器的信息,所述中间设备包括:接收单元,用于从所述第一服务器接收对所述数据的获取请求;转发单元,用于根据所述存储所述数据的最新版本的服务器的信息,将所述获取请求转发给所述第二服务器;所述接收单元还用于从所述第二服务器接收所述数据的第一版本;所述转发单元还用于将所述数据的第一版本转发给所述第一服务器。
- 根据权利要求19所述的中间设备,其特征在于,所述接收单元还用于从所述第一服务器接收对所述数据的改写完成信息;所述中间设备还包括修改单元,用于基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息。
- 根据权利要求20所述的中间设备,其特征在于,所述获取请求中携带有改写标识,所述接收单元还用于在将所述获取请求转发给所述第二服务器之后,从所述第二服务器接收所述数据的第一版本被删除的信息。
- 根据权利要求21所述的中间设备,其特征在于,所述中间设备中记录有对所述数据的写锁信息,所述修改单元还用于:在从所述第一服务器接收到对所述数据的获取请求之后,根据所述获取请求中的改写标识修改所述写锁信息以锁定所述数据,在基于所述改写完成信息,将所述存储所述数据的最新版本的服务器的信息修改为所述第一服务器的信息之后,修改所述写锁信息以对所述数据解锁。
- 根据权利要求19-22任一所述的中间设备,其特征在于,所述数据为热点数据。
- 一种中间设备,其特征在于,包括处理单元和存储单元,所述存储单元中存储有可执行代码,所述处理单元执行所述可执行代码以实现权利要求14-18任意一项所述的方法。
- 一种中间设备,其特征在于,包括:通信接口,用于与服务器进行数据传输;处理单元,用于对所述通信接口接收的数据进行处理,以执行权利要求14-18任意一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110197578.0A CN114968539A (zh) | 2021-02-22 | 2021-02-22 | 数据处理方法、计算机系统和中间设备 |
| CN202110197578.0 | 2021-02-22 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2022174705A1 true WO2022174705A1 (zh) | 2022-08-25 |
Family
ID=82932203
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/072422 Ceased WO2022174705A1 (zh) | 2021-02-22 | 2022-01-17 | 数据处理方法、计算机系统和中间设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN114968539A (zh) |
| WO (1) | WO2022174705A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115357196A (zh) * | 2022-08-31 | 2022-11-18 | 鹏城实验室 | 动态可扩展的组相联高速缓存方法、装置、设备及介质 |
| CN117851281A (zh) * | 2022-09-30 | 2024-04-09 | 成都华为技术有限公司 | 一种数据的访问方法及装置 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6324584B1 (en) * | 1997-11-26 | 2001-11-27 | International Business Machines Corp. | Method for intelligent internet router and system |
| CN102314506A (zh) * | 2011-09-07 | 2012-01-11 | 北京人大金仓信息技术股份有限公司 | 基于动态索引的分布式缓冲区管理方法 |
| WO2013009806A1 (en) * | 2011-07-12 | 2013-01-17 | Bank Of America Corporation | Service mediation framework |
| CN110059026A (zh) * | 2018-01-19 | 2019-07-26 | 华为技术有限公司 | 一种目录处理方法、装置及存储系统 |
| CN110933137A (zh) * | 2019-10-31 | 2020-03-27 | 北京浪潮数据技术有限公司 | 一种数据同步方法、系统、设备及可读存储介质 |
| CN112632029A (zh) * | 2020-12-04 | 2021-04-09 | 杭州海康威视系统技术有限公司 | 分布式存储系统的数据管理方法、装置及设备 |
-
2021
- 2021-02-22 CN CN202110197578.0A patent/CN114968539A/zh active Pending
-
2022
- 2022-01-17 WO PCT/CN2022/072422 patent/WO2022174705A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6324584B1 (en) * | 1997-11-26 | 2001-11-27 | International Business Machines Corp. | Method for intelligent internet router and system |
| WO2013009806A1 (en) * | 2011-07-12 | 2013-01-17 | Bank Of America Corporation | Service mediation framework |
| CN102314506A (zh) * | 2011-09-07 | 2012-01-11 | 北京人大金仓信息技术股份有限公司 | 基于动态索引的分布式缓冲区管理方法 |
| CN110059026A (zh) * | 2018-01-19 | 2019-07-26 | 华为技术有限公司 | 一种目录处理方法、装置及存储系统 |
| CN110933137A (zh) * | 2019-10-31 | 2020-03-27 | 北京浪潮数据技术有限公司 | 一种数据同步方法、系统、设备及可读存储介质 |
| CN112632029A (zh) * | 2020-12-04 | 2021-04-09 | 杭州海康威视系统技术有限公司 | 分布式存储系统的数据管理方法、装置及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114968539A (zh) | 2022-08-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108810041B (zh) | 一种分布式缓存系统的数据写入及扩容方法、装置 | |
| US8396936B2 (en) | Computer system with cooperative cache | |
| US10891228B2 (en) | Cache line states identifying memory cache | |
| CN103744799B (zh) | 一种内存数据访问方法、装置和系统 | |
| JP3399501B2 (ja) | 分割フェーズ制御を用いる明示的コヒーレンス | |
| CN103559319B (zh) | 分布式集群文件系统的缓存同步方法和设备 | |
| US20150058570A1 (en) | Method of constructing share-f state in local domain of multi-level cache coherency domain system | |
| CN111868699B (zh) | 用于一致性共享存储器系统的方法和设备 | |
| JP2000227909A (ja) | 混成不均等メモリ・ア―キテクチャ/単純キャッシュ専用メモリ・ア―キテクチャ・システム及び方法 | |
| CN110750507A (zh) | 面向dfs的全局命名空间下的客户端持久缓存方法及系统 | |
| JPWO2004055675A1 (ja) | ファイル管理装置、ファイル管理プログラム、ファイル管理方法およびファイルシステム | |
| CN107992270B (zh) | 一种多控存储系统全局共享缓存的方法及装置 | |
| CN107341114B (zh) | 一种目录管理的方法、节点控制器和系统 | |
| JPWO2010100679A1 (ja) | コンピュータシステム、制御方法、記録媒体及び制御プログラム | |
| CN116821058B (zh) | 元数据访问方法、装置、设备及存储介质 | |
| WO2014146424A1 (zh) | 一种基于有限数据一致性状态的服务器节点数据缓存方法 | |
| CN108363641A (zh) | 一种主备机数据传递方法、控制节点以及数据库系统 | |
| CN111406251B (zh) | 数据预取方法及装置 | |
| US20240256696A1 (en) | Data System, Data Access Method and Apparatus, and Data Processing Unit | |
| CN110737392B (zh) | 管理存储系统中的地址的方法、设备和计算机可读存储介质 | |
| CN111488293A (zh) | 多核系统中数据访问者目录的访问方法及设备 | |
| CN118550849A (zh) | 一种缓存一致性维护方法、多核系统及电子设备 | |
| CN114968539A (zh) | 数据处理方法、计算机系统和中间设备 | |
| EP2629206B1 (en) | Directory replacement method and device | |
| CN111796772B (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: 22755478 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: 22755478 Country of ref document: EP Kind code of ref document: A1 |