-
Notifications
You must be signed in to change notification settings - Fork 15
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
add hard-coded deadline for reflection stream. #150
Merged
rainerschoe
merged 8 commits into
IBM:master
from
abb3r:fixDescDbCloseUsingHardCodedDeadline
Dec 4, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
42436ae
add hard-code deadline for refelection stream.
b9d3df1
remove cache file when failed to close descdb stream gracefully.
0e77e01
log error and continue with rpc if the desc db stream was not closed …
08fd444
fix comments.
6929a23
increase timeout from 10 to 20 seconds.
117c215
added some comments to mention default timeout to close descDb stream.
958a2e2
comment-correction: timeout is 20secs.
6d49288
add comment for streamClose in DescDbProxy dtor.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ using grpc::reflection::v1alpha::ServerReflection; | |
using grpc::reflection::v1alpha::ServerReflectionRequest; | ||
using grpc::reflection::v1alpha::ServerReflectionResponse; | ||
|
||
const uint8_t g_timeoutGrpcMainStreamSeconds = 20; //using default gwhisper timeout of 20 seconds. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. increased since we already have default rpc timeout of 30secs anyway, is that too big? we saw that 10secs easily times out on slower systems. |
||
namespace grpc { | ||
|
||
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase( | ||
|
@@ -300,6 +301,9 @@ void ProtoReflectionDescriptorDatabase::AddFileFromResponse( | |
const std::shared_ptr<ProtoReflectionDescriptorDatabase::ClientStream> | ||
ProtoReflectionDescriptorDatabase::GetStream() { | ||
if (!stream_) { | ||
std::chrono::system_clock::time_point deadline = | ||
std::chrono::system_clock::now() + std::chrono::seconds(g_timeoutGrpcMainStreamSeconds); | ||
ctx_.set_deadline(deadline); | ||
stream_ = stub_->ServerReflectionInfo(&ctx_); | ||
} | ||
return stream_; | ||
|
@@ -317,16 +321,13 @@ bool ProtoReflectionDescriptorDatabase::DoOneRequest( | |
return success; | ||
} | ||
|
||
grpc::Status ProtoReflectionDescriptorDatabase::closeStreamWithDeadline(std::optional<std::chrono::time_point<std::chrono::system_clock>> deadline) | ||
grpc::Status ProtoReflectionDescriptorDatabase::closeDescDbStream() | ||
{ | ||
stream_mutex_.lock(); | ||
if( deadline != std::nullopt ) | ||
{ | ||
ctx_.set_deadline(deadline.value()); | ||
} | ||
|
||
auto status = closeStream(); | ||
stream_.reset(); | ||
|
||
stream_mutex_.unlock(); | ||
return status; | ||
} | ||
|
@@ -342,6 +343,9 @@ grpc::Status ProtoReflectionDescriptorDatabase::closeStream() | |
fprintf(stderr, | ||
"Reflection request not implemented; " | ||
"is the ServerReflection service enabled?\n"); | ||
} else if (status.error_code() == StatusCode::DEADLINE_EXCEEDED) { | ||
fprintf(stderr, | ||
"ServerReflectionInfo rpc failed. Grpc Server failed to close the stream within %d seconds.\n", g_timeoutGrpcMainStreamSeconds); | ||
} else { | ||
fprintf(stderr, | ||
"ServerReflectionInfo rpc failed. Error code: %d, message: %s, " | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good thought :)