Skip to content

Conversation

@akramcodez
Copy link

Summary

Fixes the stampeding lock problem where Sentry App tokens share the same proxy_user_id as their outbox shard_identifier, causing severe lock contention.

Closes #105425

Changes

  • Override outboxes_for_update() on ApiToken to use token.id as shard_identifier
  • Add tests to verify sharding behavior

Before vs After

Scenario Before (user_id) After (token.id)
Sentry App with 10K installations 1 shard, all serialized 10K shards, fully parallel
User with 5 tokens 1 shard, serialized 5 shards, parallel

Testing

  • Added unit tests for outbox sharding behavior
  • Verified Sentry App tokens with same proxy_user get different shards
  • Verified explicit shard_identifier override still works

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hybridcloud): ApiToken outbox sharding causes lock contention due to proxy_user

1 participant