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

   ### Motivation
   The issue occurs when configuring 
   bookkeeperMetadataServiceUri=metadata-store:zk:metadata-store:2181/ledgers 
along with enabling:
   
   text
   
-Dbookkeeper.metadata.bookie.drivers=org.apache.pulsar.metadata.bookkeeper.PulsarMetadataBookieDriver
  
   
-Dbookkeeper.metadata.client.drivers=org.apache.pulsar.metadata.bookkeeper.PulsarMetadataClientDriver
  
   Root Cause Analysis
   The problem arises in AbstractMetadataDriver when creating 
MetadataStoreExtended. Specifically:
   
   The resolveLedgersRootPath() method has a bug in path parsing.
   
   When using ZooKeeper (ZK), the connection string typically includes a double 
slash (//) (e.g., zk://metadata-store:2181/ledgers), which ensures 
URI.getPath() correctly returns /ledgers.
   
   However, Pulsar’s metadata service connection string 
(metadata-store:zk:metadata-store:2181/ledgers) lacks the // prefix, causing 
URI.getPath() to incorrectly parse the ledger root path, defaulting to /ledgers 
regardless of the configured path.
   
   ```
   URI metadataServiceUri = URI.create(metadataServiceUriStr);
   String path = metadataServiceUri.getPath();
   return path == null ? BookKeeperConstants.DEFAULT_ZK_LEDGERS_ROOT_PATH : 
path;
   ```
   
   ### Modifications
   The fix should ensure proper path resolution regardless of the connection 
string format. Possible approaches:
   
   Normalize the connection string before parsing (e.g., ensure // is present 
for consistency).
   
   Improve resolveLedgersRootPath() to handle both formats (with or without //).
   
   Example: Extract the path segment after the last : or / if the URI parsing 
fails.
   
   Explicitly enforce a default /ledgers fallback only when path extraction 
fails.
   
   ### Verifying this change
   
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   
   
   - [ ] 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
   
   ### 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 -->
   - [ ] `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: <!-- ENTER URL HERE -->
   
   <!--
   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