Status verification method, device, electronic device and computer readable storage medium

By obtaining and comparing status verification parameters in the distributed system, the problem of status inconsistency is solved, efficient and accurate status verification is achieved, resource waste and historical record problems are avoided, and the reliability and traceability of the system are improved. .

CN112988689BActive Publication Date: 2024-10-18ALIBABA GROUP HOLDING LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201911312978.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-18
Publication Date
2024-10-18
Estimated Expiration
2039-12-18

AI Technical Summary

Technical Problem

In distributed systems, existing state machine replication methods lead to inconsistent states due to factors such as program versions, operating environments, and software defects among members. Existing solutions suffer from resource consumption, poor timeliness, difficulty in ensuring correctness, and difficulty in history. Traceability issues.

Method used

By obtaining the status verification parameters, each member calculates the status verification value, and determines the status verification results through comparison of the check values ​​to achieve consistency verification of the status, avoid using other tools, reduce system resource consumption, and ensure timeliness and correctness and facilitate recording of historical data.

Benefits of technology

It achieves the timeliness and correctness of status verification, avoids the expansion of faults, facilitates the recording of historical data, and improves the reliability and traceability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112988689B_ABST
    Figure CN112988689B_ABST
Patent Text Reader

Abstract

The disclosed embodiments disclose a state verification method, device, electronic device and computer-readable storage medium, wherein the state verification method comprises: obtaining state verification parameters, and calculating the current state verification value according to the state verification parameters as the expected verification value of the master member; synchronously sending the expected verification value of the master member to the slave member, so that the slave member determines the state verification result according to the expected verification value of the master member and the calculated verification value of the slave member; and receiving the state verification result returned by the slave member. This technical solution can realize state verification without the aid of other tools, does not consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of distributed systems, and in particular to a state verification method, device, electronic device, and computer-readable storage medium. Background Art

[0002] In distributed systems, in order to achieve high availability and strong consistency of roles, state machine replication methods are often used to synchronize states. This method groups multiple instances of a system role into a group, dynamically elects a leader and multiple followers, and the leader records the changes to its state machine, i.e., the key memory state, into a log file (LogEntry) and copies it to all members including itself, and writes it persistently to their respective log files (Log). When members reach a consensus on the log content through a distributed consistency algorithm, they apply the changes to the log file to their own memory state one by one according to the log index (LogIndex). In theory, the consistent log files negotiated by members ensure that members will get the same state after applying the log write file according to a unified and deterministic logic, that is, the state machines between members are consistent. However, in engineering practice, due to the influence of factors such as program versions, operating environments, and software defects between members, the states generated after members apply the same log write file may not be consistent, which may cause serious problems such as data errors. Therefore, it is necessary to verify the consistency of the status between members and detect status inconsistencies in a timely manner during testing or even production to prevent the problem from further expanding.

[0003] The solution adopted in the prior art is: let each member generate a full state file regularly, then use the tool to load the file one by one and apply all subsequent logs to write the file to a certain same log index, generate the state summary value at this time, and then compare whether the summary values ​​obtained by each member are the same. If they are not the same, it means that there is a state inconsistency problem. This solution has multiple disadvantages: 1. Resource consumption: additional tools and system resources are required to transmit, load the full state file and generate summary values; 2. Poor timeliness: It takes a long time to calculate the summary of the full state, resulting in a long time to find consistency problems, and the problem has a larger time window for expansion; 3. Correctness is difficult to guarantee: the log position of the full state file generated between members is not necessarily the same, and the tool needs to apply a part of the full state file after the log write file to obtain the state of the same log position between members, but at this time, the logic used to apply the log write file is not necessarily the same as the logic actually run by the member; 4. History is difficult to trace: the history of state verification cannot be conveniently and reliably saved for subsequent analysis. Summary of the invention

[0004] Embodiments of the present disclosure provide a state verification method, device, electronic device, and computer-readable storage medium.

[0005] In a first aspect, a state verification method is provided in an embodiment of the present disclosure.

[0006] Specifically, the state verification method includes:

[0007] Obtaining a status check parameter, and calculating a current status check value according to the status check parameter as an expected check value of the primary member;

[0008] Synchronously sending the expected check value of the master member to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the calculated check value of the slave member;

[0009] Receive the status verification result returned by the slave member.

[0010] In combination with the first aspect, in a first implementation of the first aspect of the present disclosure, the obtaining status check parameter is implemented as follows:

[0011] In response to receiving the status verification request, generating an initial log write file, wherein the initial log write file includes a status verification parameter;

[0012] Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member;

[0013] In response to the initial log write file being applied, the status check parameter is obtained.

[0014] In combination with the first aspect and the first implementation manner of the first aspect, in a second implementation manner of the first aspect of the embodiment of the present invention, the obtaining status check parameter is implemented as follows:

[0015] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0016] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0017] In combination with the first aspect, the first implementation method of the first aspect and the second implementation method of the first aspect, in the third implementation method of the first aspect of the embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0018] In combination with the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, and the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect of the embodiment of the present invention, when the current state check value is an incremental state check value, the calculating according to the state check parameter to obtain the current state check value is implemented as follows:

[0019] Get the verification increment information and the previous state verification value;

[0020] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0021] In combination with the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, and the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect of the embodiment of the present invention, synchronously sending the expected check value of the master member to the slave member is implemented as follows:

[0022] In response to the expected checksum value of the primary member being calculated, generating a checksum log write file, wherein the checksum log write file includes the expected checksum value of the primary member;

[0023] The check log write file is written into a log file, and the check log write file is synchronously written into the log file of the slave member, so that when the check log write file is applied, the expected check value of the master member can be obtained.

[0024] In a second aspect, a state verification method is provided in an embodiment of the present disclosure.

[0025] Specifically, the state verification method includes:

[0026] Obtaining a status check parameter, and calculating a current status check value according to the status check parameter as the current member check value;

[0027] Obtaining the expected check value of the primary member, and determining the status check result according to the check value calculated by the current member and the expected check value of the primary member;

[0028] Return the status verification result to the primary member.

[0029] In combination with the second aspect, in a first implementation of the second aspect of the present disclosure, the obtaining status check parameter is implemented as follows:

[0030] Acquire an initial log write file for synchronous writing, wherein the initial log write file includes a status verification parameter;

[0031] In response to the initial log write file being applied, the status check parameter is obtained.

[0032] In combination with the second aspect and the first implementation of the second aspect, in a second implementation of the second aspect of the embodiment of the present invention, the obtaining status check parameter is implemented as follows:

[0033] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0034] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0035] In combination with the second aspect, the first implementation of the second aspect and the second implementation of the second aspect, in the third implementation of the second aspect of the embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0036] In combination with the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, and the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect of the embodiment of the present invention, when the current state check value is an incremental state check value, the calculating according to the state check parameter to obtain the current state check value is implemented as follows:

[0037] Get the verification increment information and the previous state verification value;

[0038] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0039] In combination with the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, and the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect of the embodiment of the present invention, obtaining the expected check value of the primary member is implemented as follows:

[0040] Obtaining a synchronously written verification log write file, wherein the verification log write file includes the expected verification value of the primary member;

[0041] In response to the checksum log write file being applied, obtaining the primary member expected checksum value.

[0042] In a third aspect, a state verification method is provided in an embodiment of the present disclosure.

[0043] Specifically, the state verification method includes:

[0044] The master member and the slave member obtain the state verification parameters, and calculate the current state verification value according to the state verification parameters, which are used as the master member expected verification value and the slave member calculated verification value respectively;

[0045] The master member synchronously sends the master member expected check value to the slave member, and the slave member determines the slave member status check result according to the master member expected check value and the slave member calculated check value;

[0046] The slave member returns the status verification result to the master member.

[0047] In combination with the third aspect, in a first implementation of the third aspect of the present disclosure, the master member and the slave member obtain the status verification parameter, which is implemented as follows:

[0048] In response to receiving the status verification request, the primary member generates an initial log write file, wherein the initial log write file includes a status verification parameter;

[0049] The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member;

[0050] The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied.

[0051] In combination with the third aspect and the first implementation of the third aspect, in the second implementation of the third aspect of the embodiment of the present invention, the master member and the slave member obtain the status verification parameter, which is implemented as follows:

[0052] The master member and the slave member determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0053] In response to the preset status check triggering condition being triggered, the master member and the slave member obtain the preset status check parameters.

[0054] In combination with the third aspect, the first implementation manner of the third aspect and the second implementation manner of the third aspect, in the third implementation manner of the third aspect of an embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0055] In combination with the third aspect, the first implementation manner of the third aspect, the second implementation manner of the third aspect, and the third implementation manner of the third aspect, in a fourth implementation manner of the third aspect of the embodiment of the present invention, when the current state check value is an incremental state check value, the calculating according to the state check parameter to obtain the current state check value is implemented as follows:

[0056] Get the verification increment information and the previous state verification value;

[0057] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0058] In combination with the third aspect, the first implementation manner of the third aspect, the second implementation manner of the third aspect, the third implementation manner of the third aspect, and the fourth implementation manner of the third aspect, in a fifth implementation manner of the third aspect of the embodiment of the present invention, the master member synchronously sends the master member expected check value to the slave member, which is implemented as follows:

[0059] In response to the primary member expected checksum being calculated, the primary member generates a checksum log write file, wherein the checksum log write file includes the primary member expected checksum;

[0060] The primary member writes the verification log write file into a log file, and synchronously writes the verification log write file into the log file of the secondary member;

[0061] In response to the checksum log write file being applied, the slave member obtains the master member's expected checksum value.

[0062] In a fourth aspect, a state verification device is provided in an embodiment of the present disclosure.

[0063] Specifically, the state verification device includes:

[0064] A first acquisition module is configured to acquire a state check parameter, and calculate a current state check value according to the state check parameter as an expected check value of the primary member;

[0065] A first sending module is configured to synchronously send the expected check value of the master member to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the member calculated check value obtained by the slave member;

[0066] The receiving module is configured to receive the status verification result returned by the slave member.

[0067] In combination with the fourth aspect, in a first implementation of the fourth aspect of the present disclosure, the part of the first acquisition module that acquires the status check parameter is configured as follows:

[0068] In response to receiving the status verification request, generating an initial log write file, wherein the initial log write file includes a status verification parameter;

[0069] Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member;

[0070] In response to the initial log write file being applied, the status check parameter is obtained.

[0071] In combination with the fourth aspect and the first implementation manner of the fourth aspect, in the second implementation manner of the fourth aspect of the embodiment of the present invention, the part of the first acquisition module that acquires the status check parameter is configured as follows:

[0072] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0073] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0074] In combination with the fourth aspect, the first implementation method of the fourth aspect and the second implementation method of the fourth aspect, in the third implementation method of the fourth aspect of an embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0075] In combination with the fourth aspect, the first implementation manner of the fourth aspect, the second implementation manner of the fourth aspect, and the third implementation manner of the fourth aspect, in a fourth implementation manner of the fourth aspect of an embodiment of the present invention, when the current state check value is an incremental state check value, the part of the first acquisition module that calculates the current state check value according to the state check parameter is configured as follows:

[0076] Get the verification increment information and the previous state verification value;

[0077] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0078] In combination with the fourth aspect, the first implementation manner of the fourth aspect, the second implementation manner of the fourth aspect, the third implementation manner of the fourth aspect, and the fourth implementation manner of the fourth aspect, in a fifth implementation manner of the fourth aspect of the embodiment of the present invention, the first sending module includes:

[0079] A generation submodule is configured to generate a verification log write file in response to the expected verification value of the primary member being calculated, wherein the verification log write file includes the expected verification value of the primary member;

[0080] The sending submodule is configured to write the verification log write file into a log file, and synchronously write the verification log write file into the log file of the slave member, so that when the verification log write file is applied, the expected verification value of the master member can be obtained.

[0081] In a fifth aspect, a state verification device is provided in an embodiment of the present disclosure.

[0082] Specifically, the state verification device includes:

[0083] A second acquisition module is configured to acquire a state check parameter, and calculate a current state check value according to the state check parameter as a current member check value;

[0084] A determination module is configured to obtain an expected check value of the primary member, and determine a status check result according to the check value calculated by the current member and the expected check value of the primary member;

[0085] The return module is configured to return the status verification result to the primary member.

[0086] In combination with the fifth aspect, in a first implementation of the fifth aspect of the present disclosure, the part of the second acquisition module that acquires the status check parameter is configured as follows:

[0087] Acquire an initial log write file for synchronous writing, wherein the initial log write file includes a status verification parameter;

[0088] In response to the initial log write file being applied, the status check parameter is obtained.

[0089] In combination with the fifth aspect and the first implementation manner of the fifth aspect, in the second implementation manner of the fifth aspect of the embodiment of the present invention, the part of the second acquisition module that acquires the status check parameter is configured as follows:

[0090] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0091] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0092] In combination with the fifth aspect, the first implementation method of the fifth aspect and the second implementation method of the fifth aspect, in the third implementation method of the fifth aspect of an embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0093] In combination with the fifth aspect, the first implementation manner of the fifth aspect, the second implementation manner of the fifth aspect, and the third implementation manner of the fifth aspect, in a fourth implementation manner of the fifth aspect of the embodiment of the present invention, when the current state check value is an incremental state check value, the part of the second acquisition module that calculates the current state check value according to the state check parameter is configured as follows:

[0094] Get the verification increment information and the previous state verification value;

[0095] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0096] In combination with the fifth aspect, the first implementation manner of the fifth aspect, the second implementation manner of the fifth aspect, the third implementation manner of the fifth aspect, and the fourth implementation manner of the fifth aspect, in a fifth implementation manner of the fifth aspect of an embodiment of the present invention, the part of the determination module that obtains the expected check value of the primary member is configured as follows:

[0097] Obtaining a synchronously written verification log write file, wherein the verification log write file includes the expected verification value of the primary member;

[0098] In response to the checksum log write file being applied, obtaining the primary member expected checksum value.

[0099] In a sixth aspect, a state verification device is provided in an embodiment of the present disclosure.

[0100] Specifically, the state verification device includes:

[0101] A third acquisition module is configured to acquire state verification parameters for the master member and the slave member, and calculate a current state verification value according to the state verification parameter as the master member expected verification value and the slave member calculated verification value respectively;

[0102] The second sending module is configured to send the master member expected check value to the slave member synchronously, and the slave member determines the slave member status check result according to the master member expected check value and the slave member calculated check value;

[0103] The return module is configured to return the status verification result from the member to the primary member.

[0104] In combination with the sixth aspect, in a first implementation of the sixth aspect of the present disclosure, the part of the third acquisition module in which the master member and the slave member acquire the status verification parameter is configured as follows:

[0105] In response to receiving the status verification request, the primary member generates an initial log write file, wherein the initial log write file includes a status verification parameter;

[0106] The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member;

[0107] The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied.

[0108] In combination with the sixth aspect and the first implementation of the sixth aspect, in the second implementation of the sixth aspect of the embodiment of the present invention, the part in which the master member and the slave member acquire the status verification parameter in the third acquisition module is configured as follows:

[0109] The master member and the slave member determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0110] In response to the preset status check triggering condition being triggered, the master member and the slave member obtain the preset status check parameters.

[0111] In combination with the sixth aspect, the first implementation method of the sixth aspect and the second implementation method of the sixth aspect, in the third implementation method of the sixth aspect of an embodiment of the present invention, the current state check value is a full state check value or an incremental state check value.

[0112] In combination with the sixth aspect, the first implementation manner of the sixth aspect, the second implementation manner of the sixth aspect, and the third implementation manner of the sixth aspect, in a fourth implementation manner of the sixth aspect of the embodiment of the present invention, when the current state check value is an incremental state check value, the part of the third acquisition module that calculates the current state check value according to the state check parameter is configured as follows:

[0113] Get the verification increment information and the previous state verification value;

[0114] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0115] In combination with the sixth aspect, the first implementation manner of the sixth aspect, the second implementation manner of the sixth aspect, the third implementation manner of the sixth aspect, and the fourth implementation manner of the sixth aspect, in a fifth implementation manner of the sixth aspect of the embodiment of the present invention, the part in the second sending module in which the master member synchronously sends the master member expected check value to the slave member is configured as follows:

[0116] In response to the primary member expected checksum being calculated, the primary member generates a checksum log write file, wherein the checksum log write file includes the primary member expected checksum;

[0117] The primary member writes the verification log write file into a log file, and synchronously writes the verification log write file into the log file of the secondary member;

[0118] In response to the checksum log write file being applied, the slave member obtains the master member's expected checksum value.

[0119] In the seventh aspect, an embodiment of the present disclosure provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, and wherein the one or more computer instructions are executed by the processor to implement the method steps of the above-mentioned status verification method.

[0120] In an eighth aspect, an embodiment of the present disclosure provides a computer-readable storage medium for storing computer instructions used by a state verification device, which includes computer instructions involved in the state verification device for executing the above-mentioned state verification method.

[0121] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0122] The above technical solution obtains the state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. This technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0123] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0124] Other features, objectives and advantages of the present disclosure will become more apparent through the following detailed description of non-limiting embodiments in conjunction with the accompanying drawings. In the accompanying drawings:

[0125] Figure 1 A flow chart showing a state verification method according to an embodiment of the present disclosure is shown;

[0126] Figure 2 Show according to Figure 1 A flowchart of step S102 of the state verification method of the illustrated embodiment;

[0127] Figure 3 A flow chart showing a state verification method according to another embodiment of the present disclosure;

[0128] Figure 4 A flow chart showing a state verification method according to another embodiment of the present disclosure;

[0129] Figure 5 An overall flow chart of a state verification method according to an embodiment of the present disclosure is shown;

[0130] Figure 6 A structural block diagram of a state verification device according to an embodiment of the present disclosure is shown;

[0131] Figure 7 Show according to Figure 6 A structural block diagram of a first sending module 602 of a state checking device in the illustrated embodiment;

[0132] Figure 8 A structural block diagram of a state verification device according to another embodiment of the present disclosure is shown;

[0133] Fig. 9 A structural block diagram of a state verification device according to another embodiment of the present disclosure is shown;

[0134] Fig.10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown;

[0135] Fig.11 It is a structural diagram of a computer system suitable for implementing a state verification method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0136] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.

[0137] In the present disclosure, it should be understood that terms such as "include" or "have" are intended to indicate the presence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof exist or are added.

[0138] It should also be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0139] The technical solution provided by the embodiment of the present disclosure obtains the state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. The technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0140] Figure 1 A flow chart showing a state verification method according to an embodiment of the present disclosure is shown, which can be applied to the primary member side. Figure 1 As shown, the state verification method includes the following steps S101-S103:

[0141] In step S101, a state check parameter is obtained, and a current state check value is calculated according to the state check parameter as an expected check value of the primary member;

[0142] In step S102, the expected check value of the master member is synchronously sent to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the calculated check value of the slave member;

[0143] In step S103, the status verification result returned from the member is received.

[0144] As mentioned above, in a distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to synchronize states. In theory, a log file with consistent content negotiated between members ensures that members will obtain the same state after writing logs to the file according to a unified and deterministic logic, that is, the state machines between members are consistent. However, in engineering practice, due to the influence of factors such as program versions, operating environments, and software defects between members, the states generated after members apply the same log to write files may not be consistent, which may cause serious problems such as data errors. Therefore, it is necessary to verify the consistency of states between members, and detect state inconsistencies in a timely manner during testing or even production to prevent the problem from further expanding. However, the solutions used in the prior art have the disadvantages of consuming resources, poor timeliness, difficulty in ensuring correctness, and difficulty in tracing history.

[0145] In view of the above defects, in this embodiment, a state verification method is proposed, which obtains state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. This technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0146] In an optional implementation of this embodiment, the leader refers to a dominant member in a distributed system, which performs information transmission and operation coordination with multiple followers in the distributed system to ensure the consistency of cluster data.

[0147] In an optional implementation of this embodiment, the state verification parameter refers to the parameter required for calculating the state verification value, which will be subsequently synchronized to all members. The state verification parameter may include one or more of the following parameters: the state summary calculation algorithm used, for example, whether to use the MD5 algorithm (Message-Digest Algorithm5) or the CRC (Cyclic Redundancy Check) algorithm; whether to adopt the full state calculation method or the incremental state calculation method; when the incremental state calculation method is adopted, the incremental information used for the incremental state calculation and the previous state summary value, etc., wherein the incremental information includes the error code (ErrorCode) when applying the log entry file (LogEntry) within a preset historical time, the code path marking information when applying the log entry file within a preset historical time, etc.

[0148] In an optional implementation of the present embodiment, the expected check value of the master member is the current state check value that needs to be checked and is calculated by the master member according to the obtained state check parameters. This check value is used as the expected check value of the master member and will be subsequently synchronized to the slave members. Each slave member calculates the calculated check value of the member according to the state check parameters obtained synchronously, and then compares the synchronized expected check value of the master member with the calculated check value of the member calculated by each slave member to obtain the verification result of this state verification. If the expected check value of the master member is the same as the calculated check value of the member calculated by each slave member, the verification is deemed to be successful and the verification is terminated. If they are different, the alarm process can be initiated and the continued execution of the member can be stopped.

[0149] In an optional implementation of this embodiment, the status check result may be embodied in the form of text, message, etc., or in the form of sound, audio, video, etc.

[0150] In an optional implementation of this embodiment, the step of obtaining the status verification parameter in step S101 may be implemented as follows:

[0151] In response to receiving the status verification request, generating an initial log write file, wherein the initial log write file includes a status verification parameter;

[0152] Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member;

[0153] In response to the initial log write file being applied, the status check parameter is obtained.

[0154] In this implementation, the state verification method supports a user-initiated triggering mode, that is, the state verification of the distributed system is performed according to the user's active triggering, and the corresponding state verification parameters are obtained. Specifically, in response to receiving a state verification request, such as one sent by a user, an initial log write file is generated, wherein the initial log write file contains the state verification parameters required for this state verification, and the state verification parameters may be carried by the state verification request or generated according to the state verification request; then the initial log write file is written to the log file of the primary member, and the initial log write file is synchronously written to the log file of the secondary member; when the initial log write file is applied, the state verification parameters can be obtained.

[0155] In an optional implementation of this embodiment, the status verification request may be a status verification request initiated by a user or a status verification request automatically initiated by a system.

[0156] In an optional implementation of the present embodiment, in order to achieve effective and accurate data synchronization, when generating an initial log write file, a corresponding log index (LogIndex) is also generated for the generated initial log write file to uniquely identify the initial log write file, so that the master member and the slave member can identify the applied log write file and the application results according to the log index of the initial log write file, and then perform targeted calculations, comparisons and processing.

[0157] In another optional implementation of this embodiment, the step of obtaining the status verification parameter in step S101 may also be implemented as follows:

[0158] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0159] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0160] In this implementation, the status verification method supports a mode of triggering status verification periodically according to a log index or other guide information. Specifically, first determine a preset status verification file including a preset status verification trigger condition and a preset status verification parameter; then, when it is detected that the preset status verification trigger condition is triggered, start the status verification operation and obtain the preset status verification parameter. The preset status verification trigger condition refers to pre-set conditional data that can be triggered to start the status verification operation. The meaning of the preset status verification parameter is similar to the status verification parameter in the previous implementation, except that in this implementation, the preset status verification parameter is pre-set and stored, and when the preset status verification trigger condition is triggered, the preset status verification parameter can be obtained. For example, the information in the preset status verification file can be expressed as "starting from LogIndex Y, trigger an ErrorCode incremental MD5 verification every K LogIndexs". In the preset status verification file, the status verification trigger condition is: starting from LogIndexY, trigger it once every K LogIndexs, and the status verification parameters are: ErrorCode, increment, MD5, that is, the status verification is implemented as an incremental verification method for ErrorCode, and the MD5 verification algorithm is used to perform status verification.

[0161] As mentioned above, the state verification method can adopt either a full state calculation method or an incremental state calculation method. Therefore, the current state verification value can be either a full state verification value or an incremental state verification value. When the current state verification value is a full state verification value, that is, when the full state calculation method is adopted, the linuxfork mechanism can be used to perform a full state calculation according to the state verification parameters in a new process to obtain the full state verification value as the current state verification value. When the current state verification value is an incremental state verification value, that is, when the incremental state calculation method is adopted, firstly, the verification increment information and the previous state verification value are obtained according to the state verification parameters; then, the current incremental state verification value is calculated according to the verification increment information and the previous state verification value as the current state verification value.

[0162] In an optional implementation of this embodiment, Figure 2 As shown, the step S102, i.e., the step of synchronously sending the expected check value of the master member to the slave member, includes the following steps S201-S202:

[0163] In step S201, in response to the expected checksum value of the primary member being calculated, a checksum log write file is generated, wherein the checksum log write file includes the expected checksum value of the primary member;

[0164] In step S202, the check log write file is written into a log file, and the check log write file is synchronously written into the log file of the slave member, so that when the check log write file is applied, the expected check value of the master member can be obtained.

[0165] In order to send the expected check value of the master member calculated by the master member to all slave members as a reference value, so that the slave member can compare it with the check value calculated by the member itself, and confirm the status check result of each slave member, in this implementation method, the completion of the calculation of the expected check value of the master member is used as the time point for synchronization of the expected check value of the master member, that is, in response to the expected check value of the master member being calculated, a check log write file containing the expected check value of the master member is generated; then the check log write file is written into a log file, and the check log write file is synchronously written to the log file of the slave member, so that when the check log write file is applied by the slave member, the expected check value of the master member can be obtained.

[0166] As mentioned above, in order to achieve effective and accurate data synchronization, when generating the initial log write file, a log index corresponding to a certain state verification operation is also generated for the generated initial log write file. In this implementation method, in order to achieve effective and accurate data synchronization, the primary member expected verification value contained in the verification log write file is also configured with a log index corresponding to the state verification operation, wherein the log index of the primary member expected verification value can be the same as or corresponding to the log index of the initial log write file, so that it can be identified as being associated with the same state verification operation. Subsequently, after the slave member completes the calculation of the current member calculated verification value corresponding to the above-mentioned state verification operation, the current member calculated verification value associated with the same state verification operation is compared with the primary member expected verification value to obtain the state verification result.

[0167] Figure 3 A flow chart showing a state verification method according to another embodiment of the present disclosure is shown, which can be applied to a slave member side. Figure 3 As shown, the state verification method includes the following steps S301-S303:

[0168] In step S301, a state check parameter is obtained, and a current state check value is calculated according to the state check parameter as a current member check value;

[0169] In step S302, the expected check value of the primary member is obtained, and the status check result is determined according to the calculated check value of the current member and the expected check value of the primary member;

[0170] In step S303, the status verification result is returned to the primary member.

[0171] As mentioned above, in a distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to synchronize states. In theory, a log file with consistent content negotiated between members ensures that members will obtain the same state after writing logs to the file according to a unified and deterministic logic, that is, the state machines between members are consistent. However, in engineering practice, due to the influence of factors such as program versions, operating environments, and software defects between members, the states generated after members apply the same log to write files may not be consistent, which may cause serious problems such as data errors. Therefore, it is necessary to verify the consistency of states between members, and detect state inconsistencies in a timely manner during testing or even production to prevent the problem from further expanding. However, the solutions used in the prior art have the disadvantages of consuming resources, poor timeliness, difficulty in ensuring correctness, and difficulty in tracing history.

[0172] In view of the above defects, in this embodiment, a state verification method is proposed, which obtains state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. This technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0173] In an optional implementation of this embodiment, the step of obtaining the status verification parameter in step S201 may be implemented as follows:

[0174] Acquire an initial log write file for synchronous writing, wherein the initial log write file includes a status verification parameter;

[0175] In response to the initial log write file being applied, the status check parameter is obtained.

[0176] In an optional implementation of this embodiment, the initial log write file containing the state verification parameters is generated by the primary member and written into its log file, and then synchronously written into the log file of the secondary member, and after the initial log write file is applied, the required state verification parameters can be obtained.

[0177] In an optional implementation of this embodiment, in order to achieve effective and accurate data synchronization, the initial log write file is also configured with a corresponding log index (LogIndex) to uniquely identify the initial log write file, so that the master member and the slave member can identify the applied log write file and the application result according to the log index of the initial log write file, and then perform targeted calculations, comparisons and processing. Assuming that the log index of an initial log write file is X, then when each member applies the initial log write file and obtains the state verification parameter, the current state verification value calculated according to the state verification parameter can be marked as the state verification value corresponding to the log index X and recorded, so as to perform subsequent consistency comparisons of the state verification values ​​corresponding to the log index X by each member.

[0178] In another optional implementation of this embodiment, the step of obtaining the status verification parameter in step S201 may be implemented as follows:

[0179] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0180] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0181] In this implementation, the state verification method supports a mode of triggering the state verification periodically according to a log index or other guide information. Specifically, firstly, a preset state verification file including a preset state verification trigger condition and a preset state verification parameter is determined; then, when it is detected that the preset state verification trigger condition is triggered, the state verification operation is started to obtain the preset state verification parameter.

[0182] Similar to the implementation method described above, the state verification method can adopt either a full state calculation method or an incremental state calculation method. Therefore, the current state verification value can be either a full state verification value or an incremental state verification value. When the current state verification value is a full state verification value, that is, when the full state calculation method is adopted, the linux fork mechanism can be used to perform a full state calculation according to the state verification parameters in a new process to obtain a full state verification value as the current state verification value. When the current state verification value is an incremental state verification value, that is, when the incremental state calculation method is adopted, firstly, the verification increment information and the previous state verification value are obtained according to the state verification parameters; then, the current incremental state verification value is calculated according to the verification increment information and the previous state verification value as the current state verification value.

[0183] In an optional implementation of this embodiment, the step of obtaining the expected checksum value of the primary member in step S202 may be implemented as follows:

[0184] Obtaining a synchronously written verification log write file, wherein the verification log write file includes the expected verification value of the primary member;

[0185] In response to the checksum log write file being applied, obtaining the primary member expected checksum value.

[0186] Among them, the verification log write file is generated by the primary member after calculating the expected verification value of the primary member. After the primary member writes the verification log write file into the log file, it is synchronized to the log file of the slave member. Subsequently, when the verification log write file is applied, the expected verification value of the primary member can be obtained to compare with the calculated verification value of each slave member, so as to confirm the status verification result of each slave member.

[0187] As mentioned above, in order to achieve effective and accurate data synchronization, the initial log write file is configured with a log index. In this implementation, in order to achieve effective and accurate data synchronization, the verification log write file is also configured with the same or corresponding log index so that it can be identified as being associated with the same status verification operation.

[0188] It should be noted that Figure 3 Some of the technical terms or technical features involved in its related implementation methods are the same or similar to the technical terms or technical features mentioned in the implementation methods shown above. The corresponding explanations and descriptions can refer to the descriptions of the implementation methods shown above, and the present invention will not be repeated here.

[0189] Figure 4 A flow chart showing a state verification method according to another embodiment of the present disclosure is shown, which can be applied to a system consisting of a master member and a slave member. Figure 4 As shown, the state verification method includes the following steps S401-S403:

[0190] In step S401, the master member and the slave member obtain state verification parameters, and calculate the current state verification value according to the state verification parameters, which are used as the master member expected verification value and the slave member calculated verification value respectively;

[0191] In step S402, the master member synchronously sends the master member expected check value to the slave member, and the slave member determines the slave member status check result according to the master member expected check value and the slave member calculated check value;

[0192] In step S403, the slave member returns the status verification result to the master member.

[0193] In an optional implementation of this embodiment, the step of the master member and the slave member acquiring the status verification parameter in step S401 is implemented as follows:

[0194] In response to receiving the status verification request, the primary member generates an initial log write file, wherein the initial log write file includes a status verification parameter;

[0195] The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member;

[0196] The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied.

[0197] In another optional implementation of this embodiment, the step of the master member and the slave member acquiring the status verification parameter in step S401 is implemented as follows:

[0198] The master member and the slave member determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0199] In response to the preset status check triggering condition being triggered, the master member and the slave member obtain the preset status check parameters.

[0200] In an optional implementation of this embodiment, the current state check value is a full state check value or an incremental state check value.

[0201] In an optional implementation of this embodiment, when the current state check value is an incremental state check value, the step of calculating the current state check value according to the state check parameter in step S401 is implemented as follows:

[0202] Get the verification increment information and the previous state verification value;

[0203] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0204] In an optional implementation of this embodiment, the step of the master member synchronously sending the master member expected check value to the slave member in step S402 is implemented as follows:

[0205] In response to the primary member expected checksum being calculated, the primary member generates a checksum log write file, wherein the checksum log write file includes the primary member expected checksum;

[0206] The primary member writes the verification log write file into a log file, and synchronously writes the verification log write file into the log file of the secondary member;

[0207] In response to the checksum log write file being applied, the slave member obtains the master member's expected checksum value.

[0208] It should be noted that Figure 4 Some of the technical terms or technical features involved in its related implementation methods are the same or similar to the technical terms or technical features mentioned in the implementation methods shown above. The corresponding explanations and descriptions can refer to the descriptions of the implementation methods shown above, and the present invention will not be repeated here.

[0209] Figure 5 The overall flow chart of the state verification method according to an embodiment of the present disclosure is shown as follows: Figure 5 As shown, after receiving the status verification request, the primary member generates an initial log write file including the status verification parameters, and then synchronously writes the initial log write file to its log file and the log file of the slave member. Once the initial log write file is subsequently applied, both the primary member and the slave member can obtain the status verification parameters; the primary member calculates the current status verification value according to the status verification parameters as the expected verification value of the primary member, and synchronously sends the calculated expected verification value of the primary member to the slave member; the slave member calculates the current status verification value according to the obtained status verification parameters as the verification value of the member, and compares it with the received expected verification value of the primary member to determine the status verification result, and finally returns the status verification result to the primary member.

[0210] The following are embodiments of the apparatus of the present disclosure, which can be used to execute embodiments of the method of the present disclosure.

[0211] Figure 6 The structural block diagram of the state verification device according to one embodiment of the present disclosure is shown, which can be implemented as a master member. The device can be implemented as part or all of the electronic device through software, hardware or a combination of both. Figure 6 As shown, the state checking device comprises:

[0212] The first acquisition module 601 is configured to acquire a state check parameter, and calculate a current state check value according to the state check parameter as an expected check value of the primary member;

[0213] A first sending module 602 is configured to synchronously send the expected check value of the master member to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the member calculated check value calculated by the slave member;

[0214] The receiving module 603 is configured to receive the status verification result returned from the member.

[0215] As mentioned above, in a distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to synchronize states. In theory, a log file with consistent content negotiated between members ensures that members will obtain the same state after writing logs to the file according to a unified and deterministic logic, that is, the state machines between members are consistent. However, in engineering practice, due to the influence of factors such as program versions, operating environments, and software defects between members, the states generated after members apply the same log to write files may not be consistent, which may cause serious problems such as data errors. Therefore, it is necessary to verify the consistency of states between members, and detect state inconsistencies in a timely manner during testing or even production to prevent the problem from further expanding. However, the solutions used in the prior art have the disadvantages of consuming resources, poor timeliness, difficulty in ensuring correctness, and difficulty in tracing history.

[0216] Taking the above defects into consideration, in this embodiment, a state verification device is proposed, which obtains state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. This technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0217] In an optional implementation of this embodiment, the leader refers to a dominant member in a distributed system, which performs information transmission and operation coordination with multiple followers in the distributed system to ensure the consistency of cluster data.

[0218] In an optional implementation of this embodiment, the state verification parameter refers to the parameter required for calculating the state verification value, which will be subsequently synchronized to all members. The state verification parameter may include one or more of the following parameters: the state summary calculation algorithm used, for example, whether to use the MD5 algorithm (Message-Digest Algorithm5) or the CRC (Cyclic Redundancy Check) algorithm; whether to adopt the full state calculation method or the incremental state calculation method; when the incremental state calculation method is adopted, the incremental information used for the incremental state calculation and the previous state summary value, etc., wherein the incremental information includes the error code (ErrorCode) when applying the log entry file (LogEntry) within a preset historical time, the code path marking information when applying the log entry file within a preset historical time, etc.

[0219] In an optional implementation of the present embodiment, the expected check value of the master member is the current state check value that needs to be checked and is calculated by the master member according to the obtained state check parameters. This check value is used as the expected check value of the master member and will be subsequently synchronized to the slave members. Each slave member calculates the calculated check value of the member according to the state check parameters obtained synchronously, and then compares the synchronized expected check value of the master member with the calculated check value of the member calculated by each slave member to obtain the verification result of this state verification. If the expected check value of the master member is the same as the calculated check value of the member calculated by each slave member, the verification is deemed to be successful and the verification is terminated. If they are different, the alarm process can be initiated and the continued execution of the member can be stopped.

[0220] In an optional implementation of this embodiment, the status check result may be embodied in the form of text, message, etc., or in the form of sound, audio, video, etc.

[0221] In an optional implementation of this embodiment, the part of acquiring the status check parameter in the first acquisition module 601 may be configured as follows:

[0222] In response to receiving the status verification request, generating an initial log write file, wherein the initial log write file includes a status verification parameter;

[0223] Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member;

[0224] In response to the initial log write file being applied, the status check parameter is obtained.

[0225] In this implementation, the state verification device supports a user-initiated triggering mode, that is, the state verification of the distributed system is performed according to the user's active triggering, and the corresponding state verification parameters are obtained. Specifically, in response to receiving a state verification request, such as one sent by a user, an initial log write file is generated, wherein the initial log write file contains the state verification parameters required for this state verification, and the state verification parameters may be carried by the state verification request or generated according to the state verification request; then the initial log write file is written to the log file of the primary member, and the initial log write file is synchronously written to the log file of the secondary member; when the initial log write file is applied, the state verification parameters can be obtained.

[0226] In an optional implementation of this embodiment, the status verification request may be a status verification request initiated by a user or a status verification request automatically initiated by a system.

[0227] In an optional implementation of the present embodiment, in order to achieve effective and accurate data synchronization, when generating an initial log write file, a corresponding log index (LogIndex) is also generated for the generated initial log write file to uniquely identify the initial log write file, so that the master member and the slave member can identify the applied log write file and the application results according to the log index of the initial log write file, and then perform targeted calculations, comparisons and processing.

[0228] In another optional implementation of this embodiment, the part of acquiring the status check parameter in the first acquisition module 601 may also be configured as follows:

[0229] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0230] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0231] In this implementation, the status verification device supports a mode of periodically triggering status verification according to a log index or other guide information. Specifically, first determine a preset status verification file including a preset status verification trigger condition and a preset status verification parameter; then, when it is detected that the preset status verification trigger condition is triggered, start the status verification operation and obtain the preset status verification parameter. The preset status verification trigger condition refers to pre-set condition data that can be triggered to start the status verification operation. The meaning of the preset status verification parameter is similar to the status verification parameter in the previous implementation, except that in this implementation, the preset status verification parameter is pre-set and stored, and when the preset status verification trigger condition is triggered, the preset status verification parameter can be obtained. For example, the information in the preset status verification file can be expressed as "starting from LogIndex Y, trigger an ErrorCode incremental MD5 verification every K LogIndexs". In the preset status verification file, the status verification trigger condition is: starting from LogIndexY, trigger it once every K LogIndexs, and the status verification parameters are: ErrorCode, increment, MD5, that is, the status verification is implemented as an incremental verification method for ErrorCode, and the MD5 verification algorithm is used to perform status verification.

[0232] As mentioned above, the state verification device can adopt either a full state calculation method or an incremental state calculation method. Therefore, the current state verification value can be either a full state verification value or an incremental state verification value. When the current state verification value is a full state verification value, that is, when the full state calculation method is adopted, the linuxfork mechanism can be used to perform a full state calculation according to the state verification parameters in a new process to obtain the full state verification value as the current state verification value. When the current state verification value is an incremental state verification value, that is, when the incremental state calculation method is adopted, firstly, the verification increment information and the previous state verification value are obtained according to the state verification parameters; then, the current incremental state verification value is calculated according to the verification increment information and the previous state verification value as the current state verification value.

[0233] In an optional implementation of this embodiment, Figure 7 As shown, the first sending module 602 includes:

[0234] A generation submodule 701 is configured to generate a verification log write file in response to the expected verification value of the primary member being calculated, wherein the verification log write file includes the expected verification value of the primary member;

[0235] The sending submodule 702 is configured to write the verification log write file into a log file, and synchronously write the verification log write file into the log file of the slave member, so that when the verification log write file is applied, the expected verification value of the master member can be obtained.

[0236] In order to send the expected check value of the master member calculated by the master member to all slave members as a reference value, so that the slave member can compare it with the check value calculated by the member itself, and confirm the status check result of each slave member, in this implementation method, the completion of the calculation of the expected check value of the master member is used as the time point for synchronization of the expected check value of the master member, that is, in response to the expected check value of the master member being calculated, a check log write file containing the expected check value of the master member is generated; then the check log write file is written into a log file, and the check log write file is synchronously written to the log file of the slave member, so that when the check log write file is applied by the slave member, the expected check value of the master member can be obtained.

[0237] As mentioned above, in order to achieve effective and accurate data synchronization, when generating the initial log write file, a log index corresponding to a certain state verification operation is also generated for the generated initial log write file. In this implementation method, in order to achieve effective and accurate data synchronization, the primary member expected verification value contained in the verification log write file is also configured with a log index corresponding to the state verification operation, wherein the log index of the primary member expected verification value can be the same as or corresponding to the log index of the initial log write file, so that it can be identified as being associated with the same state verification operation. Subsequently, after the slave member completes the calculation of the current member calculated verification value corresponding to the above-mentioned state verification operation, the current member calculated verification value associated with the same state verification operation is compared with the primary member expected verification value to obtain the state verification result.

[0238] Figure 8 The structural block diagram of the state checking device according to another embodiment of the present disclosure is shown, which can be implemented as a slave member. The device can be implemented as part or all of the electronic device through software, hardware or a combination of both. Figure 8 As shown, the state checking device comprises:

[0239] The second acquisition module 801 is configured to acquire a state check parameter, and calculate a current state check value according to the state check parameter as a current member check value;

[0240] The determination module 802 is configured to obtain the expected check value of the primary member, and determine the status check result according to the calculated check value of the current member and the expected check value of the primary member;

[0241] The return module 803 is configured to return the status verification result to the primary member.

[0242] As mentioned above, in a distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to synchronize states. In theory, a log file with consistent content negotiated between members ensures that members will obtain the same state after writing logs to the file according to a unified and deterministic logic, that is, the state machines between members are consistent. However, in engineering practice, due to the influence of factors such as program versions, operating environments, and software defects between members, the states generated after members apply the same log to write files may not be consistent, which may cause serious problems such as data errors. Therefore, it is necessary to verify the consistency of states between members, and detect state inconsistencies in a timely manner during testing or even production to prevent the problem from further expanding. However, the solutions used in the prior art have the disadvantages of consuming resources, poor timeliness, difficulty in ensuring correctness, and difficulty in tracing history.

[0243] Taking the above defects into consideration, in this embodiment, a state verification device is proposed, which obtains state verification parameters by triggering the state verification operation, and each member calculates the corresponding state verification value according to the synchronized state verification parameters, and determines the state verification result by comparing the state verification values. This technical solution can realize the state verification without the help of other tools, does not need to consume too many system resources, can ensure the timeliness and correctness of the verification operation, avoids the expansion of faults and thus causes unnecessary losses, and can also conveniently and reliably record historical verification data to facilitate information tracing.

[0244] In an optional implementation of this embodiment, the part of acquiring the status check parameter in the second acquisition module 801 may be configured as follows:

[0245] Acquire an initial log write file for synchronous writing, wherein the initial log write file includes a status verification parameter;

[0246] In response to the initial log write file being applied, the status check parameter is obtained.

[0247] In an optional implementation of this embodiment, the initial log write file containing the state verification parameters is generated by the primary member and written into its log file, and then synchronously written into the log file of the secondary member, and after the initial log write file is applied, the required state verification parameters can be obtained.

[0248] In an optional implementation of this embodiment, in order to achieve effective and accurate data synchronization, the initial log write file is also configured with a corresponding log index (LogIndex) to uniquely identify the initial log write file, so that the master member and the slave member can identify the applied log write file and the application result according to the log index of the initial log write file, and then perform targeted calculations, comparisons and processing. Assuming that the log index of an initial log write file is X, then when each member applies the initial log write file and obtains the state verification parameter, the current state verification value calculated according to the state verification parameter can be marked as the state verification value corresponding to the log index X and recorded, so as to perform subsequent consistency comparisons of the state verification values ​​corresponding to the log index X by each member.

[0249] In another optional implementation of this embodiment, the part of acquiring the status check parameter in the second acquisition module 801 may be configured as follows:

[0250] Determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0251] In response to the preset state check triggering condition being triggered, the preset state check parameter is acquired.

[0252] In this implementation, the state verification device supports a mode of triggering the state verification according to the log index or other guidance information. Specifically, firstly, a preset state verification file including a preset state verification trigger condition and a preset state verification parameter is determined; then, when it is detected that the preset state verification trigger condition is triggered, the state verification operation is started to obtain the preset state verification parameter.

[0253] Similar to the implementation described above, the state verification device can adopt either a full state calculation method or an incremental state calculation method. Therefore, the current state verification value can be either a full state verification value or an incremental state verification value. When the current state verification value is a full state verification value, that is, when the full state calculation method is adopted, the Linux fork mechanism can be used to perform a full state calculation according to the state verification parameters in a new process to obtain a full state verification value as the current state verification value. When the current state verification value is an incremental state verification value, that is, when the incremental state calculation method is adopted, firstly, the verification increment information and the previous state verification value are obtained according to the state verification parameters; then, the current incremental state verification value is calculated according to the verification increment information and the previous state verification value as the current state verification value.

[0254] In an optional implementation of this embodiment, the part of obtaining the expected checksum value of the primary member in the determination module 802 may be configured as follows:

[0255] Obtaining a synchronously written verification log write file, wherein the verification log write file includes the expected verification value of the primary member;

[0256] In response to the checksum log write file being applied, obtaining the primary member expected checksum value.

[0257] Among them, the verification log write file is generated by the primary member after calculating the expected verification value of the primary member. After the primary member writes the verification log write file into the log file, it is synchronized to the log file of the slave member. Subsequently, when the verification log write file is applied, the expected verification value of the primary member can be obtained to compare with the calculated verification value of each slave member, so as to confirm the status verification result of each slave member.

[0258] As mentioned above, in order to achieve effective and accurate data synchronization, the initial log write file is configured with a log index. In this implementation, in order to achieve effective and accurate data synchronization, the verification log write file is also configured with the same or corresponding log index so that it can be identified as being associated with the same status verification operation.

[0259] It should be noted that Figure 8 Some of the technical terms or technical features involved in its related implementation methods are the same or similar to the technical terms or technical features mentioned in the implementation methods shown above. The corresponding explanations and descriptions can refer to the descriptions of the implementation methods shown above, and the present invention will not be repeated here.

[0260] Fig. 9 The structural block diagram of the state verification device according to another embodiment of the present disclosure is shown, which can be implemented as a system consisting of a master member and a slave member. The device can be implemented as part or all of an electronic device through software, hardware or a combination of both. Fig. 9 As shown, the state checking device comprises:

[0261] The third acquisition module 901 is configured to acquire state verification parameters for the master member and the slave member, and calculate the current state verification value according to the state verification parameter, which are used as the master member expected verification value and the slave member calculated verification value respectively;

[0262] The second sending module 902 is configured to send the master member expected check value to the slave member synchronously, and the slave member determines the slave member status check result according to the master member expected check value and the slave member calculated check value;

[0263] The return module 903 is configured to return the status verification result from the member to the master member.

[0264] In an optional implementation of this embodiment, the part of the master member and the slave member acquiring the status verification parameter in the third acquisition module 901 is configured as follows:

[0265] In response to receiving the status verification request, the primary member generates an initial log write file, wherein the initial log write file includes a status verification parameter;

[0266] The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member;

[0267] The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied.

[0268] In another optional implementation of this embodiment, the part of the master member and the slave member acquiring the status verification parameter in the third acquisition module 901 is configured as follows:

[0269] The master member and the slave member determine a preset state verification file, wherein the preset state verification file includes a preset state verification trigger condition and a preset state verification parameter;

[0270] In response to the preset status check triggering condition being triggered, the master member and the slave member obtain the preset status check parameters.

[0271] In an optional implementation of this embodiment, the current state check value is a full state check value or an incremental state check value.

[0272] In an optional implementation of this embodiment, when the current state check value is an incremental state check value, the part of the third acquisition module 901 that calculates the current state check value according to the state check parameter is configured as follows:

[0273] Get the verification increment information and the previous state verification value;

[0274] The current incremental state check value is calculated based on the check increment information and the previous state check value.

[0275] In an optional implementation of this embodiment, the part of the second sending module 902 in which the master member synchronously sends the master member expected check value to the slave member is configured as follows:

[0276] In response to the primary member expected checksum being calculated, the primary member generates a checksum log write file, wherein the checksum log write file includes the primary member expected checksum;

[0277] The primary member writes the verification log write file into a log file, and synchronously writes the verification log write file into the log file of the secondary member;

[0278] In response to the checksum log write file being applied, the slave member obtains the master member's expected checksum value.

[0279] It should be noted that Fig. 9 Some of the technical terms or technical features involved in its related implementation methods are the same or similar to the technical terms or technical features mentioned in the implementation methods shown above. The corresponding explanations and descriptions can refer to the descriptions of the implementation methods shown above, and the present invention will not be repeated here.

[0280] The present disclosure also discloses an electronic device, Fig.10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. Fig.10 As shown, the electronic device 1000 includes a memory 1001 and a processor 1002; wherein,

[0281] The memory 1001 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 1002 to implement the above method steps.

[0282] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing the status verification method according to an embodiment of the present disclosure.

[0283] like Fig.11 As shown, the computer system 1100 includes a processing unit 1101, which can perform various processes in the above-mentioned embodiments according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage part 1108 into a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the system 1100 are also stored. The processing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0284] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed, so that a computer program read therefrom is installed into the storage section 1108 as needed. Among them, the processing unit 1901 can be implemented as a processing unit such as a CPU, a GPU, an FPAG, an NPU, etc.

[0285] In particular, according to an embodiment of the present disclosure, the method described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a readable medium thereof, and the computer program includes a program code for executing the above-mentioned state verification method. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 1109, and / or installed from the removable medium 1111.

[0286] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the road map or block diagram can represent a part of a module, program segment or code, and the part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a different order from the order marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0287] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units or modules described may also be set in a processor, and the names of these units or modules do not constitute limitations on the units or modules themselves in some cases.

[0288] As another aspect, the present disclosure further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the device described in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into the device. The computer-readable storage medium stores one or more programs, and the programs are used by one or more processors to execute the method described in the present disclosure.

[0289] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.

Claims

1. A state verification method, characterized in that: include: In response to receiving the status verification request, generating an initial log write file, and generating a corresponding log index for the initial log write file, wherein the initial log write file includes a status verification parameter; Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member; In response to the initial log write file being applied, obtaining the status verification parameter; Calculate the current state check value according to the state check parameter as the expected check value of the primary member; Synchronously sending the expected check value of the master member to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the calculated check value of the member calculated by the slave member; the synchronous sending of the expected check value of the master member to the slave member is implemented as follows: in response to the expected check value of the master member being calculated, generating a check log write file, wherein the check log write file includes the expected check value of the master member, and the expected check value of the master member is configured with the same log index as the initial log write file; writing the check log write file into a log file, and synchronously writing the check log write file to the log file of the slave member, so that when the check log write file is applied, the expected check value of the master member can be obtained; Receiving the status verification result returned from the member; The master member is a dominant member dynamically elected in the distributed system, and is used to perform information transmission and operation coordination with multiple slave members in the distributed system.

2. The state verification method according to claim 1, characterized in that: The current state check value is a full state check value or an incremental state check value.

3. The state verification method according to claim 2, characterized in that: When the current state check value is an incremental state check value, the current state check value is calculated according to the state check parameter and is implemented as follows: Get the verification increment information and the previous state verification value; The current incremental state check value is calculated based on the check increment information and the previous state check value.

4. A state verification method, characterized in that: include: Acquire an initial log write file for synchronous writing, wherein the initial log write file includes a status verification parameter; In response to the initial log write file being applied, obtaining the status verification parameter; Calculate the current state check value according to the state check parameter as the member check value; Obtaining the expected check value of the primary member, and determining the status check result according to the check value calculated by the current member and the expected check value of the primary member; the obtaining of the expected check value of the primary member is implemented as follows: obtaining a synchronously written check log write file, wherein the check log write file includes the expected check value of the primary member, and the expected check value of the primary member is configured with the same log index as the initial log write file; in response to the check log write file being applied, obtaining the expected check value of the primary member; Return the status verification result to the primary member; The member is a slave member in the distributed system.

5. The state verification method according to claim 4, characterized in that: The current state check value is a full state check value or an incremental state check value.

6. The state verification method according to claim 5, characterized in that: When the current state check value is an incremental state check value, the current state check value is calculated according to the state check parameter and is implemented as follows: Get the verification increment information and the previous state verification value; The current incremental state check value is calculated based on the check increment information and the previous state check value.

7. A state verification method, characterized in that: include: In response to receiving the status verification request, the primary member generates an initial log write file and generates a corresponding log index for the initial log write file, wherein the initial log write file includes a status verification parameter; The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member; The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied; The current state check value is calculated according to the state check parameter and used as the expected check value of the primary member and the calculated check value of the secondary member respectively; The master member synchronously sends the master member expected check value to the slave member, and the slave member determines the slave member status check result according to the master member expected check value and the check value calculated by the slave member; the master member synchronously sends the master member expected check value to the slave member, which is implemented as follows: in response to the master member expected check value being calculated, the master member generates a check log write file, wherein the check log write file includes the master member expected check value, and the master member expected check value is configured with the same log index as the initial log write file; the master member writes the check log write file into a log file, and synchronously writes the check log write file into the log file of the slave member; in response to the check log write file being applied, the slave member obtains the master member expected check value; The slave member returns the status verification result to the master member; The master member is a dominant member dynamically elected in the distributed system, and is used to perform information transmission and operation coordination with multiple slave members in the distributed system.

8. The state verification method according to claim 7, characterized in that: The current state check value is a full state check value or an incremental state check value.

9. The state verification method according to claim 8, characterized in that: When the current state check value is an incremental state check value, the current state check value is calculated according to the state check parameter and is implemented as follows: Get the verification increment information and the previous state verification value; The current incremental state check value is calculated based on the check increment information and the previous state check value.

10. A state verification device, characterized in that: include: A first acquisition module is configured to generate an initial log write file in response to receiving a status verification request, and generate a corresponding log index for the initial log write file, wherein the initial log write file includes a status verification parameter; Writing the initial log write file into a log file, and synchronously writing the initial log write file into the log file of the slave member; In response to the initial log write file being applied, the state check parameter is obtained; a current state check value is calculated according to the state check parameter as an expected check value of the primary member; A first sending module is configured to synchronously send the expected check value of the master member to the slave member, so that the slave member determines the status check result according to the expected check value of the master member and the calculated check value of the member calculated by the slave member; the synchronous sending of the expected check value of the master member to the slave member is implemented as follows: in response to the expected check value of the master member being calculated, generating a check log write file, wherein the check log write file includes the expected check value of the master member, and the expected check value of the master member is configured with the same log index as the initial log write file; writing the check log write file into a log file, and synchronously writing the check log write file into the log file of the slave member, so that when the check log write file is applied, the expected check value of the master member can be obtained; A receiving module, configured to receive the status verification result returned from the member; The master member is a dominant member dynamically elected in the distributed system, and is used to perform information transmission and operation coordination with multiple slave members in the distributed system.

11. A state verification device, characterized in that: include: A second acquisition module is configured to acquire an initial log write file of synchronous writing, wherein the initial log write file includes a state verification parameter; In response to the initial log write file being applied, the state check parameter is obtained; a current state check value is calculated according to the state check parameter as a check value of the current member; The determination module is configured to obtain the expected check value of the primary member, and determine the status check result according to the check value calculated by the current member and the expected check value of the primary member; the obtaining of the expected check value of the primary member is implemented as follows: obtaining a synchronously written check log write file, wherein the check log write file includes the expected check value of the primary member, and the expected check value of the primary member is configured with the same log index as the initial log write file; in response to the check log write file being applied, obtaining the expected check value of the primary member; A return module is configured to return the status verification result to the primary member; The member is a slave member in the distributed system.

12. A state verification device, characterized in that: include: A third acquisition module is configured to generate an initial log write file and a corresponding log index for the initial log write file in response to receiving the status verification request, wherein the initial log write file includes a status verification parameter; The primary member writes the initial log write file into a log file, and synchronously writes the initial log write file into the log file of the secondary member; The primary member and the secondary member obtain the status verification parameter in response to the initial log write file being applied; The current state check value is calculated according to the state check parameter and used as the expected check value of the primary member and the calculated check value of the secondary member respectively; The second sending module is configured to cause the master member to synchronously send the master member expected check value to the slave member, and the slave member determines the slave member status check result according to the master member expected check value and the check value calculated by the slave member; the master member synchronously sends the master member expected check value to the slave member, which is implemented as follows: in response to the master member expected check value being calculated, the master member generates a check log write file, wherein the check log write file contains the master member expected check value, and the master member expected check value is configured with the same log index as the initial log write file; the master member writes the check log write file into a log file, and synchronously writes the check log write file into the log file of the slave member; in response to the check log write file being applied, the slave member obtains the master member expected check value; A return module, configured to return the status verification result from the member to the master member; The master member is a dominant member dynamically elected in the distributed system, and is used to perform information transmission and operation coordination with multiple slave members in the distributed system.

13. An electronic device, characterized in that: The method comprises a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps described in any one of claims 1-9.

14. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the method steps described in any one of claims 1 to 9 are implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method steps described in any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Method for judging the master / slave computer consistent via static data or dynamic data

    CN101193001A