Data synchronization method and device, computer equipment and readable storage medium

By introducing preset timeout control thresholds and switching strategies into the master node of the PGXC architecture, the blocking problem caused by GTM slave node failures is resolved and the availability of the database cluster is improved by isolating faulty slave nodes and switching replication modes.

CN121542325APending Publication Date: 2026-02-17CHINA TELECOM CLOUD TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202610065649.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-19
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

In the PGXC architecture, when a GTM slave node fails or there is a network partition, the GTM master node cannot collect acknowledgment messages from all slave nodes, causing client write operation threads to be blocked indefinitely, reducing the availability of the database cluster.

Method used

Introduce a preset timeout control threshold in the master node, detect and isolate faulty target slave nodes, and interrupt fully synchronous replication according to a preset switching strategy, switching to asynchronous or semi-synchronous replication, and sending a confirmation message to the client.

Benefits of technology

By dynamically managing the connection status of slave nodes, the high availability of the extended cluster architecture is improved, avoiding the master node from continuously waiting for confirmation from the faulty slave node. This ensures that clients are unblocked within the preset timeout control threshold.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121542325A_ABST
    Figure CN121542325A_ABST
Patent Text Reader

Abstract

The invention relates to a data synchronization method and device, computer equipment and a readable storage medium. The method is applied to a master node in an extended cluster architecture, the master node comprises a preset timeout control threshold, and the method comprises the steps of determining a target slave node with a fault based on a node state of the slave node and the preset timeout control threshold in a process of performing full-synchronous replication on the master node and the slave node, the target slave node is isolated; and interrupting full-synchronous replication of the master node and the target slave node according to a preset switching strategy, and feeding back a confirmation message to the client. By adopting the method, the high availability of the slave node in the expansion cluster architecture when the fault exists can be improved, and the high availability of the expansion cluster architecture is further realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a data synchronization method, apparatus, computer device, and readable storage medium. Background Technology

[0002] With the development of relational database management systems, a distributed database architecture based on PostgreSQL (an open-source relational database management system) has emerged, namely PGXC (PostgreSQL eXtended Cluster). The PGXC architecture includes a Global Transaction Manager (GTM) node. In order to ensure data consistency, the GTM master node and GTM slave nodes need to perform full synchronization replication.

[0003] In traditional PGXC architecture, when a GTM node is configured for fully synchronous replication, the GTM master node responds to a client's write request by synchronously sending the transaction log to all configured GTM slave nodes and waiting for all GTM slave nodes to complete data persistence and return acknowledgment messages (ACKs). Only after receiving acknowledgment messages from all GTM slave nodes will the GTM master node return a success response to the client, at which point the client's write operation thread can continue.

[0004] However, this mechanism has a significant availability issue: if any GTM slave node fails or experiences a network partition, the GTM master node will be unable to collect acknowledgment messages from all GTM slave nodes. This causes the master node to continuously wait for responses from GTM slave nodes, making it unable to respond to clients. Ultimately, this results in client threads initiating write operations being blocked indefinitely, leading to poor availability of the entire database cluster. Summary of the Invention

[0005] Therefore, it is necessary to provide a data synchronization method, apparatus, computer device, and readable storage medium to address the aforementioned technical problems.

[0006] Firstly, this application provides a data synchronization method, which is applied to a master node in an extended cluster architecture, wherein the master node includes a preset timeout control threshold, comprising:

[0007] During the full synchronization replication process between the master node and the slave node, a target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0008] The master node and the target slave node are interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

[0009] In one embodiment, during the full synchronization replication process between the master node and the slave node, determining a target slave node with a fault based on the node status of the slave node and the preset timeout control threshold, and isolating the target slave node, includes:

[0010] During the process of full synchronization replication between the master node and the slave node, the fault duration corresponding to the initial slave node with connection delay is determined based on the node status of the slave node in each preset period.

[0011] The slave node whose fault duration exceeds the preset timeout control threshold is identified as the target slave node with a fault, and the target slave node is isolated.

[0012] In one embodiment, during the full synchronization replication process between the master node and the slave node, determining the fault duration corresponding to the initial slave node with connection delay based on the node status of the slave node in each preset period includes:

[0013] During the process of full synchronization replication between the master node and the slave node, the connection interruption start time corresponding to the initial slave node with connection delay is determined based on the comparison results of the status of each node in adjacent periods.

[0014] The fault duration corresponding to the initial slave node is determined based on the connection interruption start time.

[0015] In one embodiment, isolating the target slave node includes:

[0016] Disrupt the communication connection between the target slave node and the master node;

[0017] In the configuration file of the master node, the node information of the target slave node is configured and updated.

[0018] In one embodiment, the configuration update includes deleting the IP address and port information of the target slave node from the configuration file of the master node.

[0019] In one embodiment, during the full synchronization replication process between the master node and the slave node, determining a target slave node with a fault based on the node status of the slave node and the preset timeout control threshold, and isolating the target slave node, includes:

[0020] During the full synchronization replication process between the master node and the slave node, node detection is performed on the slave nodes connected to the master node according to a preset period to determine the node status of the slave nodes;

[0021] Based on the node status and the preset timeout control threshold, a target slave node with a fault is identified and isolated.

[0022] In one embodiment, during the full synchronization replication process between the master node and the slave node, node detection is performed on the slave nodes connected to the master node at a preset period to determine the node status of the slave nodes, including:

[0023] During the full synchronous replication process between the master node and the slave node, a scheduled task is constructed by extending the management node in the cluster architecture.

[0024] According to the preset period in the scheduled task, the node information of the slave node is obtained according to the scheduled task, and the node status of the slave node is determined according to the node information.

[0025] In one embodiment, the preset switching strategy includes switching the fully synchronous replication to asynchronous replication or semi-synchronous replication.

[0026] In one embodiment, the step of interrupting the full synchronization replication between the master node and the target slave node according to a preset switching strategy and sending a confirmation message to the client includes:

[0027] If there is a slave node whose connection status is normal, switch the full synchronous replication of the master node to the semi-synchronous replication, send a confirmation message to the client, and perform full synchronous replication with the slave node whose connection status is normal;

[0028] If no slave node is found to be in a normal connection state, the master node's fully synchronous replication is switched to asynchronous replication, and a confirmation message is sent to the client.

[0029] In one embodiment, the extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

[0030] In one embodiment, the master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

[0031] In one embodiment, the preset timeout control threshold is determined based on a recovery time target.

[0032] Secondly, this application also provides a data synchronization device, which is applied to a master node in an extended cluster architecture. The master node includes a preset timeout control threshold, comprising:

[0033] The detection module is used to identify a target slave node with a fault based on the node status of the slave node and the preset timeout control threshold during the full synchronous replication process between the master node and the slave node, and to isolate the target slave node.

[0034] The switching module is used to interrupt the full synchronous replication between the master node and the target slave node according to a preset switching strategy and send a confirmation message to the client.

[0035] In one embodiment, the detection module is specifically used to determine the fault duration corresponding to the initial slave node with connection delay based on the node status of the slave node in each preset period during the process of full synchronization replication between the master node and the slave node.

[0036] The slave node whose fault duration exceeds the preset timeout control threshold is identified as the target slave node with a fault, and the target slave node is isolated.

[0037] In one embodiment, the detection module is specifically used to determine the connection interruption start time corresponding to the initial slave node with connection delay based on the comparison results of the status of each node in adjacent periods during the full synchronous replication process between the master node and the slave node.

[0038] The fault duration corresponding to the initial slave node is determined based on the connection interruption start time.

[0039] In one embodiment, the detection module is specifically used to interrupt the communication connection between the target slave node and the master node;

[0040] In the configuration file of the master node, the node information of the target slave node is configured and updated.

[0041] In one embodiment, the configuration update includes deleting the IP address and port information of the target slave node from the configuration file of the master node.

[0042] In one embodiment, the detection module is specifically used to perform node detection on the slave nodes connected to the master node according to a preset period during the process of full synchronous replication between the master node and the slave node, and to determine the node status of the slave node.

[0043] Based on the node status and the preset timeout control threshold, a target slave node with a fault is identified and isolated.

[0044] In one embodiment, the detection module is specifically used to construct a scheduled task by extending the management and control node in the cluster architecture during the process of full synchronous replication between the master node and the slave node.

[0045] According to the preset period in the scheduled task, the node information of the slave node is obtained according to the scheduled task, and the node status of the slave node is determined according to the node information.

[0046] In one embodiment, the preset switching strategy includes switching the fully synchronous replication to asynchronous replication or semi-synchronous replication.

[0047] In one embodiment, the switching module is specifically used to switch the full synchronous replication of the master node to the semi-synchronous replication if there is a slave node whose node status is normal, send a confirmation message to the client, and perform full synchronous replication with the slave node whose connection is normal;

[0048] If no slave node is found to be in a normal connection state, the master node's fully synchronous replication is switched to asynchronous replication, and a confirmation message is sent to the client.

[0049] In one embodiment, the extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

[0050] In one embodiment, the master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

[0051] In one embodiment, the preset timeout control threshold is determined based on a recovery time target.

[0052] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0053] During the full synchronization replication process between the master node and the slave node, a target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0054] The master node and the target slave node are interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

[0055] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0056] During the full synchronization replication process between the master node and the slave node, a target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0057] The master node and the target slave node are interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

[0058] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0059] During the full synchronization replication process between the master node and the slave node, a target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0060] The master node and the target slave node are interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

[0061] The aforementioned data synchronization method, apparatus, computer equipment, and readable storage medium, by adding a preset timeout control threshold to the master node of the extended cluster architecture, detect faulty target slave nodes and isolate them upon identification. This allows the master node to dynamically manage the connection status of slave nodes, ensuring that it only sends an acknowledgment message to the client after all slave nodes have sent acknowledgment messages. This prevents the master node from continuously waiting for acknowledgment messages from faulty target slave nodes, thus avoiding the client being continuously blocked. Therefore, by interrupting the full synchronization replication state of faulty target slave nodes through the preset timeout control threshold, and enabling the master node to trigger an acknowledgment message to the client upon receiving acknowledgment messages from slave nodes with normal node status under the control of the preset timeout control threshold, the client can unblock within the limits of the preset timeout control threshold. This improves the high availability capability of the extended cluster architecture when slave nodes are faulty, thereby achieving high availability for the extended cluster architecture. Attached Figure Description

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

[0063] Figure 1 This is a diagram illustrating the application environment of a data synchronization method in one embodiment;

[0064] Figure 2 This is a flowchart illustrating a data synchronization method in one embodiment;

[0065] Figure 3 This is a signaling diagram illustrating a fully synchronous replication example between the master database and slave databases 1 and 2 in one embodiment.

[0066] Figure 4 This is a flowchart illustrating the high availability implementation of the PGXC database architecture in one embodiment;

[0067] Figure 5 This is a flowchart illustrating the process of detecting target slave nodes based on failure time in one embodiment;

[0068] Figure 6 This is a flowchart illustrating the process of determining the fault duration based on the connection interruption start time in one embodiment.

[0069] Figure 7 This is a schematic diagram illustrating the process of isolating a target slave node in one embodiment;

[0070] Figure 8 This is a schematic diagram of a process for detecting and isolating target slave nodes based on a preset period in one embodiment;

[0071] Figure 9 This is a schematic diagram of a process for obtaining node information of slave nodes through a timed task in one embodiment;

[0072] Figure 10 This is a schematic diagram of the process of performing full synchronous replication switching for normally connected slave nodes and non-normally connected slave nodes in a preset switching strategy in one embodiment;

[0073] Figure 11 This is a schematic diagram illustrating the data synchronization process between the host (primary node) and the standby machine (standby node) corresponding to the coordination node and the data node, respectively, in one embodiment.

[0074] Figure 12 This is a flowchart illustrating data synchronization between the GTM primary and GTM standby machines corresponding to the full transaction manager in one embodiment.

[0075] Figure 13 This is a structural block diagram of a data synchronization device in one embodiment;

[0076] Figure 14 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0077] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0078] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0079] The data synchronization method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, master node 102 communicates with slave node 104 via the network. During the full synchronous replication process between the master and slave nodes, the master node identifies the target slave node with a fault based on the node status of the slave node and a preset timeout control threshold, and isolates the target slave node. The master node then interrupts the full synchronous replication between the master node and the target slave node according to a preset switchover strategy and sends a confirmation message to the client. Master node 102 is the master database node in the distributed database architecture, and slave node 104 is the slave node corresponding to the master database node, used to back up the data of the master database node.

[0080] In one exemplary embodiment, such as Figure 2 As shown, a data synchronization method is provided, which can be applied to... Figure 1 Taking the master node in an extended cluster architecture as an example, this master node includes a preset timeout control threshold, comprising the following steps 202 to 204. Wherein:

[0081] Step 202: During the full synchronization replication process between the master node and the slave node, the target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0082] In this embodiment, the extended cluster architecture is a PGXC architecture, a distributed database architecture based on PostgreSQL. PGXC achieves horizontal scaling by introducing a Coordinator (CN), Data Nodes (DN), and a Global Transaction Manager (GTM). The Coordinator is responsible for query parsing and scheduling, the Data Nodes are responsible for data sharding and storage, and the Global Transaction Manager is responsible for global transactions and sequences.

[0083] The coordinating node, data nodes, and global transaction manager node can each be configured with master and slave nodes. The slave nodes back up the data on the master node to achieve disaster recovery management of the PGXC database architecture. There can be one or more slave nodes corresponding to the master node.

[0084] To ensure data consistency between the master and slave nodes, after the master node responds to a client's write request, the slave nodes need to synchronously respond with a data write response; this involves full synchronous replication between the master and slave nodes. For example, taking the coordinating node (master database) as the master node and slave 1 and slave 2 as slave nodes, the full synchronous replication between master 1 and slave 1 / 2 is as follows: Figure 3 As shown, Figure 3 This is the signaling diagram for full synchronization between the master database and slave databases 1 and 2. The master database receives write requests (e.g., INSERT or UPDATE) from clients, writes to its WAL log, and sends the WAL log to slave databases 1 and 2 respectively, then enters a full synchronization waiting state. Slave databases 1 and 2 perform the same data update operations as the master database based on the WAL logs, and return an ACK message to the master database after completing their data update operations, indicating that slave database 1 or slave database 2 has completed data synchronization. Then, upon receiving the ACK messages from slave databases 1 and 2, the master database commits the transaction, releases the relevant lock resources, and returns a write success message to the client, unblocking the client thread.

[0085] For the fully synchronous replication mode of master and slave nodes, such as Figure 4 As shown, Figure 4This document outlines a flowchart for achieving high availability in a PGXC database architecture. It includes high availability methods for CN (Coordinating Node) and DN (Data Node) standby (slave node) failures, as well as high availability methods for GTM (Global Transaction Manager) standby failures. In this embodiment, the GTM master node corresponding to the Global Transaction Manager is used as an example, with the slave node being the GTM slave node corresponding to the Global Transaction Manager. During the full synchronous replication process between the GTM master node and GTM slave nodes, GTM slave node failures may occur. For example, the server hosting the GTM slave node may experience physical issues such as power outages or hardware failures, preventing the GTM slave node from sending acknowledgment messages to the GTM master node. However, the GTM master node continues to wait for the ACK message from the GTM slave node, causing the client to enter a continuously blocked, stuck state. Therefore, a preset timeout control threshold is added to the GTM master node. For example, the preset timeout control threshold can be the "gtm_sender_timeout" parameter for timeout control of the GTM node. The master node first checks if a preset timeout control threshold exists. If the master node does not have a preset timeout control threshold, a new preset timeout control threshold is added.

[0086] In a specific embodiment, the node status of a slave node refers to the connection status between the master node and the slave node. This node status can be queried in the connection node information of the master node. For example, if the slave nodes with normal communication connections with the master node are slave node 1 and slave node 2, then the node status of the slave nodes includes slave node 1 and slave node 2. When a slave node fails, it disconnects from the master node. The node status of the slave node queried in the master node changes, and the slave node whose status changes from connected to having a connection loss duration exceeding a preset timeout control threshold is identified as having a fault, i.e., identified as the target slave node. Then, the master node removes the target slave node, achieving isolation of the target slave node in the fully synchronous replication model.

[0087] In an optional embodiment, the master node can determine the faulty target slave node based on the response latency in the slave node's node state and a preset timeout control threshold. The response latency in the node state refers to the duration after the master node sends a message to the slave node, during which the slave node does not send an acknowledgment message or does not respond to the message. For example, if the master node continuously sends heartbeat signals to the slave node, the slave node needs to send an acknowledgment message to the master node within the preset timeout control threshold. If the slave node fails to send an acknowledgment message to the master node within the preset timeout control threshold, the master node determines that the slave node's node state is faulty, that is, it determines the slave node as the target slave node and isolates the fully synchronized replication state of the target slave node.

[0088] In an optional embodiment, the master node is pre-configured with candidate timeout control thresholds adapted to different nodes or different scenarios. Specifically, before performing full synchronization replication between the master node and slave nodes, the master node first matches the candidate timeout control thresholds according to the node type of each slave node to determine a preset timeout control threshold that matches each slave node. For example, if the master node has multiple corresponding slave nodes, with slave node 1 being the primary backup node and slave node 2 being the secondary backup node, then the primary backup node has higher backup importance and can be allocated a longer waiting time. That is, the preset timeout control threshold corresponding to slave node 1 as the primary backup node is higher than that of slave node 2 as the secondary backup node.

[0089] Optionally, the master node can also select a preset timeout control threshold based on the amount of data to be synchronized. That is, based on the amount of data corresponding to the full synchronization replication, it matches candidate timeout control thresholds to determine the preset timeout control threshold that matches the data amount. For example, different data volume levels can be pre-set for the data volume of the full synchronization replication, with each level having a corresponding candidate timeout control threshold. Then, the data volume level is determined based on the amount of data corresponding to the full synchronization replication, and the preset timeout control threshold is determined based on the data volume level and the correspondence between the data volume level and the candidate timeout control thresholds.

[0090] Step 204: Interrupt the full synchronization replication between the master node and the target slave node according to the preset switching strategy, and send a confirmation message to the client.

[0091] In this embodiment, after identifying a faulty target slave node, the master node dynamically adjusts the replication mode according to a preset switching strategy to remove the synchronization dependency on the faulty target slave node. Specifically, the preset switching strategy is used to interrupt the fully synchronous replication relationship between the master node and the target slave node when the target slave node is detected to be abnormal and the timeout condition of the preset timeout control threshold is met, so that the master node can complete the transaction commit without waiting for the response of the target slave node.

[0092] The process of interrupting fully synchronous replication includes removing the target slave node from the current synchronous replication participants and downgrading the replication mode from fully synchronous to asynchronous or semi-synchronous replication, thereby unblocking the master node's transaction. Following this, the master node completes its local transaction commit, generates the corresponding acknowledgment message, and returns this message to the client to notify the client that the write operation has been successfully executed, thus unblocking the client as well.

[0093] In the aforementioned data synchronization method, a preset timeout control threshold is added to the master node of the extended cluster architecture to detect faulty target slave nodes. Upon identification, the target slave node is isolated, allowing the master node to dynamically manage the connection status of slave nodes, only sending an acknowledgment message to the client after all slave nodes have sent acknowledgment messages. This prevents the master node from continuously waiting for acknowledgment messages from faulty target slave nodes, thus avoiding continuous blocking of the client. Therefore, by using a preset timeout control threshold to interrupt the full synchronization replication state of faulty target slave nodes, and under the control of the preset timeout control threshold, the master node triggers an acknowledgment message to the client upon receiving acknowledgment messages from slave nodes with normal node status. This allows the client to unblock within the preset timeout control threshold limit, thereby improving the high availability capability of the extended cluster architecture when slave nodes are faulty, and ultimately achieving high availability for the extended cluster architecture.

[0094] In one exemplary embodiment, such as Figure 5 As shown, step 202 includes steps 502 to 504. Wherein:

[0095] Step 502: During the full synchronization replication process between the master node and the slave node, the fault duration corresponding to the initial slave node with connection delay is determined based on the node status of the slave node in each preset period.

[0096] In this embodiment, during the full synchronization replication process between the master node and slave nodes, the master node periodically collects the node status information of each slave node according to a preset cycle. Based on the changes in the node status of each slave node between adjacent cycles, it determines whether there is an initial slave node with connection delay. The node status includes the connection activity status, heartbeat response status, and log reception progress of the slave node. For example, based on the heartbeat responses of each slave node, the master node identifies slave nodes that have not returned an acknowledgment message within the normal time delay as potential initial slave nodes with connection delay. The fault duration of the initial slave node is determined based on the time it takes for the slave node to be identified as an initial slave node with connection delay. The normal time delay of the heartbeat signal can be determined based on the physical distance between the master node and each slave node, or it can be preset based on business requirements. For example, the normal time delay can be 500ms. If the master node sends a heartbeat signal to a slave node and does not receive a response from the slave node after 500ms, the master node identifies that slave node as an initial slave node with connection delay, indicating that the initial slave node may be faulty.

[0097] For an initial slave node identified as having connection latency, the master node needs to further calculate the duration since the connection failure occurred, as the fault duration. For example, the master node determines the fault duration of the initial slave node based on the current time and the sending time of the previous heartbeat signal. This fault duration is then compared with a preset timeout control threshold to determine whether to upgrade it to a target slave node requiring isolation and downgrade its replication mode.

[0098] Step 504: Identify the slave nodes whose fault duration exceeds the preset timeout control threshold as the target slave nodes with faults, and isolate the target slave nodes.

[0099] The preset timeout control threshold is a log timeout parameter. This threshold is set based on the RTO (Recovery Time Objective) requirement, allowing for adjustable RTO. For example, if the RTO is 30 seconds, the preset timeout control threshold can be set to within 30 seconds to ensure the master node and client can resume normal operation within the RTO requirement. RTO is a key metric in information technology and disaster recovery, used to measure the maximum tolerable downtime for a system or service to recover after an interruption.

[0100] In this embodiment, the master node compares the fault duration of each initial slave node with a preset timeout control threshold. If the fault duration of an initial slave node exceeds the preset timeout control threshold, it means that the target slave node is unable to send a confirmation message to the master node due to the fault, causing the master node to continuously wait for the confirmation message from the target slave node, which causes the application of the extended cluster to fail to meet the RTO requirements. Therefore, the master node determines the initial slave node as a target slave node with a fault.

[0101] To prevent the master node from getting stuck in a blocked state waiting for confirmation messages from the target slave node, the master node performs an isolation operation on the target slave node. For example, it marks the node as "unavailable" in the locally maintained list of synchronization nodes, suspends sending log streams to the target slave node, and releases the replication connection resources associated with the target slave node. After the isolation operation is completed, the target slave node no longer participates in the confirmation process of the full synchronization replication of the current transaction.

[0102] In this embodiment, the fault duration corresponding to the initial slave node with connection delay is used to determine the target slave node with fault based on the fault duration and the preset timeout control threshold. This enables the identification and isolation of the target slave node with fault, so that the master node no longer needs to wait to receive feedback signals from the target slave node, avoiding the master node continuously waiting for the response from the target slave node, ensuring that the master node recovers to normal status within the RTO requirement, thereby improving the availability of the extended cluster architecture.

[0103] In one exemplary embodiment, such as Figure 6 As shown, step 502 includes steps 602 to 604. Wherein:

[0104] Step 602: During the full synchronization replication process between the master node and the slave node, the connection interruption start time corresponding to the initial slave node with connection delay is determined based on the comparison results of the status of each node in adjacent cycles.

[0105] The preset cycle can be once per second.

[0106] In this embodiment, the master node polls its connection status with each slave node in each preset period and records the connection status of each slave node as its node status. The master node identifies slave nodes whose connection status changes from "connected" to "disconnected" or "unresponsive" by comparing the node status of each slave node in the current period with that in the previous period, and identifies these as initial slave nodes with connection delays. The node status of a slave node is its connection status with the master node. For example, if the node status list of slave nodes connected to the master node in the previous period includes slave node 1, slave node 2, and slave node 3, and the node status list in the current period only includes slave node 1 and slave node 2, it indicates that slave node 3 has a connection delay. The node status (i.e., the node status list of slave nodes connected to the master node) can be determined based on the heartbeat signal in step 502, which will not be elaborated upon in this embodiment.

[0107] For an initial slave node with connection latency, the master node records the system timestamp of its state change as the connection interruption start time. For example, if the master node detects that the slave node has not responded to the heartbeat in period T, and confirms the connection loss in period T+1, then the end time of period T is taken as the connection interruption start time.

[0108] Step 604: Determine the fault duration corresponding to the initial slave node based on the connection interruption start time.

[0109] In this embodiment, the master node calculates the initial failure duration of the slave node based on the connection interruption start time and the current system time. Specifically, the failure duration is the time difference between the current system time and the connection interruption start time.

[0110] For example, if a GTM slave node is identified as having a connection interruption at 10:00:00 on 2025-01-01, and the current time is 10:00:30 on 2025-01-01, and the preset timeout control threshold is 20 seconds, then the calculated fault duration is 30 seconds, which is greater than the preset timeout control threshold, and thus the fault determination condition is met.

[0111] In this embodiment, during the full synchronization replication process between the master node and the slave node, the connection interruption start time corresponding to the initial slave node is recorded by comparing the status of each node in adjacent cycles. This allows the fault time of the initial slave node to be recorded based on the connection interruption start time, serving as the data basis for identifying the target slave node.

[0112] In one exemplary embodiment, such as Figure 7 As shown, isolating the target slave node in step 202 or step 504 further includes steps 702 to 704. Wherein:

[0113] Step 702: Disrupt the communication connection between the target slave node and the master node.

[0114] In this embodiment, after identifying a faulty target slave node, indicating that the target slave node causes the master node to fail to meet the RTO requirements, the master node actively interrupts the communication connection with the target slave node. Specifically, the master node interrupts the TCP (Transmission Control Protocol) connection established with the slave node and releases system resources such as the replication process, memory buffer, and file descriptors related to the full synchronous replication between the master node and the target slave node.

[0115] In one specific embodiment, in an extended cluster built with PostgreSQL, the GTM master node can terminate the full synchronous replication with the target slave node by calling the underlying network interface. At this time, in the system view containing the node information of the slave node obtained by executing the "gtm_ctlstatus" command on the master node, the node information of the target slave node will no longer be displayed.

[0116] In addition, in extended clusters that employ connection pooling or proxy architectures, the master node can also notify the connection management component to update the routing table, preventing new connection requests from being forwarded to the target slave node.

[0117] Step 704: In the master node's configuration file, update the node information of the target slave node.

[0118] In this embodiment, when the failure time of the initial slave node recorded by the master node exceeds a preset timeout control threshold, the master node identifies the initial slave node as the target slave node, thus recognizing the faulty backup node. Subsequently, the master node disconnects the TCP connection between the target slave node and the master node. At this time, the node status of the slave nodes obtained according to the preset period does not contain the node information of the target slave node. Since the master node implements full synchronous replication between the master node and slave nodes based on the node information of the slave nodes existing in the configuration file, the master node removes the node information of the target slave node from the configuration information based on the absence of the target slave node's node information in the node status list, thereby severing the full synchronous replication state between the master node and the target slave node.

[0119] In this embodiment, by actively disconnecting the communication connection, the master node can update the node information in the configuration file, and then adjust the full synchronization replication status of the master node according to the updated node information, avoiding continuous waiting for the response of the target slave node, thereby relieving the blocking state of the master node and the client and improving the availability of the extended architecture.

[0120] In one exemplary embodiment, the configuration update includes removing the target node's IP (Internet Protocol) address and port information from the master node's configuration file.

[0121] In this embodiment, the IP address and port information of the target slave node are deleted from the configuration file of the master node through configuration update. This ensures that the master node will no longer attempt to establish a connection with the faulty target slave node during the full synchronization replication process, thereby achieving complete isolation of the target slave node, avoiding invalid waiting for the target slave node, and thus avoiding the anomaly of the full synchronization replication.

[0122] In one exemplary embodiment, such as Figure 8 As shown, step 202 includes steps 802 to 804. Wherein:

[0123] Step 802: During the full synchronization replication process between the master node and the slave node, the slave nodes connected to the master node are checked according to a preset period to determine the node status of the slave nodes.

[0124] In this embodiment, during the full synchronization replication process between the master node and slave nodes, the master node performs node detection operations on all currently connected slave nodes at a preset period (e.g., every 1 second or every 3 seconds) to obtain the running status of each slave node. For example, node detection includes mechanisms such as heartbeat detection, replication progress comparison, and log reception confirmation.

[0125] The master node determines the node status of each slave node based on the detection results. The node status of a slave node is the node information that has a communication connection with the master node. This node status serves as the basis for subsequent identification and isolation of faulty slave nodes.

[0126] Step 804: Based on the node status and the preset timeout control threshold, determine the target slave node with the fault and isolate the target slave node.

[0127] In this embodiment, the master node determines whether there are any persistently abnormal slave nodes based on the node status of each slave node and a preset timeout control threshold. For example, if a slave node fails to respond to a heartbeat for multiple consecutive detection cycles, and its fault duration exceeds the preset timeout control threshold, the master node identifies this slave node as a target slave node with a fault. Then, the master node performs isolation operations on the target slave node, including terminating the communication connection, updating the local configuration file, and releasing replication resources, controlling the target slave node to no longer participate in the synchronization process of the current fully synchronized replication transaction.

[0128] In this embodiment, the master node actively detects the node status of the slave nodes through a preset period and combines it with a preset timeout control threshold to identify faulty slave nodes, thereby isolating the target slave node and controlling the fully synchronized replication status of the faulty backup node. This avoids the target slave node causing continuous blocking of the master node and the client, thereby improving the availability of the extended architecture.

[0129] In one exemplary embodiment, such as Figure 9 As shown, step 802 includes steps 902 to 904. Wherein:

[0130] Step 902: During the full synchronization replication process between the master node and the slave node, a scheduled task is built by extending the management node in the cluster architecture.

[0131] In this embodiment, the master node performs periodic checks on the slave nodes by extending the scheduled tasks built by the management node in the cluster architecture. The management node, as a data plane component independent of the master node, is used to control operations such as starting, stopping, upgrading, and failover of the database instance.

[0132] Specifically, the control node registers scheduled tasks with the master node through a task scheduling framework and sets a preset period, for example, triggering once every 1 second. The control node connects to the master node according to the preset period, and then the master node initiates detection operations on the slave nodes.

[0133] Step 904: According to the preset period in the scheduled task, obtain the node information of the slave node based on the scheduled task, and determine the node status of the slave node based on the node information.

[0134] In this embodiment, the master node responds to a scheduled task by initiating a node information collection operation for each slave node in each preset period, and obtains the node information of the slave nodes. For example, the node information includes status information, IP address, and port. Specifically, for the coordination node and data nodes, the master node obtains the node information of the slave nodes currently connected to the master node through the "pg_stat_replication" view; for the global transaction manager, the master node obtains the node information of the slave nodes currently connected to the master node by executing the command ". / gtm_ctl status -H host_ip -P host_port" in the bin directory of the database in the PFXC architecture.

[0135] In this embodiment, a scheduled task is constructed through a management node, and the node status of the slave node is actively detected according to the preset period in the scheduled task. Combined with a preset timeout control threshold, the faulty slave node is identified, and the target slave node is isolated. This achieves control over the fully synchronized replication status of the faulty backup node, avoids the target slave node from causing continuous blocking of the master node and the client, and thus improves the availability of the extended architecture.

[0136] In one exemplary embodiment, the preset switching strategy includes switching from fully synchronous replication to asynchronous replication or semi-synchronous replication.

[0137] In one exemplary embodiment, such as Figure 10 As shown, step 204 includes steps 1002 to 1004. Wherein:

[0138] Step 1002: If there are slave nodes with normal connection status, switch the master node's full synchronous replication to semi-synchronous replication, send a confirmation message to the client, and perform full synchronous replication with the slave nodes with normal connection status.

[0139] In this embodiment, the master node first determines whether there are any slave nodes with a "connection normal" status. If so, the master node switches its replication mode from fully synchronous replication to semi-synchronous replication.

[0140] In one specific embodiment, the master node obtains the node information of each slave node according to the node information collection operation. If the node information of the slave node exists, it means that there is a slave node with a normal connection status. Then, the master node switches the full synchronous replication with the slave node to semi-synchronous replication. That is, the master node continues to maintain a full synchronous replication relationship with the slave node with a normal connection status (i.e., continuously sending logs and receiving ACKs), while switching to asynchronous replication with the target slave node. This allows the master node to return an acknowledgment message to the client when the transaction is committed without needing to receive the acknowledgment message from the target slave node. It only needs to receive the response from the slave node with a normal connection status.

[0141] At the same time, the master node generates an operation log to record this mode switch, and sends a confirmation message of "switched to semi-synchronous replication" to the client or operation and maintenance platform through the management interface or monitoring channel, indicating that the target slave node with the current fault is in a degraded operation state.

[0142] Step 1004: If there are no slave nodes with a normal connection status, switch the master node's fully synchronous replication to asynchronous replication and send a confirmation message to the client.

[0143] In this embodiment of the application, if it is detected that no slave node is currently in a "normal connection" state, that is, all slave nodes are disconnected and isolated, the master node will switch the replication mode to asynchronous replication.

[0144] Specifically, the master node prevents all slave nodes from participating in the synchronous waiting process for transaction commit. Afterward, the master node completes the transaction commit locally and immediately sends an acknowledgment message to the client, no longer waiting for acknowledgments from any slave nodes, directly sending an acknowledgment message to the client, ensuring that the master node's write service to the client is not interrupted.

[0145] Optionally, after completing the asynchronous replication switch, the master node can send a "Switched to asynchronous replication" confirmation message to the client and trigger an alarm to notify the administrator to intervene. When a slave node subsequently restores its connection and catches up on the data, the master node can automatically or manually revert to fully synchronous or semi-synchronous replication mode according to a preset policy.

[0146] In this embodiment, the existence of a slave node with a normal connection status is determined by the node connection status of the slave node. Different replication models are set for the cases where there is a slave node with a normal connection status and the cases where there is no slave node with a normal connection status. This can ensure that the extended cluster synchronizes data with the slave nodes with normal connections, improve the security of the extended cluster, and prevent the target slave node from blocking the master node and the client, thereby improving the availability of the extended cluster.

[0147] In one exemplary embodiment, the extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

[0148] In one embodiment, such as Figure 11 As shown, Figure 11 A flowchart for coordinating data synchronization between the primary and backup hosts (master nodes) and data nodes, respectively, including:

[0149] Step 1101: Schedule a task to connect the CN and DN hosts.

[0150] Step 1102: Check the standby information for the CN and DN hosts.

[0151] Step 1103: Propose backup units for faulty CN and DN.

[0152] Step 1104: Perform asynchronous degradation.

[0153] In one embodiment, such as Figure 12 As shown, Figure 12 A flowchart for data synchronization between the GTM primary and GTM standby machines corresponding to the full transaction manager, including:

[0154] Step 1201: Schedule a task to connect to the GTM host.

[0155] Step 1202: Check the standby information of the GTM main unit.

[0156] Step 1203: Add the transaction log timeout parameter to GTM.

[0157] Step 1204: Remove the faulty GTM backup unit.

[0158] Step 1205: Perform asynchronous degradation.

[0159] In an exemplary embodiment, the master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

[0160] In this embodiment, the first slave node corresponding to the full transaction manager is used to back up the data of the first master node corresponding to the full transaction manager, the second slave node corresponding to the coordination node is used to back up the data of the second master node corresponding to the coordination node, and the third slave node corresponding to the data node is used to back up the data of the third master node corresponding to the data node.

[0161] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0162] Based on the same inventive concept, this application also provides a data synchronization device for implementing the data synchronization method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more data synchronization device embodiments provided below can be found in the limitations of the data synchronization method described above, and will not be repeated here.

[0163] In one exemplary embodiment, such as Figure 13 As shown, a data synchronization device 1300 is provided. This device is applied to the master node in an extended cluster architecture. The master node includes a preset timeout control threshold and comprises: a detection module 1301 and a switching module 1302, wherein:

[0164] The detection module 1301 is used to identify the target slave node with a fault based on the node status of the slave node and the preset timeout control threshold during the full synchronous replication process between the master node and the slave node, and to isolate the target slave node.

[0165] The switching module 1302 is used to interrupt the full synchronous replication between the master node and the target slave node according to the preset switching strategy and send a confirmation message to the client.

[0166] In one embodiment, the detection module 1301 is specifically used to determine the fault duration corresponding to the initial slave node with connection delay based on the node status of the slave node in each preset period during the process of full synchronous replication between the master node and the slave node.

[0167] Slave nodes whose fault duration exceeds the preset timeout control threshold are identified as target slave nodes with faults, and these target slave nodes are isolated.

[0168] In one embodiment, the detection module 1301 is specifically used to determine the connection interruption start time corresponding to the initial slave node with connection delay based on the comparison results of the status of each node in adjacent periods during the process of full synchronous replication between the master node and the slave node.

[0169] The fault duration corresponding to the initial slave node is determined based on the connection interruption start time.

[0170] In one embodiment, the detection module 1301 is specifically used to interrupt the communication connection between the target slave node and the master node;

[0171] In the master node's configuration file, the node information of the target slave node is configured and updated.

[0172] In one embodiment, the configuration update includes removing the target slave node's IP address and port information from the master node's configuration file.

[0173] In one embodiment, the detection module 1301 is specifically used to perform node detection on the slave nodes connected to the master node according to a preset period during the process of full synchronous replication between the master node and the slave node, and to determine the node status of the slave nodes.

[0174] Based on the node status and preset timeout control threshold, the target slave node with the fault is identified and isolated.

[0175] In one embodiment, the detection module 1301 is specifically used to construct a scheduled task by extending the management node in the cluster architecture during the process of full synchronous replication between the master node and the slave node.

[0176] According to the preset period in the scheduled task, the node information of the slave node is obtained according to the scheduled task, and the node status of the slave node is determined according to the node information.

[0177] In one embodiment, the preset switching strategy includes switching from fully synchronous replication to asynchronous replication or semi-synchronous replication.

[0178] In one embodiment, the switching module 1302 is specifically used to switch the full synchronous replication of the master node to semi-synchronous replication if there is a slave node whose node status is normal, send a confirmation message to the client, and perform full synchronous replication with the slave node whose connection is normal.

[0179] If no slave node has a normal connection status, switch the master node's fully synchronous replication to asynchronous replication and send a confirmation message to the client.

[0180] In one embodiment, the extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

[0181] In one embodiment, the master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

[0182] In one embodiment, the preset timeout control threshold is determined based on the recovery time target.

[0183] Each module in the aforementioned data synchronization device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0184] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 14 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a data synchronization method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0185] Those skilled in the art will understand that Figure 14 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.

[0186] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0187] During the full synchronization replication process between the master node and the slave node, the target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated.

[0188] The master node and the target slave node's full synchronous replication is interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

[0189] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0190] During the full synchronization replication process between the master node and the slave node, the fault duration corresponding to the initial slave node with connection delay is determined based on the node status of the slave node in each preset period.

[0191] Slave nodes whose fault duration exceeds the preset timeout control threshold are identified as target slave nodes with faults, and these target slave nodes are isolated.

[0192] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0193] During the full synchronization replication process between the master node and the slave node, the connection interruption start time corresponding to the initial slave node with connection delay is determined based on the comparison results of the status of each node in adjacent cycles.

[0194] The fault duration corresponding to the initial slave node is determined based on the connection interruption start time.

[0195] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0196] Disrupt the communication connection between the target slave node and the master node;

[0197] In the master node's configuration file, the node information of the target slave node is configured and updated.

[0198] In one embodiment, the configuration update includes removing the target slave node's IP address and port information from the master node's configuration file.

[0199] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0200] During the full synchronization replication process between the master node and the slave node, the slave nodes connected to the master node are checked according to a preset period to determine the node status of the slave nodes.

[0201] Based on the node status and preset timeout control threshold, the target slave node with the fault is identified and isolated.

[0202] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0203] During the full synchronous replication process between the master and slave nodes, scheduled tasks are built by extending the management and control nodes in the cluster architecture.

[0204] According to the preset period in the scheduled task, the node information of the slave node is obtained according to the scheduled task, and the node status of the slave node is determined according to the node information.

[0205] In one embodiment, the preset switching strategy includes switching from fully synchronous replication to asynchronous replication or semi-synchronous replication.

[0206] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0207] If there are slave nodes with a normal connection status, switch the master node's full synchronous replication to semi-synchronous replication, send a confirmation message to the client, and perform full synchronous replication with the slave nodes with a normal connection status;

[0208] If no slave node has a normal connection status, switch the master node's fully synchronous replication to asynchronous replication and send a confirmation message to the client.

[0209] In one embodiment, the extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

[0210] In one embodiment, the master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

[0211] In one embodiment, the preset timeout control threshold is determined based on the recovery time target.

[0212] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0213] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0214] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0215] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0216] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0217] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data synchronization method, characterized in that, The method is applied to the master node in an extended cluster architecture, wherein the master node includes a preset timeout control threshold, and the method includes: During the full synchronization replication process between the master node and the slave node, a target slave node with a fault is identified based on the node status of the slave node and the preset timeout control threshold, and the target slave node is isolated. The master node and the target slave node are interrupted according to the preset switching strategy, and a confirmation message is sent back to the client.

2. The method according to claim 1, characterized in that, During the full synchronization replication process between the master node and the slave node, based on the node status of the slave node and the preset timeout control threshold, a target slave node with a fault is identified and isolated, including: During the process of full synchronization replication between the master node and the slave node, the fault duration corresponding to the initial slave node with connection delay is determined based on the node status of the slave node in each preset period. The slave node whose fault duration exceeds the preset timeout control threshold is identified as the target slave node with a fault, and the target slave node is isolated.

3. The method according to claim 2, characterized in that, During the full synchronization replication process between the master node and the slave node, based on the node status of the slave node in each preset period, the fault duration corresponding to the initial slave node with connection delay is determined, including: During the process of full synchronization replication between the master node and the slave node, the connection interruption start time corresponding to the initial slave node with connection delay is determined based on the comparison results of the status of each node in adjacent periods. The fault duration corresponding to the initial slave node is determined based on the connection interruption start time.

4. The method according to claim 1 or 2, characterized in that, The isolation of the target slave node includes: Disrupt the communication connection between the target slave node and the master node; In the configuration file of the master node, the node information of the target slave node is configured and updated.

5. The method according to claim 4, characterized in that, The configuration update includes removing the target slave node's IP address and port information from the master node's configuration file.

6. The method according to claim 1, characterized in that, During the full synchronization replication process between the master node and the slave node, based on the node status of the slave node and the preset timeout control threshold, a target slave node with a fault is identified and isolated, including: During the full synchronization replication process between the master node and the slave node, node detection is performed on the slave nodes connected to the master node according to a preset period to determine the node status of the slave nodes; Based on the node status and the preset timeout control threshold, a target slave node with a fault is identified and isolated.

7. The method according to claim 6, characterized in that, During the full synchronization replication process between the master node and the slave node, node detection is performed on the slave nodes connected to the master node at a preset period to determine the node status of the slave nodes, including: During the full synchronous replication process between the master node and the slave node, a scheduled task is constructed by extending the management node in the cluster architecture. According to the preset period in the scheduled task, the node information of the slave node is obtained according to the scheduled task, and the node status of the slave node is determined according to the node information.

8. The method according to claim 1, characterized in that, The preset switching strategy includes switching the fully synchronous replication to asynchronous replication or semi-synchronous replication.

9. The method according to claim 8, characterized in that, The step of interrupting the full synchronization replication between the master node and the target slave node according to a preset switching strategy and sending a confirmation message to the client includes: If there is a slave node whose connection status is normal, switch the full synchronous replication of the master node to the semi-synchronous replication, send a confirmation message to the client, and perform full synchronous replication with the slave node whose connection status is normal; If no slave node is found to be in a normal connection state, the master node's fully synchronous replication is switched to asynchronous replication, and a confirmation message is sent to the client.

10. The method according to claim 1, characterized in that, The extended cluster architecture includes a coordinating node, data nodes, and a full transaction manager.

11. The method according to claim 10, characterized in that, The master node includes a first master node corresponding to the full transaction manager, a second master node corresponding to the coordinating node, and a third master node corresponding to the data node; the slave node includes a first slave node corresponding to the full transaction manager, a second slave node corresponding to the coordinating node, and a third slave node corresponding to the data node.

12. The method according to claim 1, characterized in that, The preset timeout control threshold is determined based on the recovery time target.

13. A data synchronization device, characterized in that, The device is applied to the master node in an extended cluster architecture, the master node including a preset timeout control threshold, and the device includes: The detection module is used to identify a target slave node with a fault based on the node status of the slave node and the preset timeout control threshold during the full synchronous replication process between the master node and the slave node, and to isolate the target slave node. The switching module is used to interrupt the full synchronous replication between the master node and the target slave node according to a preset switching strategy and send a confirmation message to the client.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.

15. A computer-readable storage medium having a computer program stored thereon, 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 12.

Citation Information

Patent Citations

  • Database fault processing method and device, equipment and storage medium

    CN115269556A

  • Master-slave node switching method, device and equipment

    CN117950793A

  • Fault switching isolation method and system for Redis Cluster data center

    CN118503022A

  • Processing method for data backup in cluster and cluster

    CN119356941A

  • Data replication strategy adjustment method and device, electronic equipment and storage medium

    CN121210569A