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

fix: Removes unnecessary error logging for heartbeat since this is ex… #4809

Merged

Conversation

AlanConfluent
Copy link
Member

@AlanConfluent AlanConfluent commented Mar 17, 2020

…pected

Description

Disables error logging for heartbeat requests since these happen quite often and deliberately are done with nodes that might be down. During startup especially (and possibly other situations as well) this leads to tons of log spam. Since we have other mechanisms like the hearbeatAgent which log periodically when hosts are considered down, this isn't necessary.

Fixes #4807

Testing done

Ran tests.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@AlanConfluent AlanConfluent requested a review from vpapavas March 17, 2020 23:15
@AlanConfluent AlanConfluent requested a review from a team as a code owner March 17, 2020 23:15
) {
execute(HttpMethod.POST, path, jsonEntity, (resp, vcf) -> {
}).exceptionally(t -> {
log.error("Unexpected exception in async request", t);
if (expectFailures) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This precedes even this change, but I feel we should throw an exception instead of returning null? and let the caller decide whether to log or not.. I am wondering if we should pass a flag down into a common class like KsqlTarget

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, guess the class itself is aware of different endpoints.. more about this method.. can it throw the exception and let the caller decide

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd agree with Vinoth here - methods like postAsyncHeartbeatRequest and postAsyncLagReportingRequest should return a CompletableFuture, which allows the caller to decide if the care about the response and if they do, what to do with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was originally just keeping with an internal implementation that might be reusable for "fire and forget" type methods, but I'm also fine with making this a bit more general and letting callers handle the response/exception.

Changed to return CompletableFuture<RestResponse<HeartbeatResponse>> which can now be handled by the caller, including handling the exceptional case.

) {
final CompletableFuture<ResponseWithBody> vcf =
execute(httpMethod, path, requestBody, responseHandler);
return vcf.thenApply(response -> KsqlClientUtil.toRestResponse(response, path, mapper));
Copy link
Member

@vpapavas vpapavas Mar 18, 2020

Choose a reason for hiding this comment

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

Is thenApply asynchronous? We don't want to block for the response. In fact, HeartbeatAgent doesn't even care about the response.

Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline, as long as we don't call get on the future , all other callbacks are non-blocking so we are good

Copy link
Contributor

@vinothchandar vinothchandar left a comment

Choose a reason for hiding this comment

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

New structuring LGTM. I ll leave to @vpapavas for the final pass

.exceptionally(t -> {
// We send heartbeat requests quite frequently and to nodes that might be down. We don't
// want to fill the logs with spam, so we debug log exceptions.
LOG.debug("Exception in async request", t);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: async heartbeat request?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

getTarget(target, authHeader).postAsyncLagReportingRequest(lagReportingMessage);
getTarget(target, authHeader).postAsyncLagReportingRequest(lagReportingMessage)
.exceptionally(t -> {
LOG.error("Unexpected exception in async request", t);
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to debug log this as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the code, it seems like all of the hosts start off in a non-alive state and if the hoststatus callback happens at the wrong time, I think lag reporting could hit the same issue as well.

Making it debug logging as well.

Copy link
Member

@vpapavas vpapavas left a comment

Choose a reason for hiding this comment

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

Thank you @AlanConfluent ! LGTM

@AlanConfluent AlanConfluent merged commit fa84576 into confluentinc:master Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pull Queries: Heartbeat: Don't log errors when heartbeating dead nodes
4 participants