BuzzDB is a lightweight database built to support Multi-Version Concurrency Control (MVCC). It efficiently handles concurrent transactions and ensures data consistency through versioned tuple management.
- Assumes conflicts are rare and only checks for conflicts at commit time.
- If a conflict is detected during commit, the transaction is aborted and restarted.
- Transactions acquire locks on all tuples they read or write, preventing changes by other transactions during the lock period.
- Ensures serializability by preventing conflicting operations from occurring concurrently.
- Eliminates conflict checks at commit time as locks safeguard against concurrent conflicts.
./buzzdb 2PL
./buzzdb OCC
Each tuple includes the following metadata:
- Creation Timestamp: Timestamp when the version was created.
- Expiration Timestamp: Timestamp when the version was superseded or expired.
- Previous Version Metadata: Metadata (page number and slot number) of the previous version, if applicable.
The Version Manager is a centralized structure that:
- Maintains the latest committed version of each tuple.
- Enables traversal through the version chain for historical data.
- Facilitates scan operations to locate the correct tuple version based on transaction timestamps.
A Transaction in BuzzDB:
- Represents a set of isolated queries.
- Tracks tuples updated or written during execution.
- Includes a Commit Method that:
- Safely commits changes by acquiring necessary locks.
- Updates the Transaction Manager to reflect committed changes.
- Makes changes visible to other transactions.
The Transaction Manager:
- Tracks active and committed transactions.
- Maintains a mapping of committed transactions and their updates to ensure consistency.
- Locks prevent concurrent access to specific memory locations.
- In BuzzDB, locks are held on
(pageNumber + slotId)
combinations.
- Manages acquisition and release of locks.
- Maps locks to memory locations for efficient transaction handling.
-
Clone the repository:
git clone https://github.com/your-username/mvcc_buzzdb.git cd mvcc_buzzdb
-
Compile the code:
make
-
Run the database with the desired concurrency protocol:
./buzzdb <concurrency_protocol>
- Added creation and expiration timestamps.
- Included metadata for previous tuple versions.
- Centralized management of tuple versions.
- Support for version traversal and scans.
- Enhanced commit process with safe locking and visibility updates.
- Conflict detection for MVOCC at commit.
- Locks applied to
(pageNumber + slotId)
for fine-grained control. - Centralized management through Lock Manager.