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

   cherry pick #14336 to branch 2.7
   
   ### Motivation
   If the rack name set in the following case:
   -  Enabled rack aware placement policy, and user set rack name which 
contains "/" in addition to the head and tail of the string. Such as "/r/a" or 
"r/a/b"
   - Enabled region aware placement policy, and user set the rack name which 
contains multiple "/" in addition to the head and tail of the string. Such as 
"/region/region/a" or "region/a/rack/b"
   
   The broker will throw the following exception on `onBookieRackChange`
   ```
   10:29:08.112 [BookKeeperClientScheduler-OrderedScheduler-0-0] ERROR 
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy - Unexpected 
exception while handling joining bookie test.bk3:3183
   org.apache.bookkeeper.net.NetworkTopologyImpl$InvalidTopologyException: 
Invalid network topology. You cannot have a rack and a non-rack node at the 
same level of the network topology.
           at 
org.apache.bookkeeper.net.NetworkTopologyImpl.add(NetworkTopologyImpl.java:417) 
~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy.handleBookiesThatJoined(TopologyAwareEnsemblePlacementPolicy.java:719)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl.handleBookiesThatJoined(RackawareEnsemblePlacementPolicyImpl.java:80)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy.handleBookiesThatJoined(RackawareEnsemblePlacementPolicy.java:249)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy.onClusterChanged(TopologyAwareEnsemblePlacementPolicy.java:663)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl.onClusterChanged(RackawareEnsemblePlacementPolicyImpl.java:80)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy.onClusterChanged(RackawareEnsemblePlacementPolicy.java:92)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.BookieWatcherImpl.processWritableBookiesChanged(BookieWatcherImpl.java:197)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.client.BookieWatcherImpl.lambda$initialBlockingBookieRead$1(BookieWatcherImpl.java:233)
 ~[org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.discover.ZKRegistrationClient$WatchTask.accept(ZKRegistrationClient.java:147)
 [org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
org.apache.bookkeeper.discover.ZKRegistrationClient$WatchTask.accept(ZKRegistrationClient.java:70)
 [org.apache.bookkeeper-bookkeeper-server-4.14.3.jar:4.14.3]
           at 
java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
 [?:?]
           at 
java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
 [?:?]
           at 
java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
 [?:?]
           at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
           at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
           at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
 [?:?]
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
[?:?]
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
[?:?]
           at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
 [io.netty-netty-common-4.1.72.Final.jar:4.1.72.Final]
           at java.lang.Thread.run(Thread.java:834) [?:?]
   ```
   
   ### Modification
   1. Validate the rack name when setting the bookie rack info. 
      - For rack aware placement policy, the rack name shouldn't contains "/" 
in addition to the head and tail of the rack name string. 
      - For region aware placement policy, the rack name should  only contains 
one "/" in addition to the head and tail of the rack name string.
   
   
   Need to update docs? 
   
   - [x] `doc-required` 
     
     (If you need help on updating docs, create a doc issue)
     
   - [ ] `no-need-doc` 
     
     (Please explain why)
     
   - [ ] `doc` 
     
     (If this PR contains doc changes)
   
   
   


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