fix(opencode): a -wal left without its -shm is read, not ignored (Issue #60, Linux item 5, review)
_ro_connect read every database without both sidecars as immutable, which skips a -wal's committed rows: a recovered DB+WAL with no -shm showed no sessions (planner-reviewer-codex-01). That state - no writer runs without a -shm - is now read from a private DB+WAL copy, where SQLite may rebuild the index, loaded into memory; nothing beside the source is touched. The query matrix gains the walonly state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
463817ee34
commit
7803d47026
2 files changed
+28
-9
No files matched your search
@@ -135,8 +135,9 @@ def _wal_writer(db: Path, ws: Path) -> sqlite3.Connection:
|
||||
@pytest.fixture
|
||||
def wal_home(tmp_path, monkeypatch):
|
||||
"""(adapter, ctx, db, ws, make(state)) - make builds the database in one
|
||||
of three states: `clean` (closed: no sidecars), `leftover` (both sidecars
|
||||
of four states: `clean` (closed: no sidecars), `leftover` (both sidecars
|
||||
left behind by a writer that is gone, the rows only in the -wal),
|
||||
`walonly` (the same without its -shm: the committed rows still count),
|
||||
`writer` (a live writer whose rows are only in the -wal)."""
|
||||
home, ws = tmp_path / "home", tmp_path / "ws"
|
||||
ws.mkdir()
|
||||
@@ -150,11 +151,11 @@ def wal_home(tmp_path, monkeypatch):
|
||||
def make(state):
|
||||
if state == "clean":
|
||||
_wal_writer(db, ws).close()
|
||||
elif state == "leftover":
|
||||
elif state in ("leftover", "walonly"):
|
||||
src = tmp_path / "src" / "opencode.db"
|
||||
src.parent.mkdir()
|
||||
conn = _wal_writer(src, ws)
|
||||
for suffix in ("", "-wal", "-shm"):
|
||||
for suffix in ("", "-wal", "-shm")[:3 if state == "leftover" else 2]:
|
||||
shutil.copyfile(str(src) + suffix, str(db) + suffix)
|
||||
conn.close()
|
||||
else:
|
||||
@@ -170,6 +171,7 @@ def wal_home(tmp_path, monkeypatch):
|
||||
@pytest.mark.parametrize("state,listing", [
|
||||
("clean", ["opencode.db"]),
|
||||
("leftover", ["opencode.db", "opencode.db-shm", "opencode.db-wal"]),
|
||||
("walonly", ["opencode.db", "opencode.db-wal"]),
|
||||
("writer", ["opencode.db", "opencode.db-shm", "opencode.db-wal"]),
|
||||
])
|
||||
def test_a_query_reads_right_and_leaves_the_sidecars_alone(wal_home, state, listing, query):
|
||||
|
||||
Reference in new issue
Block a user