Compare and Swap API for Key-Value Store Synchronization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current key-value stores lack inherent locking mechanisms for synchronization, leading to issues in multi-threaded applications, especially in critical use-cases like financial and medical databases, and when used as block storage alternatives, where eventual consistency is not acceptable.
Innovation Solution
Incorporating Compare and Swap (CAS) functionality into ultrafast key-value stores, which includes adding a CAS component to allow multi-threaded applications to share storage resources, using a CAS process that compares the contents of a memory location with a given value and modifies it only if they match, ensuring atomicity and synchronicity among threads.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If key-value stores are used for distributed applications, then scalability and performance are improved, but synchronization capability deteriorates
Solution Approach 1:
The patent introduces an intermediary locking mechanism that mediates between multiple threads accessing the key-value store. The lock manager acts as a mediator that coordinates access requests, granting exclusive locks to threads that need to modify data while allowing read-only access to others. This resolves the contradiction by adding a coordination layer that enables reliable synchronization without sacrificing the underlying key-value store's scalability and performance characteristics.
2Reliability
If external locking mechanisms are implemented for key-value stores, then synchronization is achieved, but system complexity increases
Solution Approach 1:
The patent merges the locking mechanism with the key-value store by integrating the lock manager as a component of the storage system itself. Rather than implementing separate external locking protocols, the lock manager is combined with the key-value store's data structures and access paths. This integration reduces system complexity by consolidating synchronization functionality within the existing architecture while maintaining reliable thread synchronization.
3Reliability
If CAS functionality is added to key-value stores, then multi-threaded synchronization is improved, but operation complexity increases
Solution Approach 1:
The patent implements self-service CAS (compare-and-swap) functionality where the key-value store automatically performs atomic compare-and-swap operations without requiring external coordination. When a thread requests a CAS operation, the lock manager handles the entire process atomically: it acquires the necessary locks, performs the comparison of the expected value with the current value, and conditionally applies the new value. This self-service approach improves multi-threaded synchronization reliability while keeping operations simple for the application layer.
Data Source
AI summary
Embodiments for providing compare and swap (CAS) functionality to key value storage to allow multi-threaded applications to share storage devices and synchronize multiple concurrent threads or processes. A key-value application programming interface (API) is modified to include a CAS API in addition to the standard Put and Get APIs. The CAS function uses a key, expected old value, and new value to compare and swap an existing key value only if its current value equals the expected old value. Hash values of the key value and expected old value may be used by the CAS function to improve performance and reduce bandwidth.


