Skip to content

refactor(memory): wrap cleanup() in atomic transaction#2041

Merged
bug-ops merged 1 commit intomainfrom
issue-2032
Mar 20, 2026
Merged

refactor(memory): wrap cleanup() in atomic transaction#2041
bug-ops merged 1 commit intomainfrom
issue-2032

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Problem

ResponseCache::cleanup() executed two SQL operations independently.
A failure between them left partial state: expired rows deleted but
stale embeddings still present, or vice versa.

Solution

Wrap both operations in a single SQLite transaction via pool.begin() /
tx.commit(). On error, sqlx automatically rolls back for all-or-nothing semantics.

Tests

6014/6014 pass. No new test needed — atomicity is enforced by SQLite.

Closes #2032

@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes refactor Code refactoring without functional changes size/XS Extra small PR (1-10 lines) labels Mar 20, 2026
Both DELETE (expired rows) and UPDATE (stale embeddings) in
ResponseCache::cleanup() now run inside a single SQLite transaction.
On error, the transaction is automatically rolled back, preventing
partial cleanup state.

Closes #2032
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 13:41
@bug-ops bug-ops merged commit 102f6fc into main Mar 20, 2026
25 checks passed
@bug-ops bug-ops deleted the issue-2032 branch March 20, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) refactor Code refactoring without functional changes rust Rust code changes size/XS Extra small PR (1-10 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: cleanup() should be atomic transaction

1 participant