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
Conversation
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) { |
There was a problem hiding this comment.
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:
NamespaceResources
will be null ifconfigurationMetadataStore != null
is false, so there is a chance to throw NPE when callNamespaceResources.deleteBundleDataAsync(..)
orNamespaceResources.deleteBundleDataTenantAsync(...)
:
pulsar/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/PulsarResources.java
Lines 60 to 64 in d099ac4
if (configurationMetadataStore != null) { | |
tenantResources = new TenantResources(configurationMetadataStore, operationTimeoutSec); | |
clusterResources = new ClusterResources(configurationMetadataStore, operationTimeoutSec); | |
namespaceResources = new NamespaceResources(configurationMetadataStore, operationTimeoutSec); | |
resourcegroupResources = new ResourceGroupResources(configurationMetadataStore, operationTimeoutSec); |
NamespaceResources#BUNDLE_DATA_BASE_PATH
andModularLoadManagerImpl#BUNDLE_DATA_PATH
are duplicated.BundleResources
could unify them. WDYT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
It seems that we can't allow the
configurationMetadataStore
to be null, or there will be serious issues.
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Lines 752 to 762 in d099ac4
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(); -
Currently, bundle-data are created/updated by
LoadManager
, and deleted byLoadManager
andNamespaceResources
. It is beneficial to introduce aBundleResources
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.
There was a problem hiding this comment.
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
@heesung-sn @Demogorgon314 Could you take a look? Thanks |
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
Outdated
Show resolved
Hide resolved
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
Show resolved
Hide resolved
There was a problem hiding this 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?
There is no such bundle-data in the configuration store. Znodes for bundle-data is created by |
Yep, you are right. I was misunderstood. |
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 |
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.
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.
@thetumbled Can you help create a PR to cherry-pick this change to |
Sure. The PR for cherry-pick is #21413. |
Motivation
When deleting a namespace, we will delete znode under the path
/loadbalance/bundle-data
inlocal metadata store
instead ofglobal metadata store
.Modifications
Delete bundle data znode in local metadata store.
Verifying this change
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
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: thetumbled#26