void-ptr974 commented on PR #26146: URL: https://github.com/apache/pulsar/pull/26146#issuecomment-5065557354
Thanks for the question. While `F1` remains in `getOwnerRequests`, later lookups are still deduplicated to `F1`. A replacement becomes possible only after a state-event handler has intentionally removed `F1` before completing it. A concurrent lookup or completion continuation may then install `F2` before `F1`'s cleanup callback runs: ```text T1: map[serviceUnit] = F1 T2: event handler removes and completes F1 T3: a later lookup installs F2 T4: F1 cleanup runs T5: F2 completes and removes itself ``` With the previous unconditional `remove(serviceUnit)`, the cleanup at T4 could incorrectly remove `F2`. Using `remove(serviceUnit, F1)` only removes the future owned by that callback. This cannot retain `F1` indefinitely: if the conditional removal fails, the entry is either already absent or contains `F2`. A production `F2` created through `dedupeGetOwnerRequest` registers its own completion cleanup. I agree that the current test's direct `put` does not make this lifecycle clear. I will update it to create `F2` through the dedupe path, verify that completing `F1` preserves `F2`, and then verify that completing `F2` removes the map entry. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
