Repository navigation
Conversation
Author
|
@LabsCrypt this PR's CI is green now. Before: Root cause & fix Head |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Idempotency keys are only consulted while a client may still retry the original request, but nothing removed them afterwards, so the table and its indexes grew without bound. The backend had no idempotency storage at all, so this adds the
IdempotencyKeymodel, its migration, and a retention worker that deletes keys older than seven days — structured exactly like the existing stream runway worker (immediate first sweep, then a repeating timer registered in the worker registry and cleared on shutdown).Related Issue
Changes
backend/prisma/schema.prisma— adds theIdempotencyKeymodel (iduuid, uniquekey,createdAt @default(now()),@@index([createdAt])) so the retention sweep is index-backed.backend/prisma/migrations/20260928000000_add_idempotency_key/migration.sql— creates the table, the unique index onkey, and thecreatedAtindex.backend/src/workers/idempotency-prune-worker.ts— exports the 7-day retention window,idempotencyRetentionCutoff,isExpiredIdempotencyKey,pruneExpiredIdempotencyKeys(PrismadeleteManyoncreatedAt < cutoff, logs the pruned count) andstartIdempotencyPruneWorker(immediate run + 24 h interval).backend/src/workers/index.ts— starts the prune worker instartWorkers()and clears its timer instopWorkers().backend/tests/idempotency-prune-worker.test.ts— 6 cases covering the retention window, the delete boundary, in-window preservation, the logged count, and the immediate-plus-interval scheduling.Verification Results
pruneExpiredIdempotencyKeysdeletescreatedAt < now - 7devery 24 hPruned <count> expired idempotency key(s) older than <cutoff>; assertedCloses #1495