A method and system for multi-version data conflict processing based on logical clock

By assigning Lamport timestamps to data in the wide-area measurement system and dynamically merging multiple versions of data, the problem of concurrent write conflicts across multiple nodes is solved, improving data consistency and storage efficiency, adapting to changes in the network environment, and ensuring data integrity and consistency.

CN122240595APending Publication Date: 2026-06-19NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
Filing Date
2026-03-10
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In a wide-area measurement system, when multiple nodes concurrently write the same data item, there is a bottleneck in physical clock synchronization, network latency jitter leads to false conflicts or missed conflicts, traditional conflict detection mechanisms have a high false positive rate, single-version overlay strategies disrupt the continuity of timing, fixed threshold detection cannot adapt to dynamic network environments, and multi-version storage mechanisms lack effective management, resulting in a surge in storage overhead and insufficient post-analysis capabilities.

Method used

A multi-version data conflict handling method based on logical clock is adopted. By assigning Lamport timestamps to data written to different nodes, independently saving and calculating the timestamp difference to determine multi-version data conflicts, dynamically merging conflicting data, dynamically adjusting the clock deviation threshold, selecting a merging strategy according to data type, retaining multiple versions of data, and selecting the version with the largest timestamp when reading.

Benefits of technology

It improves data consistency, reduces storage overhead, avoids data loss, adapts to dynamic network environments, ensures data temporal continuity and semantic consistency, and provides the ability to resolve conflicts after they occur.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240595A_ABST
    Figure CN122240595A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for handling multi-version data conflicts based on a logical clock. The method includes: assigning Lamport timestamps to data written by different nodes to obtain data with Lamport timestamps; independently saving the data with Lamport timestamps written by different nodes to obtain different versions of the same data item; calculating the timestamp difference between the different versions of the same data item, and determining a multi-version data conflict when the timestamp difference exceeds a preset dynamic clock deviation threshold, while dynamically merging the conflicting multi-version data. This invention solves the problem of concurrent write conflicts between multiple nodes in a wide-area measurement system, improves data consistency, reduces storage overhead, and avoids data loss due to overwriting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data synchronization technology for wide-area measurement systems, specifically relating to a method and system for handling multi-version data conflicts based on a logical clock. Background Technology

[0002] Wide-area measurement systems, as the core architecture of the power Internet of Things (IoT), require real-time processing of massive amounts of power grid operation data from distributed nodes. In cross-regional deployment scenarios, the concurrent writing of the same data item by multiple nodes presents significant challenges. Firstly, physical clock synchronization has inherent bottlenecks, and network latency jitter leads to timing discrepancies across nodes, causing false or missed collisions. The false positive rate of traditional collision detection mechanisms increases significantly, severely compromising data consistency. Current mainstream solutions suffer from several shortcomings: single-version overlay strategies disrupt the temporal continuity of power grid state variables; fixed-threshold collision detection cannot adapt to dynamic network environment changes; and forced instant merging mechanisms struggle to accommodate the semantic characteristics of different types of measurement data. While some solutions introduce multi-version storage mechanisms, the lack of effective version management strategies results in a dramatic increase in storage overhead and insufficient post-analysis capabilities. These technical deficiencies severely restrict the reliable operation of wide-area measurement systems in complex network environments. Summary of the Invention

[0003] To address the shortcomings of existing technologies, this invention provides a multi-version data conflict handling method and system based on a logical clock. This method solves the problem of concurrent write conflicts among multiple nodes in a wide-area measurement system, improves data consistency, reduces storage overhead, and prevents data loss due to overwriting.

[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0005] Firstly, a method for handling multi-version data conflicts based on a logical clock is provided, including: assigning Lamport timestamps to data written by different nodes to obtain data with Lamport timestamps; independently saving the data with Lamport timestamps written by different nodes to obtain different versions of the same data item; calculating the timestamp difference between different versions of the same data item, and determining multi-version data conflict when the timestamp difference exceeds a preset clock deviation dynamic threshold, while dynamically merging the conflicting multi-version data.

[0006] Furthermore, the Lamport timestamp is a monotonically increasing Lamport timestamp. If operation A occurs before operation B, then the Lamport timestamp L of operation A is... A Lamport timestamp L less than operation B B .

[0007] Furthermore, the timestamp difference between different versions of the same data item is calculated, and a multi-version data conflict is determined when the timestamp difference exceeds a preset clock skew dynamic threshold, including:

[0008] If a version exists satisfy: , This indicates the new Lamport timestamp. Version Lamport timestamp, This indicates the preset dynamic threshold for clock deviation, and || indicates taking the absolute value;

[0009] and Node identifier , This indicates the node identifier for the new version of the client;

[0010] This indicates a multi-version data conflict.

[0011] Furthermore, a preset clock skew dynamic threshold is defined. Dynamically adjust based on network latency:

[0012] ;

[0013] in, Scaling factor This represents the historical average round-trip time.

[0014] Furthermore, dynamically merging conflicting multi-version data includes:

[0015] Calculate the similarity S between different versions of the same data item:

[0016] ;

[0017] in, Indicates edit distance, , These represent different versions of the same data item. Indicates taking , The larger of the absolute values;

[0018] like This triggers a merge, where, Set a preset similarity threshold;

[0019] New version data generated New version data timestamp , Defined as: when , When all data is of numeric type, the new version takes the data as... and The average value when , When all are state variables, the new version data is retrieved. and The union of .

[0020] Furthermore, when a client requests to read data identifier D, the version with the largest timestamp is selected. And return; if multiple timestamps are identical Then according to node identifier Choose according to lexicographical order.

[0021] Furthermore, the method for updating the logical clock includes: appending a local clock value to the operation broadcast message. ;

[0022] The receiving end based on the received Update local clock: .

[0023] Furthermore, the received data includes data identifier D and time range. The query request returns all queries that satisfy the condition. version collection And merging suggestions based on similarity calculations.

[0024] Secondly, a multi-version data conflict handling system based on a logical clock is provided, comprising: a logical clock maintenance unit, used to assign Lamport timestamps to data written by different nodes to obtain data with Lamport timestamps; a multi-version storage unit, used to independently save the data with Lamport timestamps written by different nodes to obtain different versions of the same data item; and a conflict resolution unit, used to calculate the timestamp difference between different versions of the same data item, and determine multi-version data conflict when the timestamp difference exceeds a preset clock deviation dynamic threshold, and dynamically merge conflicting multi-version data.

[0025] Thirdly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the multi-version data conflict handling method based on a logical clock as described in the first aspect.

[0026] Compared with existing technologies, the beneficial effects achieved by this invention are as follows: This invention obtains data with Lamport timestamps by assigning Lamport timestamps to data written by different nodes; it independently saves the data with Lamport timestamps written by different nodes to obtain different versions of the same data item; it calculates the timestamp difference between different versions of the same data item, and determines that there is a multi-version data conflict when the timestamp difference exceeds a preset clock deviation dynamic threshold, and dynamically merges the conflicting multi-version data; it solves the problem of concurrent write conflicts of multiple nodes in wide-area measurement systems, improves data consistency and reduces storage overhead, and avoids data loss due to overwriting. Attached Figure Description

[0027] Figure 1 This is a system block diagram of a multi-version data conflict handling system based on a logical clock, provided in an embodiment of the present invention.

[0028] Figure 2 This is a flowchart of the logic clock update process in an embodiment of the present invention;

[0029] Figure 3 This is a block diagram of concurrent write conflict detection in an embodiment of the present invention;

[0030] Figure 4 This is a block diagram of the dynamic version merging strategy in an embodiment of the present invention. Detailed Implementation

[0031] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.

[0032] Example 1

[0033] A method for handling multi-version data conflicts based on a logical clock includes: assigning Lamport timestamps to data written by different nodes to obtain data with Lamport timestamps; saving the data with Lamport timestamps written by different nodes independently to obtain different versions of the same data item; calculating the timestamp difference between different versions of the same data item, and determining multi-version data conflict when the timestamp difference exceeds a preset clock deviation dynamic threshold, and dynamically merging the conflicting multi-version data.

[0034] like Figures 1-4As shown, the multi-version data conflict handling system based on a logical clock includes a logical clock maintenance unit, a multi-version storage unit, and a conflict resolution unit. The logical clock maintenance unit assigns a globally monotonically increasing Lamport timestamp to each data operation. The multi-version storage unit stores multiple conflicting versions of the same data item, with each version associated with a timestamp and an operation node identifier. The conflict resolution unit detects conflicts in concurrent write operations, generates new versions based on timestamp priority, and dynamically merges versions that meet the similarity threshold.

[0035] The logical clock maintenance unit is a module that generates globally ordered timestamps using the Lamport algorithm. Specifically, it can be implemented using an incrementing counter combined with a message passing mechanism. Its function is to eliminate the impact of physical clock skew on the operation sequence. The logical clock maintenance unit is configured to assign a globally monotonically increasing Lamport timestamp L to each data operation. If operation A occurs before operation B, then... .

[0036] A multi-version storage unit (MVB) is a storage structure that stores multiple historical versions of a data item. It can be implemented using a key-value database, where each version record contains a value, a timestamp, and a node identifier. Its purpose is to preserve a complete operation history for conflict reversal. An MVB is configured to store multiple conflicting versions of the same data item. Each version is associated with a timestamp. and operation node identifier .

[0037] The conflict resolution unit is a logical processor that performs conflict detection and merging. Specifically, it can be implemented using a similarity calculation algorithm combined with a dynamic threshold adjustment mechanism. Its function is to identify concurrent operations and generate merging strategies to avoid the accumulation of invalid versions. The conflict resolution unit is configured to detect conflicts in concurrent write operations, generate new versions based on timestamp priority, and dynamically merge versions that meet the similarity threshold.

[0038] When a node performs a write operation, the logical clock maintenance unit assigns an incrementing timestamp to ensure global consistency of the operation order. The multi-version storage unit saves concurrently written data as independent versions to avoid overwriting historical data. The specific workflow when a node performs a write operation is as follows:

[0039] a. Receive a write request sent by the client, the request carrying a target data identifier D and a value v;

[0040] b. Allocate timestamps through the logic clock maintenance unit. ,in This is the local clock value. The maximum timestamp received;

[0041] c. Check if there exists a condition that satisfies the conflict resolution unit. concurrent versions ,in It is a preset clock deviation threshold;

[0042] d. If concurrent versions exist, create a new version in the multi-version storage unit. ;

[0043] e. If no concurrent versions exist, merge v into the latest version. .

[0044] The conflict resolution unit identifies concurrent operations by calculating timestamp differences. When the timestamp difference exceeds a dynamically adjusted threshold, a conflict is identified, and a new version is generated. If the difference is within the threshold and the data similarity meets the standard, version merging is triggered. The conflict determination criteria for concurrent versions include:

[0045] (1) Existing version satisfy ;

[0046] (2) and Node identifier ;

[0047] The threshold Dynamically adjust based on network latency: ,in Scaling factor and , This represents the historical average round-trip time.

[0048] For numerical data, mean merging is used; for state data, set union is used to ensure semantic consistency. Dynamic version merging includes:

[0049] a. For version sets Calculate value similarity ,in Indicates edit distance;

[0050] b. If This triggers a merge, where Set a preset similarity threshold;

[0051] c. Generate a new version Its timestamp is ;

[0052] d, where f is defined as: when the data is a numeric type When the data is a state variable, f takes... and The union of .

[0053] The system periodically cleans up versions with low similarity to control storage size.

[0054] Traditional solutions rely on physical clocks, leading to false conflicts, while this invention eliminates the impact of clock deviations through logical clocks; traditional single-version overlay strategies lose historical data, while this invention retains multiple versions to support incident tracing; fixed threshold detection cannot adapt to network fluctuations, while this invention dynamically adjusts the threshold based on historical round-trip latency; forced merging causes data distortion, while this invention distinguishes data types and performs differentiated merging.

[0055] When performing a write operation, the present invention receives a write request from the client, the request carrying the target data identifier and value; allocates a timestamp through the logical clock maintenance unit, wherein the local clock value is the local clock value and the received maximum timestamp is the received maximum timestamp; checks whether there is a concurrent version that meets the preset clock deviation threshold through the conflict resolution unit; if a concurrent version exists, a new version is created in the multi-version storage unit; if no concurrent version exists, the value is merged into the most recent version.

[0056] The process involves several key steps: First, timestamp allocation. This involves generating a globally monotonically increasing identifier based on the local clock value and the maximum timestamp in the received message. This can be implemented using the Lamport algorithm, ensuring timing consistency across nodes by comparing the local clock value with the external timestamp. Second, concurrent version checking determines if there are overlapping write operations based on a preset deviation threshold. This can be implemented using a sliding window algorithm, dynamically adjusting the time range to identify operations with genuine data contention. Third, creating a new version preserves independent data copies for write operations that meet concurrency requirements. This can be implemented using a key-value pair storage structure, with version tracking achieved by attaching timestamps and node identifiers. Fourth, merging to the most recent version integrates conflict-free write operations with existing versions. This can be implemented using an incremental update algorithm, reducing storage redundancy by overwriting or merging data values.

[0057] When a client initiates a write request, the system first extracts the data identifier and the value to be written. Then, it generates a new timestamp based on the local logical clock and the maximum timestamp in the received message. This timestamp generation mechanism eliminates timing deviations caused by physical clock synchronization errors by comparing the differences between the local and remote clocks. The conflict resolution unit then scans historical versions in multiple version storage units within a preset deviation threshold, using the new timestamp as the center. If versions with overlapping time windows and different source nodes are found, it is determined to be a concurrent conflict, and an independent new version is created. If no concurrent operation meeting the conditions is detected, the current write value is merged into the latest version to avoid generating redundant data copies.

[0058] Traditional methods use fixed time windows for conflict detection, which cannot adapt to dynamic changes in network latency and are prone to false positives. This invention, however, dynamically calculates timestamps and performs concurrent judgments based on deviation thresholds, adjusting the sensitivity of conflict detection according to actual network conditions. Furthermore, existing single-version overwrite strategies directly discard old data, while this invention performs version merging when there are no conflicts, preserving data sequence while controlling storage overhead.

[0059] The conflict determination conditions for concurrent versions of the present invention include: there exists a version that satisfies that the timestamp difference does not exceed a preset clock deviation threshold, and the version node identifier is different from the client. The threshold is dynamically adjusted according to network latency, specifically determined by the product of a scaling factor and the historical average round-trip time.

[0060] Concurrent versions refer to multiple write versions of the same data item with timestamp differences within a preset range. This is achieved by comparing the absolute difference between the newly assigned timestamp and the timestamp of an existing version. This mechanism is used to identify pseudo-concurrency operations that may be caused by network latency. Dynamically adjusting the threshold refers to automatically adjusting the time window for conflict detection based on real-time network conditions. This can be achieved by using a sliding window algorithm to calculate the average historical round-trip latency and combining it with a scaling factor for dynamic calculation. This mechanism is used to eliminate misjudgments caused by fixed thresholds in scenarios with fluctuating latency. The scaling factor is a proportional coefficient used to control the correlation strength between the threshold and network latency. It can be an empirical value obtained by fitting experimental data, for example, a value between 0.3 and 0.6 in a power grid environment. This mechanism is used to balance network jitter tolerance and conflict detection sensitivity.

[0061] When a client initiates a write operation, the system first calculates the difference between the timestamp of the new version and the timestamp of the stored version. If the difference does not exceed the current dynamic threshold and the operation node identifiers are different, it is determined to be a concurrent conflict. The dynamic threshold is generated by multiplying the average round-trip latency of communication between nodes over a period of time in real time by a preset scaling factor. For example, when a sudden increase in network latency causes the average round-trip latency to reach 50 milliseconds, the threshold will automatically expand to the range of 15 to 30 milliseconds, thereby avoiding missed conflict detection due to temporary network congestion.

[0062] Traditional solutions use fixed time windows to determine concurrent conflicts, which cannot adapt to latency fluctuations caused by weather interference and sudden load changes in power grids. For example, during typhoons, the deterioration of wireless channel quality may cause the round-trip latency to increase sharply from 20 milliseconds to 80 milliseconds. If the fixed threshold is set to 30 milliseconds, a large number of missed detections will occur. However, a dynamic adjustment mechanism can automatically raise the threshold to the range of 24 to 48 milliseconds to maintain the effectiveness of conflict detection.

[0063] The dynamic version merging proposed in this invention includes: calculating a similarity value for the version set, wherein the similarity value is obtained by editing distance; triggering merging if the similarity reaches a preset threshold; generating a new version and assigning a merged timestamp; selecting different merging functions according to the data type, using average merging for numerical types and set merging for state variables.

[0064] The similarity value refers to the degree of difference between two versions of data content calculated using edit distance. Specifically, the Levenstein distance algorithm can be used to quantify the similarity between versions to determine whether the merging conditions are met. The preset similarity threshold is the minimum similarity requirement to trigger the version merging operation. This can be set through system configuration parameters to balance storage efficiency and data accuracy. The merging function refers to the fusion rules defined based on data types. Specifically, it can be implemented using the arithmetic mean of numerical data and set operations on state data to ensure semantic consistency when merging different types of data.

[0065] When the system detects multiple versions of the same data item, it first calculates the similarity value between the versions. For example, for two text-formatted status versions, the edit distance is calculated and converted into a similarity score. When this score exceeds a set threshold, the system automatically triggers a merge operation. The timestamp of the merged new version is taken as the maximum value from the original versions to preserve the chronological order of operations. For numerical data, the merged result is the average of the values ​​of each version; for status data, it is merged into a set containing all status values. This process achieves differentiated processing of different data types through a preset merge rule base.

[0066] Existing solutions employ a uniform merging strategy for numerical and state data, leading to semantic distortion of state variables. For example, forcing the averaging of switch states can generate invalid intermediate values. This invention uses data type identification and classification merging functions to preserve statistical characteristics in numerical data and maintain the integrity of discrete values ​​in state data. Furthermore, existing technologies using fixed merging thresholds are prone to version backlog or over-merging; this invention achieves a balance between storage efficiency and data accuracy through dynamic similarity determination.

[0067] This invention proposes that when the system performs a read operation: it receives a request from the client for data identifier D; selects and returns the version with the largest timestamp from the multi-version storage unit; if multiple versions with the same timestamp exist, they are selected according to the lexicographical order of the node identifiers. When the system performs a read operation:

[0068] a. Receive the client's request for data identifier D;

[0069] b. Select the version with the largest timestamp from the multi-version storage unit. And return;

[0070] c. If multiple timestamps are identical Then according to node identifier Choose according to lexicographical order.

[0071] The version with the largest timestamp refers to the data version with the largest Lamport timestamp selected from multiple version storage units. This can be achieved by iterating through the timestamp fields of all versions in the storage unit and comparing their values ​​to ensure that the most recently written data version is returned. The lexicographical order of the node identifier refers to sorting the nodes alphabetically by their identifier strings when multiple versions have the same timestamp. This can be implemented by comparing ASCII code values ​​character by character, used to determine the priority of version selection in concurrent write scenarios.

[0072] When a client initiates a read operation request, the system first parses the target data identifier carried in the request and retrieves all historical versions corresponding to that identifier in the multi-version storage unit. By traversing the timestamps associated with each version, the system selects the version with the largest value as the latest valid data and returns it to the client. When multiple versions have the same maximum timestamp, the system sorts them lexicographically according to the identifier string of the generating node and selects the version at the top of the sorted results as the final return result. For example, if three concurrent versions all have timestamps L=100 and node identifiers N3, N1, and N2 respectively, the system will select the version corresponding to N1 in lexicographical order of N1, N2, and N3.

[0073] Traditional single-version overwrite strategies only return the last written version, which cannot handle scenarios where multiple versions coexist due to concurrent writes, leading to data loss or selection bias. This invention preserves multiple versions and introduces a deterministic selection mechanism based on timestamps and lexicographical order, ensuring data timeliness and solving the version selection consistency problem under concurrent conflicts, thus avoiding uncertainty in read results caused by random selection.

[0074] In this invention, the logic clock maintenance unit updates the clock in the following way: It appends a local clock value to the operation broadcast message; the receiving end updates its local clock based on the received clock value, specifically by setting the local clock to the larger of the current local clock value and the received clock value plus one. The logic clock maintenance unit updates the clock in the following way:

[0075] (1) Attach the local clock value to the operation broadcast message ;

[0076] (2) The receiving end, based on the received... Update local clock: .

[0077] The local clock value refers to the Lamport timestamp maintained independently by each node, which can be implemented using an incrementing counter. This counter is updated based on message interactions during each operation. This feature eliminates dependence on the physical clock, ensuring comparable timing for cross-node operations. The process of updating the local clock at the receiving end refers to the mechanism by which the message receiver synchronizes its logical time. This can be achieved by comparing the local and remote timestamps and taking the maximum value. This feature maintains the monotonically increasing nature of the global logical clock, avoiding timestamp reversal issues caused by network latency.

[0078] When a node broadcasts an operation message, its current local clock value is appended to the message. Upon receiving the message, the receiving node first extracts the sender's clock value from the message, updates its local clock to the larger of its original local clock value and the received sender's clock value, and then increments that value. This process ensures that all nodes gradually align to the logical time base during message transmission, guaranteeing the global monotonicity of the operation timestamps even in high-latency or out-of-order network environments. For example, when node A sends a message with timestamp 10 to node B, if node B's current local clock is 8, node B will update its clock to 10+1=11; if node B's local clock is 12, it will update it to 12+1=13.

[0079] Existing technologies rely on physical clock synchronization protocols (such as NTP) for timestamp allocation, which can lead to clock deviations due to network latency fluctuations, resulting in misjudgments in conflict detection. This invention, however, completely eliminates physical clock synchronization errors through a progressive update mechanism using purely logical clocks. Furthermore, it achieves autonomous time synchronization of distributed nodes by carrying clock values ​​in messages, significantly improving the accuracy of conflict determination.

[0080] This invention proposes a post-conflict resolution interface, which is configured to receive query requests containing data identifiers and time ranges, and return a set of all versions that satisfy the timestamp range and a merging suggestion based on similarity calculation, specifically:

[0081] (1) Receive data containing data identifier D and time range The query request;

[0082] (2) Return all that satisfy version collection And merging suggestions based on similarity calculations.

[0083] The post-conflict resolution interface is a service module used to trace historical conflict data. It can be implemented using a RESTful API, providing data access channels for upper-layer applications through standardized query parameters and response formats. The timestamp interval in the time range query conditions refers to a closed interval consisting of the minimum and maximum Lamport timestamps. This can be passed through a JSON field in the request message to filter conflict versions generated within a specified time period. The merge suggestion refers to a version merging guidance scheme generated based on a preset similarity algorithm. Specifically, it can use offline batch processing to calculate the edit distance or numerical difference between versions and combine this with business rules to generate automatically executable merge operation instructions.

[0084] When operations and maintenance personnel need to analyze data conflicts within a specific time period, they can submit data identifiers and time range parameters by calling the post-conflict resolution interface. The system retrieves all conflicting versions that meet the timestamp criteria from the multi-version storage unit and generates a merge suggestion based on the similarity calculation results of the data values ​​of each version. For example, for numerical measurement data, the system may recommend taking the average of the version with the largest timestamp and the second newest version as the merge result; for state data, it may suggest retaining the union of all mutually exclusive states. Thus, operations and maintenance personnel can not only obtain complete historical conflict data but also quickly perform merge operations based on the system's suggestions.

[0085] Existing technologies lack the ability to retrieve conflicting versions by time dimension and do not provide intelligent merging guidance, requiring manual analysis to traverse the entire stored data and design merging strategies manually. This invention significantly reduces the complexity of manual intervention by defining a standardized query interface and an automated merging suggestion generation mechanism, while avoiding the performance overhead caused by traversing the entire data.

[0086] The following describes in detail the implementation process of the technical solution of the present invention through a scenario of handling data conflicts in power grid status monitoring during a typhoon.

[0087] Environment: Wide Area Measurement System (WAMS) master station receives data from three substations (nodes). , , For the same bus voltage data Concurrent writes.

[0088] Data types: Numerical (voltage amplitude, unit kV) and status (circuit breaker status) ).

[0089] Network conditions: Network latency fluctuates drastically. , .

[0090] Key parameters: ,initial .

[0091] Step 1: Logical clock update and timestamp allocation:

[0092] (1) Node Initiate a write operation:

[0093] ask: ;

[0094] Assign timestamps: ;

[0095] (2) Node Synchronous clock:

[0096] Update local clock: .

[0097] Step 2: Concurrent write conflict detection:

[0098] (1) Node Initiate a write operation:

[0099] ask: ;

[0100] ;

[0101] (2) Node Initiate a write operation:

[0102] ask: ;

[0103] .

[0104] (3) Conflict determination:

[0105] Calculate the dynamic threshold: ;

[0106] Timestamp difference: , ;

[0107] Result: Create a new version.

[0108] Step 3: Version Merge

[0109] Numerical data:

[0110] Version: ;

[0111] Similarity calculation:

[0112] ;

[0113] ;

[0114] Result: The standalone version is retained.

[0115] State data:

[0116] Version: ;

[0117] Merge operation: ;

[0118] .

[0119] Step 4: Read operation execution:

[0120] Read ;

[0121] ;

[0122] Read ;

[0123] .

[0124] This invention first eliminates the impact of physical clock synchronization errors on conflict detection by using a logical clock instead of a physical clock. Second, it designs a storage mechanism that can retain historical versions and support dynamic merging to accommodate differences between numerical and state data. Finally, it establishes version merging rules based on similarity to ensure data integrity while controlling storage overhead. By introducing a dynamically adjusted conflict detection threshold, it can adapt to latency fluctuations in different network environments, achieving accurate conflict detection.

[0125] Example 2

[0126] Based on the method for handling multi-version data conflicts based on a logical clock described in Embodiment 1, this embodiment provides a system for handling multi-version data conflicts based on a logical clock, including:

[0127] The logical clock maintenance unit is used to assign Lamport timestamps to the data written by different nodes, so as to obtain data with Lamport timestamps.

[0128] Multi-version storage units are used to independently save data with Lamport timestamps written by different nodes, resulting in different versions of the same data item.

[0129] The conflict resolution unit is used to calculate the timestamp difference between different versions of the same data item, and to determine that there is a conflict between multiple versions of data when the timestamp difference exceeds the preset clock deviation dynamic threshold. At the same time, the conflicting multiple versions of data are dynamically merged.

[0130] Example 3

[0131] Based on the multi-version data conflict handling method based on logical clock described in Embodiment 1, this embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the multi-version data conflict handling method based on logical clock as described in Embodiment 1.

[0132] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0133] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0134] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0135] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0136] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.

Claims

1. A method for multi-version data conflict processing based on logical clock, characterized in that, include: Assign Lamport timestamps to data written to different nodes to obtain data with Lamport timestamps; Data with Lamport timestamps written by different nodes are saved independently to obtain different versions of the same data item; Calculate the timestamp difference between different versions of the same data item, and determine that there is a conflict between multiple versions of data when the timestamp difference exceeds the preset clock deviation dynamic threshold. At the same time, dynamically merge the conflicting multiple versions of data.

2. The method of claim 1, wherein, The Lamport timestamp is a monotonically increasing Lamport timestamp, and if operation A occurs before operation B, then the Lamport timestamp L A of operation A is less than the Lamport timestamp L B of operation B.

3. The method of claim 1, wherein, Calculate the timestamp difference between different versions of the same data item, and determine a multi-version data conflict when the timestamp difference exceeds a preset clock skew dynamic threshold, including: If there is a version satisfies: , represents the Lamport timestamp of the new version, represents the Lamport timestamp of the version , represents a preset clock skew dynamic threshold, and | | represents taking an absolute value. and node identification of , node identification of the client of the new version This indicates a multi-version data conflict.

4. The multi-version data conflict handling method based on a logical clock according to claim 3, characterized in that, Pre-set clock skew dynamic threshold Dynamic adjustment according to network latency: ; wherein, is a scaling factor, is a historical average round-trip latency.

5. The method of claim 1, wherein, Dynamically merge conflicting multi-version data, including: Calculate the similarity S between different versions of the same data item: ; in, Indicates edit distance, , These represent different versions of the same data item. Indicates taking , The larger of the absolute values; If then a merge is triggered, wherein, is a preset similarity threshold value; New version data , the timestamp of the new version data , , is defined as: when , are both numerical data, the new version data takes the average of and , when , are both state quantities, the new version data takes the union of and .

6. The multi-version data conflict handling method based on logical clock according to claim 1, characterized in that, When a client requests to read data identifier D, the version with the largest timestamp is selected. And return; If multiple timestamps are the same Then according to node identifier Choose according to lexicographical order.

7. The multi-version data conflict handling method based on logical clock according to claim 1, characterized in that, The methods for updating the logical clock include: Attach the local clock value to the operation broadcast message ; The receiving end based on the received Update local clock: .

8. The multi-version data conflict handling method based on logical clock according to claim 1, characterized in that, Receive data including data identifier D and time range The query request returns all queries that satisfy the condition. version collection And merging suggestions based on similarity calculations.

9. A multi-version data conflict handling system based on a logical clock, characterized in that, include: The logical clock maintenance unit is used to assign Lamport timestamps to the data written by different nodes, so as to obtain data with Lamport timestamps. Multi-version storage units are used to independently save data with Lamport timestamps written by different nodes, resulting in different versions of the same data item. The conflict resolution unit is used to calculate the timestamp difference between different versions of the same data item, and to determine that there is a conflict between multiple versions of data when the timestamp difference exceeds the preset clock deviation dynamic threshold. At the same time, the conflicting multiple versions of data are dynamically merged.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the multi-version data conflict handling method based on a logical clock as described in any one of claims 1 to 8.