Skip to content

feat(taskbroker): Add Canary Task Sending to Taskbroker - #752

Merged
george-sentry merged 4 commits into
mainfrom
george/push-taskbroker/send-canary-tasks
Jul 27, 2026
Merged

feat(taskbroker): Add Canary Task Sending to Taskbroker#752
george-sentry merged 4 commits into
mainfrom
george/push-taskbroker/send-canary-tasks

Conversation

@george-sentry

Copy link
Copy Markdown
Contributor

Linear

Refs STREAM-1606

Description

As of taskbroker-client version 0.20.10, every taskworker application gets an internal namespace with canary_task baked in. It would be nice to validate that brand new pools work properly by automatically sending a handful of these tasks on startup rather than manually creating and then tearing down a task generator.

This is less rigorous than spawning a task generator as it doesn't tell us whether the consumer works, but it does tell us whether the components from the fetch threads onwards work, which is already good.

@george-sentry
george-sentry requested a review from a team as a code owner July 13, 2026 20:51
@linear-code

linear-code Bot commented Jul 13, 2026

Copy link
Copy Markdown

STREAM-1606

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b95c1a0. Configure here.

Comment thread src/main.rs
}
// Get startup time after migrations and vacuum

canary_tasks::enqueue(&config, store.as_ref()).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Each replica enqueues duplicate canaries

Medium Severity

Every taskbroker process calls canary_tasks::enqueue on boot. With a shared Postgres activation store and horizontal scaling, each replica inserts another canary_tasks × worker_map batch with new UUIDs, so the same startup event can fan out far more internal canary work than the configured count intends.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b95c1a0. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm okay with this for now, but this is another good reason to send canary tasks into a topic shared by the entire pool.

Comment thread src/main.rs
}
// Get startup time after migrations and vacuum

canary_tasks::enqueue(&config, store.as_ref()).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: A transient database error when enqueuing canary tasks during startup will cause the entire broker to fail to start due to error propagation from canary_tasks::enqueue.
Severity: HIGH

Suggested Fix

Instead of using the ? operator to propagate errors from canary_tasks::enqueue, handle the Result with a match statement or if let Err(...). Log the error for debugging purposes but allow the broker startup process to continue, as canary task insertion is not a critical startup step.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/main.rs#L113

Potential issue: The call to `canary_tasks::enqueue(&config, store.as_ref()).await?`
uses the `?` operator, which propagates any errors. A transient database error during
this operation will cause the `main` function to exit, preventing the entire broker from
starting. Since canary tasks are a non-critical diagnostic feature, a failure during
their insertion should not be a fatal startup error. This is inconsistent with how other
non-critical startup tasks, like `full_vacuum_on_start`, handle errors gracefully.

Did we get this right? 👍 / 👎 to inform future reviews.

@george-sentry
george-sentry merged commit 037c987 into main Jul 27, 2026
29 checks passed
@george-sentry
george-sentry deleted the george/push-taskbroker/send-canary-tasks branch July 27, 2026 14:36
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.

2 participants