feat(auth): add refresh-token BulkDelete

InternalOAuthDoorkeeperRefreshTokensService.BulkDelete now marks up to 1,000 Doorkeeper refresh tokens deleted and returns how many rows it newly marked (gitlab-org/gitlab#632077 (closed)).

A request names tokens by token id, the owning_cell_id and source_id pair that is the row's key. Rails runs in many cells and its outbox row for a delete carries only the Rails id and the cell, so no signature travels. Spec 001 on !959 (closed) records the token-id key and the markers; the thread with Daniele below set the key. A delete never removes the row: one statement turns a live row into the marker !1069 (merged) introduced, token columns NULL and deleted_at set, and inserts a marker for an id with no row, so a later upsert for the id is refused whatever order Rails' paths deliver in. A resent delete adds nothing and a repeated id counts once, so deleted is idempotent. The row lock and the key serialise a delete against an upsert. One table-driven test pins the four interleavings: the marker lands before a first create, a create inserts before the delete, and a delete waits on a revoke or a rewrite that holds the row lock. On YugabyteDB either side may lose with a retryable error; the resend ends in the same marker. The call returns ABORTED on a write conflict or INTERNAL otherwise, and logs only a failure with the record count.

Two races have no test: a delete against a batch that upserts several ids, and a delete against a client delete. AGENTS.md states their outcome.

Read MarkDoorkeeperRefreshTokensDeleted in queries.sql and the BulkDelete integration tests first.

Part 10 of 13. The full change is in !959 (closed), the integration MR, kept open for the big picture.

  1. !988 (merged) feat(proto): add BulkUpsertClients and UpsertResult (merged)
  2. !989 (merged) feat(auth): add BulkUpsertClients with per-record results (merged)
  3. !990 (merged) refactor(auth): move the bulk record helpers to internal/batch (merged)
  4. !1010 (merged) fix(auth): decide refresh-token upserts in Go (merged)
  5. !1029 (merged) fix(auth): gate stored rows in one upsert helper and wait on the lock (merged)
  6. !1030 (merged) feat(auth): add a batch path to the refresh-token repository (merged)
  7. !1031 (merged) feat(proto): add BulkUpsert to the refresh-token service (merged)
  8. !991 (merged) feat(auth): add refresh-token BulkUpsert with per-record results (merged)
  9. !1069 (merged) feat(auth): refuse upserts for deleted refresh-token ids (merged)
  10. !992 (merged) feat(auth): add refresh-token BulkDelete <- this MR
  11. !1110 (merged) feat(auth): mark a deleted client's refresh tokens before the cascade
  12. !993 (merged) feat(auth): add refresh-token GetState
  13. !994 (merged) feat(auth): count bulk RPC records by outcome

Previous: !1069 (merged) · Next: !1110 (merged)

Edited by Shilpa Kundapur

Merge request reports

Loading
Loading