Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] [broker] remove bundle-data in local metadata store. #21078

Merged
merged 9 commits into from Aug 31, 2023

Conversation

thetumbled
Copy link
Contributor

@thetumbled thetumbled commented Aug 28, 2023

Motivation

When deleting a namespace, we will delete znode under the path /loadbalance/bundle-data in local metadata store instead of global metadata store.

Modifications

Delete bundle data znode in local metadata store.

Verifying this change

  • Make sure that the change passes the CI checks.
    This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: thetumbled#26

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 28, 2023
@thetumbled
Copy link
Contributor Author

thetumbled commented Aug 28, 2023

PTAL, thanks. @codelipenghui @hangc0276 @AnonHxy @poorbarcode


public static final String POLICIES_READONLY_FLAG_PATH = "/admin/flags/policies-readonly";
private static final String NAMESPACE_BASE_PATH = "/namespace";
private static final String BUNDLE_DATA_BASE_PATH = "/loadbalance/bundle-data";

public NamespaceResources(MetadataStore configurationStore, int operationTimeoutSec) {
public NamespaceResources(MetadataStore localStore, MetadataStore configurationStore, int operationTimeoutSec) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about creating a separate class naming BundleResources to handle the bundle-date creating and deleting. The reason is that:

  1. NamespaceResources will be null if configurationMetadataStore != null is false, so there is a chance to throw NPE when call NamespaceResources.deleteBundleDataAsync(..) or NamespaceResources.deleteBundleDataTenantAsync(...):

if (configurationMetadataStore != null) {
tenantResources = new TenantResources(configurationMetadataStore, operationTimeoutSec);
clusterResources = new ClusterResources(configurationMetadataStore, operationTimeoutSec);
namespaceResources = new NamespaceResources(configurationMetadataStore, operationTimeoutSec);
resourcegroupResources = new ResourceGroupResources(configurationMetadataStore, operationTimeoutSec);

  1. NamespaceResources#BUNDLE_DATA_BASE_PATH and ModularLoadManagerImpl#BUNDLE_DATA_PATH are duplicated. BundleResources could unify them. WDYT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It seems that we can't allow the configurationMetadataStore to be null, or there will be serious issues.

    if (config.isConfigurationStoreSeparated()) {
    configMetadataSynchronizer = StringUtils.isNotBlank(config.getConfigurationMetadataSyncEventTopic())
    ? new PulsarMetadataEventSynchronizer(this, config.getConfigurationMetadataSyncEventTopic())
    : null;
    configurationMetadataStore = createConfigurationMetadataStore(configMetadataSynchronizer);
    shouldShutdownConfigurationMetadataStore = true;
    } else {
    configurationMetadataStore = localMetadataStore;
    shouldShutdownConfigurationMetadataStore = false;
    }
    pulsarResources = newPulsarResources();

  2. Currently, bundle-data are created/updated by LoadManager, and deleted by LoadManager and NamespaceResources. It is beneficial to introduce a BundleResources to unify the opeartions to bundle-data. But i think that it should be introduced as a code optimization instead of bug fix, which need to be discussed fully.

Copy link
Contributor

@AnonHxy AnonHxy Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. As a bug fix, this change could fix the problem and it LGTM. Maybe we could refactor it in another PR

@poorbarcode poorbarcode requested review from Demogorgon314 and heesung-sn and removed request for coderzc and congbobo184 August 29, 2023 08:50
@poorbarcode
Copy link
Contributor

@heesung-sn @Demogorgon314 Could you take a look? Thanks

@poorbarcode
Copy link
Contributor

/pulsarbot run-failure-checks

1 similar comment
@poorbarcode
Copy link
Contributor

/pulsarbot run-failure-checks

@codecov-commenter
Copy link

Codecov Report

Merging #21078 (cc9bf78) into master (d06cda6) will increase coverage by 38.42%.
Report is 30 commits behind head on master.
The diff coverage is 65.17%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #21078       +/-   ##
=============================================
+ Coverage     34.70%   73.13%   +38.42%     
- Complexity    12121    32370    +20249     
=============================================
  Files          1698     1887      +189     
  Lines        129914   139862     +9948     
  Branches      14172    15384     +1212     
=============================================
+ Hits          45089   102289    +57200     
+ Misses        78825    29475    -49350     
- Partials       6000     8098     +2098     
Flag Coverage Δ
inttests 24.06% <7.46%> (?)
systests 25.15% <5.97%> (+0.04%) ⬆️
unittests 72.41% <65.17%> (+40.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 81.21% <0.00%> (+34.26%) ⬆️
...ookkeeper/PulsarLedgerUnderreplicationManager.java 51.74% <52.85%> (+51.74%) ⬆️
...etadata/bookkeeper/PulsarLedgerManagerFactory.java 61.53% <57.14%> (+30.98%) ⬆️
...ookkeeper/LongHierarchicalLedgerRangeIterator.java 81.66% <66.66%> (+81.66%) ⬆️
...metadata/bookkeeper/PulsarRegistrationManager.java 62.56% <70.96%> (+53.16%) ⬆️
...kkeeper/LegacyHierarchicalLedgerRangeIterator.java 72.15% <71.42%> (+72.15%) ⬆️
...he/pulsar/broker/resources/NamespaceResources.java 80.28% <75.00%> (+10.28%) ⬆️
...ulsar/metadata/bookkeeper/PulsarLayoutManager.java 66.66% <77.77%> (+46.66%) ⬆️
...ker/service/persistent/PersistentSubscription.java 75.89% <83.33%> (+26.20%) ⬆️
...pache/pulsar/broker/resources/PulsarResources.java 83.72% <100.00%> (ø)
... and 3 more

... and 1459 files with indirect coverage changes

@poorbarcode poorbarcode merged commit 4a87c64 into apache:master Aug 31, 2023
45 checks passed
Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Bro.

I need to confirm something related to this. The namespace-level metadata should store all the data in the configuration store.
You change deleting from the configuration store to the local store. How can we delete it in the configuration store?

@thetumbled
Copy link
Contributor Author

I need to confirm something related to this. The namespace-level metadata should store all the data in the configuration store. You change deleting from the configuration store to the local store. How can we delete it in the configuration store?

There is no such bundle-data in the configuration store. Znodes for bundle-data is created by LoadManager in local store, instead of configuration store.

@mattisonchao
Copy link
Member

Yep, you are right. I was misunderstood.

@mattisonchao
Copy link
Member

Btw, I suggest we move this logic out of the namespace resource. Because we didn't create bundle data in NamespaceResource but deleted it there, it's weird.

@AnonHxy
Copy link
Contributor

AnonHxy commented Sep 4, 2023

Btw, I suggest we move this logic out of the namespace resource. Because we didn't create bundle data in NamespaceResource but deleted it there, it's weird.

+1. As I mentioned above #21078 (comment). I have created a PR to refactor this #21119

Technoboy- pushed a commit that referenced this pull request Sep 5, 2023
Motivation: When deleting a namespace, we will delete znode under the path `/loadbalance/bundle-data` in `local metadata store` instead of `global metadata store`.

Modifications: Delete bundle data znode in local metadata store.
Technoboy- pushed a commit that referenced this pull request Sep 5, 2023
Motivation: When deleting a namespace, we will delete znode under the path `/loadbalance/bundle-data` in `local metadata store` instead of `global metadata store`.

Modifications: Delete bundle data znode in local metadata store.
@shibd
Copy link
Member

shibd commented Oct 22, 2023

@thetumbled Can you help create a PR to cherry-pick this change to branch-2.11?

@thetumbled
Copy link
Contributor Author

thetumbled commented Oct 22, 2023

@thetumbled Can you help create a PR to cherry-pick this change to branch-2.11?

Sure. The PR for cherry-pick is #21413.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants