Skip to content

bug(server): in-memory SQLite loses objects schema during Podman sandbox cleanup #3173

Description

@EmilienM

Description

An OpenShell gateway started with --db-url sqlite::memory: can lose its
migrated schema during concurrent Podman sandbox cleanup. DeleteSandbox then
fails with no such table: objects, even though the same gateway successfully
created and operated the sandbox immediately beforehand.

Changing only the gateway database URL to a temporary file-backed SQLite
database eliminated the failure in the same end-to-end test suite.

Actual behavior

The sandbox and agent command complete successfully (Agent exit code: 0).
During cleanup, openshell sandbox delete fails:

Failed to delete sandbox ci: code: 'Internal error', message:
"fetch sandbox failed: database error: error returned from database:
(code: 1) no such table: objects"

subprocess.CalledProcessError: Command
['openshell', 'sandbox', 'delete', 'ci'] returned non-zero exit status 1.

The gateway log shows the container deletion event and subsequent persistence
failure:

Container already removed when inspecting after event, emitting deleted event
Failed to apply compute driver event ... no such table: objects
DeleteSandbox ... rpc.grpc.status_code=13
gateway shutdown cleanup failed: failed to list sandboxes ... no such table: objects

This affected two OpenCode-backed sandbox runs in the suite. The agent command
and plugin-filter assertions themselves succeeded; only gateway cleanup failed.

Failing run: https://github.com/opendatahub-io/agentic-ci/actions/runs/33809097313/job/100827079164

Result: 60 passed, 2 failed.

Expected behavior

An explicitly configured in-memory SQLite gateway should retain its migrated
schema for the gateway process lifetime. Concurrent sandbox cleanup must not
replace the database with a fresh schema-less in-memory connection.

If in-memory SQLite is not supported for a running gateway, the CLI should
reject that database URL rather than accept it and fail later during lifecycle
operations.

Controlled comparison

The integration changed the gateway from:

--db-url sqlite::memory:

to a unique temporary file:

--db-url sqlite:/path/to/gateway-<unique>.db?mode=rwc

No OpenShell version, sandbox image, supervisor image, harness, policy, or test
scenario changed.

Change: opendatahub-io/agentic-ci@90aa110

Passing run: https://github.com/opendatahub-io/agentic-ci/actions/runs/33823773323/job/100872224289

Result: 62 passed, 0 failed, with no no such table or database errors.

Suspected mechanism

This is a hypothesis based on the observed transition, not a confirmed source
attribution. OpenShell correctly limits in-memory SQLite to one pooled
connection. If SQLx discards that connection after a cancelled or failed
operation during concurrent deletion, its replacement is a new independent
in-memory database without the migrations or objects table.

Relevant upstream areas:

  • crates/openshell-server/src/persistence/sqlite.rs: in-memory pool setup and migrations
  • crates/openshell-server/src/compute/mod.rs: request-side deletion and compute-driver event reconciliation
  • crates/openshell-driver-podman/src/watcher.rs: container deletion events

The cleanup path is related to the persistence contention discussed in #2999,
but the observed error differs: this report sees a missing schema with an
in-memory database rather than database is locked with file-backed SQLite.

Environment

  • Linux GitHub Actions runner
  • Privileged CI container
  • Rootful Podman compute driver
  • TLS and mTLS enabled
  • Gateway launched directly with sqlite::memory:
  • Persistent canonical sandbox main: --detach -- sleep infinity
  • Agent commands executed through openshell sandbox exec

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-neededOpened without agent diagnostics and needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions