Skip to content

feat: BLQ router v2#7954

Open
kylemumma wants to merge 8 commits into
masterfrom
krm/blq2
Open

feat: BLQ router v2#7954
kylemumma wants to merge 8 commits into
masterfrom
krm/blq2

Conversation

@kylemumma
Copy link
Copy Markdown
Member

@kylemumma kylemumma commented May 20, 2026

My last attempt to deploy the BLQ failed. It encountered crash loop issues related to the state-machine I built in the logic. This is a second attempt. I did a large refactor to make everything simpler and less prone to error. I would like to test this in s4s2 to see how it does.

This shouldn't effect anything in prod since its behind a feature flag and nothing uses the blq yet so it should be safe.

Usage

set the flag consumer.blq_enabled="my-consumer-group" this will restart the consumer group and drain the backlog. once the backlog is drained, behavior goes back to normal. to trigger the blq mechanism again, you can flip the flag off and on again.


The following is AI-Generated

Summary

  • consumer.blq_enabled is now a string (the physical consumer group to enable for) instead of a global boolean, so BLQ can be toggled per consumer group.
  • Replaces the 4-state routing FSM with a simple blq_active: bool that starts from the flag and flips off (one-way, until restart) the first time a fresh message arrives.
  • Adds a runtime kill switch: poll() watches for the flag flipping from off→on for this consumer group and calls exit_fn (defaults to std::process::exit(0)), so the consumer restarts with clean downstream state and re-enters BLQ mode on the next stale message.

Test plan

  • cargo test --lib strategies::blq_router — both new tests pass:
    • test_shutoff_until_flag_flips — with the flag off, fresh + stale both forward to next_step; flipping the flag on for this consumer group triggers exit_fn on the next poll().
    • test_blq_routes_stale_then_disables_on_fresh — with the flag on, stale messages go to the producer; first fresh message flips blq_active off; subsequent fresh + stale both go to next_step.
  • cargo build succeeds.

🤖 Generated with Claude Code

@kylemumma kylemumma requested a review from a team as a code owner May 20, 2026 22:16
@kylemumma kylemumma changed the title BLQ router: per-consumer-group kill switch + simplified routing feat: BLQ router v2 May 20, 2026
Comment thread rust_snuba/src/strategies/blq_router.rs Outdated
Comment thread rust_snuba/src/strategies/blq_router.rs
Comment thread rust_snuba/src/strategies/blq_router.rs
Comment thread rust_snuba/src/strategies/blq_router.rs
Comment thread rust_snuba/src/strategies/blq_router.rs
Comment thread rust_snuba/src/strategies/blq_router.rs
Comment thread rust_snuba/src/strategies/blq_router.rs
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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.

There are 2 total unresolved issues (including 1 from previous review).

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 7a14ed5. Configure here.

Comment thread rust_snuba/src/strategies/blq_router.rs
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