Repository navigation
PartitionAvailabilityTracker self-retains after the final producer owner is dropped
#4684
helenalgebra
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
PartitionAvailabilityTracker::startspawns a detached task that captures a strongArcto the tracker. The tracker’sDropimplementation signals that task to terminate, but the task-heldArcpreventsDropfrom running after the finalTopicProducerowner is dropped.The resulting ownership cycle is:
startconstructs anArc<PartitionAvailabilityTracker>.shared_tracker.shared_tracker.terminateis notified.Drop for PartitionAvailabilityTrackeris the only code that notifiesterminate.Arcprevents thatDropduring normal executor operation.Current source:
https://github.com/fluvio-community/fluvio/blob/master/crates/fluvio/src/producer/mod.rs
Impact
Each independently constructed
TopicProducerstarts an availability tracker. Dropping all handles to that producer does not release the tracker or stop its task.The retained task is active rather than merely allocated: it continues waking once per second and querying the topic and partition stores. Applications that repeatedly construct and retire producers can therefore accumulate background tasks and retained tracker state for the lifetime of the executor.
Clones of one
TopicProducershare the same tracker, so this concerns independently constructed producers rather than individual cloned handles.Suggested invariant
After the final externally reachable owner of a producer is dropped, its availability tracker must stop retaining itself and eventually become unreachable.
A focused unit regression could:
PartitionAvailabilityTracker.Weakreference to it.Arc.Weak::upgrade()returnsNone.Repeating this sequence would also detect task accumulation across producer construction and retirement.
Possible fix direction
The task should not own the object whose
Dropis responsible for stopping that task. Two possible approaches are:Weak<PartitionAvailabilityTracker>and hold any upgraded strong reference only for a bounded update operation, releasing it before sleeping.Either approach should preserve the current partition-refresh behavior while allowing normal producer ownership to determine the tracker’s lifetime.
All reactions