-
Notifications
You must be signed in to change notification settings - Fork 5.4k
upstream: update host's socket factory when metadata is updated. #16708
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
Changes from 3 commits
9074af6
5d58b92
1dabea0
27cbdd6
a37c7d0
79b4401
85c52c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,8 @@ class HostDescriptionImpl : virtual public HostDescription, | |
| void metadata(MetadataConstSharedPtr new_metadata) override { | ||
| absl::WriterMutexLock lock(&metadata_mutex_); | ||
| metadata_ = new_metadata; | ||
| // Update data members dependent on metadata. | ||
| socket_factory_ = resolveTransportSocketFactory(address_, metadata_.get()); | ||
| } | ||
|
|
||
| const ClusterInfo& cluster() const override { return *cluster_; } | ||
|
|
@@ -176,7 +178,7 @@ class HostDescriptionImpl : virtual public HostDescription, | |
| Outlier::DetectorHostMonitorPtr outlier_detector_; | ||
| HealthCheckHostMonitorPtr health_checker_; | ||
| std::atomic<uint32_t> priority_; | ||
| Network::TransportSocketFactory& socket_factory_; | ||
| std::reference_wrapper<Network::TransportSocketFactory> socket_factory_; | ||
|
Member
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. This needs a
Contributor
Author
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. Annotation added . |
||
| const MonotonicTime creation_time_; | ||
| }; | ||
|
|
||
|
|
||
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.
Could resolveTransportSocketFactory be moved out of the lock guard?
The referenced Metadata should be immutable and valid.
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.
@lambdai I can add a scope around the lock to unlock it before calling
resolveTransportSocketFactory. Why do you think it is necessary? Deadlock?Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry for the late reply.
It's not necessary but nice to have.
The only reason is performance.
resolveTransportSocketFactorydoesn't need the lock to protectThere 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.
Take it or leave it. It's probably not a bottleneck.
auto factory = resolveTransportSocketFactory(address_, new_metadata.get());
{
absl::WriterMutexLock lock(&metadata_mutex_);
metadata_ = new_metadata;
socket_factory_ = factory;
}
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.
Updated as you suggested. There is small performance improvement to resolve factory outside of mutex protected scope. Thanks!