feat(clock-pulse): rollout TaskProducer as checkin_producer#117107
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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) |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 9786a7997f1415c0fc2e749df98b79a7c435d7ca. Configure here.
9786a79 to
8b5b5d4
Compare
|
Converting to draft, needs a taskbroker version bump to work properly |
| _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(), |
There was a problem hiding this comment.
was removing this intentional?
There was a problem hiding this comment.
yes, get_task_producer() now handles instantiating the metrics backend: https://github.com/getsentry/sentry/pull/117107/changes#diff-c6948a9b5ad1d35d6c2187062eb4063c51988ac1159f17f1c16ea420ee5773beR19
…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.
`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`.
`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`.


Followup to #116788
This PR updates the checkin producer used by the
clock_pulsetask to use the newTaskProducer.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 theTaskProducermetrics backend automatically.