fix(alerter): honor configured query concurrency#1111
Open
Conversation
Honor the configured alerter concurrency when throttling query execution. A reported scheduling drift bug showed alert rules running well past their configured interval under load because workers were still gated by a hard-coded queue depth of 5, even when the alerter was configured for higher concurrency. Create the worker queue from the configured concurrency and pass it through the executor to each worker. Expanding the queue this way helps due rules start closer to their specified schedule when many queries become runnable at once, while preserving the historical fallback for callers that do not set concurrency. Refs: alert scheduling drift bug report Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the alerter’s query execution throttling so it honors the configured --concurrency setting rather than using a fixed global queue depth, improving schedule adherence when many rules become runnable at once.
Changes:
- Replace the fixed global worker queue with a per-executor queue sized from configured concurrency (with a default fallback).
- Thread the queue into workers via
ExecutorOpts/WorkerConfiginstead of using a global package variable. - Add regression tests covering configured and default queue sizing, plus queue propagation to workers.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| alerter/service.go | Passes configured concurrency into the engine executor for both service and lint paths. |
| alerter/queue/queue.go | Replaces the global queue with New(concurrency) and a DefaultConcurrency fallback. |
| alerter/engine/executor.go | Creates and owns the query slot semaphore based on configured concurrency; passes it to workers. |
| alerter/engine/worker.go | Uses the injected semaphore instead of the previous global queue. |
| alerter/engine/executor_test.go | Adds tests for configured/default concurrency and for passing the queue to workers. |
Avoid blocking indefinitely on query slot acquisition during shutdown by selecting on ctx.Done() while waiting for a slot. Also make the default-concurrency assertion use queue.DefaultConcurrency and add a regression test covering canceled slot acquisition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkeesey
requested changes
Apr 7, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Why
When many alert rules become runnable at once, the old fixed queue could delay query starts even if the alerter was configured for higher concurrency. Using the configured concurrency helps executions occur closer to each rule's specified schedule under load.