Improve SQLite concurrency and document EMILIA collaboration - #2
Open
TochusC wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves SQLite-backed storage reliability under contention by switching key stores to WAL mode with a consistent busy timeout, and by ensuring failed writes don’t leave transactions open (which can retain write locks). It also adds regression tests for concurrency/lock cleanup behavior and updates the README with a Collaboration acknowledgment.
Changes:
- Enable SQLite WAL mode and set a 30s busy timeout for replay, agent, and message stores.
- Add explicit rollbacks on failed writes and commit replay nonce pruning to release locks reliably.
- Add regression tests for WAL/busy-timeout configuration and for ensuring rejected writes don’t leave locks behind; update README Collaboration section.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_replay.py | Adds WAL/busy-timeout assertions and regression tests ensuring replay persistence failures don’t leave locks behind and pruning commits deletions. |
| tests/test_messages.py | Adds regression coverage that duplicate-nonce enqueue doesn’t leave a write lock, plus WAL/busy-timeout assertions. |
| tests/test_agents.py | Adds regression coverage that duplicate registration doesn’t leave a write lock, plus WAL/busy-timeout assertions. |
| src/atp/storage/messages.py | Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on integrity errors to release locks. |
| src/atp/storage/agents.py | Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on integrity errors to release locks. |
| src/atp/security/replay.py | Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on SQLite errors and commits prune deletions to release locks. |
| README.md | Adds Collaboration section and updates top link row and contributing test command wording. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+40
to
+43
| self._conn = sqlite3.connect(str(db_path), timeout=30) | ||
| self._conn.row_factory = sqlite3.Row | ||
| self._conn.execute("PRAGMA journal_mode=WAL") | ||
| self._conn.execute("PRAGMA busy_timeout=30000") |
Comment on lines
+28
to
+30
| self._conn = sqlite3.connect(str(self._db_path), timeout=30) | ||
| self._conn.execute("PRAGMA journal_mode=WAL") | ||
| self._conn.execute("PRAGMA busy_timeout=30000") |
Comment on lines
+45
to
+47
| self._conn = sqlite3.connect(str(self._db_path), timeout=30) | ||
| self._conn.execute("PRAGMA journal_mode=WAL") | ||
| self._conn.execute("PRAGMA busy_timeout=30000") |
| def test_sqlite_connection_uses_wal_and_busy_timeout(self, tmp_path): | ||
| guard = ReplayGuard(db_path=tmp_path / "nonces.db") | ||
| assert guard._conn is not None | ||
| assert guard._conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal" |
|
|
||
| def test_sqlite_connection_uses_wal_and_busy_timeout(self, tmp_path: Path) -> None: | ||
| store = MessageStore(db_path=tmp_path / "test.db") | ||
| assert store._conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal" |
|
|
||
| def test_sqlite_connection_uses_wal_and_busy_timeout(self, store): | ||
| conn = store._get_conn() | ||
| assert conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
251 passed, 1 warning