Repository navigation
fix(agent-backup): turso_client pipeline chunks preserve the session (#8545) - #11258
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
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. |
What
Fixes #8545 —
turso_clientpipeline chunks now preserve the session, so a history-enabledload_rowsbatch no longer loses itsrde_incomingstaging table mid-load.The defect (Codex finding on PR #8544, comment 4534316362):
Turso.executechunks a batch into pipeline calls of at most 100 statements, and each_pipelinecall opened a fresh libsql session (no baton carried,closeappended every time). A 100-row history-enabled page builds CREATE TEMP TABLE + 100 INSERTs + the archive INSERT..SELECT + the upsert in one batch — past the first chunk boundary the temp table no longer existed, so the archive/merge statements failed. File mode was unaffected (one sqlite connection), which is why local staging never showed it.Changes (
pkgs/agent-backup/turso_client.py)_pipeline(statements, close=…)sends the stored baton so the next call resumes the same session, records the baton each response returns, and appends thecloserequest only when told to.executepassesclose=finalper chunk — one session per batch, closed by the last chunk — and on any mid-batch failure drops the session best-effort (_drop_session), so a failed batch's temp tables can't leak into the next batch.~/tools/runtime-db-export/turso_client.pyreceived the identical fix in the same pass (it lives outside this repo; verified there separately), so the copies do not diverge on this defect.Tests
New
pkgs/agent-backup/test_turso_client.py(stdlib unittest): a fake Hrana HTTP server whose sessions are separate in-memory SQLite databases — reproducing temp-table visibility faithfully.test_temp_table_survives_chunk_boundary: the load_rows shape (CREATE TEMP + 150 INSERTs + archive INSERT..SELECT + DROP) completes across ≥2 pipeline calls on one session; the session is closed afterwards. Fails on the pre-fix client, passes with the fix (verified by stashing).test_failed_batch_drops_its_session: a batch failing in its second chunk raises, leaves no baton/session behind, and the next batch starts clean.Queue: task 20172 (repo-health-code-pilot), lane any-m.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.