heesung-sn commented on code in PR #23152:
URL: https://github.com/apache/pulsar/pull/23152#discussion_r1714369685


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -325,6 +325,16 @@ public synchronized void start() throws 
PulsarServerException {
                             
ServiceUnitStateCompactionStrategy.class.getName()))
                     .create();
             tableview.listen((key, value) -> handle(key, value));
+            tableview.forEach((serviceUnit, data) -> {
+                if (debug) {
+                    log.info("Loaded the service unit state data. serviceUnit: 
{}, data: {}", serviceUnit, data);
+                }
+                ServiceUnitState state = state(data);
+                if (state.equals(Owned) && isTargetBroker(data.dstBroker())) {
+                    pulsar.getNamespaceService()
+                            
.onNamespaceBundleOwned(LoadManagerShared.getNamespaceBundle(pulsar, 
serviceUnit));
+                }
+            });

Review Comment:
   > @heesung-sn How do the changes in this PR fix the issue?
   
   No. this PR does not fix the racing condition issue. I think we can track 
this as a separate issue, here https://github.com/apache/pulsar/issues/23158
   
   
   > It seems odd to have some code duplication in the .forEach handler and 
only handle a specific case instead of all possible cases.
   
   This is because the current table view's message handlers cannot 
differentiate "existing" and "tail" messages. The proposed solution 
in`.foreach` in this PR is partially duplicate logic to separately handle 
"existing" messages. I also mentioned this issue here, 
https://github.com/apache/pulsar/issues/23158
   
   > Why don't we fix the root cause in the table view?
   
   I assume this may require a separate PIP to improve the TableView interface. 
   
   
   Currently, in the worst case, the race condition(`between the table view 
create and listen, so it may miss some events`) can be resolved by the leader's 
bundle state channel monitor, which should fix any invalid state eventually.
   
   
   
   
   
   
   
   
   
   
   
   
   
   



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