Skip to content

backport: refactor(database): wrap connection in Arc<Mutex> and add shared_connection()#643

Merged
lklimek merged 1 commit into
v1.0-devfrom
zk-extract/db-arc-mutex
Feb 24, 2026
Merged

backport: refactor(database): wrap connection in Arc<Mutex> and add shared_connection()#643
lklimek merged 1 commit into
v1.0-devfrom
zk-extract/db-arc-mutex

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Feb 24, 2026

Summary

  • Changes Database.conn from Mutex<Connection> to Arc<Mutex<Connection>>
  • Adds shared_connection() method to get a cloneable reference to the underlying connection
  • All existing code continues to work identically (same lock semantics)
  • Enables future consumers to share the SQLite connection without going through Database methods

Test plan

  • Build succeeds with no warnings
  • All existing tests pass
  • Database operations work identically (no behavioral change)

🤖 Co-authored by Claudius the Magnificent AI Agent

Summary by CodeRabbit

  • Chores
    • Enhanced database connection management to support concurrent access scenarios

…ection()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lklimek lklimek self-assigned this Feb 24, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b42950 and b8bf56d.

📒 Files selected for processing (1)
  • src/database/mod.rs

📝 Walkthrough

Walkthrough

The database connection storage is refactored from Mutex<Connection> to Arc<Mutex<Connection>> to enable shared thread-safe access across components. Imports are updated to include Arc, and a new public method shared_connection() is added to return clones of the wrapped connection for sharing.

Changes

Cohort / File(s) Summary
Database Connection Refactoring
src/database/mod.rs
Swapped connection storage mechanism from Mutex<Connection> to Arc<Mutex<Connection>>. Updated imports to include Arc. Added new public method shared_connection() that returns a clone of the Arc<Mutex<Connection>> for callers to share the underlying connection. Execute path remains functionally unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A burrow of threads, now safely aligned,
With Arc's gentle touch, no locks left behind,
Connections are shared where the rabbits all meet,
Mutex and Arc make the synchronization sweet! 🔄✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zk-extract/db-arc-mutex

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lklimek lklimek marked this pull request as ready for review February 24, 2026 10:10
@lklimek lklimek merged commit f6a09ee into v1.0-dev Feb 24, 2026
3 of 4 checks passed
@lklimek lklimek deleted the zk-extract/db-arc-mutex branch February 24, 2026 10:10
QuantumExplorer added a commit that referenced this pull request Apr 14, 2026
- Rename BalanceUpdated::spendable to confirmed in event_bridge
- Use ManagedCoreAccount::spendable_utxos(synced_height) in funding_common

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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