Skip to content

fix: isolate sandbox reads from request transactions - #5

Open
wgu9 wants to merge 1 commit into
OpenHands:mainfrom
wgu9:fix/isolated-sandbox-read-sessions
Open

fix: isolate sandbox reads from request transactions#5
wgu9 wants to merge 1 commit into
OpenHands:mainfrom
wgu9:fix/isolated-sandbox-read-sessions

Conversation

@wgu9

@wgu9 wgu9 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Inject the existing async_sessionmaker into RemoteSandboxService and use short-lived sessions for pure database reads that are followed by runtime API calls. This keeps those reads from opening or committing the request-scoped transaction.

The isolated path now covers get_sandbox, search_sandboxes, get_sandbox_by_session_api_key, batch_get_sandboxes, and the database cross-reference in _get_user_running_sandboxes. Write paths continue using the shared request session, so their existing atomic behavior is unchanged.

This implements the productionization direction from OpenHands/OpenHands#16374 without relying on SQLAlchemy private APIs.

Closes OpenHands/OpenHands#16374

Testing

  • TMPDIR=/tmp .venv/bin/pytest -q tests/unit/app_server: 1501 passed
  • tests/unit/app_server/test_remote_sandbox_service.py: 112 passed
  • full pre-commit: trailing whitespace, EOF, YAML, debug statements, AppMode check, pyproject validation, Ruff, Ruff format, and mypy passed
  • five real SQLite regression cases verify that pure read paths do not commit a pending sibling write on the request session

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.

RemoteSandboxService: extend dedicated read-session fix to remaining read paths (follow-up to #14769, finding #1)

1 participant