Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2f3096e05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| agentToken = t | ||
| return nil | ||
| }) | ||
| orgQuota, err := s.findQuotaForNewAgent(r.Context(), agentType.OrganizationID.String()) |
There was a problem hiding this comment.
Coalesce quota loads before bypassing the registration lock
When an organization's five-minute quota cache entry is cold or expired and many agents register concurrently, every request now reaches this lookup before acquiring the advisory lock. getQuotaWithTTL performs an unsynchronized cache miss followed by loadQuota, while FeatureHubProvider opens a new gRPC connection for each load, so a registration burst can fan out into one Feature Hub request per agent and reject valid registrations if the resulting calls overload or fail. Add per-organization request coalescing to the quota client, or retain serialization specifically for cache misses.
Useful? React with 👍 / 👎.
d2f3096 to
29f8276
Compare
… lock Agent registration took the organization-wide advisory lock and then fetched the organization quota while holding it. On a quota cache miss that is a call to the feature service, and every other registration for the organization queues behind it. Fetch the quota (and reject when the feature is not available) before taking the lock. The lock now only covers counting the registered agents and inserting the new one, so the quota check stays atomic. Error responses are unchanged.
…onnection pool The test environment defaults to a pool of one connection, which serializes the goroutines, so the test passed even with the register lock removed. Widen the pool for that test and restore it afterwards.
29f8276 to
36a8528
Compare
Agent registration takes a per-organization advisory lock so the agent count and the insert stay atomic against the quota. The quota lookup (a cache hit most of the time, a remote call on a miss) ran inside that lock, so a miss stalled every registration for the organization. It now runs before the lock; only the count and the insert stay inside it.