Skip to content

fix(agent-backup): turso_client pipeline chunks preserve the session (#8545) - #11258

Merged
dezren39 merged 1 commit into
mainfrom
queue/20172-8545-turso-session
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/20172-8545-turso-session

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What

Fixes #8545 — turso_client pipeline chunks now preserve the session, so a history-enabled load_rows batch no longer loses its rde_incoming staging table mid-load.

The defect (Codex finding on PR #8544, comment 4534316362): Turso.execute chunks a batch into pipeline calls of at most 100 statements, and each _pipeline call opened a fresh libsql session (no baton carried, close appended 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)

  • The client now keeps the session baton: _pipeline(statements, close=…) sends the stored baton so the next call resumes the same session, records the baton each response returns, and appends the close request only when told to.
  • execute passes close=final per 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.
  • The hatch original at ~/tools/runtime-db-export/turso_client.py received 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.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 11:28
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T11:28:11.936816Z
We couldn’t complete this review. Comment @codex review to try again.
05b226c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46840ee7-eda8-4bcf-9d73-b188d5edb877
Commits

Reviewing files that changed from the base of the PR and between 790945d and 05b226c.

Files selected for processing: 2

  • pkgs/agent-backup/test_turso_client.py
  • pkgs/agent-backup/turso_client.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@dezren39
dezren39 merged commit 84c07af into main Nov 17, 2026
1 check passed
@dezren39
dezren39 deleted the queue/20172-8545-turso-session branch November 17, 2026 11:29
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.

id: turso_client pipeline chunks lose the session (rde_incoming vanishes mid-load)

1 participant