[go: up one dir, main page]

CN112988689B - State verification method, device, electronic equipment and computer readable storage medium - Google Patents

State verification method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN112988689B
CN112988689B CN201911312978.0A CN201911312978A CN112988689B CN 112988689 B CN112988689 B CN 112988689B CN 201911312978 A CN201911312978 A CN 201911312978A CN 112988689 B CN112988689 B CN 112988689B
Authority
CN
China
Prior art keywords
state
check
verification
file
log
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911312978.0A
Other languages
Chinese (zh)
Other versions
CN112988689A (en
Inventor
黄硕
姚文辉
黄东平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201911312978.0A priority Critical patent/CN112988689B/en
Publication of CN112988689A publication Critical patent/CN112988689A/en
Application granted granted Critical
Publication of CN112988689B publication Critical patent/CN112988689B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure discloses a state verification method, a device, an electronic device and a computer readable storage medium, wherein the state verification method comprises the following steps: acquiring a state check parameter, and calculating a current state check value according to the state check parameter to serve as a primary member expected check value; synchronously transmitting the expected check value of the master member to a slave member, so that the slave member determines a state check result according to the expected check value of the master member and the calculated check value of the slave member; and receiving the status check result returned by the member. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.

Description

State verification method, device, electronic equipment and computer readable storage medium
Technical Field
The disclosure relates to the technical field of distributed systems, and in particular relates to a state verification method, a state verification device, electronic equipment and a computer readable storage medium.
Background
In a distributed system, in order to realize high availability and strong consistency of roles, a state machine replication method is often used to realize state synchronization, the method is to form a group of multiple instances of a system role, dynamically elect a master member (Leader) and multiple slave members (Follower), the master member records modification of a key memory state which is a self state machine as a Log writing file (LogEntry) to copy to all members including the master member, and the master member permanently writes the modification of the key memory state into respective Log files (Log), and after the members agree on the Log contents through a distributed consistency algorithm, the modification of the Log writing file is applied to the self memory state one by one according to a Log index (LogIndex). In theory, the log file with consistent content negotiated between the members ensures that the members can obtain the same state after writing the file according to the unified and deterministic logic application log, namely, the state machine consistency between the members. However, in engineering practice, due to the influence of factors such as program version, running environment, software defect and the like among members, states generated after the members apply the same log to write the file may not be consistent, and thus serious problems such as data errors may be caused. Therefore, it is necessary to check the consistency of states among members, and timely detect the problem of inconsistent states during the test and even the production process, so as to prevent further expansion of the problem.
The solution adopted in the prior art is as follows: each member is enabled to generate a full state file at regular intervals, then the file is loaded by using a tool one by one, all logs after the file are applied to a certain same log index, a state abstract value at the moment is generated, whether the abstract values obtained by the members are the same or not is compared, and if the abstract values are different, the problem of inconsistent state is indicated. This solution has several drawbacks: 1. resource consumption: additional tools and system resources are required to transfer, load the full state file and generate the digest value; 2. the timeliness is poor: the time consumption for calculating the abstract of the full state is long, so that the time consumption for finding the consistency problem is long, and the problem is enlarged by a larger time window; 3. the correctness is difficult to guarantee: the log positions of the full state files generated among the members are not necessarily the same, the state of the same log positions among the members can be obtained only by using a part of log writing files after the full state files are applied by a tool, but the logic used by applying the log writing files is not necessarily the same as the logic actually operated by the members at the moment; 4. history difficult to trace: the history of the state check cannot be conveniently and reliably saved for subsequent analysis.
Disclosure of Invention
The embodiment of the disclosure provides a state verification method, a state verification device, electronic equipment and a computer readable storage medium.
In a first aspect, a state verification method is provided in an embodiment of the present disclosure.
Specifically, the state verification method includes:
acquiring a state check parameter, and calculating a current state check value according to the state check parameter to serve as a primary member expected check value;
synchronously transmitting the expected check value of the master member to a slave member, so that the slave member determines a state check result according to the expected check value of the master member and the calculated check value of the slave member;
and receiving the status check result returned by the member.
With reference to the first aspect, in a first implementation manner of the first aspect, the acquiring a status check parameter is implemented as:
generating an initial log writing file in response to receiving a state checking request, wherein the initial log writing file contains state checking parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
and acquiring the state verification parameters in response to the initial log writing file being applied.
With reference to the first aspect and the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the acquiring a status check parameter is implemented as:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
With reference to the first aspect, the first implementation manner of the first aspect, and the second implementation manner of the first aspect, in a third implementation manner of the first aspect, the current state check value is a full state check value or an incremental state check value.
With reference to 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, 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:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, the embodiment of the present invention is implemented to send the expected check value of the master member to the slave member synchronously:
generating a verification log writing file in response to the expected verification value of the main member being calculated, wherein the verification log writing file contains the expected verification value of the main member;
and writing the check log writing file into a log file, and synchronously writing the check log writing file into the log file of the slave member, so that when the check log writing file is applied, the expected check value of the master member can be obtained.
In a second aspect, a state verification method is provided in an embodiment of the present disclosure.
Specifically, the state verification method includes:
acquiring a state check parameter, and calculating a current state check value according to the state check parameter to serve as a member check value;
Acquiring a primary member expected check value, and determining a state check result according to the calculated check value of the member and the primary member expected check value;
And returning a state verification result to the master member.
With reference to the second aspect, in a first implementation manner of the second aspect, the acquiring a status check parameter is implemented as:
acquiring an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
and acquiring the state verification parameters in response to the initial log writing file being applied.
With reference to the second aspect and the first implementation manner of the second aspect, in a second implementation manner of the second aspect, the acquiring a status check parameter is implemented as:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
With reference to the second aspect, the first implementation manner of the second aspect, and the second implementation manner of the second aspect, in a third implementation manner of the second aspect, the current state check value is a full state check value or an incremental state check value.
With reference to 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, when the current state check value is an incremental state check value, the calculating, according to the state check parameter, the current state check value is implemented as follows:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, the obtaining the expected check value of the master member is implemented as:
Acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member;
And acquiring the expected check value of the master member in response to the check log writing file being applied.
In a third aspect, a state verification method is provided in an embodiment of the present disclosure.
Specifically, the state verification method includes:
The method comprises the steps that a master member and a slave member acquire state check parameters, a current state check value is obtained through calculation according to the state check parameters, and the current state check value is respectively used as a master member expected check value and a slave member calculated check value;
The master member synchronously transmits the expected check value of the master member to the slave member, and the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member;
And returning a state check result from the slave member to the master member.
With reference to the third aspect, in a first implementation manner of the third aspect, the obtaining, by the master member and the slave member, a status check parameter is implemented as:
the method comprises the steps that a master member responds to a received state verification request to generate an initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
and the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters.
With reference to the third aspect and the first implementation manner of the third aspect, in a second implementation manner of the third aspect, the obtaining, by the master member and the slave member, a state check parameter is implemented as:
the method comprises the steps that a master member and a slave member determine a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
And responding to the triggering condition of the preset state check, and acquiring the preset state check parameters by the master member and the slave member.
With reference to the third aspect, the first implementation manner of the third aspect, and the second implementation manner of the third aspect, in a third implementation manner of the third aspect, the embodiment of the present invention is that the current state check value is a full state check value or an incremental state check value.
With reference to 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, when the current state check value is an incremental state check value, the calculating, according to the state check parameter, the current state check value is implemented as follows:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, the embodiment of the present invention sends the expected check value of the master member to the slave member synchronously, where the method is implemented as follows:
responding to the calculated expected check value of the master member, and generating a check log writing file by the master member, wherein the check log writing file contains the expected check value of the master member;
the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member;
And the secondary member acquires the expected check value of the primary member in response to the check log writing file being applied.
In a fourth aspect, a state verification device is provided in an embodiment of the present disclosure.
Specifically, the state verification device includes:
The first acquisition module is configured to acquire a state check parameter, calculate a current state check value according to the state check parameter and serve as a primary member expected check value;
The 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 a state check result according to the expected check value of the master member and the calculated check value of the slave member;
And the receiving module is configured to receive the status check result returned by the slave member.
With reference to the fourth aspect, in a first implementation manner of the fourth aspect, the portion of the first obtaining module that obtains the status checking parameter is configured to:
generating an initial log writing file in response to receiving a state checking request, wherein the initial log writing file contains state checking parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
and acquiring the state verification parameters in response to the initial log writing file being applied.
With reference to the fourth aspect and the first implementation manner of the fourth aspect, in a second implementation manner of the fourth aspect, an embodiment of the present invention is a portion of acquiring a state check parameter in the first acquiring module, where the portion is configured to:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
With reference to the fourth aspect, the first implementation manner of the fourth aspect, and the second implementation manner of the fourth aspect, in a third implementation manner of the fourth aspect, the current state check value is a full state check value or an incremental state check value.
With reference to 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, when the current state check value is an incremental state check value, a portion of the first acquisition module that calculates the current state check value according to the state check parameter is configured to:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, the first sending module includes:
A generation sub-module configured to generate a verification log write file in response to the primary member expected verification value being calculated, wherein the verification log write file contains the primary member expected verification value;
and the sending sub-module is configured to write the check log writing file into a log file and synchronously write the check log writing file into the log file of the slave member, so that when the check log writing file is applied, the master member expects a check value to be obtained.
In a fifth aspect, a status checking device is provided in an embodiment of the present disclosure.
Specifically, the state verification device includes:
the second acquisition module is configured to acquire a state check parameter, calculate a current state check value according to the state check parameter and serve as a member check value;
the determining module is configured to acquire an expected check value of the main member and determine a state check result according to the calculated check value of the member and the expected check value of the main member;
and the return module is configured to return a state check result to the master member.
With reference to the fifth aspect, in a first implementation manner of the fifth aspect, the portion of the second obtaining module that obtains the status checking parameter is configured to:
acquiring an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
and acquiring the state verification parameters in response to the initial log writing file being applied.
With reference to the fifth aspect and the first implementation manner of the fifth aspect, in a second implementation manner of the fifth aspect, an embodiment of the present invention obtains a portion of the state check parameter in the second obtaining module, where the portion is configured to:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
With reference to the fifth aspect, the first implementation manner of the fifth aspect, and the second implementation manner of the fifth aspect, in a third implementation manner of the fifth aspect, the current state check value is a full state check value or an incremental state check value.
With reference to 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, when the current state check value is an incremental state check value, the portion of the second obtaining module that is calculated according to the state check parameter and that is configured to:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, the embodiment of the present invention obtains, in the determining module, a portion of the primary member expected check value, where the portion is configured to:
Acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member;
And acquiring the expected check value of the master member in response to the check log writing file being applied.
In a sixth aspect, a status checking device is provided in an embodiment of the present disclosure.
Specifically, the state verification device includes:
The third acquisition module is configured to acquire state check parameters of the master member and the slave member, calculate a current state check value according to the state check parameters, and respectively serve as an expected check value of the master member and a calculated check value of the slave member;
The second sending module is configured to synchronously send the expected check value of the master member to the slave member, and the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member;
and the return module is configured to return a state check result from the member to the master member.
With reference to the sixth aspect, in a first implementation manner of the sixth aspect, the portion of the third obtaining module that obtains the status checking parameter from the master member and the slave member is configured to:
the method comprises the steps that a master member responds to a received state verification request to generate an initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
and the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters.
With reference to the sixth aspect and the first implementation manner of the sixth aspect, in a second implementation manner of the sixth aspect, a portion of the third obtaining module that obtains the status checking parameter from the master member and the slave member is configured to:
the method comprises the steps that a master member and a slave member determine a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
And responding to the triggering condition of the preset state check, and acquiring the preset state check parameters by the master member and the slave member.
With reference to the sixth aspect, the first implementation manner of the sixth aspect, and the second implementation manner of the sixth aspect, in a third implementation manner of the sixth aspect, the current state check value is a full state check value or an incremental state check value.
With reference to 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, when the current state check value is an incremental state check value, a portion of the third obtaining module that calculates the current state check value according to the state check parameter is configured to:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
With reference to 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, an embodiment of the present invention, in the second sending module, the master member sends the master member expected check value to a portion of the slave member synchronously, where the portion is configured to:
responding to the calculated expected check value of the master member, and generating a check log writing file by the master member, wherein the check log writing file contains the expected check value of the master member;
the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member;
And the secondary member acquires the expected check value of the primary member in response to the check log writing file being applied.
In a seventh aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor, where the memory is configured to store one or more computer instructions, where the one or more computer instructions are executed by the processor to implement method steps of the above-described state checking method.
In an eighth aspect, embodiments of the present disclosure provide a computer readable storage medium storing computer instructions for use by a state verification device, including computer instructions for performing the above-described state verification method as referred to by the state verification device.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
According to the technical scheme, the state verification parameters are acquired through triggering the state verification operation, the members calculate corresponding state verification values according to the synchronous state verification parameters, and the state verification results are determined through comparison of the state verification values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 illustrates a flow chart of a status checking method according to an embodiment of the present disclosure;
FIG. 2 shows a flow chart of step S102 of a status checking method according to the embodiment shown in FIG. 1;
FIG. 3 illustrates a flow chart of a status checking method according to another embodiment of the present disclosure;
FIG. 4 illustrates a flow chart of a status checking method according to yet another embodiment of the present disclosure;
FIG. 5 illustrates an overall flow diagram of a status checking method according to an embodiment of the present disclosure;
FIG. 6 shows a block diagram of a state checking device according to an embodiment of the present disclosure;
FIG. 7 shows a block diagram of a first transmission module 602 of a status checking device according to the embodiment shown in FIG. 6;
FIG. 8 shows a block diagram of a state checking device according to another embodiment of the present disclosure;
FIG. 9 shows a block diagram of a state checking device according to yet another embodiment of the present disclosure;
FIG. 10 shows a block diagram of an electronic device according to an embodiment of the present disclosure;
FIG. 11 is a schematic diagram of a computer system suitable for use in implementing a state verification method according to an embodiment of the present disclosure.
Detailed Description
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, portions irrelevant to description of the exemplary embodiments are omitted in the drawings.
In this disclosure, it should be understood that terms such as "comprises" or "comprising," etc., are intended to indicate the presence of features, numbers, steps, acts, components, portions, or combinations thereof disclosed in this specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, acts, components, portions, or combinations thereof are present or added.
In addition, it should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
According to the technical scheme provided by the embodiment of the disclosure, the state check parameters are acquired through triggering the state check operation, the members calculate the corresponding state check values according to the synchronous state check parameters, and the state check results are determined through comparison of the state check values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
Fig. 1 shows a flow chart of a state checking method according to an embodiment of the present disclosure, applicable to a primary member side. As shown in fig. 1, the state verification method includes the following steps S101 to S103:
In step S101, a state check parameter is obtained, and a current state check value is obtained through calculation according to the state check parameter and is used as a primary member expected check value;
In step S102, the expected check value of the master member is synchronously sent to the slave member, so that the slave member determines a status check result according to the expected check value of the master member and the calculated check value of the slave member;
In step S103, the status check result returned from the member is received.
In the distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to achieve state synchronization, and in theory, the log files with consistent contents negotiated between the members ensure that the members can obtain the same state after writing the files according to unified and deterministic logic application logs, namely, the state machines among the members are consistent. However, in engineering practice, due to the influence of factors such as program version, running environment, software defect and the like among members, states generated after the members apply the same log to write the file may not be consistent, and thus serious problems such as data errors may be caused. Therefore, it is necessary to check the consistency of states among members, and timely detect the problem of inconsistent states during the test and even the production process, so as to prevent further expansion of the problem. However, the solutions adopted in the prior art have the defects of resource consumption, poor timeliness, difficult guarantee of correctness and difficult historical traceability.
In view of the above-mentioned drawbacks, in this embodiment, a state verification method is proposed, in which a state verification parameter is obtained by triggering a state verification operation, each member calculates a corresponding state verification value according to the synchronized state verification parameter, and a state verification result is determined by comparing the state verification values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
In an alternative implementation manner of this embodiment, the master member (Leader) refers to a master member in the distributed system, and performs information transmission and operation coordination with multiple slave members (Follow) in the distributed system, so as to ensure consistency of cluster data.
In an alternative implementation of this embodiment, the status checking parameters refer to parameters required for calculating a status checking value, and then synchronizing to all members, where the status checking parameters may include one or more of the following parameters: the state Digest calculation Algorithm used is, for example, either the MD5 Algorithm (Message-Digest algoritm 5) or CRC (Cyclic Redundancy Check) Algorithm; adopting a full state calculation mode or an incremental state calculation mode; when the incremental state calculation mode is adopted, incremental information for incremental state calculation, a previous state abstract value and the like are adopted, wherein the incremental information comprises error codes (error codes) when the log entry file (LogEntry) is applied in a preset historical time, code path marking information when the log entry file is applied in the preset historical time and the like.
In an optional implementation manner of this embodiment, the expected check value of the master member is a current state check value, which is calculated by the master member according to the obtained state check parameter and needs to be checked, and is used as the expected check value of the master member, and then the master member is synchronized to the slave member, each slave member calculates the calculated check value of the master member according to the state check parameter obtained by synchronization, and then compares the obtained expected check value of the master member obtained by synchronization with the calculated check value of the slave member, so as to obtain the check result of the current state check, if the expected check value of the master member is the same as the calculated check value of the slave member, the check is considered to be successful, and if the expected check value of the master member is different, the alarm process can be started and the continuous execution of the slave member is stopped.
In an optional implementation manner of this embodiment, the status check result may be embodied in a text, a message, or the like, or may be embodied in a sound, an audio, a video, or the like.
In an optional implementation manner of this embodiment, the step of acquiring the status check parameter in step S101 may be implemented as follows:
generating an initial log writing file in response to receiving a state checking request, wherein the initial log writing file contains state checking parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
and acquiring the state verification parameters in response to the initial log writing file being applied.
In this implementation manner, the state verification method supports a mode of active triggering by a user, that is, performs state verification of the distributed system according to active triggering by the user, and obtains a corresponding state verification parameter. Specifically, an initial log writing file is generated in response to receiving a state check request sent by a user, wherein the initial log writing file contains state check parameters required by the state check, and the state check parameters can be carried by the state check request or generated according to the state check request; then writing the initial log writing file into the log file of the master member, and synchronously writing the initial log writing file into the log file of the slave member; and when the initial log writing file is applied, acquiring the state verification parameters.
In an alternative implementation manner of this embodiment, the status check request may be a status check request initiated by a user or a status check request initiated automatically by a system.
In an optional implementation manner of this embodiment, in order to achieve effective and accurate data synchronization, when an initial log writing file is generated, a corresponding log index (LogIndex) is also generated for the generated initial log writing file, so as to uniquely identify the initial log writing file, so that a master member and a slave member can identify the applied log writing file and an applied result according to the log index of the initial log writing file, and further perform targeted calculation, comparison and processing.
In another optional implementation manner of this embodiment, the step of acquiring the status check parameter in step S101 may be further implemented as:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
In this implementation, the state verification method supports a mode of periodically triggering state verification according to log indexes or other boot information. Specifically, a preset state check file comprising a preset state check trigger condition and a preset state check parameter is firstly determined; and then when the triggering condition of the preset state check is detected to be triggered, starting a state check operation to acquire the preset state check parameters. The preset state check trigger condition refers to preset condition data which can be triggered to start state check operation. The meaning of the preset state check parameter is similar to that of the previous implementation, but in this implementation, the preset state check parameter is preset and stored, and when the preset state check trigger condition is triggered, the preset state check parameter may be acquired. For example, the information in the preset status check file may be expressed as "trigger an error code increment MD5 check once every K LogIndex from LogIndex Y", where the status check trigger conditions in the preset status check file are: triggered once every interval K LogIndex from LogIndex Y, the state check parameters are: the status check is implemented by using an incremental check mode for the ErrorCode and using an MD5 check algorithm for the ErrorCode, namely MD 5.
The state verification method can adopt a full-quantity state calculation mode or an increment state calculation mode. Therefore, the current state check value may be either a full state check value or an incremental state check value. When the current state check value is a full state check value, that is, a full state calculation mode is adopted, a linux fork mechanism can be used for carrying out full state calculation in a new process according to the state check parameters, and the full state check value is obtained and used as the current state check value. When the current state check value is an increment state check value, namely adopting an increment state calculation mode, firstly acquiring check increment information and a previous state check value according to the state check parameter; and then calculating the current increment state check value according to the check increment information and the previous state check value to obtain the current increment state check value as the current state check value.
In an alternative implementation manner of this embodiment, as shown in fig. 2, the step S102, that is, the step of synchronously transmitting the expected check value of the master member to the slave member, includes the following steps S201 to S202:
in step S201, in response to the expected check value of the primary member being calculated, a check log write file is generated, where the check log write file contains the expected check value of the primary member;
In step S202, the verification log writing file is written into a log file, and the verification log writing file is synchronously written into a log file of a slave member, so that when the verification log writing file is applied, the master member expects a verification value to be obtained.
In order to send the expected check value of the master member calculated by the master member to all the slave members as a reference value, the slave members can compare the expected check value with the calculated check value of the slave member, and the state check result of each slave member is confirmed; and then writing the check log writing file into a log file, and synchronously writing the check log writing file into the log file of the slave member, so that the expected check value of the master member can be obtained when the check log writing file is applied by the slave member.
In order to achieve the efficient and accurate data synchronization, the method further comprises generating a log index corresponding to a certain state check operation for the initial log writing file when generating the initial log writing file, and in this implementation manner, the master member expected check value contained in the check log writing file is also configured with the log index corresponding to the state check operation, so as to achieve the efficient and accurate data synchronization, wherein the log index of the master member expected check value can be identical to or corresponding to the log index of the initial log writing file, so as to be identified as being associated with the same state check operation, and after the slave member calculates the present member calculated check value corresponding to the state check operation, comparing the present member calculated check value associated with the same state check operation with the master member expected check value, thereby obtaining the state check result.
Fig. 3 shows a flow chart of a status checking method according to another embodiment of the present disclosure, applicable from the member side. As shown in fig. 3, the state verification method includes the following steps S301 to S303:
in step S301, a state check parameter is obtained, and a current state check value is obtained by calculation according to the state check parameter and is used as a member check value;
In step S302, an expected check value of a master member is obtained, and a status check result is determined according to the calculated check value of the member and the expected check value of the master member;
in step S303, a status check result is returned to the master member.
In the distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to achieve state synchronization, and in theory, the log files with consistent contents negotiated between the members ensure that the members can obtain the same state after writing the files according to unified and deterministic logic application logs, namely, the state machines among the members are consistent. However, in engineering practice, due to the influence of factors such as program version, running environment, software defect and the like among members, states generated after the members apply the same log to write the file may not be consistent, and thus serious problems such as data errors may be caused. Therefore, it is necessary to check the consistency of states among members, and timely detect the problem of inconsistent states during the test and even the production process, so as to prevent further expansion of the problem. However, the solutions adopted in the prior art have the defects of resource consumption, poor timeliness, difficult guarantee of correctness and difficult historical traceability.
In view of the above-mentioned drawbacks, in this embodiment, a state verification method is proposed, in which a state verification parameter is obtained by triggering a state verification operation, each member calculates a corresponding state verification value according to the synchronized state verification parameter, and a state verification result is determined by comparing the state verification values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
In an optional implementation manner of this embodiment, the step of obtaining the status check parameter in step S201 may be implemented as:
acquiring an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
and acquiring the state verification parameters in response to the initial log writing file being applied.
In an optional implementation manner of this embodiment, after the initial log writing file including the state checking parameters is generated by the master member and written into the log file thereof, the initial log writing file is synchronously written into the log file of the slave member, and after the initial log writing file is applied, the required state checking parameters can be obtained
In an optional implementation manner of this embodiment, in order to achieve effective and accurate data synchronization, the initial log writing file is further configured with a corresponding log index (LogIndex) so as to uniquely identify the initial log writing file, so that the master member and the slave member can identify the applied log writing file and the applied result according to the log index of the initial log writing file, and further perform targeted computation, comparison and processing. If the log index of a certain initial log writing file is X, after each member applies to the initial log writing file and obtains the state check parameter, the current state check value calculated according to the state check parameter can be marked as the state check value corresponding to the log index X and recorded, so as to perform consistency comparison of the corresponding state check value of the log index X by each member.
In another alternative implementation manner of this embodiment, the step of obtaining the status check parameter in step S201 may be implemented as:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
In this implementation, the state verification method supports a mode of periodically triggering state verification according to log indexes or other boot information. Specifically, a preset state check file comprising a preset state check trigger condition and a preset state check parameter is firstly determined; and then when the triggering condition of the preset state check is detected to be triggered, starting a state check operation to acquire the preset state check parameters.
Similar to the above embodiments, the state verification method may use either a full-scale state calculation method or an incremental state calculation method. Therefore, the current state check value may be either a full state check value or an incremental state check value. When the current state check value is a full state check value, that is, a full state calculation mode is adopted, a linux fork mechanism can be used for carrying out full state calculation in a new process according to the state check parameters, and the full state check value is obtained and used as the current state check value. When the current state check value is an increment state check value, namely adopting an increment state calculation mode, firstly acquiring check increment information and a previous state check value according to the state check parameter; and then calculating the current increment state check value according to the check increment information and the previous state check value to obtain the current increment state check value as the current state check value.
In an optional implementation manner of this embodiment, the step of obtaining the expected check value of the primary member in step S202 may be implemented as follows:
Acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member;
And acquiring the expected check value of the master member in response to the check log writing file being applied.
The master member writes the verification log into the log file, and then synchronizes the verification log into the log file of the slave member, and then obtains the master member expected verification value when the verification log writing file is applied, so as to compare the master member expected verification value with the calculated verification value of the slave member calculated by each slave member, and confirm the state verification result of each slave member.
It is mentioned above that for efficient, accurate data synchronization, the initial log write file is configured with a log index, and in this implementation, also for efficient, accurate data synchronization, the verification log write file is configured with the same or a corresponding log index to be able to be identified as being associated with the same state verification operation.
It should be noted that, some technical terms or technical features related to fig. 3 and related embodiments thereof are the same as or similar to those mentioned in the above embodiments, and corresponding explanation and description may refer to the description of the above embodiments, which is not repeated herein.
Fig. 4 shows a flow chart of a status checking method according to still another embodiment of the present disclosure, which is applicable to a system composed of a master member and a slave member. As shown in fig. 4, the state verification method includes the following steps S401 to S403:
in step S401, a master member and a slave member acquire a state check parameter, calculate a current state check value according to the state check parameter, and calculate a check value as an expected check value of the master member and a check value of the slave member respectively;
In step S402, the master member synchronously transmits the expected check value of the master member to the slave member, and the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member;
in step S403, the slave member returns a status check result to the master member.
In an optional implementation manner of this embodiment, the step of acquiring the status check parameters of the master member and the slave member in step S401 is implemented as follows:
the method comprises the steps that a master member responds to a received state verification request to generate an initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
and the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters.
In another optional implementation manner of this embodiment, the step of acquiring the status check parameters of the master member and the slave member in step S401 is implemented as follows:
the method comprises the steps that a master member and a slave member determine a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
And responding to the triggering condition of the preset state check, and acquiring the preset state check parameters by the master member and the slave member.
In an alternative implementation of this embodiment, the current state check value is a full state check value or an incremental state check value.
In an optional implementation manner 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:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
In an optional implementation manner of this embodiment, the step of synchronously transmitting, by the master member, the master member expected check value to the slave member in step S402 is implemented as:
responding to the calculated expected check value of the master member, and generating a check log writing file by the master member, wherein the check log writing file contains the expected check value of the master member;
the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member;
And the secondary member acquires the expected check value of the primary member in response to the check log writing file being applied.
It should be noted that, some technical terms or technical features related to fig. 4 and related embodiments thereof are the same as or similar to those mentioned in the above embodiments, and corresponding explanation and description may refer to the description of the above embodiments, which is not repeated herein.
FIG. 5 is a flowchart illustrating an overall status checking method according to an embodiment of the present disclosure, as shown in FIG. 5, after a master member receives a status checking request, an initial log writing file containing status checking parameters is generated, and then the initial log writing file is synchronously written into a log file thereof and a log file of a slave member, and once the initial log writing file is applied, the master member and the slave member can acquire the status checking parameters; the master member calculates a current state check value according to the state check parameter to serve as a master member expected check value, and synchronously sends the calculated master member expected check value to the slave member; and the slave member calculates the current state check value according to the obtained state check parameter to serve as the member check value, compares the member check value with the received expected check value of the master member to determine a state check result, and finally returns the state check result to the master member.
The following are device embodiments of the present disclosure that may be used to perform method embodiments of the present disclosure.
Fig. 6 shows a block diagram of a state checking device, which may be implemented as a master member, that may be implemented as part or all of an electronic device by software, hardware, or a combination of both, according to an embodiment of the present disclosure. As shown in fig. 6, the state checking device includes:
The first obtaining module 601 is configured to obtain a state check parameter, and calculate a current state check value according to the state check parameter, and use the current state check value as a primary member expected check value;
a first sending module 602, configured to send the expected check value of the master member to the slave member synchronously, so that the slave member determines a state check result according to the expected check value of the master member and the calculated check value of the slave member;
The receiving module 603 is configured to receive the status check result returned from the member.
In the distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to achieve state synchronization, and in theory, the log files with consistent contents negotiated between the members ensure that the members can obtain the same state after writing the files according to unified and deterministic logic application logs, namely, the state machines among the members are consistent. However, in engineering practice, due to the influence of factors such as program version, running environment, software defect and the like among members, states generated after the members apply the same log to write the file may not be consistent, and thus serious problems such as data errors may be caused. Therefore, it is necessary to check the consistency of states among members, and timely detect the problem of inconsistent states during the test and even the production process, so as to prevent further expansion of the problem. However, the solutions adopted in the prior art have the defects of resource consumption, poor timeliness, difficult guarantee of correctness and difficult historical traceability.
In view of the above-mentioned drawbacks, in this embodiment, a state verification device is proposed, which acquires state verification parameters by triggering a state verification operation, calculates corresponding state verification values according to the synchronized state verification parameters by each member, and determines a state verification result by comparing the state verification values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
In an alternative implementation manner of this embodiment, the master member (Leader) refers to a master member in the distributed system, and performs information transmission and operation coordination with multiple slave members (Follow) in the distributed system, so as to ensure consistency of cluster data.
In an alternative implementation of this embodiment, the status checking parameters refer to parameters required for calculating a status checking value, and then synchronizing to all members, where the status checking parameters may include one or more of the following parameters: the state Digest calculation Algorithm used is, for example, either the MD5 Algorithm (Message-Digest algoritm 5) or CRC (Cyclic Redundancy Check) Algorithm; adopting a full state calculation mode or an incremental state calculation mode; when the incremental state calculation mode is adopted, incremental information for incremental state calculation, a previous state abstract value and the like are adopted, wherein the incremental information comprises error codes (error codes) when the log entry file (LogEntry) is applied in a preset historical time, code path marking information when the log entry file is applied in the preset historical time and the like.
In an optional implementation manner of this embodiment, the expected check value of the master member is a current state check value, which is calculated by the master member according to the obtained state check parameter and needs to be checked, and is used as the expected check value of the master member, and then the master member is synchronized to the slave member, each slave member calculates the calculated check value of the master member according to the state check parameter obtained by synchronization, and then compares the obtained expected check value of the master member obtained by synchronization with the calculated check value of the slave member, so as to obtain the check result of the current state check, if the expected check value of the master member is the same as the calculated check value of the slave member, the check is considered to be successful, and if the expected check value of the master member is different, the alarm process can be started and the continuous execution of the slave member is stopped.
In an optional implementation manner of this embodiment, the status check result may be embodied in a text, a message, or the like, or may be embodied in a sound, an audio, a video, or the like.
In an optional implementation manner of this embodiment, the portion of the first obtaining module 601 that obtains the status checking parameter may be configured to:
generating an initial log writing file in response to receiving a state checking request, wherein the initial log writing file contains state checking parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
and acquiring the state verification parameters in response to the initial log writing file being applied.
In this implementation manner, the state verification device supports a mode of active triggering by a user, that is, performs state verification of the distributed system according to active triggering by the user, and obtains a corresponding state verification parameter. Specifically, an initial log writing file is generated in response to receiving a state check request sent by a user, wherein the initial log writing file contains state check parameters required by the state check, and the state check parameters can be carried by the state check request or generated according to the state check request; then writing the initial log writing file into the log file of the master member, and synchronously writing the initial log writing file into the log file of the slave member; and when the initial log writing file is applied, acquiring the state verification parameters.
In an alternative implementation manner of this embodiment, the status check request may be a status check request initiated by a user or a status check request initiated automatically by a system.
In an optional implementation manner of this embodiment, in order to achieve effective and accurate data synchronization, when an initial log writing file is generated, a corresponding log index (LogIndex) is also generated for the generated initial log writing file, so as to uniquely identify the initial log writing file, so that a master member and a slave member can identify the applied log writing file and an applied result according to the log index of the initial log writing file, and further perform targeted calculation, comparison and processing.
In another optional implementation manner of this embodiment, the portion of the first obtaining module 601 that obtains the status checking parameter may be further configured to:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
In this implementation, the status checking means supports a mode of triggering status checking periodically according to a log index or other guidance information. Specifically, a preset state check file comprising a preset state check trigger condition and a preset state check parameter is firstly determined; and then when the triggering condition of the preset state check is detected to be triggered, starting a state check operation to acquire the preset state check parameters. The preset state check trigger condition refers to preset condition data which can be triggered to start state check operation. The meaning of the preset state check parameter is similar to that of the previous implementation, but in this implementation, the preset state check parameter is preset and stored, and when the preset state check trigger condition is triggered, the preset state check parameter may be acquired. For example, the information in the preset status check file may be expressed as "trigger an error code increment MD5 check once every K LogIndex from LogIndex Y", where the status check trigger conditions in the preset status check file are: triggered once every interval K LogIndex from LogIndex Y, the state check parameters are: the status check is implemented by using an incremental check mode for the ErrorCode and using an MD5 check algorithm for the ErrorCode, namely MD 5.
The state checking device can adopt a full-quantity state calculation mode or an increment state calculation mode. Therefore, the current state check value may be either a full state check value or an incremental state check value. When the current state check value is a full state check value, that is, a full state calculation mode is adopted, a linux fork mechanism can be used for carrying out full state calculation in a new process according to the state check parameters, and the full state check value is obtained and used as the current state check value. When the current state check value is an increment state check value, namely adopting an increment state calculation mode, firstly acquiring check increment information and a previous state check value according to the state check parameter; and then calculating the current increment state check value according to the check increment information and the previous state check value to obtain the current increment state check value as the current state check value.
In an alternative implementation of the present embodiment, as shown in fig. 7, the first sending module 602 includes:
A generating sub-module 701 configured to generate a verification log write file in response to the primary member expected verification value being calculated, wherein the verification log write file contains the primary member expected verification value;
The sending sub-module 702 is configured to write the verification log write file into a log file, and synchronously write the verification log write file into a log file of a slave member, so that when the verification log write file is applied, an expected verification value of the master member can be obtained.
In order to send the expected check value of the master member calculated by the master member to all the slave members as a reference value, the slave members can compare the expected check value with the calculated check value of the slave member, and the state check result of each slave member is confirmed; and then writing the check log writing file into a log file, and synchronously writing the check log writing file into the log file of the slave member, so that the expected check value of the master member can be obtained when the check log writing file is applied by the slave member.
In order to achieve the efficient and accurate data synchronization, the method further comprises generating a log index corresponding to a certain state check operation for the initial log writing file when generating the initial log writing file, and in this implementation manner, the master member expected check value contained in the check log writing file is also configured with the log index corresponding to the state check operation, so as to achieve the efficient and accurate data synchronization, wherein the log index of the master member expected check value can be identical to or corresponding to the log index of the initial log writing file, so as to be identified as being associated with the same state check operation, and after the slave member calculates the present member calculated check value corresponding to the state check operation, comparing the present member calculated check value associated with the same state check operation with the master member expected check value, thereby obtaining the state check result.
Fig. 8 shows a block diagram of a state checking device, which may be implemented as a slave member, that may be implemented as part or all of an electronic device by software, hardware, or a combination of both, according to another embodiment of the present disclosure. As shown in fig. 8, the state checking device includes:
a second obtaining module 801, configured to obtain a state check parameter, and calculate a current state check value according to the state check parameter, as a member check value;
A determining module 802 configured to obtain an expected check value of the master member, and determine a status check result according to the calculated check value of the member and the expected check value of the master member;
a return module 803 configured to return the status check result to the master member.
In the distributed system, in order to achieve high availability and strong consistency of roles, a state machine replication method is often used to achieve state synchronization, and in theory, the log files with consistent contents negotiated between the members ensure that the members can obtain the same state after writing the files according to unified and deterministic logic application logs, namely, the state machines among the members are consistent. However, in engineering practice, due to the influence of factors such as program version, running environment, software defect and the like among members, states generated after the members apply the same log to write the file may not be consistent, and thus serious problems such as data errors may be caused. Therefore, it is necessary to check the consistency of states among members, and timely detect the problem of inconsistent states during the test and even the production process, so as to prevent further expansion of the problem. However, the solutions adopted in the prior art have the defects of resource consumption, poor timeliness, difficult guarantee of correctness and difficult historical traceability.
In view of the above-mentioned drawbacks, in this embodiment, a state verification device is proposed, which acquires state verification parameters by triggering a state verification operation, calculates corresponding state verification values according to the synchronized state verification parameters by each member, and determines a state verification result by comparing the state verification values. According to the technical scheme, the state verification can be realized without other tools, excessive system resources are not required to be consumed, timeliness and correctness of verification operation can be guaranteed, unnecessary loss caused by fault expansion is avoided, historical verification data can be recorded conveniently and reliably, and information tracing is facilitated.
In an optional implementation manner of this embodiment, the portion of the second obtaining module 801 that obtains the status checking parameter may be configured to:
acquiring an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
and acquiring the state verification parameters in response to the initial log writing file being applied.
In an optional implementation manner of this embodiment, after the initial log writing file including the state checking parameters is generated by the master member and written into the log file thereof, the initial log writing file is synchronously written into the log file of the slave member, and after the initial log writing file is applied, the required state checking parameters can be obtained
In an optional implementation manner of this embodiment, in order to achieve effective and accurate data synchronization, the initial log writing file is further configured with a corresponding log index (LogIndex) so as to uniquely identify the initial log writing file, so that the master member and the slave member can identify the applied log writing file and the applied result according to the log index of the initial log writing file, and further perform targeted computation, comparison and processing. If the log index of a certain initial log writing file is X, after each member applies to the initial log writing file and obtains the state check parameter, the current state check value calculated according to the state check parameter can be marked as the state check value corresponding to the log index X and recorded, so as to perform consistency comparison of the corresponding state check value of the log index X by each member.
In another optional implementation manner of this embodiment, the portion of the second obtaining module 801 that obtains the status checking parameter may be configured to:
Determining a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
and responding to the triggering condition of the preset state check to obtain the preset state check parameter.
In this implementation, the status checking means supports a mode of triggering status checking periodically according to a log index or other guidance information. Specifically, a preset state check file comprising a preset state check trigger condition and a preset state check parameter is firstly determined; and then when the triggering condition of the preset state check is detected to be triggered, starting a state check operation to acquire the preset state check parameters.
Similar to the above embodiments, the state verification device may use either a full state calculation mode or an incremental state calculation mode. Therefore, the current state check value may be either a full state check value or an incremental state check value. When the current state check value is a full state check value, that is, a full state calculation mode is adopted, a linux fork mechanism can be used for carrying out full state calculation in a new process according to the state check parameters, and the full state check value is obtained and used as the current state check value. When the current state check value is an increment state check value, namely adopting an increment state calculation mode, firstly acquiring check increment information and a previous state check value according to the state check parameter; and then calculating the current increment state check value according to the check increment information and the previous state check value to obtain the current increment state check value as the current state check value.
In an alternative implementation of this embodiment, the portion of the determining module 802 that obtains the expected check value of the primary member may be configured to:
Acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member;
And acquiring the expected check value of the master member in response to the check log writing file being applied.
The master member writes the verification log into the log file, and then synchronizes the verification log into the log file of the slave member, and then obtains the master member expected verification value when the verification log writing file is applied, so as to compare the master member expected verification value with the calculated verification value of the slave member calculated by each slave member, and confirm the state verification result of each slave member.
It is mentioned above that for efficient, accurate data synchronization, the initial log write file is configured with a log index, and in this implementation, also for efficient, accurate data synchronization, the verification log write file is configured with the same or a corresponding log index to be able to be identified as being associated with the same state verification operation.
It should be noted that, some technical terms or technical features related to fig. 8 and related embodiments are the same as or similar to those mentioned in the above embodiments, and corresponding explanation and description may refer to the description of the above embodiments, which is not repeated herein.
Fig. 9 shows a block diagram of a state checking device according to yet another embodiment of the present disclosure, which may be implemented as a system of master and slave members, which may be implemented as part or all of an electronic device by software, hardware, or a combination of both. As shown in fig. 9, the state checking device includes:
The third obtaining module 901 is configured to obtain a state check parameter from a master member and a slave member, calculate a current state check value according to the state check parameter, and respectively calculate a check value as an expected check value of the master member and a check value of the slave member;
A second sending module 902, configured to send the expected check value of the master member to the slave member synchronously, where the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member;
the return module 903 is configured to return a status check result from the member to the master member.
In an optional implementation manner of this embodiment, the portion of the third obtaining module 901 that obtains the status check parameters from the master member and the slave member is configured to:
the method comprises the steps that a master member responds to a received state verification request to generate an initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
and the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters.
In another optional implementation manner of this embodiment, the portion of the third obtaining module 901 that obtains the status checking parameters from the master member and the slave member is configured to:
the method comprises the steps that a master member and a slave member determine a preset state check file, wherein the preset state check file comprises a preset state check triggering condition and a preset state check parameter;
And responding to the triggering condition of the preset state check, and acquiring the preset state check parameters by the master member and the slave member.
In an alternative implementation of this embodiment, the current state check value is a full state check value or an incremental state check value.
In an optional implementation manner of this embodiment, when the current state check value is an incremental state check value, the portion of the third obtaining module 901 that calculates the current state check value according to the state check parameter is configured to:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
In an optional implementation manner of this embodiment, the second sending module 902 is configured to send the expected check value of the master member to the portion of the slave member synchronously by the master member, where the portion is configured to:
responding to the calculated expected check value of the master member, and generating a check log writing file by the master member, wherein the check log writing file contains the expected check value of the master member;
the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member;
And the secondary member acquires the expected check value of the primary member in response to the check log writing file being applied.
It should be noted that, some technical terms or technical features related to fig. 9 and related embodiments are the same as or similar to those mentioned in the above embodiments, and corresponding explanation and description may refer to the description of the above embodiments, which is not repeated herein.
The present disclosure also discloses an electronic device, fig. 10 shows a block diagram of the electronic device according to an embodiment of the present disclosure, and as shown in fig. 10, the electronic device 1000 includes a memory 1001 and a processor 1002; wherein,
The memory 1001 is configured to store one or more computer instructions that are executed by the processor 1002 to perform the method steps described above.
FIG. 11 is a schematic diagram of a computer system suitable for use in implementing a state verification method according to an embodiment of the present disclosure.
As shown in fig. 11, the computer system 1100 includes a processing unit 1101 that can execute various processes in the above-described embodiments in accordance with a program stored in a Read Only Memory (ROM) 1102 or a program loaded from a storage section 1108 into a Random Access Memory (RAM) 1103. In the RAM1103, various programs and data required for the operation of the system 1100 are also stored. The processing unit 1101, ROM1102, and RAM1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
The following components are connected to the I/O interface 1105: an input section 1106 including a keyboard, a mouse, and the like; an output portion 1107 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 1108 including a hard disk or the like; and a communication section 1109 including a network interface card such as a LAN card, a modem, and the like. The communication section 1109 performs communication processing via a network such as the internet. The drive 1110 is also connected to the I/O interface 1105 as needed. Removable media 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is installed as needed in drive 1110, so that a computer program read therefrom is installed as needed in storage section 1108. The processing unit 1901 may be implemented as a processing unit CPU, GPU, FPAG, NPU or the like.
In particular, according to embodiments of the present disclosure, the methods described above may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the above-described state verification method. In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion 1109, and/or installed from the removable media 1111.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software, or may be implemented by hardware. The units or modules described may also be provided in a processor, the names of which in some cases do not constitute a limitation of the unit or module itself.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus described in the above embodiment; or may be a computer-readable storage medium, alone, that is not assembled into a device. The computer-readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention referred to in this disclosure is not limited to the specific combination of features described above, but encompasses other embodiments in which any combination of features described above or their equivalents is contemplated without departing from the inventive concepts described. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).

Claims (15)

1. A method for checking a state, comprising:
generating an initial log writing file in response to receiving a state checking request, and generating a corresponding log index for the initial log writing file, wherein the initial log writing file contains state checking parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
acquiring the state verification parameters in response to the initial log writing file being applied;
calculating a current state check value according to the state check parameter, and taking the current state check value as a main member expected check value;
Synchronously transmitting the expected check value of the master member to a slave member, so that the slave member determines a state check result according to the expected check value of the master member and the calculated check value of the slave member; the step of synchronously transmitting the expected check value of the master member to the slave member is implemented as follows: generating a verification log writing file in response to the primary member expected verification value being calculated, wherein the verification log writing file contains the primary member expected verification value, and the primary member expected verification value is configured with the same log index as the initial log writing file; writing the check log writing file into a log file, and synchronously writing the check log writing file into a log file of a slave member, so that when the check log writing file is applied, the expected check value of the master member can be obtained;
receiving a status check result returned by the slave member;
The master member is a master member dynamically elected in the distributed system and is used for carrying out information transmission and operation coordination with a plurality of slave members in the distributed system.
2. The state verification method according to claim 1, wherein the current state verification value is a full state verification value or an incremental state verification value.
3. The state verification method according to claim 2, wherein when the current state verification value is an incremental state verification value, the calculating the current state verification value according to the state verification parameter is implemented as:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
4. A method for checking a state, comprising:
acquiring an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
acquiring the state verification parameters in response to the initial log writing file being applied;
Calculating a current state check value according to the state check parameter to serve as a member check value;
Acquiring a primary member expected check value, and determining a state check result according to the calculated check value of the member and the primary member expected check value; the obtaining the primary member expected check value is implemented as: acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member, and the expected verification value of the master member is configured with the same log index as the initial log writing file; responding to the application of the check log writing file, and acquiring the expected check value of the master member;
Returning a state verification result to the main member;
The member is a slave member in the distributed system.
5. The state verification method according to claim 4, wherein the current state verification value is a full state verification value or an incremental state verification value.
6. The state verification method according to claim 5, wherein when the current state verification value is an incremental state verification value, the calculating the current state verification value according to the state verification parameter is implemented as:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
7. A method for checking a state, comprising:
the method comprises the steps that a master member responds to a received state verification request, an initial log writing file is generated, and a corresponding log index is generated for the initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters;
Calculating a current state check value according to the state check parameter, and respectively serving as a master member expected check value and a slave member calculated check value;
the master member synchronously transmits the expected check value of the master member to the slave member, and the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member; the master member synchronously transmits the master member expected check value to the slave member, and is implemented as: in response to the primary member expected check value being calculated, the primary member generates a check log write file, wherein the check log write file contains the primary member expected check value configured with the same log index as the initial log write file; the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member; in response to the verification log writing file being applied, the secondary member obtaining the primary member expected verification value;
The slave member returns a state verification result to the master member;
The master member is a master member dynamically elected in the distributed system and is used for carrying out information transmission and operation coordination with a plurality of slave members in the distributed system.
8. The state verification method according to claim 7, wherein the current state verification value is a full state verification value or an incremental state verification value.
9. The state verification method according to claim 8, wherein when the current state verification value is an incremental state verification value, the calculating the current state verification value according to the state verification parameter is implemented as:
acquiring verification increment information and a previous state verification value;
and calculating to obtain the current increment state check value according to the check increment information and the previous state check value.
10. A status checking device, comprising:
the first acquisition module is configured to respond to the received state verification request, generate an initial log writing file and generate a corresponding log index for the initial log writing file, wherein the initial log writing file contains state verification parameters;
writing the initial log writing file into a log file, and synchronously writing the initial log writing file into a log file of a slave member;
Acquiring the state verification parameters in response to the initial log writing file being applied; calculating a current state check value according to the state check parameter, and taking the current state check value as a main member expected check value;
The 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 a state check result according to the expected check value of the master member and the calculated check value of the slave member; the step of synchronously transmitting the expected check value of the master member to the slave member is implemented as follows: generating a verification log writing file in response to the primary member expected verification value being calculated, wherein the verification log writing file contains the primary member expected verification value, and the primary member expected verification value is configured with the same log index as the initial log writing file; writing the check log writing file into a log file, and synchronously writing the check log writing file into a log file of a slave member, so that when the check log writing file is applied, the expected check value of the master member can be obtained;
the receiving module is configured to receive the state verification result returned by the slave member;
The master member is a master member dynamically elected in the distributed system and is used for carrying out information transmission and operation coordination with a plurality of slave members in the distributed system.
11. A status checking device, comprising:
The second acquisition module is configured to acquire an initial log writing file written synchronously, wherein the initial log writing file contains a state verification parameter;
acquiring the state verification parameters in response to the initial log writing file being applied; calculating a current state check value according to the state check parameter to serve as a member check value;
The determining module is configured to acquire the expected check value of the main member and determine a state check result according to the calculated check value of the member and the expected check value of the main member; the obtaining the primary member expected check value is implemented as: acquiring a synchronously written verification log writing file, wherein the verification log writing file contains the expected verification value of the master member, and the expected verification value of the master member is configured with the same log index as the initial log writing file; responding to the application of the check log writing file, and acquiring the expected check value of the master member;
The return module is configured to return a state verification result to the main member;
The member is a slave member in the distributed system.
12. A status checking device, comprising:
The third acquisition module is configured to generate an initial log writing file in response to receiving a state verification request by a main member, and generate a corresponding log index for the initial log writing file, wherein the initial log writing file contains state verification parameters;
the master member writes the initial log writing file into a log file, and synchronously writes the initial log writing file into the log file of the slave member;
the master member and the slave member respond to the initial log writing file to be applied, and acquire the state verification parameters;
Calculating a current state check value according to the state check parameter, and respectively serving as a master member expected check value and a slave member calculated check value;
The second sending module is configured to synchronously send the expected check value of the master member to the slave member, and the slave member determines a state check result of the slave member according to the expected check value of the master member and the calculated check value of the slave member; the master member synchronously transmits the master member expected check value to the slave member, and is implemented as: in response to the primary member expected check value being calculated, the primary member generates a check log write file, wherein the check log write file contains the primary member expected check value configured with the same log index as the initial log write file; the master member writes the check log writing file into a log file, and synchronously writes the check log writing file into the log file of the slave member; in response to the verification log writing file being applied, the secondary member obtaining the primary member expected verification value;
The return module is configured to return a state check result from the member to the master member;
The master member is a master member dynamically elected in the distributed system and is used for carrying out information transmission and operation coordination with a plurality of slave members in the distributed system.
13. An electronic device comprising a memory and a processor; wherein the memory is for storing one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of any of claims 1-9.
14. A computer readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the method steps of any of claims 1-9.
15. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the method steps of any of claims 1-9.
CN201911312978.0A 2019-12-18 2019-12-18 State verification method, device, electronic equipment and computer readable storage medium Active CN112988689B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911312978.0A CN112988689B (en) 2019-12-18 2019-12-18 State verification method, device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911312978.0A CN112988689B (en) 2019-12-18 2019-12-18 State verification method, device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112988689A CN112988689A (en) 2021-06-18
CN112988689B true CN112988689B (en) 2024-10-18

Family

ID=76344135

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911312978.0A Active CN112988689B (en) 2019-12-18 2019-12-18 State verification method, device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112988689B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114124707A (en) * 2021-11-22 2022-03-01 中国电子科技集团公司第五十四研究所 A kind of network control center multi-point hot backup method

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193001A (en) * 2006-11-23 2008-06-04 中兴通讯股份有限公司 Method for judging the master/slave computer consistent via static data or dynamic data

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101841388B (en) * 2009-03-18 2012-07-04 中国科学院沈阳计算技术研究所有限公司 Information security transmission method for numerical control bus
JP5026561B2 (en) * 2010-06-29 2012-09-12 京楽産業.株式会社 Game machine, main control board, peripheral board, game machine authentication method and authentication program
US20130198134A1 (en) * 2012-01-30 2013-08-01 International Business Machines Corporation Online verification of a standby database in log shipping physical replication environments
CN103927236B (en) * 2013-01-11 2018-01-16 深圳市腾讯计算机系统有限公司 On-line testing method and apparatus
US9229796B1 (en) * 2013-09-25 2016-01-05 Emc Corporation System and method for determining disk failure indicator to predict future disk failures
KR101555194B1 (en) * 2014-05-26 2015-09-25 성재용 Parity re-synchronization apparatus for disk array using merged intent logs and parity re-synchronization method thereof
CN104504062B (en) * 2014-12-22 2018-06-05 浙江宇视科技有限公司 Master/slave data storehouse method of data synchronization and device
TW202016743A (en) * 2018-10-25 2020-05-01 財團法人資訊工業策進會 Data processing apparatus and data processing method for internet of things system
CN109492436A (en) * 2018-11-29 2019-03-19 深圳市网心科技有限公司 A kind of file verification method and relevant apparatus
CN109995866B (en) * 2019-04-03 2022-04-29 深圳市网心科技有限公司 Distributed file verification method and device, computer device and storage medium
CN110413441A (en) * 2019-06-18 2019-11-05 平安科技(深圳)有限公司 Active and standby storage volume synchrodata method of calibration, device, equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193001A (en) * 2006-11-23 2008-06-04 中兴通讯股份有限公司 Method for judging the master/slave computer consistent via static data or dynamic data

Also Published As

Publication number Publication date
CN112988689A (en) 2021-06-18

Similar Documents

Publication Publication Date Title
CN109951331B (en) Method, device and computing cluster for sending information
CN105718570B (en) Data migration method and device for database
US9189348B2 (en) High availability database management system and database management method using same
US8381015B2 (en) Fault tolerance for map/reduce computing
CN110795503A (en) Multi-cluster data synchronization method and related device of distributed storage system
US20120259912A1 (en) Cluster unique identifier
US20130198134A1 (en) Online verification of a standby database in log shipping physical replication environments
US10747776B2 (en) Replication control using eventually consistent meta-data
JP6987340B2 (en) Database data change request processing method and equipment
EP3163447B1 (en) Data replication method, device and system
US11593216B2 (en) Method, device, and computer program product for managing file system
CN115562911B (en) Virtual machine data backup method, device, system, electronic equipment and storage medium
CN114238495A (en) Method and device for switching main cluster and standby cluster of database, computer equipment and storage medium
CN113190620B (en) Method, device, equipment and storage medium for synchronizing data between Redis clusters
US20080133967A1 (en) Distributed object sharing system and method thereof
CN112988689B (en) State verification method, device, electronic equipment and computer readable storage medium
CA2920430C (en) Managing data feeds
US10970266B2 (en) Ensuring consistent replication of updates in databases
CN111338834B (en) Data storage method and device
JP6577901B2 (en) Computer system and system state reproduction method
CN111147554A (en) Data storage method and device and computer system
CN112860746B (en) Cache reduction-based method, equipment and system
CN113515574B (en) Data synchronization method and device
US10728323B2 (en) Method and apparatus for operating infrastructure layer in cloud computing architecture
US20140156714A1 (en) Distributed file system processing apparatus and method, and storage media storing the same

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant