Skip to content

fix(alerter): honor configured query concurrency#1111

Open
jessejlt wants to merge 5 commits intomainfrom
fix-configurable-alerter-queue
Open

fix(alerter): honor configured query concurrency#1111
jessejlt wants to merge 5 commits intomainfrom
fix-configurable-alerter-queue

Conversation

@jessejlt
Copy link
Copy Markdown
Member

@jessejlt jessejlt commented Apr 7, 2026

Summary

  • honor the configured alerter concurrency when building the query execution queue
  • pass that queue through the executor to workers instead of using a fixed global depth of 5
  • add regression tests for configured and default queue behavior

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.

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/WorkerConfig instead 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@jessejlt jessejlt marked this pull request as ready for review April 7, 2026 16:15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jessejlt jessejlt requested a review from Copilot April 7, 2026 17:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants