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] Fix SystemTopicBasedTopicPoliciesService NPE issue #17602

Merged
merged 1 commit into from
Sep 14, 2022

Conversation

Technoboy-
Copy link
Contributor

@Technoboy- Technoboy- commented Sep 13, 2022

Motivation

When SystemTopicBasedTopicPoliciesService#getTopicPolicies is invoked before SystemTopicBasedTopicPoliciesService#addOwnedNamespaceBundleAsync, it will cause NPE:

Stack trace

java.lang.NullPointerException: null
	at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService.addOwnedNamespaceBundleAsync(SystemTopicBasedTopicPoliciesService.java:222) ~[classes/:?]
	at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService$1.onLoad(SystemTopicBasedTopicPoliciesService.java:301) ~[classes/:?]
	at org.apache.pulsar.broker.namespace.NamespaceService.notifyNamespaceBundleOwnershipListener(NamespaceService.java:1052) ~[classes/:?]
	at org.apache.pulsar.broker.namespace.NamespaceService.onNamespaceBundleOwned(NamespaceService.java:1020) ~[classes/:?]
	at org.apache.pulsar.broker.namespace.OwnershipCache.lambda$tryAcquiringOwnership$1(OwnershipCache.java:200) ~[classes/:?]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642) ~[?:?]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[?:?]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073) ~[?:?]
	at org.apache.pulsar.metadata.coordination.impl.LockManagerImpl.lambda$acquireLock$1(LockManagerImpl.java:105) ~[classes/:?]
	at java.util.concurrent.CompletableFuture$UniRun.tryFire$$$capture(CompletableFuture.java:783) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java) ~[?:?]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[?:?]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073) ~[?:?]
	at org.apache.pulsar.metadata.coordination.impl.ResourceLockImpl.lambda$acquire$2(ResourceLockImpl.java:127) ~[classes/:?]
	at java.util.concurrent.CompletableFuture$UniRun.tryFire$$$capture(CompletableFuture.java:783) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java) ~[?:?]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[?:?]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073) ~[?:?]
	at org.apache.pulsar.metadata.coordination.impl.ResourceLockImpl.lambda$acquireWithNoRevalidation$6(ResourceLockImpl.java:166) ~[classes/:?]
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire$$$capture(CompletableFuture.java:714) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java) ~[?:?]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[?:?]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073) ~[?:?]
	at org.apache.pulsar.metadata.impl.ZKMetadataStore.handlePutResult(ZKMetadataStore.java:214) ~[classes/:?]
	at org.apache.pulsar.metadata.impl.ZKMetadataStore.lambda$batchOperation$6(ZKMetadataStore.java:171) ~[classes/:?]
	at org.apache.pulsar.metadata.impl.PulsarZooKeeperClient$3$1.processResult(PulsarZooKeeperClient.java:490) [classes/:?]
	at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:722) [zookeeper-3.6.3.jar:3.6.3]
	at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:563) [zookeeper-3.6.3.jar:3.6.3]

We have pushed this patch to branch-2.9(#13840), we only need to add this to branch-2.10, 2.11.

Modifications

  1. Move ownedBundlesCountPerNamespace.putIfAbsent(namespace, new AtomicInteger(1)) in the prepareInitPoliciesCache method.

Documentation

  • no-need-doc

@Technoboy- Technoboy- self-assigned this Sep 13, 2022
@Technoboy- Technoboy- added this to the 2.11.0 milestone Sep 13, 2022
@Technoboy- Technoboy- added the doc-not-needed Your PR changes do not impact docs label Sep 13, 2022
@Technoboy- Technoboy- changed the title Fix SystemTopicBasedTopicPoliciesService NPE issue [fix][broker] Fix SystemTopicBasedTopicPoliciesService NPE issue Sep 13, 2022
@github-actions
Copy link

@Technoboy- Please provide a correct documentation label for your PR.
Instructions see Pulsar Documentation Label Guide.

@github-actions github-actions bot removed the doc-not-needed Your PR changes do not impact docs label Sep 13, 2022
@Technoboy- Technoboy- added doc-not-needed Your PR changes do not impact docs type/bug The PR fixed a bug or issue reported a bug area/broker release/2.10.3 and removed doc-label-missing labels Sep 13, 2022
@github-actions github-actions bot added doc-label-missing and removed doc-not-needed Your PR changes do not impact docs labels Sep 13, 2022
@codelipenghui
Copy link
Contributor

@Technoboy- Could you please also link the PR that push to branch-2.9?

@Technoboy-
Copy link
Contributor Author

Technoboy- commented Sep 13, 2022

@Technoboy- Could you please also link the PR that push to branch-2.9?

yes, #13840, also updated in the motivation.

@Technoboy- Technoboy- added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Sep 13, 2022
@github-actions github-actions bot added doc-label-missing and removed doc-not-needed Your PR changes do not impact docs labels Sep 13, 2022
@Technoboy- Technoboy- closed this Sep 13, 2022
@Technoboy- Technoboy- reopened this Sep 13, 2022
@Technoboy- Technoboy- added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Sep 13, 2022
@Technoboy- Technoboy- closed this Sep 13, 2022
@Technoboy- Technoboy- reopened this Sep 13, 2022
@github-actions github-actions bot removed the doc-not-needed Your PR changes do not impact docs label Sep 13, 2022
@Technoboy- Technoboy- merged commit b789b08 into apache:master Sep 14, 2022
liangyepianzhou pushed a commit that referenced this pull request Dec 5, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Dec 6, 2022
@Technoboy- Technoboy- deleted the fix-13840-2 branch September 14, 2023 11:34
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.

4 participants