fix(RuntimeConfigurationPlugin): avoid Jetty/webconsole starts on slave when using RuntimeConfigurationBroker plugin#1921
fix(RuntimeConfigurationPlugin): avoid Jetty/webconsole starts on slave when using RuntimeConfigurationBroker plugin#1921jbonofre wants to merge 2 commits intoapache:mainfrom
Conversation
…plugin init logic (config loading, file monitoring, MBean registration) from start() to nowMasterBroker(). This callback is invoked by BrokerService.doStartBroker(), after startAllConnectors() has set slave=true. It's the proper lifecycle hook for "this broker is now a master".
…ecycle Verify that RuntimeConfigurationBroker defers init (config loading, file monitoring, MBean registration) to nowMasterBroker() instead of start(), preventing race conditions in master/slave topologies.
|
I'm not sure there is really a problem with having the RuntimeConfigPlugin running while the broker is active or inactive. The Broker does not have a lifecycle hook to indicate when the persistent store is not available (aka 'slave'). So this change only solves for the 'first time' becoming primary/master. If the broker flips back to failover/slave, the RuntimeConfigPlugin will still be active and processing configuration changes. Since the plugin can process transportConnectors, I can see a scenario where an original set of transport connectors come online, but the user has already removed (or changed) via config, but the plugin hasn't processed yet so ports come online that were not intended. edit: this config race condition could also lead to incorrect security, startup destinations, policies and really anything else that is updatable via the plugin |
|
@mattrpav yes, the purpose here is specifically to avoid the race condition. |
|
@jbonofre this adds a race condition for the configuration update and then the plugin remains active, even if the broker goes back to being a failover/slave broker which leads to inconsistent behavior. The Broker interface used for lifecycle has a gap, where there is no hook/method called when a broker goes back to being a slave/failover node. Described:
Questions: |
|
@mattrpav that's a good call. Let me revisit the fix focusing on the race condition on slave: the problem I'm observing is that a slave can start Jetty/WebConsole even if the broker is waiting for the lock due to the RuntimeConfigurationPlugin. |
|
Closing this one to implement a more global fix. |
Move the RuntimeConfigurationBroker plugin init logic (config loading, file monitoring, MBean registration) from start() to nowMasterBroker(). This callback is invoked by BrokerService.doStartBroker(), after startAllConnectors() has set slave=true. It's the proper lifecycle hook for "this broker is now a master".
This avoid a potential race condition where the slave can start Jetty/webconsole.