Skip to content

fix(kv-store): make LMDB clear and drop operations atomic across sub-databases#21539

Open
Maddiaa0 wants to merge 1 commit intomerge-train/spartanfrom
fix/130-lmdb-non-atomic-clear
Open

fix(kv-store): make LMDB clear and drop operations atomic across sub-databases#21539
Maddiaa0 wants to merge 1 commit intomerge-train/spartanfrom
fix/130-lmdb-non-atomic-clear

Conversation

@Maddiaa0
Copy link
Member

@Maddiaa0 Maddiaa0 commented Mar 13, 2026

part of #21514

Summary

  • Problem: AztecLmdbStore.clear() and drop() called their respective operations on each sub-database (#data, #multiMapData, #rootDb) sequentially without a wrapping transaction. A crash between operations could leave the store in an inconsistent state (some sub-DBs cleared, others not).
  • Fix: Wrap all sub-database operations within a single this.#rootDb.transaction() call using synchronous variants (clearSync() / dropSync()) so they execute atomically.
  • Tests: Added comprehensive test suite covering clear (maps, multimaps, singletons, counters, sets), drop, and delete operations.

Changes

  • yarn-project/kv-store/src/lmdb/store.ts: clear() now uses clearSync() inside a transaction; drop() now uses dropSync() inside a transaction.
  • yarn-project/kv-store/src/lmdb/store.test.ts: New test file with 7 test cases.

Test plan

  • New unit tests for clear(), drop(), and delete() operations
  • Existing kv-store tests pass: yarn workspace @aztec/kv-store test

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@Maddiaa0 Maddiaa0 changed the base branch from next to merge-train/spartan March 13, 2026 17:41
@Maddiaa0 Maddiaa0 force-pushed the fix/130-lmdb-non-atomic-clear branch from 5f606aa to 53392a6 Compare March 13, 2026 17:43
…databases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Maddiaa0 Maddiaa0 force-pushed the fix/130-lmdb-non-atomic-clear branch from 53392a6 to fba3d29 Compare March 13, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant