Optimistic Locking for Race Condition Mitigation in Datastore Migration

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

During data migration from one datastore (DS1) to another (DS2), race conditions occur due to simultaneous updates in both systems, leading to data inconsistencies and performance issues with existing solutions like two-phase commit and centralized event streams, especially when migrating existing applications to a new infrastructure.

Innovation Solution

The use of optimistic locking and timestamps allows independent and asynchronous changes in both systems, with conflict resolution by comparing pre-update values and timestamps to determine the winning change, ensuring consistency without the performance penalties of two-phase commit.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If two-phase commit is used to coordinate edits across multiple remote datastores, then data consistency is maintained, but system performance deteriorates significantly and database resources are exhausted

Engineering Contradiction:
Improvedata consistencyVSAvoidsystem performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent uses lightweight version identifiers (version IDs or timestamps) instead of heavy transaction locking mechanisms. These version identifiers are simple, disposable metadata that can be easily created, compared, and discarded, avoiding the resource-intensive two-phase commit protocol while maintaining consistency through optimistic validation.

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

Solution Approach 2:

The patent replaces the mechanical two-phase commit locking system with an optimistic locking mechanism using version identifiers. Instead of holding actual locks on database resources, the system uses software-based version tracking and comparison, substituting a heavy mechanical coordination system with a lighter computational approach.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Reliability

If two-phase commit is used to coordinate edits across multiple remote datastores, then data consistency is maintained, but database resources are tied up and easily exhausted

Engineering Contradiction:
Improvedata consistencyVSAvoiddatabase resource usage
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent uses lightweight version identifiers (version IDs or timestamps) instead of heavy transaction locking mechanisms. These version identifiers are simple, disposable metadata that can be easily created, compared, and discarded, avoiding the resource-intensive two-phase commit protocol while maintaining consistency through optimistic validation.

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

Solution Approach 2:

The patent extracts the essential consistency-checking function from the heavy two-phase commit protocol, isolating only the necessary version comparison logic. This separates the critical consistency validation from the resource-intensive coordination overhead, allowing the system to maintain data integrity without tying up database resources.

Inventive Principle:
Principle #2Taking out (Extraction)

3Reliability

If a centralized stream is used to propagate events to all relevant systems, then event ordering is maintained and error handling is centralized, but migration of existing applications to the master stream is difficult

Engineering Contradiction:
Improveevent ordering and error handlingVSAvoidapplication migration capability
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent introduces version identifiers as an intermediary mechanism that enables gradual migration. Existing applications can continue to use their current datastores while incorporating version checking, serving as intermediaries between the old and new systems. This allows incremental adoption without requiring all applications to migrate simultaneously to a centralized stream.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent implements partial migration where applications can adopt the version-controlled optimistic locking mechanism incrementally. Applications don't need to fully migrate to a centralized stream immediately; they can partially implement version tracking and conflict resolution while continuing to operate with their existing architectures, enabling gradual transition.

Inventive Principle:
Principle #16Partial or excessive action

4Reliability

If all applications write to a central stream, then data consistency is maintained, but the infrastructure complexity increases for organizations with existing applications

Engineering Contradiction:
Improvedata consistencyVSAvoidinfrastructure complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent segments the consistency-maintenance function into distributed version tracking at each application and datastore, rather than requiring a monolithic centralized stream infrastructure. Each system independently tracks versions and detects conflicts, eliminating the need for complex centralized event streaming infrastructure while maintaining data consistency across distributed systems.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS11392574B2Mitigating race conditions across two live datastores
Publication Date: 2022.07.19 LENDINGCLUB BANK NAT ASSOC
  • US11392574B2 patent drawing
  • US11392574B2 patent drawing
  • US11392574B2 patent drawing

AI summary

Techniques are described herein to handle situations in which multiple systems can change different copies of the same data item. Optimistic locking and time stamps are used to ensure consistency between the systems without incurring the performance penalties associated with two-phase commit. Specifically, when propagating a change to a data item from a first system to a second system, the second system compares the first system's “pre-update” value of the data item with its current value of the data item. If the pre-update value from the first system does not match the current value in the second system, then a conflict has occurred. Upon detecting a conflict, both systems use timestamps associated with the respective conflicting changes to determine which conflicting change “wins”. The winning change is applied by all systems whose changes did not win.