BewareMyPower commented on PR #23786:
URL: https://github.com/apache/pulsar/pull/23786#issuecomment-2562522075
The `pulsar-io-3-6` thread that holds the lock of `BrokerService#topics` is
blocked at:
```java
public CompletableFuture<ManagedLedgerFactory>
getManagedLedgerFactoryForTopic(TopicName topicName) {
// NOTE: it calls `getTopicPoliciesBypassSystemTopic` and tries to
acquire the lock of
//. `SystemTopicBasedTopicPoliciesService#policyCacheInitMap`
return getManagedLedgerConfig(topicName)
```
called by
```java
protected CompletableFuture<Map<String, String>>
fetchTopicPropertiesAsync(TopicName topicName) {
if (!topicName.isPartitioned()) {
return getManagedLedgerFactoryForTopic(topicName).thenCompose(
```
called by
```java
private void checkOwnershipAndCreatePersistentTopic(/* ... */) {
TopicName topicName = TopicName.get(topic);
pulsar.getNamespaceService().isServiceUnitActiveAsync(topicName)
.thenAccept(isActive -> {
if (isActive) {
CompletableFuture<Map<String, String>>
propertiesFuture;
if (properties == null) {
//Read properties from storage when loading
topic.
propertiesFuture =
fetchTopicPropertiesAsync(topicName); // HERE
```
called by
```java
protected CompletableFuture<Optional<Topic>>
loadOrCreatePersistentTopic(final String topic,
boolean createIfMissing, Map<String, String> properties,
@Nullable TopicPolicies topicPolicies) {
/* ... */
checkTopicNsOwnership(topic)
.thenRun(() -> {
final Semaphore topicLoadSemaphore =
topicLoadRequestSemaphore.get();
if (topicLoadSemaphore.tryAcquire()) {
checkOwnershipAndCreatePersistentTopic(topic,
createIfMissing, topicFuture, // HERE
properties, topicPolicies);
```
Here `checkTopicNsOwnership` and `isServiceUnitActiveAsync` futures all
completed immediately in the current thread so the callback of
`topics.computeIfAbsent` is blocked at acquiring the lock of
``SystemTopicBasedTopicPoliciesService#policyCacheInitMap`.
I think the correct fix is to move `checkTopicNsOwnership(topic).thenRun` to
`checkTopicNsOwnership(topic).thenRunAsync` (or other places in the same call)
so that the callback of `topics.computeIfAbsent` won't be blocked.
--
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]