KenobiX provides FULL ACID compliance, rigorously tested with 25 comprehensive test scenarios covering all ACID properties under various real-world conditions.
Test Results: ✅ 25/25 tests passed (100%)
- ✅ Atomicity: 6/6 tests passed
- ✅ Consistency: 5/5 tests passed
- ✅ Isolation: 5/5 tests passed
- ✅ Durability: 7/7 tests passed
- ✅ Combined: 2/2 tests passed
ACID is a set of properties that guarantee database transactions are processed reliably:
- Atomicity - All operations in a transaction succeed or all fail (all-or-nothing)
- Consistency - Database remains in a valid state before and after transactions
- Isolation - Concurrent transactions don't interfere with each other
- Durability - Committed data persists even after crashes
Verifies that transactions are atomic - all operations succeed or all fail with no partial updates visible.
- Multiple Inserts - 100 inserts succeed together or fail together
- Mixed Operations - Insert, update, and delete operations are atomic
- Nested Transactions - Inner transaction failures only rollback inner changes
- Large Batches - 1000+ document operations are atomic
- Savepoints - Partial rollback within transactions works correctly
- ODM Operations - Object-document mapper operations are atomic
Key Scenarios Tested:
- Failed transactions leave no trace
- Partial failures trigger complete rollback
- Savepoints enable selective rollback
- ODM layer maintains atomicity
Verifies that transactions maintain data consistency and valid state transitions.
- Balance Transfers - Total balance invariant maintained across 50 transfers
- Business Rules - Negative balances prevented via transaction rollback
- Referential Integrity - Related records remain consistent on failure
- Counter Increments - 100 sequential increments maintain correct sequence
- Inventory Tracking - Stock counts remain accurate across operations
Key Scenarios Tested:
- Invariants preserved (total balance unchanged)
- Business logic enforced (no negative balances)
- Related data stays synchronized
- Sequential operations maintain correctness
Verifies Read Committed isolation level and concurrent transaction safety.
- No Dirty Reads - Uncommitted changes not visible to other connections
- Read Committed - Only committed data is readable by concurrent connections
- Concurrent Transactions - 4 concurrent workers × 20 operations each complete successfully
- Readers During Writes - Readers see consistent snapshots during long writes
- Serializable Writes - Balance transfers maintain total despite concurrency
Key Scenarios Tested:
- Dirty reads prevented
- Read Committed isolation verified
- Concurrent operations don't corrupt data
- Write transactions properly serialize
- Total consistency maintained under concurrency
Verifies that committed data persists across restarts and crashes.
- Simple Commit - 100 documents survive database close/reopen
- Multiple Transactions - 10 transactions × 10 documents all persist
- With Rollback - Only committed data survives (rolled back data lost)
- WAL Mode - Write-Ahead Logging provides durability guarantees
- Large Transactions - 10,000 documents in single transaction are durable
- Crash Recovery - Committed data survives simulated crash; uncommitted data lost
- ODM Persistence - ODM objects correctly persist across restarts
Key Scenarios Tested:
- Data survives process termination
- WAL mode ensures durability
- Large datasets remain durable
- Crash recovery works correctly
- ODM layer maintains durability
Real-world scenarios testing all ACID properties together.
-
Banking Scenario:
- 4 accounts with $1000 each
- 50 concurrent transfers
- Total balance preserved: $4000 → $4000 ✓
- All properties verified: Atomicity, Consistency, Isolation, Durability
-
E-Commerce Scenario:
- 20 orders processed atomically
- Failed orders completely rolled back
- Order status updates atomic
- Data survives restart
Key Scenarios Tested:
- All ACID properties work together
- Real-world transaction patterns
- Complex multi-step operations
- Production-like workloads
KenobiX implements transactions using SQLite's native transaction support:
class KenobiX:
def __init__(self):
self._in_transaction = False
self._savepoint_counter = 0
def begin(self):
"""Begin explicit transaction"""
self._connection.execute("BEGIN")
self._in_transaction = True
def commit(self):
"""Commit changes"""
self._connection.commit()
self._in_transaction = False
def rollback(self):
"""Rollback changes"""
self._connection.rollback()
self._in_transaction = FalseAutomatic transaction management via context manager:
with db.transaction():
db.insert({"user": "Alice"})
db.insert({"user": "Bob"})
# Automatically commits on success
# Automatically rolls back on exceptionNested transactions via SQLite savepoints:
with db.transaction(): # Outer
db.insert({"name": "Alice"})
with db.transaction(): # Inner (savepoint)
db.insert({"name": "Bob"})
raise Exception() # Bob rolled back
db.insert({"name": "Carol"})
# Alice and Carol committed, Bob discardedKenobiX uses SQLite's Write-Ahead Logging mode:
PRAGMA journal_mode=WALBenefits:
- Better concurrency (readers don't block writers)
- Faster commits
- Crash recovery
- Durability guarantees
Read Committed isolation level:
- ✅ No dirty reads
- ✅ Non-repeatable reads possible (expected)
- ✅ Phantom reads possible (expected)
- ✅ Write transactions serialize
This is appropriate for most applications and matches the isolation level of PostgreSQL, MySQL (InnoDB), and MongoDB.
Minimal overhead with significant benefits:
# Without transaction: 1000 separate commits
for i in range(1000):
db.insert({"value": i}) # Slow: 1000 commits
# With transaction: 1 commit
with db.transaction():
for i in range(1000):
db.insert({"value": i}) # Fast: 1 commitResult: 50-100x faster for bulk operations!
WAL mode provides excellent concurrency:
- Multiple readers: No blocking
- Reader + writer: Readers see last committed state
- Multiple writers: Serialize automatically
Tested with:
- 4 concurrent writers × 20 operations = 80 total ✓
- 4 concurrent workers doing balance transfers ✓
- No data corruption under load ✓
| Feature | KenobiX | PostgreSQL | MongoDB | MySQL InnoDB | SQLite |
|---|---|---|---|---|---|
| Atomicity | ✅ Full | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Consistency | ✅ Full | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Isolation | Read Committed | Configurable | Read Committed | Configurable | Serializable |
| Durability | ✅ Full (WAL) | ✅ Full | ✅ Full | ✅ Full | ✅ Full (WAL) |
| Savepoints | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |
| Nested Trans | ✅ Via savepoints | ✅ Via savepoints | ❌ No | ✅ Via savepoints | ✅ Via savepoints |
| Context Manager | ✅ Built-in | Library | Library | Library | Manual |
Conclusion: KenobiX provides ACID compliance on par with enterprise databases, with a simpler API and zero-configuration setup.
- Multi-step operations - Transfer money between accounts
- Batch operations - Import 1000s of records atomically
- Complex business logic - Create user + profile + preferences together
- Data consistency - Ensure invariants (e.g., total balance preserved)
- Error recovery - Rollback partial work on failure
- Single operations - Auto-commit is sufficient
- Read-only operations - No changes to protect
- Long-running operations - Avoid holding locks too long
- External side effects - API calls, emails (can't rollback)
# Use context managers
with db.transaction():
db.insert(data)
# Keep transactions short
prepare_data() # Outside transaction
with db.transaction():
db.insert(data) # Quick insert
# Handle specific errors
with db.transaction():
try:
db.insert(data)
except IntegrityError:
# Handle duplicate key
pass# Don't forget error handling
db.begin()
db.insert(data)
db.commit() # What if insert fails?
# Don't hold transactions too long
with db.transaction():
data = fetch_from_api() # Slow!
process_data(data) # Slow!
db.insert(data)
# Don't mix transaction styles
db.begin()
with db.transaction(): # ERROR!
db.insert(data)Each test follows this pattern:
- Setup - Create clean database
- Execute - Perform operations (normal + failure scenarios)
- Verify - Assert expected state
- Cleanup - Remove test database
Concurrency tests use true multiprocessing:
with multiprocessing.Pool(processes=4) as pool:
results = pool.starmap(worker_function, tasks)This ensures:
- Separate processes (not threads)
- Separate SQLite connections
- True concurrent access
- Real-world conditions
Durability tests simulate crashes:
db.begin()
db.insert(data) # Don't commit
db._connection.close() # Simulate crash
db = KenobiX(db_path) # Reopen
# Verify uncommitted data is lost# Run comprehensive ACID compliance tests
python3 tests/test_acid_compliance.py
# Run with pytest
pytest tests/test_acid_compliance.py -v
# Run specific test class
pytest tests/test_acid_compliance.py::TestAtomicity -vExpected output:
======================================================================
TOTAL: 25/25 tests passed
======================================================================
🎉 KenobiX provides FULL ACID compliance!
KenobiX provides complete ACID compliance with:
- ✅ Atomicity - All-or-nothing transactions
- ✅ Consistency - Valid state transitions
- ✅ Isolation - Read Committed isolation level
- ✅ Durability - WAL mode guarantees
Tested rigorously with 25 comprehensive tests covering:
- Simple and complex transactions
- Concurrent operations
- Crash recovery
- Real-world scenarios
- ODM layer integration
Production-ready with:
- Clean, simple API
- Context manager support
- Savepoint support
- Zero-configuration
- Excellent performance
KenobiX is suitable for applications requiring reliable, ACID-compliant data storage with the simplicity of a document database and the reliability of a SQL database.