[fix][broker]After the broker is restarted, the cache dynamic configuration is invalid
Motivation
We update some cache dynamic configurations, such as: managedLedgerCacheSizeMB=100, but after we restarted the broker, we found that the dynamically modified cache configuration on zookeeper was invalid, and the value configured in broker.conf took effect.
After restarting, the loading process of config is as follows:
-
Load the broker.conf file and initialize the ServiceConfiguration object;
-
Use the ServiceConfiguration object to build the ManagedLedgerStorage object: https://github.com/apache/pulsar/blob/4b757cf9f9046c7143329156b1009fe43217eaea/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L742-L748
-
When creating the BrokerService object, it will read the dynamic configuration on zookeeper, update it to conf, and then register the listener for the relevant configuration update, but the execution of these listeners is not triggered: https://github.com/apache/pulsar/blob/4b757cf9f9046c7143329156b1009fe43217eaea/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L746-L748 https://github.com/apache/pulsar/blob/4b757cf9f9046c7143329156b1009fe43217eaea/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java#L2217-L2250
Therefore, after the broker is restarted, the cache-related configuration used is still the configuration in the broker.conf file.
Solution: The configuration is loaded in the following order:
- Register and configure the listener;
- Read the dynamic configuration on zookeeper and trigger the corresponding listener;
Documentation
Check the box below or label this PR directly.
Need to update docs?
-
[ ]
doc-required(Your PR needs to update docs and you will update later) -
[x]
doc-not-needed(Please explain why) -
[ ]
doc(Your PR contains doc changes) -
[ ]
doc-complete(Docs have been already added)
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
Good catch 👍
Could you please help add tests? We are able to restart the broker during the test.
@codelipenghui @HQebupt @Technoboy- Fixed, PTAL,thanks!
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
@lordcheng10 Please solve CI failure.
/pulsarbot run-failure-checks
@lordcheng10 Please solve CI failure.
OK
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks
/pulsarbot run-failure-checks