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

[Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… #13905

Conversation

AnonHxy
Copy link
Contributor

@AnonHxy AnonHxy commented Jan 23, 2022

Master Issue: #13854

Motivation

See Issue: #13854

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • no-need-doc

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 23, 2022
@AnonHxy AnonHxy force-pushed the fix_call_sync_call_in_async_internalExpireMessagesForAllSubscriptions branch 2 times, most recently from 943f4d5 to bd06261 Compare January 23, 2022 04:27
@AnonHxy AnonHxy changed the title [WIP][Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… [Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… Jan 23, 2022
@AnonHxy AnonHxy changed the title [Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… [WIP][Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… Jan 23, 2022
@AnonHxy AnonHxy force-pushed the fix_call_sync_call_in_async_internalExpireMessagesForAllSubscriptions branch from bd06261 to 44451b6 Compare January 23, 2022 11:10
@AnonHxy AnonHxy changed the title [WIP][Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… [Issue 13854][Broker]Fix call sync method in async rest api for internalExpireMessagesForA… Jan 23, 2022
@@ -3445,6 +3449,92 @@ private void internalExpireMessagesByTimestampForSinglePartition(String subName,
}
}

private CompletableFuture<Void> internalExpireMessagesByTimestampForSinglePartitionAsync(String subName,
Copy link
Contributor

Choose a reason for hiding this comment

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

conflict with #13880

Copy link
Contributor Author

@AnonHxy AnonHxy Jan 23, 2022

Choose a reason for hiding this comment

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

comment in #13880

Copy link
Contributor

Choose a reason for hiding this comment

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

@liudezhi2098 Any difference between these two?

Copy link
Contributor

Choose a reason for hiding this comment

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

Both PR's modify this method,warning: There may be conflict.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think we'd better close the new one and apply the fix from the old one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I can rebase the code after #13880 merging to master to fix the conflict

}

asyncResponse.resume(Response.noContent().build());
}).exceptionally(ex -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this exceptionally in Line 1863?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This exceptionally can handle getPartitionedTopicMetadataAsync exceptions if topicName.isPartitioned() return false

Copy link
Contributor

Choose a reason for hiding this comment

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

This exceptionally can handle getPartitionedTopicMetadataAsync exceptions if topicName.isPartitioned() return false

Yes, but exceptionally is also needed there for validateGlobalNamespaceOwnership

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update


asyncResponse.resume(Response.noContent().build());
return FutureUtil.waitForAll(futures).thenRun(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use exceptionally here to handle the exceptions. No need for the exception in Line 1876

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update

@@ -3445,6 +3449,92 @@ private void internalExpireMessagesByTimestampForSinglePartition(String subName,
}
}

private CompletableFuture<Void> internalExpireMessagesByTimestampForSinglePartitionAsync(String subName,
Copy link
Contributor

Choose a reason for hiding this comment

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

@liudezhi2098 Any difference between these two?

return future.thenCompose(__ -> {
// If the topic name is a partition name, no need to get partition topic metadata again
if (!topicName.isPartitioned()) {
getPartitionedTopicMetadataAsync(topicName, authoritative, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there miss return

log.error("[{}] {} {} {}", clientAppId(), msg, topicName, subName);
throw new IllegalStateException(msg);
} else {
return doInternalExpireMessagesByTimestampForSinglePartitionAsync(subName,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can return a CompletableFuture.completedFuture(null) if this check is passed to avoid add another method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If (!topicName.isPartitioned()) && metadata.partitions == 0 , we should also doInternalExpireMessagesByTimestampForSinglePartitionAsync

@AnonHxy AnonHxy force-pushed the fix_call_sync_call_in_async_internalExpireMessagesForAllSubscriptions branch from 44451b6 to 7f18dc6 Compare January 23, 2022 12:43
}

asyncResponse.resume(Response.noContent().build());
}).exceptionally(ex -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

.thenCompose(__ -> getTopicReferenceAsync(topicName))
.thenCompose(t -> {
PersistentTopic topic = (PersistentTopic) t;
final AtomicReference<Throwable> exception = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this line? You can get the exception from the futures from line 1879 directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks the same as #13905 (comment)? I will update there code

@@ -3445,6 +3449,92 @@ private void internalExpireMessagesByTimestampForSinglePartition(String subName,
}
}

private CompletableFuture<Void> internalExpireMessagesByTimestampForSinglePartitionAsync(String subName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think we'd better close the new one and apply the fix from the old one.

@AnonHxy AnonHxy force-pushed the fix_call_sync_call_in_async_internalExpireMessagesForAllSubscriptions branch from 7f18dc6 to 4ead34d Compare January 24, 2022 13:42
@AnonHxy
Copy link
Contributor Author

AnonHxy commented Jan 25, 2022

/pulsarbot run-failure-checks

@AnonHxy AnonHxy closed this Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants