A cluster service processing method, device, electronic equipment and medium
By recording data stripes in the cluster server and forming linked list nodes, and querying the linked lists of other servers in combination with broadcast, the problem of trouble recovery caused by split brain in the cluster is solved, and the high reliability and fault tolerance of the cluster are achieved.
Patent Information
- Application Number
- CN202411971093.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-04
AI Technical Summary
In a device cluster, network abnormalities may cause the cluster to split the brain, which makes the cluster unable to independently judge the correct master node, resulting in difficulty in recovering failures.
By recording data stripes in the cluster server and forming linked list nodes, querying the linked lists of other servers in combination with broadcast, accurately determine whether there is a cluster split brain, and perform cluster recovery in the case of split brain.
Accurate judgment and recovery in the case of a cluster split brain is achieved, and the failure recovery ability and fault tolerance of the cluster are improved.
Smart Images

Figure CN119759666A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cluster technology, and in particular to a cluster service processing method, device, electronic device and medium. Background Art
[0002] The scale of modern business models often exceeds the carrying capacity of a single service device node, so device clusters are often used to carry business processing. Business clusters are oriented to operators and usually need to provide a unified entrance. Specifically, device nodes require a device that is different from other ordinary service nodes to provide operators with entry services such as configuration, information writing and reading, etc., namely the master node.
[0003] In order to ensure that the device cluster can still provide complete services to the outside world in certain failure situations, special business configurations are often used, such as introducing backup machines as slave nodes, or other software mechanisms, etc., to ensure that the entire cluster can still be run through some actions in certain device failure situations. After the master node fails, the master node is elected from the slave nodes to continue running.
[0004] In a cluster, network anomalies may cause the cluster to form two or more unconnected cluster groups, and each cluster group will re-elect a new master node, which is a cluster split-brain situation. When the network is restored, multiple master nodes will appear in the cluster at the same time, and each master node will think that the other is abnormally offline, resulting in the inability to independently determine which is the correct master node, making it difficult to restore to a unified cluster. Summary of the invention
[0005] The embodiments of the present application provide a cluster service processing method, device, electronic device and medium, which can accurately and timely determine whether there is a cluster brain split through the local linked list and other linked lists in the cluster server, and when there is a cluster brain split, perform cluster recovery according to different branches of the local linked list and other linked lists.
[0006] According to a first aspect of the present application, a cluster service processing method is provided, the method comprising:
[0007] For each server in the initialization cluster, record the data stripes generated by the cluster operation, and group the data stripes into linked list nodes according to a preset time period to obtain the local linked list of the server;
[0008] Broadcast query to other linked lists in other servers in the cluster to which the server belongs, and obtain the other linked lists;
[0009] Determine whether a cluster split-brain situation exists according to the local linked list and the other linked lists, and perform cluster recovery if a cluster split-brain situation exists.
[0010] According to a second aspect of the present application, a cluster service processing device is provided, the device comprising:
[0011] A local linked list determination module is used to record the data stripes generated by the operation of the cluster for each server in the initialization cluster, and group the data stripes into linked list nodes according to a preset time period to obtain the local linked list of the server;
[0012] Other linked lists acquisition module, used for broadcasting query other linked lists in other servers in the cluster to which the server belongs, and acquiring the other linked lists;
[0013] The situation determination module is used to determine whether there is a cluster split-brain situation according to the local linked list and the other linked lists, and to perform cluster recovery when there is a cluster split-brain situation.
[0014] According to a third aspect of the present application, an electronic device is provided, the electronic device comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the cluster service processing method of any embodiment of the present application.
[0018] According to a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the cluster service processing method of any embodiment of the present application when executed.
[0019] The technical solution of the embodiment of the present application records the data stripes generated by the operation of the cluster for each server in the initialization cluster, and groups the data stripes according to a preset time period to form linked list nodes to obtain the local linked list of the server; broadcasts and queries other linked lists in other servers in the cluster to which the server belongs to obtain the other linked lists; determines whether there is a cluster brain split according to the local linked list and the other linked lists, and performs cluster recovery in the case of a cluster brain split. The solution of the embodiment of the present application can reflect the operating data characteristics of the cluster to which the server belongs by recording the data stripes generated by the cluster operation in each server. In the case of a cluster brain split, there are differences in the data stripes in the linked lists maintained by servers in different clusters, so as to accurately and timely determine whether there is a cluster brain split by comparing the local linked list with other linked lists, and perform cluster recovery based on the local linked list and other linked lists, thereby improving the cluster's fault recovery capability and fault tolerance.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A flowchart of a cluster service processing method provided in an embodiment of the present application;
[0023] Figure 2 A flowchart of a cluster service processing method provided by another embodiment of the present application;
[0024] Figure 3 A data stripe adding result judgment flow chart provided in another embodiment of the present application;
[0025] Figure 4 A flow chart of a data stripe adding process provided by another embodiment of the present application;
[0026] Figure 5 A schematic diagram of a linked list node provided in another embodiment of the present application;
[0027] Figure 6 A simplified chain diagram provided for another embodiment of the present application;
[0028] Figure 7 A schematic diagram of a data strip provided by another embodiment of the present application;
[0029] Figure 8 A flowchart of a cluster service processing method provided by another embodiment of the present application;
[0030] Fig. 9 A flowchart of synchronizing a local linked list with other linked lists provided in another embodiment of the present application;
[0031] Fig.10 A schematic diagram of a linked list tree of a specific implementation method provided in another embodiment of the present application;
[0032] Fig.11 A schematic diagram of the structure of a cluster service processing device provided in an embodiment of the present application;
[0033] Fig.12 A schematic diagram of the structure of an electronic device for implementing a cluster service processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0035] It should be noted that the terms "first", "second", "third", "fourth", "actual", "preset", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] Figure 1The present invention provides a flowchart of a cluster service processing method according to an embodiment of the present invention. The present invention can be applied to the case of detecting and recovering a cluster brain split. The method can be executed by a cluster service processing device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device. Figure 1 As shown, the cluster service processing method includes:
[0037] S110 , for each server in the initialized cluster, record the data stripes generated by the cluster operation, and group the data stripes according to a preset time period to form linked list nodes, to obtain a local linked list of the server.
[0038] Among them, the initialized cluster is an overall cluster with only one main server, that is, a cluster without cluster brain split. The server in the cluster refers to a group of independent servers that are interconnected, and the servers work together to achieve the goals of high availability, load balancing and scalability. The data stripe is used to record the cluster operation process data. For example, when the cluster processes a request, a data stripe is formed according to the data related to the processing process for recording. The preset time interval can be determined in advance according to the actual situation, for example, it can be 1 hour. The local linked list is a linked list for the local server. For any server in the cluster, when the server executes the method of the embodiment of the present application, the linked list maintained by itself is the local linked list.
[0039] In an embodiment of the present application, the method in the embodiment of the present application is executed for each server in the initialized cluster. In the cluster, the data in each server is synchronized, and the recorded data stripes are also synchronized. That is, the cluster processes n services and forms n data stripes, then n data stripes should also be recorded in each server respectively. It should be noted that if there are data stripes that are not generated by the operation of the local server, the data stripes of the operation process recorded in the server may be complete data stripes containing data stripe content, or may only contain basic information of the data stripe without data stripe content, so as to avoid more data stripe content occupying more storage space. When the server needs the data stripe content, it can be obtained from other servers containing data stripe content.
[0040] Exemplarily, for each data stripe generated by the operation of the cluster, it is possible to group them according to a preset time period to form a linked list node. Exemplarily, as the cluster runs, the generated data stripes are recorded. If the recorded time reaches a preset time period, the data stripes within the preset time period are formed into a linked list node, and the linked list node corresponding to the preset time period is obtained, and it is no longer allowed to add data stripes to the linked list node corresponding to the preset time period. Start timing again and record the data stripes generated by the operation of the cluster. For the server in the cluster that is executing the method of the embodiment of the present application, the linked list with its own data stripes is used as the local linked list.
[0041] S120: Broadcast query to other linked lists in other servers in the cluster to which the server belongs, and obtain the other linked lists.
[0042] Among them, this solution is described by taking a server in a cluster executing the solution of the embodiment of the present application as an example, then the servers other than the server in the cluster are other servers. The linked lists in other servers are other linked lists. In network communication, broadcast is a one-to-all communication method, that is, a source server sends a data packet to all servers in the network, the destination address of the data packet is the broadcast address, and all servers in the network will receive and process this data packet.
[0043] For example, the server can query other linked lists in other servers in the cluster by broadcasting. If other servers and the server belong to the same cluster and the network connection is normal, other linked lists in other servers can be obtained. If other servers and the server belong to different clusters and the networks in different clusters are disconnected and cannot communicate with each other, the server cannot obtain other linked lists in other servers.
[0044] Among them, other linked lists in other servers obtained through broadcasting can be streamlined chains, that is, they may not contain data strips, but only contain data that can reflect the unique characteristics of the linked list nodes, such as identifiers, hash values, etc., thereby reducing the amount of transmitted data and improving data transmission efficiency.
[0045] S130: Determine whether a cluster split-brain situation exists according to the local linked list and the other linked lists, and perform cluster recovery if a cluster split-brain situation exists.
[0046] Exemplarily, if other servers and the local server executing the solution in the embodiment of the present application belong to the same cluster, the data stripes generated by the recorded cluster operation should be consistent, that is, the data stripes recorded in the local linked list and the other linked list should be consistent. If the local server and other servers belong to different clusters, the requests processed by different clusters are different, and the generated data stripes are also different, resulting in differences in the data stripes in the local linked list and the other linked list. After the network between different clusters is interconnected, after the local server obtains the local linked list and the other linked list, it can be determined by comparing the two linked lists whether the initialized cluster has a cluster brain split. In the case of a cluster brain split, since the local linked list and the other linked list record the data stripes of each cluster operation after the cluster brain split, that is, the main server, operation status, and processed requests in each cluster have been recorded, cluster recovery can be performed based on this, and the clusters after the cluster brain split are merged, and the local linked list and the other linked list are integrated to obtain a complete cluster corresponding to the linked list and maintain it in each server.
[0047] The technical solution of the embodiment of the present application records the data stripes generated by the operation of the cluster for each server in the initialization cluster, and groups the data stripes according to a preset time period to form linked list nodes to obtain the local linked list of the server; broadcasts and queries other linked lists in other servers in the cluster to which the server belongs to obtain the other linked lists; determines whether there is a cluster brain split according to the local linked list and the other linked lists, and performs cluster recovery in the case of a cluster brain split. The solution of the embodiment of the present application can reflect the operating data characteristics of the cluster to which the server belongs by recording the data stripes generated by the cluster operation in each server. In the case of a cluster brain split, there are differences in the data stripes in the linked lists maintained by servers in different clusters, so as to accurately and timely determine whether there is a cluster brain split by comparing the local linked list with other linked lists, and perform cluster recovery based on the local linked list and other linked lists, thereby improving the cluster's fault recovery capability and fault tolerance.
[0048] Figure 2 This is a flowchart of another cluster service processing method provided in an embodiment of the present application. The technical solution of this embodiment further optimizes the process of determining the first area and the second area based on the technical solution of the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. For solutions not described in detail in the embodiments of the present application, see the above embodiments. Figure 2 As shown, the cluster service processing method includes:
[0049] S210. For each server in the initialized cluster, record the data stripes generated by the cluster operation. If the time from the current moment to the previous packaging moment reaches a preset time period, package the data stripes between the previous packaging moment and the current moment to form a linked list node in a completed state; wherein the previous packaging moment is the moment when the data stripes within the previous preset time period are packaged to form the previous linked list node in a completed state.
[0050] Exemplarily, in the process of recording data stripes, if the time from the current moment to the last packaging moment reaches a preset time period, the data stripes between the last packaging moment and the current moment are packaged to form a linked list node in a complete state, and it is no longer allowed to continue recording data stripes in the linked list node. The linked list node represents the data stripes generated by the cluster operation in the time period between the last packaging moment and the current moment.
[0051] S220: If the time from the current moment to the last packaging moment does not reach the preset time period, the data stripes between the last packaging moment and the current moment are taken as a group of linked list nodes in an open state to continue adding record data stripes.
[0052] If the time between the current moment and the last packaging moment does not reach the preset time period, the currently created linked list node is used as an open linked list node, allowing data stripes to continue to be added until the data stripes generated by the cluster operation within the preset time period from the last packaging moment are recorded. The data stripes are packaged to form a complete linked list node.
[0053] For example, assuming that the preset time period is 1 hour, starting from 1 o'clock, create a linked list node to record the data stripes generated by the cluster operation. If the time does not reach 2 o'clock, continue to record. If the time reaches 2 o'clock, the data stripes generated between 1 o'clock and 2 o'clock will form a complete linked list node, and further addition of data stripes is not allowed. Create the next linked list node from 2 o'clock to continue recording the data stripes generated by the cluster operation. If the time does not reach 3 o'clock, continue to record. If the time reaches 3 o'clock, the data stripes generated between 2 o'clock and 3 o'clock will form a complete linked list node, and further addition of data stripes is not allowed.
[0054] The beneficial effect of the above scheme is that if the data stripes are not packaged into linked list nodes according to the time period, and only the data stripes are saved one by one, the data stripes currently do not contain the hash information of the previous data stripe, and the consistency of the linked list cannot be verified. If the hash information of the previous stripe is directly added to the data stripe, the streamlined chain will increase infinitely as the number of data stripes increases. In the subsequent confirmation of the integrity of the linked list by the linked list node, and the way that the linked list node closes the write at a fixed time, the streamlined chain length and data size are only related to the running time, not to the number of data stripes. This facilitates the rapid verification of the integrity of the linked list in the cluster. If the length of the linked list is calculated by the number of data stripes, a server can turn its own chain into a legal chain in the cluster by adding data stripes, affecting the reliability and accuracy of cluster recovery. At present, the length of the linked list is calculated by the number of linked list nodes and judged by the length of the linked list nodes. The length of the linked list is only related to the running time, so a single service node cannot replace the real legal chain by writing a large number of stripes.
[0055] In an embodiment of the present application, the linked list node includes a node identifier; the data stripe includes a node identifier of the linked list node, a data stripe identifier, a data stripe type, a data stripe hash value, and a data stripe content;
[0056] Record the data stripes generated by the cluster operation, including:
[0057] If the data stripe to be added is generated by the operation of the server, then the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value are broadcast to notify other servers to add the data stripe;
[0058] If addition information is received from other servers and carries the node identifier, data stripe identifier, data stripe type and data stripe hash value of the linked list node to which the data stripe to be added belongs, it is determined whether to add the data stripe based on the node identifier, data stripe identifier, data stripe type and data stripe hash value of the linked list node to which the data stripe to be added belongs.
[0059] Exemplarily, the linked list node includes a node identifier, and the node identifier is numbered in sequence according to the generation order of the linked list node. For example, when the cluster is initialized to run and generate the first data stripe, a linked list node 1 is created for recording. After the data stripes generated within a preset time period are recorded in the linked list node 1, a linked list node 2 is created to record the data stripes generated thereafter. The data stripes in the linked list node include the node identifier of the linked list node to which it belongs, which is used to reflect in which linked list node the data stripe is recorded. Specifically, the data stripes in each linked list node are numbered in sequence according to the generation order. The data stripes in the linked list node 1 may be numbered 1-50, and the data stripes in the linked list node 2 may be numbered 1-60, which contain the same number of 1-50. If the node identifier of the linked list node to which it belongs is not carried, it cannot be distinguished. The data stripes also include data stripe identifiers, which are numbered in sequence according to the generation order of the data stripes. The data stripe also includes the data stripe type, for example, global data and local data. Global data is data that needs to be added by all nodes, and local data is data that allows only the data stripe identifier to be added without adding the data stripe content. The data stripe also includes a data stripe hash value, which is calculated based on the data stripe identifier, data stripe type, and data stripe content. According to the data stripe hash value, it is possible to accurately determine whether two data stripes are consistent, without the need to transmit and compare specific data stripe content, thereby improving transmission efficiency and comparison efficiency.
[0060] In an embodiment of the present application, in the process of adding data stripes generated by the operation of the record cluster to the linked list node, if the data stripe to be added is generated by the operation of the local server, it is necessary to broadcast and notify other servers to add it. In the process of broadcast notification, it is necessary to carry the node identifier of the linked list node of the data stripe to be added and the data stripe identifier, so that other servers can clearly know the adding position of the data stripe, and it is also necessary to carry the data stripe type, so that other servers can clearly know whether the data stripe content must be added, and it is also necessary to carry the data stripe hash value, so that other servers can record the data stripe hash value when judging that the data stripe content does not need to be added, so as to obtain the data stripe content based on this later, or when judging that the data stripe content needs to be added, other servers can broadcast and obtain the data stripe content of the data stripe based on the data stripe identifier and the data stripe hash value for recording.
[0061] If data stripe adding information broadcasted by other servers is received, and the adding information broadcasted by other servers also carries the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value, after determining to which data stripe of which linked list node the data stripe to be added needs to be added based on the node identifier of the linked list node to which the data stripe to be added belongs and the data stripe identifier, determine whether the data stripe content of the data stripe needs to be added based on the data stripe type carried; if the data stripe content does not need to be added, directly add the data stripe hash value; if the data stripe content needs to be added, broadcast the data stripe content of the data stripe with the data stripe identifier and the data stripe hash value, and add it.
[0062] In the embodiment of the present application, after broadcasting the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type, and the data stripe hash value to notify other servers to add the data stripe, the method further includes:
[0063] Statistics feedback the number of other servers that have successfully added the data stripe to be added;
[0064] If the ratio of the number of other successfully added servers to the total number of servers in the cluster exceeds a preset ratio, it is determined that the data stripe to be added is added successfully and added to the local linked list;
[0065] Otherwise, it is determined that there is a cluster split-brain situation, the local linked list and other linked lists are synchronized, and after synchronization, the data stripe to be added is added again.
[0066] Exemplarily, during the process of adding data stripes, the adding results may be different due to the time difference in receiving the adding information. Exemplarily, server A broadcasts a message to add data stripe 5 to server B, and server C broadcasts a message to add data stripe 5 to server B. If the adding message from server A reaches server B first, server B adds data stripe 5 broadcasted by server A, while data stripe 5 broadcasted by server C fails to be added. If a cluster split-brain occurs, only some of the other servers are added successfully. At this time, the cluster needs to be restored first, and the linked lists need to be synchronized before adding. Figure 3As shown in the flowchart, after broadcasting the addition of the data stripe, it is necessary to further determine whether the addition is successful based on the feedback from other servers. Specifically, if the other servers are added successfully, they will feedback a message of successful addition. The local server counts the number of messages received that feedback successful addition, reflecting the number of other servers that have successfully added the data stripe to be added. If the ratio of the number of other successfully added servers to the total number of servers in the cluster exceeds the preset ratio, it is determined that the data stripe to be added is successfully added and added to the local linked list. The preset ratio can be 1 / 2, for example. If the ratio of the number of other successfully added servers to the total number of servers in the cluster does not exceed the preset ratio, it means that other servers other than the specified number have received the addition information broadcast by the local server, reflecting that the other servers that have not received the addition information may not be in the same cluster as the local server, and a cluster brain split has occurred. In this case, it is necessary to synchronize the local linked list and other linked lists, and re-add the data stripe to be added after synchronization, and the process of adding again is the same as the above-mentioned adding process.
[0067] In an embodiment of the present application, determining whether to add the data stripe according to the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type, and the data stripe hash value includes:
[0068] If it is determined that the linked list node to which the data stripe to be added belongs is an open linked list node according to the node identifier of the linked list node to which the data stripe to be added belongs, and the stripe identifier of the data stripe to be added is the next number identifier of the stripe identifier of the last data stripe in the open linked list node, then it is allowed to add the data stripe to the open linked list node;
[0069] If the data stripe type of the data stripe to be added is local data, then the data stripe identifier, data stripe type, and data stripe hash value of the data stripe to be added are added to the linked list node in the open state;
[0070] If the data stripe type of the data stripe to be added is global data, the content of the data stripe to be added is acquired by broadcasting, and the data stripe to be added is added to the linked list node in the open state.
[0071] Exemplary, the flow chart is as follows Figure 4As shown, if the local server receives the addition information of the data stripe broadcasted by other servers, it determines whether the linked list node is an open linked list node according to the node identifier of the linked list node to which the data stripe to be added belongs. If it is an open linked list node, it is allowed to add data stripes to it. If it is a completed linked list node, it is not allowed to continue to add data stripes to it. In addition, it is determined whether the stripe identifier of the data stripe to be added is the next number identifier of the stripe identifier of the last data stripe in the linked list node in the open state to determine whether the data stripes are recorded in sequence and whether there are any data stripes missing. If the stripe identifier of the data stripe to be added is the next number identifier of the stripe identifier of the last data stripe in the linked list node in the open state, it is allowed to be added. For example, if the stripe identifier of the last data stripe in the open linked list node 1 is 61, then the stripe identifier of the data stripe to be added needs to be 62 to be successfully added in sequence. If it is 63, which is not the next number identifier of 61, it is determined that a data stripe is missing, and the data stripe to be added is not allowed to be added.
[0072] Furthermore, if the data stripe type of the data stripe to be added is local data, the server to which the data stripe is broadcasted to be added can selectively add the data stripe content of the data stripe, and only add the data stripe identifier, data stripe type, and data stripe hash value of the data stripe to be added in the linked list node in the open state. If the data stripe type of the data stripe to be added is global data, the server to which the data stripe is broadcasted to be added needs to add the data stripe content, and then the data stripe content of the data stripe to be added is broadcasted and obtained according to the data stripe identifier and data stripe hash value of the data stripe to be added for addition.
[0073] In the embodiment of the present application, the linked list node also includes a linked list node hash value;
[0074] The method further comprises:
[0075] If the node identifier of the linked list node to which the data stripe to be added belongs, the linked list node hash value, the data stripe type, and the addition information of the data stripe hash value broadcasted by other servers are received, the linked list node hash value corresponding to the linked list node identifier in the local linked list is compared with the received linked list node hash value;
[0076] If the comparison is inconsistent, the broadcast query is sent to other servers to update the data stripe in the linked list node.
[0077] Exemplarily, the linked list node may also include a linked list node hash value to verify the integrity and accuracy of the linked list node. Exemplarily, if the addition information broadcasted by other servers is received, the linked list node hash value corresponding to the node identifier of the linked list node to which the data stripe to be added belongs in the local linked list is compared with the received linked list node hash value. If the comparison is consistent, it is determined that the linked list node corresponding to the node identifier in the local linked list is consistent with the content of the linked list node to which the data stripe to be added in other servers belongs. If the comparison is inconsistent, it is determined that the linked list node corresponding to the node identifier in the local linked list is inconsistent with the content of the linked list node to which the data stripe to be added in other servers belongs, then the node identifier is broadcast to query other servers to update the data stripe in the linked list node. If the hash value of the linked list node fed back by other servers exceeding the preset number is consistent with the hash value of the linked list node corresponding to the node identifier of the linked list node to which the data stripe to be added belongs in the local linked list, no update is performed; if the hash value of the linked list node fed back by other servers exceeding the preset number is consistent with the received hash value of the linked list node, the local linked list is updated based on the data stripe of the received linked list node.
[0078] For example, Figure 5 As shown, the linked list node also includes the generation time of the linked list node, that is, Figure 5 In the Time, if there is a cluster split-brain, the time when the cluster split-brain occurs can be determined based on the time corresponding to different linked list nodes in each server linked list. Figure 5 In the example, Node ID is the node ID, Previous Node Hush is the hash value of the previous linked list node, Data Strip is the data strip, and Node Hash is the hash value of the linked list node. Figure 6 As shown, the data stripe is not included. Figure 7 As shown, it includes the node identifier of the linked list node, the data stripe identifier, the data stripe type, the data stripe hash value and the data stripe content, which are consistent with the content of the data stripe to be added.
[0079] S230: Broadcast query to other linked lists in other servers in the cluster to which the server belongs, and obtain the other linked lists.
[0080] S240: Determine whether a cluster split-brain situation exists according to the local linked list and the other linked lists, and perform cluster recovery if a cluster split-brain situation exists.
[0081] The technical solution of the embodiment of the present application is to record the data stripes generated by the operation of the cluster for each server in the initialization cluster, and if the time from the current moment to the last packaging moment reaches the preset time period, the data stripes between the last packaging moment and the current moment are packaged to form a linked list node in a completed state; wherein the last packaging moment is the moment when the data stripes within the last preset time period are packaged to form the last linked list node in a completed state; if the time from the current moment to the last packaging moment does not reach the preset time period, the data stripes between the last packaging moment and the current moment are used as a group of linked list nodes in an open state to continue to add and record data stripes. Broadcast query other linked lists in other servers in the cluster to which the server belongs to obtain the other linked lists; according to the local linked list and the other linked lists, determine whether there is a cluster brain split, and perform cluster recovery in the case of a cluster brain split, and package the data stripes into linked list nodes for maintenance according to the preset time period, so as to facilitate the judgment of the length of the linked list in units of time, and compare the consistency of the linked list, which can more objectively reflect the characteristics of the linked list and avoid the accuracy of the final linked list length judgment affected by the difference in the number of data stripes. It is also convenient to calculate hash values based on linked list nodes for content verification, which is more convenient and saves memory.
[0082] Figure 8 This is a flowchart of another cluster service processing method provided in the embodiment of the present application. The technical solution of this embodiment further optimizes the process of determining whether the field of view of the image collector is blocked within the target time period according to the first area and the second area based on the technical solution of the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. For solutions not described in detail in the embodiment of the present application, see the above embodiments. Figure 8 As shown, the cluster service processing method includes:
[0083] S310, for each server in the initialized cluster, record the data stripes generated by the cluster operation, and group the data stripes according to a preset time period to form linked list nodes, to obtain a local linked list of the server.
[0084] S320: Broadcast query to other linked lists in other servers in the cluster to which the server belongs, and obtain the other linked lists.
[0085] S330, comparing each linked list node in the local linked list with each linked list node in other linked lists in terms of node identification, generation time, linked list node hash value, and previous linked list node hash value.
[0086] Exemplarily, if other servers and the local server executing the solution in the embodiment of the present application belong to the same cluster, the data stripes generated by the recorded cluster operation should be consistent, that is, the data stripes recorded in the local linked list and the other linked list should be consistent. If the local server and the other servers belong to different clusters, the requests processed by different clusters are different, and the generated data stripes are also different, resulting in differences in the data stripes in the local linked list and the other linked list. After the network between different clusters is interconnected, the local server obtains the local linked list and the other linked list, and then compares the node identification, generation time, linked list node hash value and the previous linked list node hash value of each linked list node in the local linked list with each linked list node in the other linked list, so as to determine whether there is a difference between the linked list nodes in the local linked list and the other linked list.
[0087] S340: If any of the node identifier, generation time, linked list node hash value, and previous linked list node hash value in any linked list node are inconsistent, it is determined that a cluster split-brain situation exists, and the local linked list and other linked lists are synchronized.
[0088] Among them, other linked lists in other servers obtained through broadcast query include node identification, generation time, linked list node hash value and previous linked list node hash value, which is the streamlined chain described in the above embodiment.
[0089] For example, if any one of the node identifier, generation time, linked list node hash value, and previous linked list node hash value is inconsistent, it is determined that there are differences in linked list nodes between the local linked list and other linked lists, and it is determined that a cluster split-brain situation exists, and the local linked list and other linked lists need to be synchronized for cluster recovery.
[0090] In the embodiment of the present application, it is determined that there is a cluster split-brain situation, and the local linked list and other linked lists are synchronized, including:
[0091] If it is determined that the other linked list is the main linked list, then adding the linked list nodes in the local linked list that are inconsistent with the other linked list and the data stripes in the subsequent linked list nodes to the other linked list;
[0092] If the linked list nodes in the local linked list that are inconsistent with the other linked lists and the data stripes in the subsequent linked list nodes are all added to the other linked list, the original local linked list is deleted, and the other linked list is used as the new local linked list in the server;
[0093] If it is determined that the local linked list is the main linked list, the linked list nodes in other linked lists that are inconsistent with the local linked list and the data stripes in the subsequent linked list nodes are passively added.
[0094] For example, Fig. 9As shown, the main linked list can be determined based on the comparison between the local linked list and other linked lists. Fig. 9 The length in is the number of linked list nodes, and the thickness is the number of servers that generate the linked list. If it is determined that other linked lists are the main linked lists, it is necessary to take other linked lists as the main ones, add the linked list nodes in the local linked list that are different from other linked lists to other linked lists, and store and maintain them as the updated local linked lists. Specifically, it is determined that the local linked list and the other linked list are inconsistent with the linked list nodes, reflecting that the cluster brain split has occurred since the linked list node, and the data stripes generated by the operation of different clusters are recorded respectively. Starting from the linked list node, the data stripes in the linked list node and the subsequent linked list nodes are added to other linked lists, including adding to other linked lists obtained in the local server, and adding to other linked lists of other servers. The process of adding data stripes is consistent with the process described in the above embodiment. If the local linked list is determined as the main linked list according to the local linked list and other linked lists, the other servers will broadcast the data stripes of the inconsistent linked list nodes in other linked lists, then the addition information broadcast by other servers can be passively received, and the linked list nodes in other linked lists that are inconsistent with the local linked list and the data stripes in the subsequent linked list nodes are added to the local linked list. The above process compares the local linked list with other linked lists to determine the linked list node that produces the difference, reflecting the time when the cluster split-brain occurs, and starts linked list synchronization from this linked list node, thereby re-maintaining a complete linked list, recording a data stripe generated by cluster operation, and recording a primary server, thereby realizing cluster recovery.
[0095] In the embodiment of the present application, the process of determining the main linked list includes:
[0096] The linked list with the most linked list nodes among the local linked list and the other linked lists, and / or the linked list with the largest number of servers generating the linked list, is used as the main linked list.
[0097] Exemplarily, the linked list nodes can reflect the running time of the corresponding cluster and the number of data stripes generated by the running. The more linked list nodes there are, the longer the running time of the cluster is, and the more data stripes are generated. This can be used as a judgment factor for the main linked list. In addition, the number of servers that generate the linked list reflects the number of servers in the cluster after the cluster brain split. The more servers there are, the larger the scale of the cluster is, which can also be used as a judgment factor for the main linked list. The linked list with the most linked list nodes among the local linked list and the other linked lists, and / or the linked list with the most servers generating the linked list can be used as the main linked list. In addition, in combination with the specific processing situation of the business, the cluster that can normally process the business can use the linked list that continuously and normally records the data stripes generated by the business as the main linked list.
[0098] Specifically, the local linked list and other linked lists can be constructed into a linked list tree, with the same linked list nodes on the same branch and different linked list nodes belonging to different branches, so as to determine whether there is a cluster split-brain based on whether there is a branch in the linked list.
[0099] For example, Fig.10 As shown in the figure, at time t0, there are 16 servers in the initialization cluster, which run as a cluster in the time period t0-t1, forming the same linked list. At time t1, a cluster split occurs, and the linked list branches. The left linked list branch is the linked list corresponding to the cluster where the 8 servers are located, and the right linked list is the linked list corresponding to another cluster where the other 8 servers are located. At time t2, a cluster split occurs in another cluster. Seven servers form a cluster and maintain a linked list, and another server forms a cluster and maintains a linked list. Until time t4, the network of all servers is restored to normal and intercommunication is achieved, and each server obtains all the linked lists. The durations recorded in linked lists a and b are the same, both t0-t4. The dotted part corresponding to the server corresponding to linked list c indicates shutdown due to a fault. No data is recorded in the time period after t2. The durations recorded in linked lists a and b are greater than the duration recorded in linked list c. Linked list a is recorded by 8 servers, and linked list b is recorded by 7 servers. Therefore, linked list a is used as the main linked list. The servers corresponding to linked lists b and c need to remove the data stripes marked with the data stripes generated by the main server from the linked list nodes in linked lists b and c and add them to linked list a, and also add them to the linked list a of the server corresponding to linked list a. At the same time, linked lists b and c are deleted, and only linked list a is stored and maintained. The main server recorded in linked list a is used as the global main server.
[0100] In an embodiment of the present application, the method further includes:
[0101] If it is detected that the main server is offline, broadcast to other servers a data stripe recording that the server is the main server;
[0102] If the data stripe is added successfully, determining the server as the primary server;
[0103] If the data stripe broadcasted by the other server recording that the other server is the primary server is received and added successfully, the other server is determined to be the primary server.
[0104] Exemplarily, if the local server, as a slave server, detects that the master server is offline, it attempts to become the master server itself, broadcasts to other servers a data stripe recording that the local server is the master server, notifies the other servers, and obtains recognition from the other servers. If the data stripe is added successfully, it is determined that the other servers recognize it and determine that the server is the master server. Similarly, if the local server receives a data stripe broadcasted by other servers recording that the other server is the master server, and the addition is successful, it is determined that the other server is the master server.
[0105] It should be noted that, when the above-mentioned local linked list and other linked lists are synchronized, if the other linked list is the main linked list, and there are data stripes recording the main server in the other linked list, and there are also data stripes recording the main server in the cluster to which the local linked list belongs, then the data stripe recording the main server in the cluster in the local linked list will be deleted, and the data stripe of the main server recorded in the main linked list will be used as the basis, so that there is only one main server in a cluster that is interconnected after network recovery.
[0106] The technical solution of the embodiment of the present application records the data stripes generated by the operation of the cluster for each server in the initialization cluster, and groups the data stripes according to the preset time period to form a linked list node to obtain the local linked list of the server; broadcast query other linked lists in other servers in the cluster to which the server belongs to obtain the other linked lists. Compare the node identification, generation time, linked list node hash value and the hash value of the previous linked list node of each linked list node in the local linked list with each linked list node in other linked lists; if there is any node identification, generation time, linked list node hash value and the hash value of the previous linked list node in any linked list node, it is determined that there is a cluster brain split, and the local linked list and other linked lists are synchronized. The solution in the embodiment of the present application can determine whether there are inconsistent linked list nodes by comparing the local linked list and other linked lists, accurately and timely determine whether there is a cluster brain split, and reflect the time node of the cluster brain split through the inconsistent linked list node, start synchronizing the local linked list and other linked lists from the linked list node where the cluster brain split occurs, and realize cluster recovery.
[0107] Fig.11 This is a schematic diagram of the structure of a cluster service processing device provided in an embodiment of the present application. The device can execute the cluster service processing method provided in any embodiment of the present application and has the corresponding functional modules and beneficial effects of the execution method. Fig.11 As shown, the device comprises:
[0108] The local linked list determination module 410 is used to record the data stripes generated by the operation of the cluster for each server in the initialization cluster, and group the data stripes into linked list nodes according to a preset time period to obtain the local linked list of the server;
[0109] Other linked lists acquisition module 420, used for broadcasting query other linked lists in other servers in the cluster to which the server belongs, and acquiring the other linked lists;
[0110] The situation determination module 430 is used to determine whether there is a cluster split-brain situation according to the local linked list and the other linked lists, and to perform cluster recovery if there is a cluster split-brain situation.
[0111] In the embodiment of the present application, the local linked list determination module 410 groups the data stripes into linked list nodes according to a preset time period, including:
[0112] If the time between the current moment and the last packaging moment reaches a preset time period, the data stripes between the last packaging moment and the current moment are packaged to form a linked list node in a completed state; wherein the last packaging moment is the moment when the data stripes within the last preset time period are packaged to form the last linked list node in a completed state;
[0113] If the time from the current moment to the last packaging moment does not reach the preset time period, the data stripes between the last packaging moment and the current moment are taken as a group of linked list nodes in an open state to continue adding record data stripes.
[0114] In an embodiment of the present application, the linked list node includes a node identifier; the data stripe includes a node identifier of the linked list node, a data stripe identifier, a data stripe type, a data stripe hash value, and a data stripe content;
[0115] The local link list determination module 410 records the data stripes generated by the cluster operation, including:
[0116] If the data stripe to be added is generated by the operation of the server, then the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value are broadcast to notify other servers to add the data stripe;
[0117] If addition information is received from other servers broadcasting the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe type and the data stripe hash value, it is determined whether to add the data stripe based on the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value.
[0118] In the embodiment of the present application, the device further includes:
[0119] The quantity statistics module is used to count and feedback the number of other servers that have successfully added the data stripe to be added;
[0120] An adding module, configured to determine that the data stripe to be added is successfully added and add it to the local linked list if the ratio of the number of other successfully added servers to the total number of servers in the cluster exceeds a preset ratio;
[0121] The synchronization module is used to determine that there is a cluster split brain situation, synchronize the local linked list and other linked lists, and re-add the data stripe to be added after synchronization.
[0122] In the embodiment of the present application, the local linked list determination module 410 determines whether to add the data stripe according to the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value, including:
[0123] If it is determined that the linked list node to which the data stripe to be added belongs is an open linked list node according to the node identifier of the linked list node to which the data stripe to be added belongs, and the stripe identifier of the data stripe to be added is the next number identifier of the stripe identifier of the last data stripe in the open linked list node, then it is allowed to add the data stripe to the open linked list node;
[0124] If the data stripe type of the data stripe to be added is local data, then the data stripe identifier, data stripe type, and data stripe hash value of the data stripe to be added are added to the linked list node in the open state;
[0125] If the data stripe type of the data stripe to be added is global data, the content of the data stripe to be added is acquired by broadcasting, and the data stripe to be added is added to the linked list node in the open state.
[0126] In the embodiment of the present application, the linked list node also includes a linked list node hash value;
[0127] The device also includes:
[0128] A comparison module, for comparing the linked list node hash value corresponding to the linked list node identifier in the local linked list with the received linked list node hash value if receiving the addition information broadcasted by other servers and carrying the node identifier of the linked list node to which the data stripe to be added belongs, the linked list node hash value, the data stripe type and the data stripe hash value;
[0129] The query module is used to broadcast and query other servers to update the data stripe in the linked list node if the comparison is inconsistent.
[0130] In the embodiment of the present application, other linked lists in other servers obtained by broadcast query include node identification, generation time, linked list node hash value, and previous linked list node hash value;
[0131] Accordingly, the situation determination module 430 determines whether there is a cluster split-brain situation according to the local linked list and the other linked lists, and performs cluster recovery in the case of a cluster split-brain situation, including:
[0132] Compare the node identification, generation time, hash value of each node in the local linked list and the hash value of the previous linked list node with the node identification, generation time, hash value of each node in the local linked list and the hash value of each node in the other linked lists;
[0133] If any of the node identifier, generation time, linked list node hash value and previous linked list node hash value in any linked list node are inconsistent, it is determined that a cluster split-brain situation exists, and the local linked list and other linked lists are synchronized.
[0134] In the embodiment of the present application, the situation determination module 430 determines that there is a cluster split-brain situation, and synchronizes the local linked list with other linked lists, including:
[0135] If it is determined that the other linked list is the main linked list, then adding the linked list nodes in the local linked list that are inconsistent with the other linked list and the data stripes in the subsequent linked list nodes to the other linked list;
[0136] If the linked list nodes in the local linked list that are inconsistent with the other linked lists and the data stripes in the subsequent linked list nodes are all added to the other linked list, the original local linked list is deleted, and the other linked list is used as the new local linked list in the server;
[0137] If it is determined that the local linked list is the main linked list, the linked list nodes in other linked lists that are inconsistent with the local linked list and the data stripes in the subsequent linked list nodes are passively added.
[0138] In the embodiment of the present application, the device further includes:
[0139] The main linked list determination module is used to use the linked list with the most linked list nodes among the local linked list and the other linked lists, and / or the linked list with the largest number of servers generating the linked list, as the main linked list.
[0140] In the embodiment of the present application, the device further includes:
[0141] A main server data stripe adding module is used to broadcast to other servers the data stripe recording that the server is the main server if the main server is detected to be offline;
[0142] A main server determination module, used for determining the server as the main server if the data stripe is added successfully;
[0143] The main server data stripe receiving module is used to determine that the other server is the main server if the data stripe broadcasted by the other server and recording that the other server is the main server is received and added successfully.
[0144] A cluster service processing device provided in an embodiment of the present application can execute a cluster service processing method provided in any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
[0145] Fig.12 A schematic diagram of the structure of an electronic device for implementing a cluster service processing method provided in an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0146] like Fig.12 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0147] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0148] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a cluster service processing method.
[0149] In some embodiments, the cluster service processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the cluster service processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the cluster service processing method in any other appropriate manner (e.g., by means of firmware).
[0150] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0151] The computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable cluster service processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0152] In the context of the present application, a computer readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device or equipment. A computer readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer readable storage medium may be a machine readable signal medium. A more specific example of a machine readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0154] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0155] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0156] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the information expected by the technical solution of this application can be achieved, and this document is not limited here.
[0157] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A cluster service processing method, characterized in that: The method comprises: For each server in the initialization cluster, record the data stripes generated by the cluster operation, and group the data stripes into linked list nodes according to a preset time period to obtain the local linked list of the server; Broadcast query to other linked lists in other servers in the cluster to which the server belongs, and obtain the other linked lists; Determine whether a cluster split-brain situation exists according to the local linked list and the other linked lists, and perform cluster recovery if a cluster split-brain situation exists.
2. The method according to claim 1, characterized in that: The data stripes are grouped according to a preset time period to form linked list nodes, including: If the time between the current moment and the last packaging moment reaches a preset time period, the data stripes between the last packaging moment and the current moment are packaged to form a linked list node in a completed state; wherein the last packaging moment is the moment when the data stripes within the last preset time period are packaged to form the last linked list node in a completed state; If the time from the current moment to the last packaging moment does not reach the preset time period, the data stripes between the last packaging moment and the current moment are taken as a group of linked list nodes in an open state to continue adding record data stripes.
3. The method according to claim 1, characterized in that The linked list node includes a node identifier; the data stripe includes a node identifier of the linked list node, a data stripe identifier, a data stripe type, a data stripe hash value, and a data stripe content; Record the data stripes generated by the cluster operation, including: If the data stripe to be added is generated by the operation of the server, then the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type and the data stripe hash value are broadcast to notify other servers to add the data stripe; If addition information is received from other servers and carries the node identifier, data stripe identifier, data stripe type and data stripe hash value of the linked list node to which the data stripe to be added belongs, it is determined whether to add the data stripe based on the node identifier, data stripe identifier, data stripe type and data stripe hash value of the linked list node to which the data stripe to be added belongs.
4. The method according to claim 3, characterized in that After broadcasting the node identifier of the linked list node to which the data stripe to be added belongs, the data stripe identifier, the data stripe type, and the data stripe hash value to notify other servers to add the data stripe, the method further includes: Statistics feedback the number of other servers that have successfully added the data stripe to be added; If the ratio of the number of other successfully added servers to the total number of servers in the cluster exceeds a preset ratio, it is determined that the data stripe to be added is added successfully and added to the local linked list; Otherwise, it is determined that there is a cluster split-brain situation, the local linked list and other linked lists are synchronized, and after synchronization, the data stripe to be added is added again.
5. The method according to claim 3, characterized in that: The linked list node also includes a linked list node hash value; The method further comprises: If the node identifier of the linked list node to which the data stripe to be added belongs, the linked list node hash value, the data stripe type, and the addition information of the data stripe hash value broadcasted by other servers are received, the linked list node hash value corresponding to the linked list node identifier in the local linked list is compared with the received linked list node hash value; If the comparison is inconsistent, the broadcast query is sent to other servers to update the data stripe in the linked list node.
6. The method according to claim 1, characterized in that Other linked lists in other servers obtained through broadcast query include node identification, generation time, linked list node hash value, and previous linked list node hash value; Accordingly, determining whether a cluster split-brain situation exists according to the local linked list and the other linked lists, and performing cluster recovery in the case of a cluster split-brain situation includes: Compare the node identification, generation time, hash value of each node in the local linked list and the hash value of the previous linked list node with the node identification, generation time, hash value of each node in the local linked list and the hash value of each node in the other linked lists; If any of the node identifier, generation time, linked list node hash value and previous linked list node hash value in any linked list node are inconsistent, it is determined that a cluster split-brain situation exists, and the local linked list and other linked lists are synchronized.
7. The method according to any one of claims 4 to 6, characterized in that: Determine whether a cluster split-brain exists, and synchronize the local linked list with other linked lists, including: If it is determined that the other linked list is the main linked list, then adding the linked list nodes in the local linked list that are inconsistent with the other linked list and the data stripes in the subsequent linked list nodes to the other linked list; If the linked list nodes in the local linked list that are inconsistent with the other linked lists and the data stripes in the subsequent linked list nodes are all added to the other linked list, the original local linked list is deleted, and the other linked list is used as the new local linked list in the server; If it is determined that the local linked list is the main linked list, the linked list nodes in other linked lists that are inconsistent with the local linked list and the data stripes in the subsequent linked list nodes are passively added.
8. The method according to claim 7, characterized in that The process of determining the main linked list includes: The linked list with the most linked list nodes among the local linked list and the other linked lists, and / or the linked list with the largest number of servers generating the linked list, is used as the main linked list.
9. The method according to claim 1, characterized in that: The method further comprises: If it is detected that the main server is offline, broadcast to other servers a data stripe recording that the server is the main server; If the data stripe is added successfully, determining the server as the primary server; If the data stripe broadcasted by the other server recording that the other server is the primary server is received and added successfully, the other server is determined to be the primary server.
10. A cluster service processing device, characterized in that: The device comprises: A local linked list determination module is used to record the data stripes generated by the operation of the cluster for each server in the initialization cluster, and group the data stripes into linked list nodes according to a preset time period to obtain the local linked list of the server; Other linked lists acquisition module, used for broadcasting query other linked lists in other servers in the cluster to which the server belongs, and acquiring the other linked lists; The situation determination module is used to determine whether there is a cluster split-brain situation according to the local linked list and the other linked lists, and to perform cluster recovery when there is a cluster split-brain situation.
11. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the cluster service processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the cluster service processing method according to any one of claims 1 to 9 when executed.