Skip to content

graph: limit concurrent personal data exports #3970

Description

@pbleser-oc

The personal data export (POST /graph/v1.0/users/{userID}/exportPersonalData) answers 202 right away and does the actual work in a background goroutine. Nothing limits how many of these run at the same time, neither per user nor overall.

Why it matters

Each export loads all events of the user from the event history (plus the Keycloak report, if configured), builds the whole JSON document in memory, and uploads it into the user's personal space. For a user with a long history, this takes time and memory.

  • Per user: a user can start a new export while the previous one is still running. Every run holds its own copy of the data in memory, and all of them write to the same file, so only the last result is kept and the other runs are wasted work. A per-user rate limit on starting exports (being added separately) reduces this, but doesn't prevent it: when an export takes longer than the interval the limit allows, runs still overlap.
  • Overall: many users, or many accounts of one person, can start exports at the same time, and there is no upper bound on how many run in parallel in one graph instance.
  • The goroutines are not tied to the service's lifecycle: they aren't cancelled or waited for on shutdown.

Proposal

  1. At most one running export per user (per graph instance): while an export of the user is running, a new request is rejected, e.g. with 409 Conflict and an error message saying that an export is already in progress. The web client would need to handle that response.
  2. A global cap on concurrent exports per graph instance (configurable), with requests beyond it either rejected (429 or 503 with Retry-After) or queued.

Both are in memory and per graph instance, which is enough to protect each instance; they don't need a shared store.

Open questions

  • Which status code for "already running": 409, or 429 like the rate limit?
  • Reject or queue when the global cap is reached?
  • Should the export be cancelled on shutdown, and should a cancelled export leave the (empty) target file behind?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions