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

Set splitNamespaceBundle with readonly=false. #14680

Merged
merged 1 commit into from
Mar 15, 2022

Conversation

Technoboy-
Copy link
Contributor

@Technoboy- Technoboy- commented Mar 14, 2022

Master Issue: #14668

Fixes: #14668

Motivation

When we split a not loaded namespace bundle, we will meet the below error:

Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000

Because when validating namespace bundle ownership with readonly=true :

try {
nsBundle = validateNamespaceBundleOwnership(namespaceName, policies.bundles, bundleRange,
authoritative, true);
} catch (Exception e) {
asyncResponse.resume(e);
return;
}

and if the bundle is not owned by any broker, it will return empty(line-392):

ownershipCache.getOwnerAsync(bundle).thenAccept(nsData -> {
if (!nsData.isPresent()) {
// No one owns this bundle
if (options.isReadOnly()) {
// Do not attempt to acquire ownership
future.complete(Optional.empty());
} else {
// Now, no one owns the namespace yet. Hence, we will try to dynamically assign it
pulsar.getExecutor().execute(() -> {
searchForCandidateBroker(bundle, future, options);
});
}

so throw the below exception :

Optional<URL> webUrl = nsService.getWebServiceUrl(bundle, options);
// Ensure we get a url
if (webUrl == null || !webUrl.isPresent()) {
log.warn("Unable to get web service url");
throw new RestException(Status.PRECONDITION_FAILED,
"Failed to find ownership for ServiceUnit:" + bundle.toString());
}

Modification

  • Change readonly from true to false when validating namespace bundle ownership.

Documentation

  • no-need-doc

@Technoboy-
Copy link
Contributor Author

As the difference I said in #14668, I'm still curious why standalone works while cluster doesn't work. See the following screenshot, even if readOnly is true, the webUrl is still retrieved successfully.

image

This is not for cluster only, standalone is also not work. My test could reproduce.

@BewareMyPower
Copy link
Contributor

I deleted my reply at this moment. I'll dig deeper into this issue.

@BewareMyPower
Copy link
Contributor

I think the difference is that when I ran a standalone, each bundle was owned by the broker because I've sent some messages to some partitions. See the original code snippet:

            try (PulsarClient client = PulsarClient.builder().serviceUrl("pulsar://localhost:6650").build()) {
                for (int i = 0; i < numPartitions; i++) {
                    client.newProducer().topic(topic + TopicName.PARTITIONED_TOPIC_SUFFIX + i)
                            .create().send("1".getBytes());
                }
            }

When I debugged in a standalone, i.e. the nsData returned by ownershipCache.getOwnerAsync(bundle) is not empty.

image

There is another weird thing I've described in #14668. I'm not sure if it's related.

The standard output is also weird:

[0x00000000, 0x10000000, 0x20000000, 0x30000000, 0x40000000, 0x50000000, 0x60000000, 0x70000000, 0x80000000, 0x90000000, 0xa0000000, 0xb0000000, 0xc0000000, 0xd0000000, 0xe0000000, 0xf0000000, 0xffffffff]
The defaultNumberOfNamespaceBundles is 4, but the initial number of bundles is 16.

Maybe some bundles were not owned by the broker. I'll try to split all bundle ranges to see if there is any bundle range that can be split.

@BewareMyPower
Copy link
Contributor

It works now.

When I ran a standalone, there were 4 bundle ranges. However, when I ran a cluster, there were 16 bundle ranges and some bundle ranges were not owned.

I think we need another issue to track the issue that defaultNumberOfNamespaceBundles doesn't work for cluster mode.

@BewareMyPower BewareMyPower merged commit 4ffef1a into apache:master Mar 15, 2022
@lhotari lhotari mentioned this pull request Mar 15, 2022
codelipenghui pushed a commit that referenced this pull request Mar 18, 2022
Master Issue: #14668

Fixes: #14668

### Motivation

When we split a not loaded namespace bundle, we will meet the below error:
```
Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000
```
Because when validating namespace bundle ownership with `readonly=true` :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1145-L1151

and if the bundle is not owned by any broker, it will return empty(line-392):
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L388-L400

so throw the below exception :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L576-L582

### Modification

- Change readonly from `true` to `false` when validating namespace bundle ownership.

(cherry picked from commit 4ffef1a)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Mar 18, 2022
codelipenghui pushed a commit that referenced this pull request Mar 18, 2022
Master Issue: #14668

Fixes: #14668

### Motivation

When we split a not loaded namespace bundle, we will meet the below error:
```
Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000
```
Because when validating namespace bundle ownership with `readonly=true` :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1145-L1151

and if the bundle is not owned by any broker, it will return empty(line-392):
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L388-L400

so throw the below exception :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L576-L582

### Modification

- Change readonly from `true` to `false` when validating namespace bundle ownership.

(cherry picked from commit 4ffef1a)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Mar 18, 2022
@codelipenghui codelipenghui modified the milestones: 2.11.0, 2.10.0 Mar 19, 2022
codelipenghui pushed a commit that referenced this pull request Mar 19, 2022
Master Issue: #14668

Fixes: #14668

### Motivation

When we split a not loaded namespace bundle, we will meet the below error:
```
Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000
```
Because when validating namespace bundle ownership with `readonly=true` :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1145-L1151

and if the bundle is not owned by any broker, it will return empty(line-392):
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L388-L400

so throw the below exception :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L576-L582

### Modification

- Change readonly from `true` to `false` when validating namespace bundle ownership.

(cherry picked from commit 4ffef1a)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Apr 5, 2022
Master Issue: apache#14668

Fixes: apache#14668

### Motivation

When we split a not loaded namespace bundle, we will meet the below error:
```
Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000
```
Because when validating namespace bundle ownership with `readonly=true` :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1145-L1151

and if the bundle is not owned by any broker, it will return empty(line-392):
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L388-L400

so throw the below exception :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L576-L582

### Modification

- Change readonly from `true` to `false` when validating namespace bundle ownership.

(cherry picked from commit 4ffef1a)
(cherry picked from commit 43f2562)
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
Master Issue: apache#14668

Fixes: apache#14668

### Motivation

When we split a not loaded namespace bundle, we will meet the below error:
```
Failed to find ownership for ServiceUnit:tenant/namespace/0x00000000_0x10000000
```
Because when validating namespace bundle ownership with `readonly=true` :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1145-L1151

and if the bundle is not owned by any broker, it will return empty(line-392):
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L388-L400

so throw the below exception :
https://github.com/apache/pulsar/blob/fe7e55d9f353925a559e88f8ceef2b47b59668e0/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L576-L582

### Modification

- Change readonly from `true` to `false` when validating namespace bundle ownership.
@Technoboy- Technoboy- deleted the fix-14668 branch August 10, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.4 release/2.9.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to get web service url when split bundle
4 participants