CN-122019666-A - Metadata consistency management method and device
Abstract
The specification provides a metadata consistency management method and device. The method comprises the steps that a target client node initiates write operation for locally cached target metadata, a state label of the locally cached target metadata is modified to be a first state, a remote call request for consistency management of the target metadata is initiated to a management node, the management node responds to the remote call request, if the current state of the locally recorded target metadata is a second state, the management node obtains the latest data of the target metadata from the target client node and notifies other client nodes to modify the state label of the locally cached target metadata to be the first state, and the management node responds to notification responses returned by the other client nodes to modify the state label of the locally cached target metadata to be the first state, modifies the current state of the locally recorded target metadata to be the first state, and notifies the other client nodes to update the locally cached target metadata to be the latest data.
Inventors
- YANG JUAN
- LIU YIHUA
- WANG ZHENG
- Zheng Jinfan
- LI GUOLIANG
Assignees
- 清华大学
- 北京海致星图科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260123
Claims (10)
- 1. A metadata consistency management method is characterized by being applied to a distributed system, wherein the distributed system comprises a management node for providing metadata service and a client node for using the metadata service, the client node locally caches metadata synchronized from the management node, and a cache item of the metadata comprises a state label for representing a cache state, and the method comprises the following steps: The method comprises the steps that a target client node initiates a write operation for target metadata of a local cache, a state label of the target metadata of the local cache is modified to be a first state, and a remote call request for consistency management of the target metadata is initiated to a management node, wherein the first state indicates that the metadata are being updated and unreadable; The management node responds to the remote call request to inquire the current state of the target metadata recorded locally, acquires the latest data of the target metadata from the target client node if the current state of the target metadata is a second state, and informs other client nodes to modify the state label of the target metadata cached locally into the first state, wherein the second state represents that the metadata is readable; And the management node responds to notification responses returned by the other client nodes, and if the notification responses are all the state labels of the locally cached target metadata and are changed into the first state, the management node changes the current state of the locally recorded target metadata from the second state to the first state and notifies the other client nodes to update the locally cached target metadata into the latest data.
- 2. The method of claim 1, further comprising, after the management node queries the local record for the current state of the target metadata in response to the remote invocation request: And if the current state of the target metadata is the first state, acquiring the latest data of the target metadata from the target client node.
- 3. The method according to claim 1, wherein the method further comprises: The other client nodes change the state label of the target metadata of the local cache from the first state to the second state after updating the target metadata of the local cache to the latest data; And the management node responds to notification responses returned by the other client nodes, and if the notification responses are all the notification responses for updating the locally cached target metadata to the latest data, the management node changes the current state of the locally recorded target metadata from the first state to the second state and notifies the target client node to change the state label of the locally cached target metadata from the first state to the second state.
- 4. The method of claim 1, wherein the metadata server of the distributed system maintains a list of client nodes corresponding to each metadata; The notifying other client nodes to modify the state tag of the locally cached target metadata to the first state includes: and the management node queries a client node list corresponding to the target metadata and notifies all client nodes except the target client node in the client node list to modify the state label of the locally cached target metadata into the first state.
- 5. The method according to claim 1, further comprising, after the management node responds to notification replies returned by the other client nodes, if the notification replies are all that the state tags of the locally cached target metadata have been modified to the first state: Persisting the latest data of the target metadata acquired from the target client node.
- 6. The method according to claim 1, wherein the method further comprises: A target client node initiates a reading operation of target metadata and queries a state label of the target metadata cached locally; and if the state label is in the first state, blocking the reading operation until the target metadata is read when the state label is in the second state.
- 7. The method of claim 6, wherein the method further comprises: If the state label is a third state, initiating a cache request for the target metadata to the management node, wherein the third state represents local uncached metadata; if the current state of the target metadata is a first state, the cache request is blocked, and the latest target metadata is locally maintained and issued to the target client node until the current state is a second state; the target client node receives the latest target metadata issued by the management node, caches the latest target metadata locally, and modifies the state label of the target metadata from the third state to the second state.
- 8. The method of claim 4, wherein the management node maintains a current state of all metadata and a list of client nodes corresponding to the metadata using a hash table structure.
- 9. A metadata consistency management apparatus, characterized by being applied to a distributed system including a management node providing metadata service and a client node using the metadata service, the client node locally caching metadata synchronized from the management node and a cache item of the metadata including a status tag indicating a cache status, the apparatus comprising: A write operation unit, wherein a target client node initiates write operation of target metadata of a local cache, changes a state tag of the target metadata of the local cache into a first state, and initiates a remote call request of consistency management of the target metadata to the management node, wherein the first state indicates that the metadata are being updated and unreadable; The management node responds to the remote call request and inquires the current state of the target metadata recorded locally, if the current state of the target metadata is a second state, the latest data of the target metadata is obtained from the target client node, and other client nodes are informed to change the state label of the target metadata cached locally into the first state, wherein the second state represents that the metadata is readable; And the management node responds to notification responses returned by the other client nodes, and if the notification responses are all the state labels of the locally cached target metadata and are changed into the first state, the management node changes the current state of the locally recorded target metadata from the second state to the first state and notifies the other client nodes to update the locally cached target metadata into the latest data.
- 10. An electronic device, comprising: A processor; A memory for storing processor-executable instructions; wherein the processor is configured to perform the method of any of the preceding claims 1-8.
Description
Metadata consistency management method and device Technical Field The embodiment of the specification relates to the technical field of computers, in particular to a metadata consistency management method and device. Background In a distributed system, metadata (Meta Data) plays an important role in management, for example, metadata can control information such as Data table structure, data structure, tag definition, rights, index, etc. To improve access performance, metadata is typically cached on the client (meta-client) side in a distributed system. However, metadata has a characteristic that update frequency is relatively low and reading is frequent, and a plurality of clients may access and modify the same piece of metadata at the same time, so that the metadata modified at the client side needs to be synchronized to other client sides in time, so that metadata at all client sides can be kept consistent. Otherwise, data errors may occur due to inconsistencies in the same metadata. In the related art, there are provided two synchronization modes of passive synchronization and broadcast synchronization. Passive synchronization refers to that the client pulls the latest metadata through regular heartbeat to update the local metadata, which has a problem of update delay (the local metadata may lag in the heartbeat period, so that the client may read old data). Broadcast synchronization refers to that after the local metadata of any client is changed, all clients are notified through the whole network broadcast, and the range cannot be precisely controlled in this way, so that network congestion may be caused. Therefore, there is an urgent need for a metadata consistency management scheme that combines low latency and accurate control. Disclosure of Invention The embodiment of the specification provides a metadata consistency management method and device. According to a first aspect of embodiments of the present specification, there is provided a metadata consistency management method applied to a distributed system including a management node providing metadata service and a client node using the metadata service, the client node locally caching metadata synchronized from the management node and a cache item of the metadata including a status tag indicating a cache status, the method comprising: The method comprises the steps that a target client node initiates a write operation for target metadata of a local cache, a state label of the target metadata of the local cache is modified to be a first state, and a remote call request for consistency management of the target metadata is initiated to a management node, wherein the first state indicates that the metadata are being updated and unreadable; The management node responds to the remote call request to inquire the current state of the target metadata recorded locally, acquires the latest data of the target metadata from the target client node if the current state of the target metadata is a second state, and informs other client nodes to modify the state label of the target metadata cached locally into the first state, wherein the second state represents that the metadata is readable; And the management node responds to notification responses returned by the other client nodes, and if the notification responses are all the state labels of the locally cached target metadata and are changed into the first state, the management node changes the current state of the locally recorded target metadata from the second state to the first state and notifies the other client nodes to update the locally cached target metadata into the latest data. Optionally, after the management node queries the current state of the target metadata recorded locally in response to the remote call request, the method further includes: And if the current state of the target metadata is the first state, acquiring the latest data of the target metadata from the target client node. Optionally, the method further comprises: The other client nodes change the state label of the target metadata of the local cache from the first state to the second state after updating the target metadata of the local cache to the latest data; And the management node responds to notification responses returned by the other client nodes, and if the notification responses are all the notification responses for updating the locally cached target metadata to the latest data, the management node changes the current state of the locally recorded target metadata from the first state to the second state and notifies the target client node to change the state label of the locally cached target metadata from the first state to the second state. Optionally, the metadata server of the distributed system maintains a client node list corresponding to each metadata; The notifying other client nodes to modify the state tag of the locally cached target metadata to the first state includes: and the management node queries a cl