You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "liangyepianzhou (via GitHub)" <gi...@apache.org> on 2023/05/08 17:00:53 UTC
[GitHub] [pulsar] liangyepianzhou opened a new pull request, #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
liangyepianzhou opened a new pull request, #20261:
URL: https://github.com/apache/pulsar/pull/20261
## Motivation
The branch master has an NPE check in the `BrokerService::checkOwnershipAndCreatePersistentTopic`, but it will lead to a `UnsupportedOperationException`. The returned map might be an unmodifiable `Collections.emptyMap()`. The call chain involved is as follows:
1. `BrokerService::checkOwnershipAndCreatePersistentTopic`
2. `BrokerService::fetchTopicPropertiesAsync`
3. `ManagedLedgerFactory::getManagedLedgerPropertiesAsync`
4. `MetaStoreImpl::getManagedLedgerPropertiesAsync`
5. `operationFailed`
```java
public void operationFailed(MetaStoreException e) {
if (e instanceof MetadataNotFoundException) {
result.complete(Collections.emptyMap());
} else {
result.completeExceptionally(e);
}
}
```
### Modifications
Make the getManagedLedgerPropertiesAsync return a modifiable map.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (10MB)*
- *Extended integration test for recovery after broker failure*
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*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
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] gaoran10 commented on a diff in pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "gaoran10 (via GitHub)" <gi...@apache.org>.
gaoran10 commented on code in PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#discussion_r1188038590
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java:
##########
@@ -133,6 +133,20 @@ public void cleanup() throws Exception {
super.internalCleanup();
}
+ @Test
+ public void updatePropertiesForAutoCreatedTopicTest() throws Exception {
+ TopicName topicName = TopicName.get(
+ TopicDomain.persistent.value(),
+ NamespaceName.get(myNamespace),
+ "test-" + UUID.randomUUID()
+ );
+ String testTopic = topicName.toString();
+ Producer<byte[]> producer = pulsarClient.newProducer().topic(testTopic).create();
Review Comment:
Please close the producer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#issuecomment-1543004989
>Why remove these labels?
@poorbarcode
Because this [PR](https://github.com/apache/pulsar/pull/17711) didn’t been cherry-picked.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#issuecomment-1542541072
Why were the labels lost?

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- merged pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- merged PR #20261:
URL: https://github.com/apache/pulsar/pull/20261
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- commented on a diff in pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#discussion_r1188040910
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -665,7 +665,7 @@ protected CompletableFuture<Void> internalUpdatePropertiesAsync(boolean authorit
return validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.UPDATE_METADATA))
.thenCompose(__ -> {
- if (topicName.isPartitioned()) {
+ if (!topicName.isPartitioned()) {
Review Comment:
Why change here ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] michaeljmarshall commented on pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "michaeljmarshall (via GitHub)" <gi...@apache.org>.
michaeljmarshall commented on PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#issuecomment-1540469524
@liangyepianzhou - would you mind sharing the stack trace for the `UnsupportedOperationException`? Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- closed pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- closed pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
URL: https://github.com/apache/pulsar/pull/20261
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on code in PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#discussion_r1188181130
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -665,7 +665,7 @@ protected CompletableFuture<Void> internalUpdatePropertiesAsync(boolean authorit
return validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.UPDATE_METADATA))
.thenCompose(__ -> {
- if (topicName.isPartitioned()) {
+ if (!topicName.isPartitioned()) {
Review Comment:
Oh, thanks for your point out.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#issuecomment-1543000448
>@liangyepianzhou - would you mind sharing the stack trace for the UnsupportedOperationException? Thanks!
@michaeljmarshall Sure, of course.
```shell
Message: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
Stacktrace:
org.apache.bookkeeper.mledger.ManagedLedgerException$MetaStoreException: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
Caused by: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:722)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
at org.apache.bookkeeper.common.util.OrderedExecutor$TimedRunnable.run(OrderedExecutor.java:201)
at org.apache.bookkeeper.common.util.SingleThreadSafeScheduledExecutorService$SafeRunnable.run(SingleThreadSafeScheduledExecutorService.java:46)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.UnsupportedOperationException
at java.base/java.util.AbstractMap.put(AbstractMap.java:209)
at java.base/java.util.AbstractMap.putAll(AbstractMap.java:281)
at org.apache.pulsar.broker.admin.impl.PersistentTopicsBase$1.updatePropertiesComplete(PersistentTopicsBase.java:701)
at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl$26.operationComplete(ManagedLedgerImpl.java:4177)
at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl$26.operationComplete(ManagedLedgerImpl.java:4173)
at org.apache.bookkeeper.mledger.impl.MetaStoreImpl.lambda$asyncUpdateLedgerIds$7(MetaStoreImpl.java:203)
at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718)
... 10 more
at org.apache.pulsar.client.admin.PulsarAdminException.wrap(PulsarAdminException.java:252)
at org.apache.pulsar.client.admin.internal.BaseResource.sync(BaseResource.java:352)
at org.apache.pulsar.client.admin.internal.TopicsImpl.updateProperties(TopicsImpl.java:419)
at org.apache.pulsar.broker.admin.TopicPoliciesTest.updatePropertiesForAutoCreatedTopicTest(TopicPoliciesTest.java:142)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Suppressed: org.apache.pulsar.client.admin.PulsarAdminException$ServerSideErrorException:
--- An unexpected error occurred in the server ---
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #20261: [fix][broker] Fix `UnsupportedOperationException` when update topic properties.
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20261:
URL: https://github.com/apache/pulsar/pull/20261#discussion_r1188063931
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java:
##########
@@ -133,6 +133,20 @@ public void cleanup() throws Exception {
super.internalCleanup();
}
+ @Test
+ public void updatePropertiesForAutoCreatedTopicTest() throws Exception {
+ TopicName topicName = TopicName.get(
+ TopicDomain.persistent.value(),
+ NamespaceName.get(myNamespace),
+ "test-" + UUID.randomUUID()
+ );
+ String testTopic = topicName.toString();
+ Producer<byte[]> producer = pulsarClient.newProducer().topic(testTopic).create();
Review Comment:
+1
And suggestion to remove this topic.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -665,7 +665,7 @@ protected CompletableFuture<Void> internalUpdatePropertiesAsync(boolean authorit
return validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.UPDATE_METADATA))
.thenCompose(__ -> {
- if (topicName.isPartitioned()) {
+ if (!topicName.isPartitioned()) {
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org