<< All versions

Skill v1.0.0

currentAutomated scan100/100
alizainx/intelligence-systems-skills/btree-lsm-wal-storage-engines
──Details
PublishedNovember 5, 2026 at 09:04 AM
Content Hashsha256:dc5821fc4d34f7b5...
Git SHA4446b059cc96
──Files
Files (1 file, 2.1 KB)
SKILL.md2.1 KBactive
SKILL.md · 27 lines · 2.1 KB

name: btree-lsm-wal-storage-engines id: ISS-163 token_budget: 700 chain_with: [mvcc-ssi-acid-transaction-managers, vfs-journaling-cow-filesystems, sql-query-planner-acid] description: "Database storage engines: Write-Ahead Logging (ARIES recovery), B+Tree latch crabbing & slotted pages, LSM-Tree (MemTable, SSTables, Bloom filters, Leveled Compaction)." metadata: version: "1.0.0"


btree-lsm-wal-storage-engines (ISS-163)

1. First-Principles Invariant

  • ARIES Write-Ahead Logging & Torn-Page Law: Before flushing a dirty buffer-pool page $P$ to disk, all WAL records up to P.pageLSN must be fsynced (flushedLSN >= P.pageLSN), and before acknowledging COMMIT to a client, the transaction's commit WAL record must be fsynced (flushedLSN >= commitLSN) with CRC32C frame checksums.

2. Fast-Pass Low-Token Protocol (Web & Coding Agents)

  • In LSM-Trees (RocksDB/Pebble style), guard every immutable SSTable with a Block-Based Bloom Filter (10 bits/key -> < 1% false-positive rate) and Fence Pointers (min_key..max_key index block in RAM) so point lookups skip 99% of non-matching disk reads.

3. Zero-Bug & Zero-Vulnerability Guards

  1. Acquire B+Tree page latches using Latch Crabbing (lock parent -> lock child -> if child is safe against split/merge, immediately release parent latch) and never hold a page latch across disk I/O.
  2. Implement ARIES 3-phase crash recovery (Analysis -> Redo (Repeating History from min RecLSN) -> Undo (in reverse LSN order emitting Compensation Log Records CLRs)) so repeated crashes during recovery remain idempotent.
  3. Rate-limit background LSM compaction I/O and stall MemTable writes smoothly when L0 file count approaches the stall threshold to prevent latency cliffs.
  4. Align slotted pages to 4 KiB / 16 KiB hardware block boundaries and write checkpoints atomically via doublewrite buffers or CoW shadow paging to defeat torn page writes.
  5. Verify crash consistency by killing/truncating the WAL mid-transaction and asserting zero committed data loss and zero corrupt pages.

4. Verification Gate

  • python3 -c 'import zlib, struct; ...'
All versions