Skip to content

feat(clock-pulse): rollout TaskProducer as checkin_producer#117107

Merged
bmckerry merged 7 commits into
masterfrom
ben/clock-pulse-taskproducer
Jun 10, 2026
Merged

feat(clock-pulse): rollout TaskProducer as checkin_producer#117107
bmckerry merged 7 commits into
masterfrom
ben/clock-pulse-taskproducer

Conversation

@bmckerry

@bmckerry bmckerry commented Jun 8, 2026

Copy link
Copy Markdown
Member

Followup to #116788

This PR updates the checkin producer used by the clock_pulse task to use the new TaskProducer.

The reason for this change is that SingletonProducer doesn't guarantee at-least-once delivery when used inside a task. TaskProducer keeps track of any producer futures generated as a part of task execution, and only marks a task as successful if all producer futures succeed.

To ensure a safe rollout, workers will instantiate an instance of the old and new producer, and cut over to the new producer based on a rollout option. This means that task futures won't be properly tracked while the rollout option is <1.0, but since our base state is to just ignore producer futures that's acceptable.

This PR also adds a get_task_producer() helper function that fills in the TaskProducer metrics backend automatically.

@bmckerry bmckerry requested review from a team as code owners June 8, 2026 18:08
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 8, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 9786a7997f1415c0fc2e749df98b79a7c435d7ca. Configure here.

if in_random_rollout("tasks.producer.clock-pulse.rollout"):
_checkin_task_producer.produce(dest, payload)
else:
_checkin_producer.produce(dest, payload)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rollout evaluated per partition

Medium Severity

in_random_rollout runs inside the partition loop, so one clock_pulse invocation can send some pulses via _checkin_task_producer and others via _checkin_producer. Task completion then tracks only the TaskProducer futures, while other pulses may still be in flight on the singleton path.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9786a7997f1415c0fc2e749df98b79a7c435d7ca. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is expected

Comment thread src/sentry/issues/producer.py
@bmckerry bmckerry force-pushed the ben/clock-pulse-taskproducer branch from 9786a79 to 8b5b5d4 Compare June 8, 2026 18:12
@bmckerry

bmckerry commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Converting to draft, needs a taskbroker version bump to work properly

@bmckerry bmckerry marked this pull request as draft June 8, 2026 18:56
_occurrence_task_producer = get_task_producer(
producer_name="sentry.issues.tasks.producer",
producer_factory=partial(_get_occurrence_producer, name="sentry.issues.tasks.producer"),
metrics_backend=SentryMetricsBackend(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

was removing this intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@bmckerry bmckerry marked this pull request as ready for review June 9, 2026 16:48
Comment thread src/sentry/monitors/tasks/clock_pulse.py
Comment thread src/sentry/monitors/tasks/clock_pulse.py
@bmckerry bmckerry merged commit 7b6049f into master Jun 10, 2026
85 checks passed
@bmckerry bmckerry deleted the ben/clock-pulse-taskproducer branch June 10, 2026 14:59
bmckerry added a commit that referenced this pull request Jun 10, 2026
…er (#117360)

Followup to #117107 

This PR updates the snapshot producer used by several tasks to use the
new `TaskProducer`.

The reason for this change is that SingletonProducer doesn't guarantee
at-least-once delivery when used inside a task. TaskProducer keeps track
of any producer futures generated as a part of task execution, and only
marks a task as successful if all producer futures succeed.

To ensure a safe rollout, workers will instantiate an instance of the
old and new producer, and cut over to the new producer based on a
rollout option. This means that task futures won't be properly tracked
while the rollout option is <1.0, but since our base state is to just
ignore producer futures that's acceptable.
bmckerry added a commit that referenced this pull request Jun 16, 2026
`KafkaPublisher` was a deprecated Kafka producer API which was only
still used in replay deletion tasks and replay linking in postprocess.
This PR moves all instances where `KafkaPublisher` was used over to the
existing `sentry.replays.lib.kafka.publish_replay_event` function, which
is backed by `SingletonProducer`. It also fixes corresponding tests, and
completely deletes `KafkaPublisher` from the codebase.

This is a step towards migrating replay-related tasks to use
taskbroker-client's `TaskProducer` abstraction (similar to what I've
done in #117081,
#117107,
#117360). I'll open up another
PR stacked on top of this one that adds the rollout code for
`TaskProducer`.
sehr-m pushed a commit that referenced this pull request Jun 23, 2026
`KafkaPublisher` was a deprecated Kafka producer API which was only
still used in replay deletion tasks and replay linking in postprocess.
This PR moves all instances where `KafkaPublisher` was used over to the
existing `sentry.replays.lib.kafka.publish_replay_event` function, which
is backed by `SingletonProducer`. It also fixes corresponding tests, and
completely deletes `KafkaPublisher` from the codebase.

This is a step towards migrating replay-related tasks to use
taskbroker-client's `TaskProducer` abstraction (similar to what I've
done in #117081,
#117107,
#117360). I'll open up another
PR stacked on top of this one that adds the rollout code for
`TaskProducer`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants