Skip to content

[improve][client]When namespace is deleted, the client is constantly reconnecting - #18194

Merged
codelipenghui merged 3 commits into
apache:masterfrom
poorbarcode:fix/status_code_ns_del
Oct 28, 2022
Merged

codelipenghui merged 3 commits into
apache:masterfrom
poorbarcode:fix/status_code_ns_del

Conversation

@poorbarcode

@poorbarcode poorbarcode commented Oct 25, 2022 •

Copy link
Copy Markdown
Contributor

Motivation

If the namespace is deleted, the cmd-lookup will still keep retrying, because the error code sent to the client is MetadataError, and the client will retry when it gets MetadataError. No matter how many times it tries again, it will not succeed.

requestId,
false));
}).exceptionally(ex -> {
validationFuture.complete(
newLookupErrorResponse(ServerError.MetadataError,
FutureUtil.unwrapCompletionException(ex).getMessage(), requestId));
return null;
});

Modifications

If the namespace is deleted

  • the cmd-lookup will get the error code TopicNotFound
  • the rest request will get the response code 404
  • improve response message for API topics and API namespaces
  • TODO I will write a test later

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added doc-required Your PR changes impact docs and you will update later. doc-not-needed Your PR changes do not impact docs and removed doc-required Your PR changes impact docs and you will update later. labels Oct 25, 2022
@codelipenghui codelipenghui added this to the 2.12.0 milestone Oct 26, 2022
@codelipenghui codelipenghui added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/client labels Oct 26, 2022

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The technical change looks good to me. I think we might want to clean up the annotations before merging, though.

@ApiOperation(value = "Set entry filters for specified topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Topic does not exist"),
@ApiResponse(code = 404, message = "Tenant or namespace or topic doesn't exist"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this string has Tenant, but most of the others do not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed. Could you take a look again?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was fixed. Why do we have tenant in this annotation but not in the annotation on line 192 above?

@Technoboy- Technoboy- closed this Oct 26, 2022
@Technoboy- Technoboy- reopened this Oct 26, 2022

@Technoboy- Technoboy- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please fix @michaeljmarshall suggestion.

@poorbarcode
poorbarcode force-pushed the fix/status_code_ns_del branch from b01f29a to a222926 Compare October 26, 2022 10:50
@poorbarcode

Copy link
Copy Markdown
Contributor Author

rebase master

@poorbarcode poorbarcode reopened this Oct 26, 2022
Comment on lines +829 to +830
if (throwable instanceof RestException restException){
throw restException;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove these lines.
The RestException is a sub-class of WebApplicationException

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed

String msg = String.format("Namespace %s is deleted", namespace.toString());
log.warn(msg);
validationFuture.completeExceptionally(new RestException(Status.PRECONDITION_FAILED,
validationFuture.completeExceptionally(new RestException(Status.NOT_FOUND,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's incorrect here.
If allowDeletedNamespace is false. We should return Status.PRECONDITION_FAILED. No matter if policies.deleted is true or false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return Status.PRECONDITION_FAILED here, the error code will same as the scenario if (policies.replication_clusters.isEmpty(), then we can not determine whether the error was caused by namespace deleted when calling this method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, got it. I misunderstand the allowDeletedNamespace. I thought it was forceDeleteNamespaceAllowed=false in broker.conf.

@codecov-commenter

codecov-commenter commented Oct 27, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #18194 (3f7179e) into master (6c65ca0) will decrease coverage by 7.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18194      +/-   ##
============================================
- Coverage     34.91%   27.89%   -7.02%     
+ Complexity     5707     3695    -2012     
============================================
  Files           607      398     -209     
  Lines         53396    43561    -9835     
  Branches       5712     4478    -1234     
============================================
- Hits          18644    12153    -6491     
+ Misses        32119    29511    -2608     
+ Partials       2633     1897     -736     
Flag Coverage Δ
unittests 27.89% <0.00%> (-7.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...in/java/org/apache/pulsar/PulsarBrokerStarter.java 0.00% <ø> (ø)
.../org/apache/pulsar/PulsarClusterMetadataSetup.java 0.00% <ø> (ø)
...g/apache/pulsar/PulsarClusterMetadataTeardown.java 0.00% <ø> (ø)
...org/apache/pulsar/PulsarInitialNamespaceSetup.java 0.00% <ø> (ø)
.../main/java/org/apache/pulsar/PulsarStandalone.java 0.00% <0.00%> (ø)
...ava/org/apache/pulsar/PulsarStandaloneBuilder.java 0.00% <ø> (ø)
...ava/org/apache/pulsar/PulsarStandaloneStarter.java 0.00% <ø> (ø)
...ava/org/apache/pulsar/broker/admin/v2/Brokers.java 0.00% <0.00%> (-100.00%) ⬇️
.../org/apache/pulsar/client/impl/RawMessageImpl.java 0.00% <0.00%> (-93.11%) ⬇️
.../pulsar/broker/service/SharedConsumerAssignor.java 3.70% <0.00%> (-64.82%) ⬇️
... and 337 more

@poorbarcode
poorbarcode force-pushed the fix/status_code_ns_del branch from 9fd0426 to 3f7179e Compare October 27, 2022 09:20
@poorbarcode

Copy link
Copy Markdown
Contributor Author

/pulsarbot rerun-failure-checks

@codelipenghui
codelipenghui merged commit 8f8637a into apache:master Oct 28, 2022
@poorbarcode
poorbarcode deleted the fix/status_code_ns_del branch October 28, 2022 04:55
nodece pushed a commit to nodece/pulsar that referenced this pull request Mar 18, 2025
…reconnecting (apache#18194)

(cherry picked from commit 8f8637a)
Signed-off-by: Zixuan Liu <[email protected]>
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Mar 18, 2025
…reconnecting (apache#18194)

(cherry picked from commit 8f8637a)
Signed-off-by: Zixuan Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/client doc-not-needed Your PR changes do not impact docs ready-to-test type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants