You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UpdateLastTimeUsed fires on every authenticated request and is one of the largest sources of dead-tuple churn on team_api_keys, for a column that is minute-grade observability metadata. An in-process per-key debounce (60s window) keeps last_used fresh to the minute while removing almost all of that write load; with multiple auth replicas the worst case is one write per key per replica per minute.
Low Risk
Behavior change is limited to throttling observability metadata writes; auth and authorization paths are unchanged aside from fewer background DB updates.
Overview
Authenticated API key lookups no longer trigger a team_api_keys.last_used update on every request. A per-process, per-key 60-second debounce decides whether to run the existing async UpdateLastTimeUsed call, with compare-and-swap so concurrent requests after the window still produce only one write, and occasional map sweeps so idle keys do not grow memory forever. last_used stays accurate to about a minute; with multiple auth replicas the upper bound is roughly one write per key per replica per minute. Unit tests cover window suppression, key independence, and concurrent single-winner behavior.
Reviewed by Cursor Bugbot for commit 7c37367. Bugbot is set up for automated code reviews on this repo. Configure here.
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
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.
Summary
UpdateLastTimeUsedfires on every authenticated request and is one of the largest sources of dead-tuple churn onteam_api_keys, for a column that is minute-grade observability metadata. An in-process per-key debounce (60s window) keepslast_usedfresh to the minute while removing almost all of that write load; with multiple auth replicas the worst case is one write per key per replica per minute.