Skip to content

dash: archive, eviction and janitor delete by session id only, so one tenant's rows can be removed with another's #1069

Closed

Description

@boazdavid

Summary

Archiving, eviction and the janitor remove rows by session_id alone. On the hosted path the stored id is tenant:base (session.Scoped), so two tenants cannot normally share one; rows written another way (tests, direct inserts, an import) can. Archiving or evicting that id for one tenant can then delete the other tenant's rows. This is data loss, not a wrong figure.

Found in the review of #1064 (the fix for #501). Not reproduced: this comes from reading the code. A reproduction test should come first.

Where

On main:

  • dash/archive.go around line 297: DELETE FROM request_content WHERE request_id IN (SELECT id FROM requests WHERE session_id = ?).
  • dash/archive.go around line 345: DELETE FROM requests WHERE session_id = ?.
  • dash/janitor.go around line 382: DELETE FROM requests WHERE session_id = ?.
  • dash/store.go around line 1032: DELETE FROM requests WHERE session_id IN (...).
  • archived_sessions.session_id: dash/schema.go (comment near line 617) and dash/toolinventory_test.go (near line 660) call this a known defect, in the same shape as the tool inventory key that was already fixed by putting tenant_id first.

Proposal

  • Add tenant_id to every one of these WHERE clauses. The candidate lists (c.SessionID, victims) need to carry the tenant too.
  • Make tenant_id lead the key of archived_sessions, as tool_declarations already does.
  • Test: two tenants on one session id. Archive or evict one tenant. The other tenant's rows must stay.

Related: #501, #1064.

Update: fixed in #1064. Reachability is narrower than first written: see that PR.

Activity

  1. self-assigned this
    on Nov 11, 2026
  2. boazdavid commented on Nov 16, 2026

    @boazdavid
    CollaboratorAuthor

    Fixed in #1064 (merged 2026-11-11): the archive, janitor and eviction deletes now filter on (tenant_id, session_id), and archived_sessions is keyed PRIMARY KEY (tenant_id, session_id), with a migration for existing databases.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions