pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[fix][broker]After the broker is restarted, the cache dynamic configuration is invalid

Open lordcheng10 opened this issue 3 years ago • 0 comments

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:

  1. Load the broker.conf file and initialize the ServiceConfiguration object;

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

  3. 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:

  1. Register and configure the listener;
  2. 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)

lordcheng10 avatar Aug 10 '22 06:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 10 '22 10:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 10 '22 11:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 10 '22 14:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 11 '22 02:08 lordcheng10

Good catch 👍

HQebupt avatar Aug 12 '22 14:08 HQebupt

Could you please help add tests? We are able to restart the broker during the test.

@codelipenghui @HQebupt @Technoboy- Fixed, PTAL,thanks!

lordcheng10 avatar Aug 26 '22 03:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 26 '22 06:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 26 '22 06:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 26 '22 10:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 26 '22 11:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 26 '22 14:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 27 '22 05:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 27 '22 08:08 lordcheng10

@lordcheng10 Please solve CI failure.

Jason918 avatar Aug 27 '22 09:08 Jason918

/pulsarbot run-failure-checks

lordcheng10 avatar Aug 27 '22 09:08 lordcheng10

@lordcheng10 Please solve CI failure.

OK

lordcheng10 avatar Aug 27 '22 09:08 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 01 '22 10:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 04:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 04:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 05:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 10:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 10:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 10:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 11:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 11:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 12:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 02 '22 18:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 03 '22 02:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 03 '22 15:09 lordcheng10

/pulsarbot run-failure-checks

lordcheng10 avatar Sep 03 '22 16:09 lordcheng10