Etcd-based distributed middleware metadata management method, device and storage medium

By adopting a distributed middleware metadata management method based on Etcd, the complexity and consistency issues of metadata management in distributed systems are solved, achieving efficient metadata synchronization and fault handling, adapting to data growth, and reducing system complexity and maintenance costs.

CN118296077BActive Publication Date: 2026-11-27JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410421211.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-09
Publication Date
2026-11-27
Estimated Expiration
2044-04-09

AI Technical Summary

Technical Problem

Existing distributed systems suffer from problems such as high consistency and synchronization latency, large network communication overhead, complex fault handling, difficulty in expansion, insufficient security, and high maintenance and management costs in metadata management.

Method used

A distributed middleware metadata management method based on Etcd is adopted. This method achieves version control and cross-node metadata synchronization by loading all metadata, pushing incremental changes, comparing changes on a regular basis, and checking for chain break recovery. It is combined with Etcd's key-value storage system and subscription-publish mechanism.

Benefits of technology

It improves the consistency and timeliness of metadata management, effectively handles node failures, easily copes with data growth, and reduces system complexity and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118296077B_ABST
    Figure CN118296077B_ABST
Patent Text Reader

Abstract

The application provides an Etcd-based distributed middleware metadata management method and device and a storage medium. The method stores key metadata information based on an Etcd key-value storage system, combines cluster deployment of a plurality of Etcd nodes and a plurality of management nodes, uses an Etcd node data version number as a version identifier of middleware metadata management to realize version control and synchronization, uses an Etcd subscription and publication mechanism to realize broadcast notification of metadata change, realizes cross-node metadata synchronization, ensures consistency and timeliness of metadata management, has high adaptability to a distributed environment, can effectively handle data synchronization problems caused by node failure, and easily copes with growing data size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database middleware technology, and in particular to a method for metadata management in a distributed environment. Background Technology

[0002] Metadata in a database describes data, providing information about its structure, content, and relationships. It helps in understanding, managing, and organizing data, including database structure, table definitions, and index information, providing crucial support for data management and analysis. In distributed database scenarios, metadata management is key to ensuring data consistency and reliability. Currently, distributed systems face challenges such as data synchronization, node failure handling, and system scalability.

[0003] Current solutions for metadata management in distributed scenarios primarily involve distributed database storage. This approach distributes metadata across various nodes, using consistency protocols to ensure synchronization and consistency. However, these solutions typically require complex maintenance and management, including monitoring node status, handling data conflicts, and upgrading the system, thus increasing overall system complexity. Summary of the Invention

[0004] To address the problems of high consistency and synchronization latency, large network communication overhead, complex fault handling, poor scalability, insufficient security, and high maintenance and management costs in existing solutions, this application provides a distributed middleware metadata management method based on Etcd, characterized by including: Full metadata loading, including: The management node cluster requests and retrieves metadata from the Etcd cluster; Incremental push notifications for metadata changes include: The online actuator receives a DDL change request and sends it to a randomly selected first management node. The first management node persists data changes on the Etcd node and records the Etcd node data version number as the metadata change record version number. The first management node uses Etcd's publish-subscribe mechanism to broadcast metadata change tasks; Other management nodes in the management node cluster receive metadata change tasks using Etcd's publish-subscribe mechanism and push them to their online executors respectively; Other management nodes' online executors respond to metadata change task pushes and incremental application updates; The first management node updates the change task information in the Etcd node; The first management node checks whether it has received response information from all other management nodes and then broadcasts the result back to the online executor that sent the DDL change request. Metadata is periodically compared and changed, including: The online executor periodically sends local metadata information to its management node. The local metadata information includes a compressed package of local metadata, change record version number, and snapshot. The management node compares the hash value of the local metadata snapshot with the hash value of the management node's current metadata snapshot; When hash values ​​are inconsistent, the management node decompresses the local metadata, compares each change record, and decides whether to push the metadata change task to its online executor based on whether the version number of the change record is consistent. The online executor responds to metadata change task pushes and performs incremental updates to the application.

[0005] This application also provides an electronic device, including a processor and a memory, wherein the memory stores a program that can run on the processor, characterized in that the program, when executed by the processor, implements the steps of the above-described distributed middleware metadata management method based on Etcd.

[0006] This application also provides a computer-readable storage medium storing at least one program, characterized in that the at least one program can be executed by at least one processor to implement the steps of the above-described Etcd-based distributed middleware metadata management method.

[0007] This application presents a distributed middleware metadata management method based on Etcd. It stores key metadata information using the Etcd key-value storage system, combines a cluster deployment of multiple Etcd nodes and multiple management nodes, and utilizes the Etcd node data version number as the version identifier for middleware metadata management (i.e., the version number of the metadata change record) to achieve version control and synchronization. It leverages Etcd's publish-subscribe mechanism to broadcast notifications of metadata changes, enabling cross-node metadata synchronization. This ensures consistency and timeliness in metadata management, exhibits high adaptability to distributed environments, effectively handles data synchronization issues caused by node failures, and easily copes with ever-growing data volumes. Attached Figure Description

[0008] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0009] Figure 1This is a diagram of the distributed middleware metadata management architecture based on Etcd, according to an embodiment of this application. Figure 2 This is a flowchart of a distributed middleware metadata management method based on Etcd, according to an embodiment of this application. Figure 3 This is a flowchart illustrating the incremental metadata change push process in an embodiment of this application. Figure 4 This is a timing diagram of the incremental push of metadata changes according to an embodiment of this application; Figure 5 This is a flowchart illustrating the periodic comparison and modification process of metadata in an embodiment of this application. Figure 6 This is a timing diagram of the metadata periodic comparison and change in an embodiment of this application; Figure 7 This is a flowchart of the metadata check for broken link recovery according to an embodiment of this application; Figure 8 This is a schematic diagram of the electronic device structure according to an embodiment of this application. Detailed Implementation

[0010] To make the technical solution of the present invention easier to understand, the technical solution of the present invention will be further described in detail below with reference to specific embodiments and accompanying drawings. Obviously, the following embodiments are only some embodiments of the present invention and do not constitute a limitation on the technical solution of the present invention. For those skilled in the art, other embodiments can be obtained based on the embodiments of this application without creative effort.

[0011] It should be noted that the order of steps described in the method embodiments below does not constitute a limitation on the technical solution of the present invention. For those skilled in the art, certain step orders can be reasonably adjusted based on the embodiments of this application without creative effort. It should also be noted that the terms "first," "second," etc., used in the following embodiments are only used to distinguish similar objects and are not used to describe a specific order, nor do they constitute a limitation on the technical solution of the present invention. Example 1

[0012] This embodiment provides a distributed middleware metadata management method based on Etcd, which is based on... Figure 1 The management architecture shown includes: (1) Etcd cluster: As a distributed key-value store, the Etcd cluster contains multiple Etcd nodes to store metadata information and maintain metadata consistency.

[0013] (2) Management Node Cluster: The management node cluster contains multiple management nodes, which are only shown as m1, m2, and m3 in the diagram. Each management node subscribes to Etcd cluster notifications, and each management node can operate and manage the Etcd cluster, and is responsible for handling changes to metadata in the database.

[0014] (3) Actuators: Each management node can have multiple executors, and each executor can correspond to multiple management nodes. The diagram only illustrates one management node mi (i=1, 2, 3) corresponding to one executor di (i=1, 2, 3). Each management node is a stateless component. When an executor receives a DDL change request, it randomly selects a management node to process it, which can improve system availability and load balancing. The Etcd cluster establishes secure connection channels between the management node and the executors to ensure reliable data exchange.

[0015] This embodiment presents a distributed middleware metadata management method based on Etcd, such as... Figure 2 As shown, it includes the following steps: S101, Cluster Deployment, including: Build a dedicated Etcd cluster with multiple Etcd nodes in the core of the distributed system to store and manage metadata in a consistent and fault-tolerant manner. Deploy a cluster of management nodes containing multiple management nodes. Each management node subscribes to Etcd cluster notifications and is responsible for handling changes to metadata in the database.

[0016] Specifically, the Etcd API is integrated into the codebase of each management node to enable communication with the Etcd cluster. During deployment, each management node is configured to join the existing Etcd cluster as a member. Appropriate parameters, such as cluster size, are configured for Etcd.

[0017] Whenever an executor performs a metadata operation (such as adding, modifying, or deleting), the management node updates the information in Etcd. Etcd ensures consistency and distributes the updated metadata to all nodes.

[0018] The management node is responsible for metadata management tasks, including: 1. Adding, modifying, and deleting metadata: The management node is responsible for handling changes to metadata in the database, including adding new metadata items, modifying existing metadata, and deleting metadata.

[0019] 2. Distributed lock management: Ensure mutual exclusion when changing metadata by using distributed locks to coordinate access between management nodes and prevent conflicts and data inconsistencies.

[0020] 3. Metadata version control: The management node needs to maintain version control of metadata to ensure that each node can correctly synchronize and update when performing metadata operations.

[0021] 4. Metadata Change Broadcast Notification: When metadata changes, the management node is responsible for notifying other relevant nodes to ensure that all components in the system can obtain the latest metadata information in a timely manner.

[0022] 5. Periodic incremental comparison of metadata: When the executor triggers a periodic comparison task, it will send a periodic comparison message to the management node to ensure that the executor obtains the latest metadata information.

[0023] S102, Full loading of metadata, including: The management node starts up and requests all metadata from the Etcd cluster for the application system it belongs to. The Etcd cluster sends metadata to the management node on a database-by-database and table-by-table basis.

[0024] Specifically, at startup, the management node initializes its metadata cache by traversing the Etcd cluster and querying relevant information through the Etcd API, ensuring that each management node starts running with an accurate representation of the current metadata.

[0025] To reduce data transmission pressure, the Etcd cluster sends only one data object at a time.

[0026] S103, Incremental push of metadata changes: For metadata changes, such as table disabling (alter / drop), modification, undisabling (alter), and unlocking DDL locks, taking the online executor d1 and the first management node m1 as an example, such as... Figure 3 As shown, pushing incremental metadata changes includes the following steps: S1031. When the online executor d1 receives a DDL change request, it randomly selects the first management node m1 and sends the DDL change request to the first management node m1 for processing.

[0027] S1032. The first management node m1 persists the data changes on the Etcd node and records the data version number revision of the Etcd node as the metadata change record version number.

[0028] S1033, the first management node m1 broadcasts metadata change tasks using Etcd's publish-subscribe mechanism. The change task notification carries the version number of the metadata change record.

[0029] S1034. When other management nodes (m2, m3, etc.) in the management node cluster receive the metadata change task, they push the metadata change task to their online executors (d2, d3, etc.).

[0030] S1035, online executors (d2, d3, etc.) respond to metadata change task pushes and incremental updates of applications.

[0031] S1036, The first management node m1 updates the change task information in the Etcd node; S1037. The first management node m1 checks whether it has received response information from all other management nodes and feeds back the broadcast result to the online executor d1.

[0032] Specifically, the aforementioned incremental metadata change push process also includes: The first management node m1 creates a task node on Etcd. This task node monitors metadata change tasks and provides a mechanism for handling task responses. When other management nodes receive a response from their online executors regarding a successful metadata change task, they write the response information to this task node to indicate that the task response was successful. After the task node is created, all management nodes in the cluster monitor it.

[0033] Correspondingly, the online executors of other management nodes respond to metadata change task pushes, and after the application incremental update, also include: When other management nodes receive a response from their online executor metadata change task, they write the metadata change task response information into the task node. The first management node m1 checks whether it has received response information from all other management nodes; If all requests are received, the first management node m1 deletes the task node, notifies the online executor d1 that the task is complete, and replies to the online executor d1 with the interaction result.

[0034] For both online and offline DDL processing, a distributed lock needs to be added to the management node to ensure DDL mutual exclusion. Online DDL does not send table prohibition requests. Adding and releasing DDL locks only involves creating the corresponding path in the Etcd, without the need for broadcast notifications.

[0035] Online DDL processing: Locking: During online DDL processing, the management node uses distributed locks to ensure mutual exclusion. This is achieved by creating a node with a specific path in Etcd as an identifier for the lock. When creating this node, Etcd's transaction operations can be used to ensure that the node is only created if it does not already exist, thus achieving the purpose of locking.

[0036] No table ban requests are sent: In the case of online DDL, locking itself already ensures mutual exclusion of metadata operations, and online DDL does not need to interrupt the normal use of the table.

[0037] Offline DDL processing: Locking: For offline DDL, distributed locks are also required, which are implemented by creating nodes for the corresponding paths in Etcd.

[0038] Sending a table disable request: Unlike online DDL processing, offline DDL requires placing the table in an inactive state to avoid conflicts with change operations. In this case, a table disable request needs to be sent to notify other components to stop operations on the table.

[0039] Offline DDL change push incremental timing diagram as follows: Figure 4 As shown in the diagram. Here, `store` corresponds to the management node persisting data changes on the `Etcd` node, `create / watch task` corresponds to the management node creating and monitoring task nodes, `pub` corresponds to broadcasting notifications, and `delete task` corresponds to deleting task nodes.

[0040] S104. Periodic comparison and change of metadata, such as Figure 5 As shown, it includes: S1041. The online executor periodically sends incremental change requests to its management node. The incremental change request contains local metadata information of the online executor, including the key of all local metadata database tables, compressed package, change record version number and snapshot; S1042. The management node compares the hash value of the local metadata snapshot sent by its online executor with the hash value of the management node's current metadata snapshot; S1043. When hash values ​​are inconsistent, the management node decompresses the local metadata, compares each change record, and determines whether to push the metadata change task to its online executor based on whether the version numbers of the change records are consistent. The metadata change task includes incremental change data.

[0041] Specifically, when an inconsistency is found in the hash values ​​of the metadata snapshots, the management node decompresses the current metadata record and then compares the version number of each change record. Each metadata change record has an associated version number; in this embodiment, the data version number (revision) of the Etcd node is used as the metadata change record version number. The version number typically represents the change history of the record, and it increments with each change operation.

[0042] If the comparison results show that the version number of a record is inconsistent between the local snapshot and the remote node's snapshot, it indicates that this record has been changed on other nodes. Based on the synchronization policy, it can be determined whether this change needs to be pushed. Generally, if the local version number is older, the latest changes need to be pushed to the local machine.

[0043] S1044, Online executor responds to metadata change task push, application incremental update.

[0044] The metadata timed comparison and change sequence diagram of this application embodiment is as follows: Figure 6 As shown, inc req corresponds to the incremental change request process, rsp:inc data corresponds to the incremental change data push process, cmp corresponds to the metadata change record comparison process, and apply corresponds to the application incremental update process.

[0045] As a preferred embodiment, the distributed middleware metadata management method based on Etcd in this embodiment further includes: S105. Metadata Check During Disconnection Recovery: When the online executor loses connection with its management node and reconnects, the online executor proactively initiates an incremental comparison to align the metadata.

[0046] like Figure 7 As shown, it specifically includes: S1051. The online executor sends the local metadata change record version number and snapshot to its management node; S1052. The management node compares the local metadata change record version number and the snapshot hash value with the current metadata change record version number and the snapshot hash value of the management node, respectively. S1053. When the hash value is inconsistent or the version number of the local metadata change record is older, the management node sends incremental information to the online executor. S1054. The online actuator application incrementally updates the local metadata cache to ensure that the local metadata is synchronized with the management node.

[0047] As an optional solution, the distributed middleware metadata management method based on Etcd in this embodiment can adopt a load balancing mechanism to distribute the issued DDL change requests evenly to each management node for processing, ensuring that the system can efficiently handle different workloads and enhance fault tolerance.

[0048] As an optional solution, the distributed middleware metadata management method based on Etcd in this embodiment can be configured with monitoring tools to track the health and performance of the Etcd cluster and management nodes, and to regularly maintain and update the system to ensure security and efficiency.

[0049] It is worth noting that the above embodiment only uses management node m1 and its executor d1 as examples. For each management node in the cluster, the metadata management process based on Etcd distributed middleware is basically the same. The management processes of each management node in the cluster are both independent and collaborative to maintain the metadata consistency of the entire system. Taking management node m1 as an example again, the metadata management process of the management node based on Etcd distributed middleware can be summarized as follows: 1. Metadata Change Request: The management node m1 receives a metadata change request (e.g., adding a new metadata item) from its online executor d1.

[0050] 2. Add a distributed lock: Management node m1 uses distributed locks to ensure that changes to metadata are mutually exclusive, preventing other management nodes in the management cluster from performing the same operation simultaneously.

[0051] 3. Metadata Change Operations: The management node m1 performs metadata change operations in the Etcd cluster, such as adding or modifying metadata items. While performing metadata changes, the management node m1 obtains the node data version number (revision) of the corresponding metadata path in Etcd. After obtaining the node data version number, m1 uses this version number as the version identifier for the middleware (i.e., the management node) metadata management, which is the metadata change record version number.

[0052] 4. Metadata version update: After confirming the version identifier, the management node m1 updates the version information of the metadata in Etcd to ensure that other nodes can obtain the latest version number.

[0053] 5. Broadcast Announcement: After the update is complete, management node m1 can use the obtained version number to update its own metadata management version identifier to reflect the latest metadata status. Management node m1 broadcasts metadata change notifications to other management nodes, informing them of the changes to the metadata.

[0054] 6. Waiting for broadcast response: Management node m1 waits for responses from other management nodes to ensure that they have all received notification of the metadata change.

[0055] 7. Unlock: Management node m1 unlocks the distributed lock, allowing other management nodes to perform metadata modification operations.

[0056] This embodiment of the distributed middleware metadata management method based on Etcd combines Etcd distributed storage, mutual exclusion control, version management, real-time notification, and performance optimization technologies, including: 1. Etcd Distributed Storage: Etcd is used in the system core to store metadata information and maintain metadata consistency.

[0057] 2. Management Node Cluster: The cluster is equipped with multiple management nodes, each responsible for different metadata management tasks, in order to improve system availability and load balancing.

[0058] 3. Distributed Locks and Mutual Exclusion: Utilizing Etcd's distributed lock mechanism, it ensures that the executor's changes to the metadata of the database and tables are mutually exclusive, including locking, disabling tables, making changes, unblocking, and unlocking, in order to maintain data consistency.

[0059] 4. Version control and synchronization: Use the node data version number of Etcd as the version identifier for middleware metadata management.

[0060] 5. Publish / Subscribe Notifications: Utilize Etcd's publish / subscribe mechanism to broadcast notifications of metadata changes, ensuring that all system components receive the latest metadata information in a timely manner.

[0061] 6. Comparison technology and performance optimization: Introduce timed snapshot comparison and real-time comparison when the chain breaks. Reduce CPU pressure by using the hash value of the snapshot and reduce bandwidth pressure by combining metadata compression technology to optimize comparison performance and improve the performance and efficiency of metadata management.

[0062] Compared with existing technologies, the Etcd-based distributed middleware metadata management method in this embodiment has the advantage of high adaptability to distributed environments. It can effectively handle data synchronization problems caused by node failures, enabling the system to easily cope with the ever-increasing data scale and ensuring the consistency and timeliness of metadata. Through sophisticated snapshot comparison and real-time link break detection, performance loss is effectively reduced and system efficiency is improved. Example 2

[0063] This embodiment provides an electronic device, such as... Figure 8 As shown, it includes a processor 31 and a memory 32 communicatively connected to the processor 31. The memory 32 stores a program that can run on the processor 31. When executed by the processor 31, the program implements the steps of the Etcd-based distributed middleware metadata management method provided in the above embodiments. Example 3

[0064] This embodiment provides a computer-readable storage medium storing at least one program, which can be executed by at least one processor to implement the steps of the Etcd-based distributed middleware metadata management method provided in the above embodiment. The storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0065] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing the present invention. In addition to the above embodiments, the present invention may have other implementation methods. All technical solutions formed by equivalent substitution or equivalent transformation fall within the protection scope claimed by the present invention.

Claims

1. A distributed middleware metadata management method based on Etcd, characterized in that, include: Full metadata loading, including: The management node cluster requests and retrieves metadata from the Etcd cluster; Incremental push notifications for metadata changes include: The online actuator receives a DDL change request and sends it to a randomly selected first management node. The first management node persists data changes on the Etcd node and records the Etcd node data version number as the metadata change record version number. The first management node uses Etcd's publish-subscribe mechanism to broadcast metadata change tasks; Other management nodes in the management node cluster receive metadata change tasks using Etcd's publish-subscribe mechanism and push them to their online executors respectively; Other management nodes' online executors respond to metadata change task pushes and incremental application updates; The first management node updates the change task information in the Etcd node; The first management node checks whether it has received response information from all other management nodes and then broadcasts the result back to the online executor that sent the DDL change request. Metadata is periodically compared and changed, including: The online executor periodically sends local metadata information to its management node. The local metadata information includes a compressed package of local metadata, change record version number, and snapshot. The management node compares the hash value of the local metadata snapshot with the hash value of the management node's current metadata snapshot; When hash values ​​are inconsistent, the management node decompresses the local metadata, compares each change record, and decides whether to push the metadata change task to its online executor based on whether the version number of the change record is consistent. The online executor responds to metadata change task pushes and performs incremental updates to the application.

2. The distributed middleware metadata management method based on Etcd as described in claim 1, characterized in that, It also includes metadata checks for disconnection recovery: when the online executor disconnects from its management node and reconnects, the online executor proactively initiates incremental comparisons to align the metadata.

3. The distributed middleware metadata management method based on Etcd as described in claim 2, characterized in that, The online executor proactively initiates incremental comparisons to align metadata, including: The online executor sends the local metadata change record version number and snapshot to its management node; The management node compares the local metadata change record version number and snapshot hash value with the current metadata change record version number and snapshot hash value of the management node, respectively. When the hash value is inconsistent or the version number of the local metadata change record is older, the management node sends incremental information to the online executor. The online actuator application uses incremental updates to ensure that metadata remains synchronized.

4. The distributed middleware metadata management method based on Etcd as described in claim 1, characterized in that, The incremental metadata change push also includes: the first management node creates a task node to monitor metadata change tasks, and the task node is monitored by all management nodes in the management node cluster.

5. The distributed middleware metadata management method based on Etcd as described in claim 4, characterized in that, Other management nodes' online executors respond to metadata change task pushes, and after incremental application updates, also include: When other management nodes receive a response from their online executor metadata change task, they write the metadata change task response information into the task node. The first management node checks whether it has received response information from all other management nodes; If all requests are received, the first management node deletes the task node, notifies its online executor that the task is complete, and replies with the interaction result to its online executor.

6. The distributed middleware metadata management method based on Etcd as described in claim 1, characterized in that, The management node uses Etcd distributed locks to ensure DDL mutual exclusion.

7. The distributed middleware metadata management method based on Etcd as described in claim 1, characterized in that, The issued DDL change requests are evenly distributed to each management node to achieve load balancing.

8. The distributed middleware metadata management method based on Etcd as described in claim 1, characterized in that, The full load process, including cluster deployment, includes: Build an Etcd cluster containing multiple Etcd nodes to store and manage metadata in a consistent and fault-tolerant manner; Deploy a cluster of management nodes containing multiple management nodes. Each management node subscribes to Etcd cluster notifications and is responsible for handling changes to metadata in the database.

9. An electronic device comprising a processor and a memory, the memory storing a program executable on the processor, characterized in that, When the program is executed by the processor, it implements the steps of the distributed middleware metadata management method based on Etcd as described in any one of claims 1-8.

10. A computer-readable storage medium storing at least one program, characterized in that, The at least one program can be executed by at least one processor to implement the steps of the Etcd-based distributed middleware metadata management method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Metadata synchronization method, system and equipment for distributed storage system

    CN115599747A

  • Distributed file system metadata management system and operation method thereof

    CN117539841A