lhotari opened a new pull request, #25942: URL: https://github.com/apache/pulsar/pull/25942
Fixes #25936 ### Motivation When the thread calling `WorkerUtils.createExclusiveProducerWithRetry` was interrupted while waiting for the producer creation to complete, the `InterruptedException` thrown by `Future.get` was swallowed by the generic `catch (Exception e)` retry handler. The retry loop kept running with the interrupt status cleared, and the in-flight `createAsync()` future was abandoned: when the exclusive producer was eventually created, nothing closed it, leaking the producer and holding on to the topic's exclusive producer access. The `.get(10, TimeUnit.SECONDS)` timeout had the same abandonment problem: a timed-out attempt left the pending producer creation behind while a new attempt was started, leaking an orphan exclusive producer. ### Modifications - Wait on the producer creation with `FutureUtil.getAndCleanupOnInterrupt(producerFuture, Producer::closeAsync)` so that an interrupt registers a cleanup that closes the producer if the pending creation completes later. - Handle `InterruptedException` explicitly: restore the interrupt status and propagate it, aborting the retry loop instead of retrying. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change added tests and can be verified as follows: - Added `WorkerUtilsTest.testCreateExclusiveProducerWithRetryClosesProducerOnInterrupt` verifying that an interrupt aborts the retry loop instead of retrying, restores the interrupt status, and closes the producer once the pending creation completes after the interrupt. ### Does this pull request potentially affect one of the following parts: *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment -- 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]
