Skip to content

Implement MVCC (Multi-Version Concurrency Control) #40

@sectasy0

Description

@sectasy0

Feature Title

Implement MVCC (Multi-Version Concurrency Control)

Feature Description

Add support for Multi-Version Concurrency Control (MVCC) to zcached. MVCC will allow the database to handle concurrent read and write operations efficiently by maintaining multiple versions of data. This will enable readers to access consistent snapshots without blocking writers, improving performance and consistency under high concurrency.

Motivation

Currently, zcached does not support concurrent transactions efficiently. Without MVCC, readers and writers may block each other, leading to reduced throughput and increased latency. MVCC will solve this by allowing multiple transactions to operate on the database simultaneously, providing snapshot isolation and improving the user experience for applications with high concurrency requirements.

Proposed Solution

  • Design and document an MVCC model suitable for zcached’s in-memory architecture.
  • Implement versioned storage for keys/values, associating each version with a transaction or timestamp.
  • Ensure readers can access a consistent snapshot of the data as of the start of their transaction.
  • Writers will create new versions of data without blocking readers.
  • Implement garbage collection to remove obsolete versions once they are no longer needed.
  • Add tests for concurrent read/write scenarios to verify correctness and performance.
  • Update documentation to describe MVCC behavior and configuration options.

Alternatives Considered

  • Traditional locking mechanisms (mutexes, read-write locks): simpler but can reduce concurrency and performance.
  • Optimistic concurrency control: may be less suitable for high-write workloads compared to MVCC.

Additional Context

  • Consider memory overhead and performance trade-offs of storing multiple versions.
  • Reference: Wikipedia - MVCC
  • This feature will make zcached more competitive with other modern in-memory databases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions