AnonHxy commented on code in PR #17371:
URL: https://github.com/apache/pulsar/pull/17371#discussion_r963810771
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1036,6 +1036,14 @@ public CompletableFuture<Void> deleteTopic(String topic,
boolean forceDelete) {
new IllegalStateException("Delete forbidden topic is
replicated on clusters " + clusters));
}
+ // shadow topic should be deleted first.
+ if (t.isShadowReplicated()) {
+ final List<String> shadowTopics =
t.getShadowReplicators().keys();
+ log.error("Delete forbidden. Topic {} is replicated to shadow
topics: {}", topic, shadowTopics);
+ return FutureUtil.failedFuture(new IllegalStateException(
+ "Delete forbidden. Topic " + topic + " is replicated
to shadow topics: "));
Review Comment:
This is still not a correct error message, we should add `+ shadowTopics` at
the end.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1423,6 +1439,38 @@ public CompletableFuture<Void> checkReplication() {
}
});
+ futures.add(checkShadowReplication());
+
+ return FutureUtil.waitForAll(futures);
+ }
+
+ private CompletableFuture<Void> checkShadowReplication() {
+ if (CollectionUtils.isEmpty(shadowTopics)) {
+ return CompletableFuture.completedFuture(null);
+ }
+ List<String> configuredShadowTopics = shadowTopics;
Review Comment:
The update of `shadowTopics` will lead to `configuredShadowTopics` update,
because they refer to same object.
If I understand correctly, we should write like below, which will copy the
`shadowTopics` at the moment:
```
List<String> configuredShadowTopics = new ArrayList<>(shadowTopics);
```
WDYT @Jason918
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]