Skip to content

Release: idempotency retention sweep (#73) - #74

Merged
Poojithvsc merged 1 commit into
mainfrom
dev
Jun 5, 2026
Merged

Release: idempotency retention sweep (#73)#74
Poojithvsc merged 1 commit into
mainfrom
dev

Conversation

@Poojithvsc

Copy link
Copy Markdown
Owner

Bounds the growth of ordering.idempotency_keys — the unbounded-growth limitation deferred in ADR-0014 (Phase 14).

What shipped

  • IdempotencyRetention@Scheduled sweep deleting claims older than shopsphere.ordering.idempotency.ttl (default PT24H), at fixed delay shopsphere.ordering.idempotency.sweep-interval (default PT1H). Logic lives in a package-private sweep(); the schedule only delegates.
  • IdempotencyKeys.deleteOlderThan(cutoff) — the DELETE … WHERE created_at < ?.
  • OrderingConfig@EnableScheduling, scoped to the Ordering module.
  • Flyway V13 — index on created_at so the periodic delete avoids a full scan (PK is (customer_id, idempotency_key)).
  • IdempotencyRetentionIT — backdated key swept, fresh key survives.
  • ADR-0014 updated to record the closed limitation.

Acceptance criteria (#73)

  • Records older than the configured TTL removed automatically (scheduled)
  • TTL configurable with a documented default (PT24H)
  • IT: backdated key → swept; fresh key survives
  • No dedupe regression — Phase-14 IdempotencyKeyIT stays green (default TTL ≫ test lifetime)
  • mvn verify green (94 tests)
  • ADR note referencing ADR-0014's deferred cleanup

Closes #73.

🤖 Generated with Claude Code

The ordering.idempotency_keys table grew unbounded — every keyed
POST /api/v1/orders inserted a row and nothing removed it (the honest
limitation deferred in ADR-0014). Add a scheduled retention sweep that
deletes claims older than a configurable TTL.

- IdempotencyRetention: @scheduled sweep deleting claims older than
  shopsphere.ordering.idempotency.ttl (default PT24H), at fixed delay
  shopsphere.ordering.idempotency.sweep-interval (default PT1H). The
  package-private sweep() carries the logic so it can be driven
  deterministically from a test; the schedule only delegates.
- IdempotencyKeys.deleteOlderThan(cutoff): the DELETE by created_at.
- OrderingConfig: @EnableScheduling, scoped to the Ordering module.
- Flyway V13: index on created_at so the periodic DELETE avoids a full
  scan (PK is on (customer_id, idempotency_key)).
- IdempotencyRetentionIT: backdated key swept, fresh key survives.

The 24h default is a wide margin over a legitimate retry window, so the
sweep never races live dedupe and the Phase-14 IdempotencyKeyIT dedup
scenarios stay green. ADR-0014 updated to record the closed limitation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Poojithvsc
Poojithvsc merged commit 19db067 into main Jun 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retention sweep for ordering.idempotency_keys (unbounded growth)

1 participant