Metadata synchronization method, distributed database system, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINZHUAN INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2022-12-28
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]为解决现有的元数据同步过程,在满足强一致性的同时,系统性能较低的技术问题,本发明实施例提供一种元数据同步方法、分布式数据库系统和存储介质
[0029]本发明实施例提供的元数据同步方法、分布式数据库系统和存储介质,所述方法应用于分布式数据库系统,所述分布式数据库系统包括第一层元数据节点和第二层元数据节点;所述第一层元数据节点保存业务节点和所述第二层元数据节点的匹配关系;所述第二层元数据节点保存元数据信息;所述方法包括:在接收到业务节点发送的元数据更新指令时,所述第一层元数据节点根据所述匹配关系,通知所述第二层元数据节点进行修改和同步。本发明提供的方案能加快元数据同步速度,提高分布式数据库系统性能。
Smart Images

Figure CN116226274B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a metadata synchronization method, a distributed database system, and a storage medium. Background Technology
[0002] Databases are the core underlying component of financial business systems. In large-scale distributed database products, metadata includes data dictionaries for each table, distribution rules, system configuration information, etc., and records the number of storage nodes in the distributed database cluster, along with their corresponding IP addresses, ports, and other metadata information.
[0003] When a distributed database receives an SQL request, it first accesses the metadata to obtain all cluster information before correctly parsing and routing the SQL. Almost every client request requires querying the relevant metadata information. Metadata is uniformly provided by the Metadata Management Server (MDS). When the system is large, a single-node metadata service cannot handle high-concurrency requests. It needs to be expanded to multiple MDS replica nodes.
[0004] When metadata changes, multiple distribution replica nodes will experience data consistency issues, and the existing serialized synchronization logic will reduce performance metrics. Therefore, the existing distributed database metadata synchronization process has defects. Summary of the Invention
[0005] To address the technical problem of low system performance in existing metadata synchronization processes while maintaining strong consistency, this invention provides a metadata synchronization method, a distributed database system, and a storage medium.
[0006] The technical solution of this invention is implemented as follows:
[0007] This invention provides a metadata synchronization method applied to a distributed database system, the distributed database system including a first-layer metadata node and a second-layer metadata node; the first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information; the method includes: when receiving a metadata update instruction sent by a business node, the first-layer metadata node notifies the second-layer metadata node to modify and synchronize according to the matching relationship.
[0008] In one embodiment, the first layer metadata node includes a first layer master node and a first layer backup node, and a master-slave switchover is performed in the event of a failure of the first layer master node.
[0009] In one embodiment, when the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including:
[0010] The matching relationship between the business node and the second-layer metadata node is queried through the first-layer metadata node, the metadata information in the corresponding second-layer metadata node is modified, and pointer routing information is constructed. The metadata information in other second-layer metadata nodes is synchronized through the pointer routing information.
[0011] In one embodiment, constructing pointer routing information and synchronizing metadata information in other second-layer metadata nodes through the pointer routing information includes:
[0012] The startup process asynchronously modifies the pointer routing information to specific data;
[0013] When synchronizing metadata information in other second-layer metadata nodes, the specific data is synchronized according to the pointer routing information.
[0014] In one embodiment, when the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including:
[0015] During the preparation phase, the first-level metadata node sends a transaction preprocessing request to the second-level metadata node corresponding to the business node; the corresponding second-level metadata node adds a replica node, updates the table creation statement of the new replica node, and after execution, does not commit, but sends a success response to the first-level metadata node; other second-level metadata nodes update the pointer routing information, pointing to the original replica node in the corresponding second-level metadata node, and other second-level metadata nodes add replica nodes, synchronously replacing the information of the new replica nodes with the pointer routing information; after execution, other second-level metadata nodes do not commit the transaction, but send a success response to the coordinator.
[0016] During the commit phase, after the first-level metadata node receives the successful responses from all second-level metadata nodes, it notifies all second-level metadata nodes to commit the transaction.
[0017] In one embodiment, updating the pointer routing information includes:
[0018] Get the pointer route address of the replica;
[0019] Locate the most recently modified replica node based on the pointer's content;
[0020] Read the data from the replica node and assign the read data to the pointer.
[0021] In one embodiment, during the commit phase, after the first-layer metadata node receives successful responses from all second-layer metadata nodes, it notifies all second-layer metadata nodes to commit the transaction, including:
[0022] After the corresponding second-level metadata node receives the transaction commit request, the new replica node overwrites the content of the original replica node, completes the update of the table creation statement, and completes the transaction commit.
[0023] Once a change is detected in the copy information pointed to by the pointer route, an asynchronous task is started to replace the data and modify the pointer route information;
[0024] The newly added replica information of other second-level metadata nodes is also updated synchronously, overwriting the content of the original replica nodes, completing the update of the table creation statement, and completing the transaction commit.
[0025] In one embodiment, after the transaction is committed, the method further includes:
[0026] Release transaction resources held during the entire transaction execution.
[0027] This invention also provides a distributed database system, which includes a first-layer metadata node and a second-layer metadata node; the first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information; and the distributed database system executes the steps of any of the above methods.
[0028] This invention also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above methods.
[0029] This invention provides a metadata synchronization method, a distributed database system, and a storage medium. The method is applied to a distributed database system, which includes a first-layer metadata node and a second-layer metadata node. The first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information. The method includes: upon receiving a metadata update instruction sent by a business node, the first-layer metadata node, based on the matching relationship, notifies the second-layer metadata node to modify and synchronize the metadata. The solution provided by this invention can accelerate metadata synchronization and improve the performance of the distributed database system. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the structure of a distributed database system according to an embodiment of the present invention;
[0031] Figure 2This is a flowchart illustrating the synchronous preparation phase of an embodiment of the present invention.
[0032] Figure 3 This is a schematic diagram of the background synchronization of routing information according to an embodiment of the present invention;
[0033] Figure 4 This is a schematic diagram of the background replacement and synchronization metadata process in an embodiment of the present invention;
[0034] Figure 5 This is a flowchart illustrating the synchronous submission phase of an embodiment of the present invention;
[0035] Figure 6 This is a schematic diagram illustrating the process of adding synchronized data to MDS nodes in real time according to an embodiment of the present invention;
[0036] Figure 7 This is an internal structural diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0037] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.
[0038] This invention provides a metadata synchronization method, applicable to, for example... Figure 1 The distributed database system shown includes a first-layer metadata node and a second-layer metadata node; the first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information; the method includes:
[0039] Upon receiving a metadata update instruction from a service node, the first-layer metadata node notifies the second-layer metadata node to modify and synchronize based on the matching relationship.
[0040] In this embodiment, the metadata nodes are divided into two layers: a first-layer metadata node and a second-layer metadata node. The first-layer metadata node can adopt a high-availability (HA) mode and divide into primary and backup nodes, storing the matching relationship between service nodes and MDS nodes. The second-layer metadata node stores specific metadata information. In the second-layer metadata node, the metadata copies required by the service can be placed together according to the service type.
[0041] In one embodiment, the first layer metadata node includes a first layer master node and a first layer backup node, and a master-slave switchover is performed in the event of a failure of the first layer master node.
[0042] The first-level metadata nodes are divided into first-level master nodes and first-level backup nodes. When the first-level master node fails, a master-slave switch is performed to prevent the coordinator failure from causing all participants in the uncommitted state to be blocked.
[0043] In one embodiment, when the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including:
[0044] The matching relationship between the business node and the second-layer metadata node is queried through the first-layer metadata node, the metadata information in the corresponding second-layer metadata node is modified, and pointer routing information is constructed. The metadata information in other second-layer metadata nodes is synchronized through the pointer routing information.
[0045] In one embodiment, constructing pointer routing information and synchronizing metadata information in other second-layer metadata nodes through the pointer routing information includes:
[0046] The startup process asynchronously modifies the pointer routing information to specific data;
[0047] When synchronizing metadata information in other second-layer metadata nodes, the specific data is synchronized according to the pointer routing information.
[0048] In this embodiment, when a client service node needs to update its metadata, the first-layer master node acts as the metadata coordinator, and the second-layer metadata nodes act as participants, to synchronize the metadata. Specifically, the data in the second-layer metadata node of the current service connection is first modified, and then pointer routing information is constructed. Other second-layer metadata nodes synchronize through the pointer routing. Then, a dedicated process is started in the background to asynchronously modify the routing information to change the specific data. By using pointer routing information to identify the latest modification, when synchronizing copies, it is not necessary to synchronize the specific data; only one routing information needs to be synchronized according to the pointer routing, which can speed up the metadata synchronization process.
[0049] The following will provide a detailed description of two specific embodiments.
[0050] First Embodiment
[0051] In one embodiment, when the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including:
[0052] During the preparation phase, the first-level metadata node sends a transaction preprocessing request to the second-level metadata node corresponding to the business node; the corresponding second-level metadata node adds a replica node, updates the table creation statement of the new replica node, and after execution, does not commit, but sends a success response to the first-level metadata node; other second-level metadata nodes update the pointer routing information, pointing to the original replica node in the corresponding second-level metadata node, and other second-level metadata nodes add replica nodes, synchronously replacing the information of the new replica nodes with the pointer routing information; after execution, other second-level metadata nodes do not commit the transaction, but send a success response to the coordinator.
[0053] During the commit phase, after the first-level metadata node receives the successful responses from all second-level metadata nodes, it notifies all second-level metadata nodes to commit the transaction.
[0054] This embodiment uses a two-phase protocol to synchronize metadata.
[0055] In this embodiment, updating pointer routing information includes: obtaining the pointer routing address of the replica; locating the latest modified replica node based on the content of the pointer; reading the replica node data and assigning the read data to the pointer.
[0056] In practice, during the commit phase, after the first-level metadata node receives successful responses from all second-level metadata nodes, it notifies all second-level metadata nodes to commit the transaction. This includes: upon receiving the commit request, the corresponding second-level metadata node overwrites the content of the original replica node, updates the table creation statement, and commits the transaction; upon detecting a change in the replica information pointed to by the pointer route, it initiates an asynchronous task to replace and modify the pointer route information; the newly added replica information of other second-level metadata nodes is also synchronously changed, overwriting the content of the original replica node, updating the table creation statement, and committing the transaction.
[0057] In this embodiment, after the transaction is committed, the transaction resources occupied during the entire transaction execution are released.
[0058] See Figure 2 In this implementation, the steps for large-scale metadata synchronization can be further divided into:
[0059] (1) Step 1: Layering.
[0060] The metadata is divided into two layers. The first layer stores the matching relationship between two types of services, A and B, and the MDS nodes. The second layer is divided based on the matching relationship stored in the first layer.
[0061] like Figure 1As shown in this embodiment, when an external request is passed to the first layer, requiring modification of the table creation statement, the first-layer metadata node notifies the second-layer replica node to perform modification synchronization based on the saved matching relationship.
[0062] (2) Step 2, the preparation phase of the two-phase agreement.
[0063] The first layer acts as the coordinator, sending transaction preprocessing requests to the participant nodes of the second layer. Figure 2 In the first step, a1 performs a local transaction operation, adds a replica node, updates the table creation statement of the newly added replica node, and does not commit after execution, but sends a "Yes" response to the coordinator.
[0064] For other nodes, update the pointer route to point to the original replica node in a1. Other nodes then synchronize replica information based on the pointer route.
[0065] When synchronizing via pointer routing, if each replica node retrieves data according to the pointer's direction, the synchronization efficiency is low due to the large amount of data in the table creation statements. To achieve efficient, large-scale synchronization, a dedicated process is started in the background to modify the constructed routing information to the specific replica data it points to.
[0066] In this embodiment, the background process used to replace pointer routing information changes the pointer routing information to the original replica node information of a1. The background process used to replace synchronized metadata adds replica nodes to other nodes and synchronously replaces the new node information with the pointer routing information. After other nodes complete their execution, they do not commit the transaction but send a "Yes" response to the coordinator.
[0067] An asynchronous route replacement task is generated in the background to replace route information with actual data information, improving the data access speed of subsequent nodes and eliminating the need for indirect route access. Strongly consistent data access is achieved through eventual consistency of the route information.
[0068] The workflow of the background process used to replace pointer routing information can be found in the following example. Figure 3 The process retrieves the pointer routing address of the replica, locates the most recently modified replica node based on the pointer's content, reads the node's data, assigns the read data to the pointer, and finally sends a response to the background process used to replace and synchronize metadata, informing the process that metadata synchronization can begin.
[0069] like Figure 4 As shown, during the preparation phase, the background process used to replace the synchronous metadata first obtains the pointer routing information, performs the operation of adding replica nodes on other nodes, and then assigns the data in the pointer routing to all the newly added nodes.
[0070] (3) Step 3, the submission phase of the two-phase agreement.
[0071] After receiving "Yes" responses from all participants, the first-level coordinator notifies all participants to commit the transaction.
[0072] In this embodiment, as Figure 4 As shown, after receiving the transaction commit request, the new replica node overwrites the contents of the original replica node, completing the update of the table creation statement. After a1 completes the commit, it releases the resources occupied during the entire transaction execution.
[0073] After a1 is committed, the content of the replica node pointed to by the pointer route changes. A background process monitors the replica information pointed to by the pointer route; upon a change, it initiates an asynchronous task to replace the data and modify the pointer route information. After the route information changes, such as... Figure 4 As shown, the newly added replica information on other nodes is also updated synchronously, then overwriting the content of the original replica nodes. After execution, other nodes commit the transaction, and finally release the transaction resources used during the entire transaction execution.
[0074] (4) Failure Mode
[0075] The coordinator fails. Because the first-level coordinator fails, commit requests cannot be sent, and all participants in the uncommitted state will be blocked. Therefore, a high-availability (HA) mode is introduced at the first level. Figure 2 As shown, in the first layer, one node is in the master state and performs distribution operations to the second layer; the other node is in the backup state and does not perform distribution or response operations. The master and backup nodes synchronize state information, and a master-slave switchover occurs when the master node fails. Other failure modes all employ a two-phase protocol for exception handling.
[0076] Second Embodiment
[0077] See Figure 6 The method for synchronizing data when adding MDS nodes in real time in this embodiment is further analyzed as follows:
[0078] In this embodiment, external requirements are passed to the first-level node, and the master node notifies the second level to add a new business type, 'new'. Taking instance 'new1' as an example, all nodes are synchronized through pointer routing.
[0079] When synchronizing user information nodes for the new1 business, during the preparation phase, the first layer sends a transaction preprocessing request to the second layer. Upon receiving the request, instance new1 begins user information synchronization, constructing a pointer route pointing to the user information node in b1. A background process starts synchronizing routing information, replacing the routing information with the node information in b1. After this process completes, the background starts a process to replace synchronized metadata, adding a replica node to new1 and assigning the routing information to the new node. After successful data synchronization of the new node, a "Yes" response is returned to the coordinator, which sends a transaction commit request to the second layer, entering the commit phase. Upon receiving the request, the new1 node overwrites the original replica node information with the newly added replica information and then commits the transaction. After successful user information synchronization, the transaction resources occupied during the entire transaction execution are released.
[0080] When synchronizing the table creation statements for the `new1` business, during the preparation phase, the first layer sends a transaction preprocessing request to the second layer. Upon receiving the request, `new1` begins synchronizing the table creation statements. The pointer route points to the table creation statement node in `a1`. At this time, the replica node of `a1` has just entered the commit phase and has not yet executed the transaction commit. After `new1` adds a replica node, the background synchronization routing information process and the background synchronization metadata replacement process synchronize the information of the newly added replica node in `new1` with the table creation statement information of the original replica node in `a1`. At the end of the preparation phase, the `new1` node enters the commit phase, at which point `a1` completes the transaction commit. The background synchronization routing information process detects that the node data pointed to by the pointer route has been updated and synchronously updates the routing information. The background synchronization metadata replacement process starts, synchronously updating the table creation statements in `new1`, overwriting the original node information with the newly added node information, completing the table creation statement synchronization. After the transaction commits, the transaction resources occupied during the entire transaction execution are released, and the table creation statements are successfully synchronized.
[0081] This embodiment of the solution enables efficient large-scale metadata synchronization in a distributed database. It employs a layered approach, a two-phase protocol, pointer routing, and a high-availability (HA) mode, resolving the performance issues inherent in existing serialized synchronization logic. Specifically, this embodiment avoids the high-concurrency problems associated with directly modifying single-point metadata through layering. Furthermore, the use of routing information marking significantly reduces the update time of serialized synchronization logic.
[0082] The metadata synchronization method provided in this invention is applied to a distributed database system, which includes a first-layer metadata node and a second-layer metadata node. The first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information. The method includes: upon receiving a metadata update instruction sent by a business node, the first-layer metadata node, based on the matching relationship, notifies the second-layer metadata node to modify and synchronize the metadata. The solution provided by this invention can accelerate metadata synchronization and improve the performance of the distributed database system.
[0083] To implement the method of the embodiments of the present invention, the embodiments of the present invention also provide a distributed database system, the distributed database system including a first layer metadata node and a second layer metadata node; the first layer metadata node stores the matching relationship between business nodes and the second layer metadata node; the second layer metadata node stores metadata information; the distributed database system executes the steps of any of the above-described methods.
[0084] To implement the method of the embodiments of the present invention, the present invention also provides a computer program product, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of the above-described method.
[0085] Based on the hardware implementation of the above-described program modules, and in order to implement the method of this embodiment of the invention, this embodiment also provides an electronic device (computer device). Specifically, in one embodiment, the computer device may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05, and a memory (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A06. The network interface A02 is used for communication with external terminals via a network connection. When the computer program is executed by the processor A01, it implements the method of any of the above embodiments. The display screen A04 can be a liquid crystal display or an electronic ink display. The input device A05 can be a touch layer covering the display screen, a button, trackball, or touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0086] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0087] The device provided in the embodiments of the present invention includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the method of any of the above embodiments.
[0088] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0089] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0090] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0091] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0092] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0093] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0094] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0095] It is understood that the memory in the embodiments of the present invention can be volatile memory or non-volatile memory, or both. Specifically, non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this invention are intended to include, but are not limited to, these and any other suitable types of memories.
[0096] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0097] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A metadata synchronization method, characterized in that, This is applied to a distributed database system, which includes a first-layer metadata node and a second-layer metadata node. The first-layer metadata node stores the matching relationship between the business node and the second-layer metadata node; The second-layer metadata node stores metadata information; The method includes: Upon receiving a metadata update instruction from a service node, the first-layer metadata node notifies the second-layer metadata node to modify and synchronize based on the matching relationship. When the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including: During the preparation phase, the first-level metadata node sends a transaction preprocessing request to the second-level metadata node corresponding to the business node; the corresponding second-level metadata node adds a replica node, updates the table creation statement of the new replica node, and after execution, does not commit, but sends a success response to the first-level metadata node; other second-level metadata nodes update the pointer routing information, pointing to the original replica node in the corresponding second-level metadata node, and other second-level metadata nodes add replica nodes, synchronously replacing the information of the new replica nodes with the pointer routing information; after execution, other second-level metadata nodes do not commit the transaction, but send a success response to the coordinator. During the commit phase, after the first-level metadata node receives the successful responses from all second-level metadata nodes, it notifies all second-level metadata nodes to commit the transaction. The method further includes: When the first-layer metadata node receives the new node metadata update instruction sent by the business node, it notifies the newly added second-layer metadata node to update the pointer routing information and point to the original replica node in the corresponding second-layer metadata node. The newly added second-layer metadata node adds a replica node, and the information of the newly added replica node is synchronously replaced with pointer routing information.
2. The method according to claim 1, characterized in that, The first layer of metadata nodes includes a first layer primary node and a first layer backup node. In the event of a failure of the first layer primary node, a primary-backup switch is performed.
3. The method according to claim 1, characterized in that, When the first-layer metadata node receives a metadata update instruction from a service node, it notifies the second-layer metadata node to modify and synchronize based on the matching relationship, including: The matching relationship between the business node and the second-layer metadata node is queried through the first-layer metadata node, the metadata information in the corresponding second-layer metadata node is modified, and pointer routing information is constructed. The metadata information in other second-layer metadata nodes is synchronized through the pointer routing information.
4. The method according to claim 3, characterized in that, The construction of pointer routing information, and the synchronization of metadata information in other second-layer metadata nodes through the pointer routing information, includes: The startup process asynchronously modifies the pointer routing information to specific data; When synchronizing metadata information in other second-layer metadata nodes, the specific data is synchronized according to the pointer routing information.
5. The method according to claim 1, characterized in that, The updated pointer routing information includes: Get the pointer route address of the replica; Locate the most recently modified replica node based on the pointer's content; Read the data from the replica node and assign the read data to the pointer.
6. The method according to claim 1, characterized in that, During the commit phase, after the first-level metadata node receives successful responses from all second-level metadata nodes, it notifies all second-level metadata nodes to commit the transaction, including: After the corresponding second-level metadata node receives the transaction commit request, the new replica node overwrites the content of the original replica node, completes the update of the table creation statement, and completes the transaction commit. Once a change is detected in the copy information pointed to by the pointer route, an asynchronous task is started to replace the data and modify the pointer route information; The newly added replica information of other second-level metadata nodes is also updated synchronously, overwriting the content of the original replica nodes, completing the update of the table creation statement, and completing the transaction commit.
7. The method according to claim 6, characterized in that, After the transaction is committed, the method further includes: Release transaction resources held during the entire transaction execution.
8. A distributed database system, characterized in that, The distributed database system includes a first-layer metadata node and a second-layer metadata node; the first-layer metadata node stores the matching relationship between business nodes and the second-layer metadata node; the second-layer metadata node stores metadata information. The distributed database system performs the steps of the method according to any one of claims 1 to 7.
9. A storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Distributed key-value query method and query engine system
CN102591970A
Data processing method, device and system
CN103902230A