Denovo1998 opened a new pull request, #24770:
URL: https://github.com/apache/pulsar/pull/24770

   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see 
*[Guideline - Pulsar PR Naming 
Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*. 
   
     - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from 
multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and 
this checklist, leaving only the filled out template below.
   -->
   
   <!-- Either this PR fixes an issue, -->
   
   Fixes #xyz
   
   <!-- or this PR is one task of an issue -->
   
   Main Issue: #xyz
   
   <!-- If the PR belongs to a PIP, please add the PIP link here -->
   
   PIP: #xyz 
   
   <!-- Details of when a PIP is required and how the PIP process work, please 
see: https://github.com/apache/pulsar/blob/master/pip/README.md -->
   
   ### Motivation
   
   **log:** https://gist.github.com/Denovo1998/c48c58c1de0270a4008ae77b6161adfb
   
   When running `ExtensibleLoadManagerImplTest`, testDisableBroker occasionally 
fails. There are two root causes:
   
   - In the test, disableBroker() was called on the third broker. Subsequently, 
during the shutdown process, disableBroker() will be called again through 
BrokerService. The exception log itself does not affect the test assertion.
   
   - More importantly, even after disabling, testDisableBroker will still call 
ternaryLoadManager.checkOwnershipAsync(...). At this time, the channel has 
cleaned up ownerships and unregistered. And when using the metadata-based 
`ServiceUnitStateTableViewImpl`, 
`ServiceUnitStateChannelImpl.getActiveOwnerAsync` will throw a 
`MetadataStoreException` because the brokerRegistry is not registered, causing 
`.get()` to return an ExecutionException.
   
   Semantically, a disabled/closed broker should no longer claim to own any 
bundle, nor should it trigger metadata liveness checks and exceptions in this 
state.
   
   Therefore, in the "Channel disable/closed" scenario, directly 
short-circuiting the "ownership" check to "no" avoids exceptions and stabilizes 
testing.
   
   ### Modifications
   
   Add handling of channel state in 
`org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl#getActiveOwnerAsync`,
 specifically as follows:
   
   - New channel status judgment:
     - When channelState is Disabled or Closed, the current broker cannot be an 
active owner:
       - If the table already has an owner and it is not the local machine (for 
example, the bundle has been assigned to another broker), then return the owner 
as is for upper-layer redirection;
       - If the owner in the table is the local machine or is empty, return 
Optional.empty().
   - When the channel is normal (not Disabled/Closed), keep the original logic 
unchanged:
     - Still throw MetadataStoreException when brokerRegistry.isRegistered() is 
false and using metadata-based table view (this branch is only triggered in 
non-disabled/shutdown state), directly return owner under in-memory table.
     - Still validate liveness according to the original logic through 
dedupeGetOwnerRequest and brokerRegistry.lookupAsync.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe 
tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/Denovo1998/pulsar/pull/11
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions 
will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since 
the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed 
in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments 
have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
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]

Reply via email to