Repository navigation
Open
Description
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
- 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 Conflictand an error message saying that an export is already in progress. The web client would need to handle that response. - A global cap on concurrent exports per graph instance (configurable), with requests beyond it either rejected (
429or503withRetry-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, or429like 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?
Activity