Database cluster information processing method, product and equipment
By introducing an epoch mechanism to verify the validity of messages to be processed, the problem of residual messages in the channel when database cluster nodes change is solved, dynamic node switching and data consistency are realized, and the stability and efficient operation of the system are ensured.
Patent Information
- Application Number
- CN202511080789.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-01
- Publication Date
- 2025-11-18
AI Technical Summary
In database clusters, when node members change, there are residual data messages in the channel that have not been sent or received, leading to service interruption and data inconsistency. Existing technologies cannot effectively solve this problem.
By introducing an epoch mechanism into the database cluster, the validity of messages to be processed is verified, ensuring minimal service interruption during node list changes and achieving dynamic, smooth node switching and data consistency.
Effectively identify and clean up residual messages in the channel to ensure the consistency of information exchange in the database cluster during dynamic node changes, avoid service interruptions, and protect system security and performance.
Smart Images

Figure CN120973556A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, in particular to a database cluster information processing method, product and equipment. BACKGROUND
[0002] Multi-write database cluster is based on single-node database, coordinates database instance read-write access to the same data directory on each node in the cluster, and uniformly provides external services. The nodes in the cluster cooperate with each other by establishing inter-process communication and inter-node communication, and provide guarantee for consistent access of database instances on different nodes to shared data.
[0003] In a cluster environment, the node list in the cluster can be added, removed or maintained, helping the database cluster to adapt to the changing workload requirements and maintain the best performance state. After the cluster node members change, there will be residual messages of data that have not been sent or received before the change in the channel. For channel residual information, the general processing method is to close all existing connections, empty the network buffer, and reset the communication state, but this will cause service interruption, may lose unfinished transactions, and reduce system availability. SUMMARY
[0004] In view of the above problems, the present application provides a database cluster information processing method, product and equipment which overcomes the above problems or at least partially solves the above problems.
[0005] One object of the present application is to minimize the impact of service interruption during the change of the member list of the cluster, to ensure data consistency and dynamic and smooth node switching.
[0006] In particular, the present application provides a database cluster information processing method, comprising:
[0007] Obtaining a to-be-processed message generated by a sending node in the database cluster, the to-be-processed message comprising target information generated by the sending node and a target epoch number corresponding to the target information at the same time;
[0008] Performing validity check on the to-be-processed message inside the sending node, the validity check being used to determine whether the to-be-processed message is a channel residual message according to the target epoch number;
[0009] After the target epoch number passes the validity check of the sending node, sending the to-be-processed message to a receiving node;
[0010] Performing validity check on the to-be-processed message again by the receiving node, and in the case that the to-be-processed message does not pass the validity check of the receiving node, determining the to-be-processed message as a channel residual message and cleaning up the channel residual message.
[0011] Optionally, the sending node comprises a sending node service process;
[0012] The step of obtaining the to-be-processed message generated by the sending node in the database cluster comprises:
[0013] In response to the information generation instruction, the target information is generated by the sending node service process;
[0014] It is judged whether the cache epoch number of the sending node service process is valid;
[0015] In the case where the cache epoch number is valid, the cache epoch number is obtained;
[0016] The cache epoch number is merged as the target epoch number with the target information as the to-be-processed message.
[0017] Optionally, the step of judging whether the cache epoch number of the sending node service process is valid further comprises:
[0018] In the case where the cache epoch number is invalid, the latest epoch number is determined from the cluster member list of the database cluster, and the cache epoch number corresponding to the sending node is updated to the latest epoch number;
[0019] The latest epoch number is merged as the target epoch number with the target information as the to-be-processed message.
[0020] Optionally, the sending node further comprises a sending node communication process, which is configured to receive the to-be-processed message of the sending node service process and establish communication with other nodes;
[0021] The step of performing validity check on the to-be-processed message in the sending node comprises:
[0022] The to-be-processed message is received by the sending node communication process from the sending node service process;
[0023] It is judged in the sending node communication process whether the target epoch number in the to-be-processed message is valid;
[0024] In the case where the target epoch number is valid, the cache epoch number of the sending node communication process is obtained as a check epoch number;
[0025] The target epoch number is checked by the check epoch number;
[0026] In the case where the check is successful, it is determined that the target epoch number passes the validity check of the sending node, and the sending node communication process continues to process the to-be-processed message;
[0027] In the case where the check fails, it is determined that the target epoch number does not pass the validity check of the sending node, and the to-be-processed message is determined as a channel residual message and the channel residual message is cleaned up.
[0028] Optionally, the step of determining whether the target epoch number in the to-be-processed message is valid in the sending node communication process further comprises: in the case that the target epoch number is invalid, skipping the validity check, and continuing to process the to-be-processed message by the sending node communication process.
[0029] The step of checking the target epoch number by checking the epoch number comprises: determining whether the checking epoch number is consistent with the target epoch number, and determining that the target epoch number passes the check in the case that the checking epoch number is consistent with the target epoch number.
[0030] Optionally, the database cluster comprises a node list change period and an epoch number update period, in the node list change period, the cache epoch number of each node in the database cluster is invalid, and in the epoch number update period, the cache epoch number of the node that has not completed synchronization in the database cluster is valid, but the latest epoch number recorded in the cluster member list of the database cluster is frozen and cannot be obtained until the latest epoch number is synchronized in the database cluster.
[0031] The step of determining whether the target epoch number in the to-be-processed message is valid in the sending node communication process comprises:
[0032] Determining whether the database cluster is in a node list change period;
[0033] In the case that the database cluster is in the node list change period, determining that the target epoch number is invalid;
[0034] In the case that the database cluster is not in the node list change period, determining that the target epoch number is valid.
[0035] Optionally, the database cluster comprises an epoch number white list, and the epoch number white list is used to record the to-be-processed message that does not need to be subjected to the validity check.
[0036] The step of performing the validity check on the to-be-processed message in the sending node further comprises:
[0037] Determining whether the message type corresponding to the to-be-processed message is recorded in the epoch number white list;
[0038] In the case that the message type corresponding to the to-be-processed message is recorded in the epoch number white list, skipping the validity check;
[0039] In the case that the message type of the to-be-processed message is not recorded in the epoch number white list, performing the step of performing the validity check on the to-be-processed message in the sending node.
[0040] Optionally, the receiving node includes a receiving node communication process and a receiving node service process. The receiving node communication process is used to receive messages to be processed and establish communication with other nodes, while the receiving node service process is used to perform corresponding operations based on the messages to be processed.
[0041] The steps for the receiving node to re-validate the message to be processed include:
[0042] The receiving node's communication process receives messages to be processed from the sending node's communication process;
[0043] Determine whether the target epoch number in the message to be processed is valid;
[0044] If the target epoch number is invalid, the validity check is skipped, and the receiving node's communication process continues to process the message to be processed.
[0045] If the target epoch is valid, obtain the cached epoch corresponding to the communication process of the receiving node as the verification epoch;
[0046] The target epoch is verified by verifying the epoch number;
[0047] If the verification is successful, the target epoch number is determined to have passed the validity verification of the receiving node, and the receiving node's communication process continues to process the message to be processed.
[0048] If the verification fails, the target epoch number is determined to have failed the validity verification of the sending node, and the message to be processed is identified as a channel residual message and the channel residual message is cleaned up.
[0049] According to another aspect of the present invention, a computer program product is also provided, comprising a computer program that, when executed by a processor, implements the steps of the information processing method for any of the above-described database clusters.
[0050] According to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor executes the machine-executable program to implement the steps of the information processing method for the database cluster described above.
[0051] The information processing method for a database cluster of the present invention first obtains a message to be processed generated by a sending node in the database cluster. The message to be processed includes target information generated by the sending node and the target epoch number corresponding to the target information at the same time. Then, the sending node performs a validity check on the message to be processed. The validity check is used to determine whether the message to be processed is a channel remnant message based on the target epoch number. After the target epoch number passes the validity check of the sending node, the message to be processed is sent to the receiving node. The receiving node performs a validity check on the message to be processed again. If the message to be processed fails the validity check of the receiving node, it is determined to be a channel remnant message and is cleaned up. Through this method, the impact of service interruption can be minimized during changes to the cluster member list, ensuring data consistency and dynamic, smooth node switching and state synchronization. This ensures that the normal communication channel is not closed, and also promptly cleans up any channel remnant messages from before the change, preventing channel remnant messages from affecting the system security, performance, and data integrity after the database cluster changes.
[0052] The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description
[0053] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:
[0054] Figure 1 This is a flowchart illustrating an information processing method for a database cluster according to an embodiment of the present invention;
[0055] Figure 2 This is a schematic diagram of the epoch number validity verification process in a database cluster information processing method according to an embodiment of the present invention;
[0056] Figure 3 This is a schematic diagram of the node change process in a database cluster information processing method according to an embodiment of the present invention;
[0057] Figure 4 This is a flowchart illustrating the process of a sending node service process generating a message to be processed in an information processing method for a database cluster according to an embodiment of the present invention.
[0058] Figure 5 This is a flowchart illustrating the process of resetting its own cached epoch number in an information processing method for a database cluster according to an embodiment of the present invention.
[0059] Figure 6 This is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0060] Figure 7 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and
[0061] Figure 8 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0062] Those skilled in the art should understand that the embodiments described below are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. These partial embodiments are intended to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those skilled in the art without creative effort should still fall within the scope of protection of the present invention.
[0063] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from an instruction execution system, apparatus or device, or in conjunction with such instruction execution system, apparatus or device).
[0064] Multi-write database clusters, built upon single-node databases, coordinate the read and write access of database instances on each node within the cluster to the same data directory, providing a unified external service. Nodes in the cluster collaborate through inter-process communication and inter-node communication, ensuring consistent access to shared data for database instances on different nodes.
[0065] In the current cluster environment, nodes can be added, removed, or maintained to help the database cluster adapt to changing workload demands and maintain optimal performance. When cluster node members change, residual data messages that were not sent or received before the change will remain in the channel. The common approach to handling residual channel information is to close all existing connections, clear the network buffer, and reset the communication state. However, this can lead to service interruptions, potentially resulting in the loss of unfinished transactions and reduced system availability.
[0066] To minimize service interruptions, ensure data consistency, and facilitate dynamic and smooth node switching and state synchronization during cluster member list changes, normal communication channels are not closed. After cluster node members change, residual data messages from before the change will remain in the channels. This residual information can affect system security, performance, and data integrity after the cluster change.
[0067] To address the aforementioned issues, this proposal suggests an information processing method for database clusters based on epoch numbers. Figure 1 This is a flowchart illustrating an information processing method for a database cluster according to an embodiment of the present invention, as shown below. Figure 1 As shown, the information processing method of the database cluster includes at least the following steps S101 to S106.
[0068] Step S101: Obtain the pending messages generated by the sending nodes in the database cluster. The pending messages generally include target information generated by the sending nodes and the target epoch number corresponding to the target information at the same time.
[0069] When handling cache-consistent lock resources, global lock resources, and Remote Procedure Call (RPC) resources, the service processes in the cluster need to collaborate with each other through communication processes between the cluster nodes to maintain cache consistency. Therefore, after a change in the cluster node list, residual information may remain between the time when the service processes within a node send messages to the communication processes, and between the inter-node communication processes sending messages to each other.
[0070] To mark information in the channel before and after cluster changes, this invention introduces an epoch number. The epoch number corresponds to the cluster node list; when the node list changes, the epoch number also changes. After a node list change, receiving a message marked with the epoch number before the change indicates that the message is a residual message. The target information generally refers to business data generated by the service process of the sending node (e.g., database operation instructions, data query results, node status notifications, etc.), and the target epoch number is the epoch number when the sending node generated this target information. It is typically used to identify the state of the cluster member list at the time the information was generated. This epoch number corresponds to the cluster node list, and when the cluster node list changes, the epoch number also changes.
[0071] Specifically, a sending node can generally include a sending node service process and a sending node communication process. The sending node service process is generally used to generate corresponding target information according to instructions, while the sending node communication process is generally used to receive pending messages from the sending node service process and establish communication with other nodes.
[0072] This invention selects the target epoch number to identify whether the message to be processed is a channel remnant message. During node changes in the database cluster, the epoch number is updated along with the node change. To ensure that the correct epoch number can still be obtained during node changes, in some optional embodiments, the steps of obtaining the message to be processed generated by the sending node in the database cluster generally include: in response to an information generation instruction, the sending node service process generates target information; determining whether the cached epoch number of the sending node service process is valid; if the cached epoch number is valid, obtaining the cached epoch number; and merging the cached epoch number as the target epoch number with the target information to obtain the message to be processed.
[0073] The validity of an epoch number is generally determined by the state of the database cluster. For example, during node changes in a database cluster, there are typically periods of node list changes and epoch number updates. The node list change period involves modifying the nodes, during which the latest epoch number needs to be regenerated upon completion of the node change. To ensure normal message flow during the period of node changes and before the latest epoch number is generated, this invention stipulates that the cached epoch number of each node in the database cluster is invalid during the node list change period.
[0074] After a node change is completed and a new epoch is generated, the new epoch needs to be synchronized to other nodes. This invention selects a new coordinating node, which then synchronizes the new epoch to other members in the cluster, ensuring epoch consistency within the cluster. The synchronization process performed by the coordinating node is called the epoch update period. During this time, the cached epochs of nodes in the database cluster that have not yet completed synchronization are valid, but the new epoch recorded in the cluster member list of the database cluster is frozen and cannot be retrieved until the new epoch is fully synchronized in the database cluster.
[0075] In addition, if the sending node's own cached epoch is invalid, the epoch number needs to be retrieved from the current cluster member list and updated in the current cached epoch number. That is, after determining whether the sending node's cached epoch number is valid at the current moment, the process generally includes: if the cached epoch number is invalid, determining the latest epoch number from the database cluster member list and updating the sending node's corresponding cached epoch number to the latest epoch number; merging the latest epoch number as the target epoch number with the target information as the message to be processed.
[0076] Step S102 involves performing a validity check on the message to be processed within the sending node. This validity check determines whether the message to be processed is a channel remnant message based on the target epoch number. This step is a preliminary check of message validity by the sending node, with the core purpose of preventing messages carrying invalid epoch numbers from entering the cluster transmission link.
[0077] In some optional embodiments, the step of validating the message to be processed within the sending node generally includes: the sending node communication process receiving the message to be processed from the sending node service process; determining whether the target epoch number in the message to be processed is valid within the sending node communication process; if the target epoch number is valid, obtaining the cached epoch number of the sending node communication process as the verification epoch number; verifying the target epoch number using the verification epoch number; if the verification is successful, determining that the target epoch number has passed the validity verification of the sending node, and the sending node communication process continuing to process the message to be processed; if the verification fails, determining that the target epoch number has not passed the validity verification of the sending node, classifying the message to be processed as a channel remnant message, and clearing the channel remnant message.
[0078] The steps for verifying the target epoch number by verifying the epoch number generally include: determining whether the verification epoch number is consistent with the target epoch number; if the verification epoch number is consistent with the target epoch number, it indicates that the message to be processed generated by the sending node service process is in the same epoch as the sending node communication process, so it can continue to be processed, and the target epoch number is determined to have passed the verification.
[0079] Optionally, after the step of determining whether the target epoch number in the message to be processed is valid in the communication process of the sending node, the process may also include: if the target epoch number is invalid, skip the validity check and let the communication process of the sending node continue to process the message to be processed.
[0080] Since a database cluster includes periods of node list changes and epoch updates, during a node list change, the cached epoch of each node in the database cluster is invalid. During an epoch update, the cached epochs of nodes that have not yet completed synchronization are valid, but the latest epoch recorded in the cluster member list is frozen and cannot be obtained until the latest epoch is synchronized throughout the database cluster. Therefore, the steps for determining the validity of the target epoch in the message to be processed during the sending node's communication process generally include: determining whether the database cluster is in a node list change period; if the database cluster is in a node list change period, determining that the target epoch is invalid; if the database cluster is not in a node list change period, determining that the target epoch is valid. This ensures that if the target epoch is invalid, it indicates that the database cluster is currently in a node list change period. To ensure the normal operation of other nodes, the validity check can be skipped, and the sending node's communication process can send the message to be processed to the corresponding receiving node.
[0081] This way, by performing internal verification at the sending node, invalid messages caused by local cache anomalies (such as the service process and the communication process being out of sync with each other) can be filtered out in advance, reducing the waste of cluster transmission resources.
[0082] Step S103: If the message to be processed fails the validity check of the sending node, determine that the message to be processed is a channel residual message and clean up the channel residual message.
[0083] Step S104: If the message to be processed passes the validity check of the sending node, the message to be processed is sent to the receiving node.
[0084] In step S105, the receiving node performs another validity check on the message to be processed.
[0085] In some optional embodiments, the determination process of the receiving node and the sending node is the same. The receiving node includes a receiving node communication process and a receiving node service process. The receiving node communication process is used to receive messages to be processed and establish communication with other nodes. The receiving node service process is used to perform corresponding operations according to the messages to be processed.
[0086] Specifically, the steps for the receiving node to re-verify the validity of the message to be processed generally include: the receiving node's communication process receiving the message to be processed from the sending node's communication process; determining whether the target epoch number in the message to be processed is valid; if the target epoch number is invalid, skipping the validity verification and allowing the receiving node's communication process to continue processing the message to be processed; if the target epoch number is valid, obtaining the cached epoch number corresponding to the receiving node's communication process as the verification epoch number; verifying the target epoch number using the verification epoch number; if the verification is successful, determining that the target epoch number has passed the receiving node's validity verification and allowing the receiving node's communication process to continue processing the message to be processed; if the verification fails, determining that the target epoch number has not passed the sending node's validity verification, classifying the message to be processed as a channel remnant message, and clearing the channel remnant message.
[0087] Step S106: If the message to be processed fails the validity check of the receiving node, the message to be processed is determined to be a channel remnant message and the channel remnant message is cleaned up. This step is the processing mechanism after the receiving node's verification fails. The core is to clear the remnant message in the cluster transmission link caused by the epoch number asynchrony between nodes. A typical scenario where the verification fails is that the receiving node has synchronized to the new epoch number, while the sending node is still using the old epoch number. In this case, the communication process of the receiving node determines that the old epoch number carried by the message is inconsistent with its own verification epoch number, indicating that this message is a channel remnant message. The communication process of the receiving node directly discards the message and does not pass it to the service process to avoid invalid information interfering with business processing.
[0088] Step S107: If the message to be processed passes the validity check of the receiving node, the receiving node processes the message. The target epoch number in the message matches the verification epoch number of the receiving node's communication process, and both are in a valid state, indicating that the message conforms to the current cluster state of the receiving node. The receiving node's communication process transmits the message to be processed to the receiving node's service process. The service process extracts the target information and executes the corresponding business operation (such as performing data writing, responding to queries, etc.).
[0089] This method enables the accurate identification and cleanup of residual messages in the database cluster by verifying the validity of the target epoch, thus ensuring the consistency of information exchange in the cluster under dynamic node change scenarios.
[0090] In some alternative embodiments, during cluster node list changes, before the epoch number update is complete, there may be a situation where communication is established to reset the cached epoch number, and the current epoch number cannot be obtained from the cluster node list. During this period, some Remote Procedure Call (RPC) resources are processed. At this time, the cluster node list change is not complete, and there is no residual information in the channel. To avoid the epoch number affecting the processing of these messages, an epoch number whitelist is established for the message types processed during this period. That is, if these messages are processed, epoch number verification is not required. In other words, the database cluster includes an epoch number whitelist, which is used to record pending messages that do not require validity verification.
[0091] Optionally, before the step of validating the message to be processed within the sending node, the process may generally include: determining whether the message type corresponding to the message to be processed is recorded in the epoch whitelist; if the message type corresponding to the message to be processed is recorded in the epoch whitelist, skipping the validity check; if the message type of the message to be processed is not recorded in the epoch whitelist, performing the step of validating the message to be processed within the sending node. Some optional examples of message types in the whitelist include: node change status: querying node change completed messages, querying node status messages, querying node change status messages, querying cluster node list change messages; coordinating node election: electing a coordinating node message, resetting the election of a coordinating node message, and the election of a coordinating node completed message. Those skilled in the art can determine the message types to be added to the whitelist based on actual business needs.
[0092] Figure 2 This is a schematic diagram of the epoch validity verification process in a database cluster information processing method according to an embodiment of the present invention; as follows: Figure 2 As shown, the epoch number validity verification process includes at least the following steps S201 to S207.
[0093] Step S201: The sending node's communication process receives the message to be processed from the sending node's service process. This step involves data transfer between processes within the sending node. After the sending node's service process generates the message to be processed (including target information and target epoch number), it needs to transmit it across nodes through the communication process. Therefore, the communication process first acts as the receiver to obtain the message transmitted by the service process.
[0094] Step S202: Determine whether the target epoch number in the message to be processed is valid. After receiving the message, the communication process first determines the validity of the target epoch number; this is a pre-screening step in the verification logic. A valid example is when the cluster state corresponding to the target epoch number is stable (e.g., the cluster is not in a node list change period, and the epoch number has not been marked as obsolete by the coordinating node); an invalid example is when the cluster is in a node list change period, causing all epoch numbers in the cluster to become invalid.
[0095] Step S203: If the determination in step S202 is negative, the verification is skipped, and the sending node's communication process continues to process the message to be processed. This mainly applies to messages from periods of node list changes. When the target epoch number is invalid, the communication process does not perform epoch number comparison and directly enters the subsequent processing flow.
[0096] Step S204: If the determination in step S202 is yes, obtain the cached epoch number of the communication process of the sending node as the verification epoch number.
[0097] Step S205 involves verifying the target epoch by checking the epoch number. This step is the core of the internal verification within the sending node. By comparing the target epoch number with the verification epoch number, it determines whether the message conforms to the cluster state recognized by the communication process. Specifically: if they match, it indicates that the epoch number when the service process generated the message is synchronized with the current epoch number of the communication process (i.e., the message is generated based on the same cluster state); if they do not match, it indicates that the message may be generated based on an outdated cluster state (e.g., the service process cache has not been updated in time).
[0098] Step S206: If step S205 shows that the verification failed, it is determined that the target epoch number failed the validity verification of the sending node. The message to be processed is then identified as a channel remnant message and cleaned up. If the target epoch number is inconsistent with the verification epoch number, the communication process determines that the message to be processed is a channel remnant message and performs cleanup. For example, the service process's cache may not be updated to the latest epoch number of the communication process in time, causing the message to carry an old epoch number. This can intercept invalid messages before they enter the cluster transmission link, preventing them from occupying network resources or interfering with the processing logic of the receiving node.
[0099] Step S207: If the verification in step S205 shows that the target epoch number has passed the validity check of the sending node, the sending node's communication process continues to process the message to be processed. If the target epoch number matches the verification epoch number, it indicates that the message conforms to the cluster state as perceived by the communication process, and the communication process proceeds to subsequent processing (such as sending to the receiving node). This ensures that the message sent to the receiving node is a valid message generated based on the current cluster state from the sender's perspective.
[0100] This method enables precise message filtering within the sending node, ensuring the smooth transmission of valid messages while blocking invalid residual messages. It also accommodates the special needs of dynamic cluster changes, providing efficient and reliable upfront protection for information interaction across the entire database cluster.
[0101] Figure 3 This is a schematic diagram of the node change process in a database cluster information processing method according to an embodiment of the present invention; as shown. Figure 3 As shown, the information processing method of the database cluster includes at least the following steps S301 to S306.
[0102] Step S301, Node List Change. This step is the triggering event for cluster topology adjustment, referring to the process in the database cluster where the member list changes due to the addition, removal, failure, or recovery of nodes. Some possible examples include: active changes: adding nodes to expand cluster capacity, removing redundant nodes to optimize resources; passive changes: nodes going offline due to network failures or hardware malfunctions, or rejoining the cluster after recovery. Node list changes can disrupt the original cluster consistency (e.g., the epoch number corresponding to the old member list can no longer match the new topology), therefore, subsequent steps are needed to update the epoch number to mark the new state.
[0103] Step S302, Freeze the Epoch Number. After the node list is changed, the cluster enters the preparation phase before the Epoch Number is updated. At this time, the Epoch Numbers recorded in the cluster node list need to be frozen. Freezing means prohibiting all nodes in the cluster from obtaining the Epoch Number from the cluster node list, ensuring that the Epoch Number state of each node remains stable before the new Epoch Number is generated, thereby avoiding communication conflicts caused by inconsistent Epoch Numbers during the transition phase after the node list change.
[0104] Step S303: Elect a coordinating node. After the node list changes, a new coordinating node needs to be determined through an election mechanism to be responsible for the generation and synchronization of subsequent epochs.
[0105] Step S304: Update the epoch number of the coordinating node. After the coordinating node election is completed, it generates a new epoch number bound to the new node list, thus completing the update of its own epoch number.
[0106] Step S305: Unfreeze the coordinating node's epoch number. After completing its own epoch number update, the coordinating node unfreezes its epoch number, allowing it to provide synchronization services for the new epoch number. Unfreezing means restoring the coordinating node's read and write permissions for the epoch number, enabling it to write the new epoch number to the cluster member list and respond to synchronization requests from other nodes.
[0107] Step S306: The coordinating node synchronizes the epoch number with other nodes in the cluster. The coordinating node synchronizes the new epoch number to all nodes in the cluster through broadcast or point-to-point communication, completing the epoch number update for the entire cluster. At this point, the cluster enters a stable operation phase based on the new epoch number.
[0108] This method ensures the uniqueness and consistency of the new epoch number and provides an accurate state benchmark for subsequent message verification, ultimately achieving a smooth transition and reliable operation of the cluster during dynamic adjustments.
[0109] Figure 4 This is a flowchart illustrating the process of a sending node service process generating a message to be processed in an information processing method for a database cluster according to an embodiment of the present invention; as follows: Figure 4 As shown, the process of generating the message to be processed includes at least the following steps S401 to S406.
[0110] Step S401: In response to the information generation instruction, the sending node service process generates the target information. After receiving the information generation instruction (such as a data operation request initiated by a user or a state synchronization instruction within the cluster), the sending node service process (the core component responsible for business logic processing) generates the specific target information, which is the core business data that needs to be transmitted within the cluster, according to the instruction content.
[0111] Step S402: Determine if the cached epoch number of the sending node service process is valid. After generating the target information, the service process needs to bind the corresponding epoch number (the cluster state at the time of information generation) to it. Before binding, it is necessary to determine if the locally cached epoch number is valid. A cached epoch number is considered valid if the cluster member list corresponding to it is stable (e.g., the cluster is not in a node list change period, and the epoch number has not been marked as outdated). If the cluster state corresponding to the cached epoch number has expired (e.g., the cluster is in a node addition / exit change period, the member list bound to the old epoch number is inconsistent with the current actual list, or the cache has been cleared / marked as invalid due to timeout, process restart, etc.), then the epoch number is deemed invalid. Through validity determination, the method of obtaining the epoch number (directly using the cache or updating from the cluster) is decided, avoiding binding invalid epoch numbers to the target information and ensuring the legality of the message from the source.
[0112] Step S403: If the determination in step S402 is yes, obtain the cached epoch number, and merge the cached epoch number as the target epoch number with the target information as the message to be processed.
[0113] Step S404: If the determination in step S402 is negative, determine the latest epoch number from the cluster member list of the database cluster. When the cached epoch number is invalid, the service process needs to obtain the latest valid epoch number from the cluster member list. The cluster member list is generally used to record the current valid epoch number of the cluster in real time. This can overcome the limitations of local caching and ensure that the service process can obtain an epoch number that reflects the current true state of the cluster, providing an accurate status identifier for subsequent message binding.
[0114] Step S405: Update the cached epoch number corresponding to the sending node to the latest epoch number.
[0115] Step S406: The latest epoch number is used as the target epoch number and merged with the target information as a message to be processed.
[0116] This method can improve processing efficiency under normal conditions through caching mechanism and ensure accuracy in dynamic scenarios through cluster update mechanism. Ultimately, it provides state-matched messages to be processed for cross-node information interaction in the database cluster, which is the premise and foundation for subsequent validity verification, residual message cleanup and other processes.
[0117] Figure 5 This is a flowchart illustrating the process of resetting its own cached epoch number in an information processing method for a database cluster according to an embodiment of the present invention; as follows: Figure 5 As shown, the information processing method of the database cluster includes at least the following steps S501 to S505.
[0118] Step S501: The sending node communication process establishes a connection with other processes.
[0119] Step S502: Read the cached epoch number of the communication process of the sending node.
[0120] Step S503: Determine whether the cached epoch number of the sending node's communication process is valid. The communication process needs to reset the cached epoch number each time it communicates to avoid using an invalid epoch number for message verification and to prevent valid messages from being misjudged as residual messages due to an incorrect verification benchmark.
[0121] Step S504: If the determination in step S503 is negative, determine the latest epoch number from the cluster member list of the database cluster.
[0122] Step S505: Update the cached epoch number corresponding to the communication process of the sending node to the latest epoch number.
[0123] This method resets the cached epoch number when each communication process establishes a connection with other processes, thereby ensuring the accuracy and real-time performance of subsequent verification benchmarks. This reduces the transmission of invalid messages and improves the fault tolerance of the cluster in dynamic change scenarios, providing a fundamental support for the efficient and reliable operation of the database cluster.
[0124] In summary, in order to correctly clean up residual channel information based on the epoch number, the method of the present invention selects to maintain an epoch number for each node. The specific operations for the epoch number include the following aspects:
[0125] Regarding the acquisition of the epoch number, when the communication process establishes a connection with other processes, the epoch number cached by the communication process is reset to facilitate the subsequent verification process; when the service process generates a message to be processed, it needs to read the cached epoch number. If the current cached epoch number is invalid, the epoch number is obtained from the current cluster member list and updated to the current cached epoch number.
[0126] Regarding the freezing, updating, and synchronization of epoch numbers, the method of this invention sets the epoch number to be frozen during the epoch number update period, so that other processes cannot obtain the current epoch number from the cluster node list, ensuring normal communication during the epoch number update period; and after electing a new coordinating node, the epoch number is updated, the epoch number is unfrozen, and the coordinating node synchronizes it to other members in the cluster, ensuring epoch number consistency within the cluster.
[0127] In addition, a whitelist of epoch numbers is set up. If messages within the whitelist are processed, epoch number verification is not required.
[0128] The flowchart provided in this embodiment is not intended to indicate that the operations of the method will be performed in any particular order, or that all operations of the method are included in every case. Furthermore, the method may include additional operations. Within the scope of the technical concept provided by the method in this embodiment, additional variations can be made to the above method.
[0129] It should be understood that in some embodiments, the components may be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented using software or firmware stored in memory and executed by a suitable instruction execution system.
[0130] This embodiment also provides a computer program product 10, a computer-readable storage medium 20, and a computer device 30. Figure 6 This is a schematic diagram of a computer program product 10 according to an embodiment of the present invention. Figure 7 This is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention. Figure 8This is a schematic diagram of a computer device 30 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which, when executed by the processor 32, implements the steps of the information processing method for the database cluster described above. A computer-readable storage medium 20 stores the computer program 11 thereon, which, when executed by the processor 32, implements the steps of the information processing method for the database cluster described above. The computer device 30 may include a memory 31, a processor 32, and the computer program 11 stored in the memory 31 and running on the processor 32.
[0131] The computer program 11 used to perform the operations of this invention may be assembly instructions, Instruction Set Architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, integrated circuit configuration data, or source code or object code written in any combination of one or more programming languages and procedural programming languages. The computer program 11 may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a Local Area Network (LAN) or Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, to perform aspects of this invention, electronic circuits, including, for example, programmable logic circuits, Field-Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), may execute computer-readable program instructions using status information from computer-readable program instructions to personalize the electronic circuits.
[0132] For the purposes of this embodiment, computer program product 10 is a related product containing computer program 11. For the purposes of this embodiment, computer-readable storage medium 20 is a tangible device capable of holding and storing computer program 11, and can be any device capable of containing, storing, communicating, propagating, or transmitting program 11 for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable storage medium 20 include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable optical disc read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical encoding device, and any suitable combination thereof.
[0133] Computer device 30 can be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, computer device 30 can be a cloud computing node. Computer device 30 can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., that perform specific tasks or implement specific abstract data types. Computer device 30 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can reside on local or remote computing system storage media, including storage devices.
[0134] Computer device 30 may include a processor 32 adapted to execute stored instructions and a memory 31 that provides temporary storage space for the operation of said instructions during operation. The processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any other configuration. The memory 31 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0135] Computer device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows external devices that can be connected to the computer device to input and output data. The network adapter / interface provides communication between the computer device and a network, typically represented as a communication network.
[0136] Therefore, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Thus, the scope of the present invention should be understood and construed as covering all such other variations or modifications.
Claims
1. An information processing method for a database cluster, comprising: Obtain the pending message generated by the sending node in the database cluster. The pending message includes the target information generated by the sending node and the target epoch number corresponding to the target information at the same time. The validity check of the message to be processed is performed inside the sending node. The validity check is used to determine whether the message to be processed is a channel remnant message based on the target epoch number. After the target epoch number passes the validity verification of the sending node, the message to be processed is sent to the receiving node; The receiving node performs the validity check on the message to be processed again. If the message to be processed fails the validity check by the receiving node, the message to be processed is determined to be a channel residual message and the channel residual message is cleared.
2. The information processing method for a database cluster according to claim 1, wherein, The sending node includes a sending node service process; The step of obtaining the pending messages generated by the sending node in the database cluster includes: In response to the information generation instruction, the target information is generated by the sending node service process; Determine whether the cached epoch number of the sending node service process is valid; If the cached epoch is valid, obtain the cached epoch. The cached epoch number is used as the target epoch number and merged with the target information to form the message to be processed.
3. The information processing method for a database cluster according to claim 2, wherein, The step of determining whether the cached epoch number of the sending node service process is valid also includes: If the cached epoch is invalid, the latest epoch is determined from the cluster member list of the database cluster, and the cached epoch corresponding to the sending node is updated to the latest epoch. The latest epoch number is used as the target epoch number and combined with the target information to form the message to be processed.
4. The information processing method for a database cluster according to claim 2, wherein, The sending node also includes a sending node communication process, which is used to receive the message to be processed from the sending node service process and establish communication with other nodes; The step of validating the message to be processed within the sending node includes: The sending node communication process receives the message to be processed from the sending node service process; During the communication process of the sending node, it is determined whether the target epoch number in the message to be processed is valid; If the target epoch is valid, the cached epoch of the sending node's communication process is obtained as the verification epoch. The target epoch is verified using the verified epoch number; If the verification is successful, the target epoch number is determined to have passed the validity verification of the sending node, and the communication process of the sending node continues to process the message to be processed. If the verification fails, the target epoch number is determined to have failed the validity verification of the sending node, the message to be processed is determined to be a channel residual message and the channel residual message is cleared.
5. The information processing method for a database cluster according to claim 4, wherein, After the step of determining whether the target epoch number in the message to be processed is valid in the communication process of the sending node, the method further includes: if the target epoch number is invalid, skipping the validity check and allowing the communication process of the sending node to continue processing the message to be processed; The step of verifying the target epoch using the verification epoch includes: determining whether the verification epoch is consistent with the target epoch; if the verification epoch is consistent with the target epoch, determining that the target epoch passes the verification.
6. The information processing method for a database cluster according to claim 4, wherein, The database cluster includes a node list change period and an epoch number update period. During the node list change period, the cached epoch number of each node in the database cluster is invalid. During the epoch number update period, the cached epoch numbers of nodes in the database cluster that have not completed synchronization are valid, but the latest epoch number recorded in the cluster member list of the database cluster is frozen and cannot be obtained until the latest epoch number is synchronized in the database cluster. The step of determining whether the target epoch number in the message to be processed is valid in the communication process of the sending node includes: Determine whether the database cluster is in the period of node list change; If the database cluster is in a period of node list change, the target epoch number is determined to be invalid; If the database cluster is not in the period of node list change, the target epoch number is determined to be valid.
7. The information processing method for a database cluster according to claim 1, wherein, The database cluster includes an epoch whitelist, which is used to record messages to be processed that do not require the validity check. Before the step of validating the message to be processed within the sending node, the method further includes: Determine whether the message type corresponding to the message to be processed is recorded in the epoch whitelist; If the message type corresponding to the message to be processed is recorded in the epoch whitelist, the validity check is skipped. If the message type of the message to be processed is not recorded in the epoch whitelist, the step of validating the message to be processed within the sending node is executed.
8. The information processing method for a database cluster according to claim 1, wherein, The receiving node includes a receiving node communication process and a receiving node service process. The receiving node communication process is used to receive the message to be processed and establish communication with other nodes. The receiving node service process is used to perform corresponding operations according to the message to be processed. The step of having the receiving node perform the validity check on the message to be processed again includes: The receiving node communication process receives the message to be processed from the sending node communication process; Determine whether the target epoch number in the message to be processed is valid; If the target epoch number is invalid, the validity check is skipped, and the receiving node's communication process continues to process the message to be processed. If the target epoch is valid, the cached epoch corresponding to the communication process of the receiving node is obtained as the verification epoch. The target epoch is verified using the verified epoch number; If the verification is successful, the target epoch number is determined to have passed the validity verification of the receiving node, and the communication process of the receiving node continues to process the message to be processed. If the verification fails, the target epoch number is determined to have failed the validity verification of the sending node, the message to be processed is determined to be a channel residual message and the channel residual message is cleared.
9. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the information processing method for a database cluster as described in any one of claims 1 to 8.
10. A computer device comprising a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor, when executing the machine-executable program, implements the steps of the information processing method for a database cluster according to any one of claims 1 to 8.