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

THRIFT-5670: lib: cpp: Fix wrong timeout error message #2732

Merged
merged 1 commit into from Oct 20, 2023

Conversation

stiga-huang
Copy link
Contributor

@stiga-huang stiga-huang commented Nov 22, 2022

We've seen a strange timeout error message like this:

TSocket::read() THRIFT_EAGAIN (timed out) after %f ms: Unknown error 30000

The log comes from this line:

GlobalOutput.perror("TSocket::read() THRIFT_EAGAIN (timed out) after %f ms", recvTimeout_);

The second argument of GlobalOutput.perror() is an errno. We should not use recvTimeout_ on it:

void perror(const char* message, int errno_copy);

class TOutput {
  ...
  void perror(const char* message, int errno_copy);  // <-- The second arg is errno
  ...
  void printf(const char* message, ...);
};
THRIFT_EXPORT extern TOutput GlobalOutput;

The implementation of perror():

void TOutput::perror(const char* message, int errno_copy) {
  std::string out = message + std::string(": ") + strerror_s(errno_copy);
  f_(out.c_str());
}

It converts the errno to the error string, and 30000 is an unknown errno.

What we want is to print the timeout threshold. We should use GlobalOutput.printf() instead.

This PR fixes the wrong usage of GlobalOutput.perror(). The error message will be

TSocket::read() THRIFT_EAGAIN (timed out) after 30000 ms
  • Did you create an Apache Jira ticket? (not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@Jens-G Jens-G added the c++ label Nov 24, 2022
@stiga-huang
Copy link
Contributor Author

@emmenlau Could you help to review this?

@stiga-huang
Copy link
Contributor Author

Ping @emmenlau @Jens-G

@stiga-huang stiga-huang changed the title THRIFT-5670: Fix wrong usage of GlobalOutput.perror() THRIFT-5670: lib: cpp: Fix wrong timeout error message Jun 17, 2023
@stiga-huang
Copy link
Contributor Author

Updated the PR description. Hopefully it's more clear about the issue.

Copy link
Member

@emmenlau emmenlau left a comment

Choose a reason for hiding this comment

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

LGTM.

lib/cpp/src/thrift/transport/TSocket.cpp Show resolved Hide resolved
@emmenlau emmenlau self-assigned this Oct 20, 2023
@emmenlau emmenlau merged commit 7f37c2d into apache:master Oct 20, 2023
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants