MagnumDB
Modern Open Source Embedded Database Engine in Native Rust
MagnumDB is an open-source embedded key-value and SQL database engine written 100% from scratch in native Rust. Designed for performance, reliability, and modularity.
Features
- Embedded Engine: Runs directly inside Rust binaries with zero external C/C++ dependencies.
- WAL Durability: Write-Ahead Logging (WAL) with TxID framing and CRC32 checksums ensures crash recovery.
- B+ Tree Indexing: Custom 4KB page disk pager, LRU buffer pool management, overflow pages, and leaf page recycling.
- Relational SQL Query Engine: Hash JOINs (
INNER JOIN,LEFT JOIN),GROUP BY&HAVINGaggregations,ORDER BYsorting,LIMIT&OFFSETpagination, and composite indexes. - MVCC & Transactions: Thread-safe MVCC row headers (
xmin,xmax) and transaction logging withBEGIN,COMMIT, andROLLBACK. - Authentication & RBAC: PostgreSQL-compatible MD5 authentication and
CREATE USERrole-based access control. - PostgreSQL Protocol & Extended Querying: Native PostgreSQL Wire Protocol (
pgwire) supporting prepared statements and$1,$2parameter binding (Parse,Bind,Execute). - Multi-Client TCP Server: Async TCP server powered by Tokio with connection limits and idle timeouts.
What's New in v0.4.2
Version 0.4.2 introduces Authentication, Role-Based Access Control (RBAC), and thread-safe MVCC concurrency:
- ๐ Authentication Handshake: PostgreSQL-compatible MD5 password authentication over
pgwire. - ๐ค
CREATE USERDDL: Provision users and manage roles directly via SQL:; - ๐งต Thread-Safe MVCC: Safe, concurrent transaction execution using
parking_lot::RwLockfor multi-client scale. - โ๏ธ
ORDER BY,LIMIT,OFFSET: Sort and paginate query results.
Architecture
graph TD
A[Client / magnum shell / psql] -->|SQL Query| B(SQL Parser)
B -->|AST| C(Query Executor)
C -->|Reads/Writes| D[B+ Tree Index]
C -->|Logs| E[(WAL - Write Ahead Log)]
D -->|Request Page| F(Buffer Pool Manager)
F -->|Evict/Load 4KB Pages| G[(Disk / Pager)]
style A fill:#f9f,stroke:#333,stroke-width:2px
style D fill:#bbf,stroke:#333,stroke-width:2px
style F fill:#bbf,stroke:#333,stroke-width:2px
style G fill:#dfd,stroke:#333,stroke-width:2px
style E fill:#dfd,stroke:#333,stroke-width:2px
Installation
Add MagnumDB to your Cargo.toml:
[]
= "0.4.2"
Quick Start (Embedded Key-Value)
use ;
Embedded SQL Usage
use ;
use ;
Contributing & License
We welcome contributions! Please review CONTRIBUTING.md.
Licensed under the MIT License.