void-ptr974 opened a new pull request, #26146: URL: https://github.com/apache/pulsar/pull/26146
### Motivation `ServiceUnitStateChannelImpl` keeps deferred owner lookups and inactive broker cleanup jobs in maps keyed by service unit or broker. Each entry is a future, and it can be replaced when the same lookup is retried or when a new cleanup is scheduled for the same broker. Before this change, some callbacks removed entries by key only. If an older callback ran after a newer future had already been installed for the same key, it could remove or cancel the newer work. Possible trigger cases include: - a deferred get-owner request completes while another lookup for the same service unit has already been queued - an inactive-broker cleanup job completes after a newer cleanup job has been scheduled for the same broker - a broker re-creation health-check callback returns after the cleanup job it observed has already been replaced The impact is broker-local ownership-channel state inconsistency. A newer get-owner request can lose its completion path and wait until timeout even when a later ownership event arrives. A newer inactive-broker cleanup job can be dropped or cancelled, delaying cleanup of orphan service units for an inactive broker. ### Modifications - Guard `getOwnerRequests` cleanup with the captured request future. - Guard `cleanupJobs` completion cleanup with the captured job future. - Guard broker-creation cleanup cancellation with the cleanup job observed before the async health check. - Add tests for stale get-owner and cleanup-job completion preserving newer futures. ### Verifying this change - `./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelTest.testCompletedGetOwnerRequestDoesNotRemoveNewRequest --tests org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelTest.testCompletedCleanupJobDoesNotRemoveNewCleanupJob` - `./gradlew :pulsar-broker:checkstyleMain :pulsar-broker:checkstyleTest` - `git diff --check` -- 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]
