fix: monitorUpstreamConnectionState CPU consumption (#3884)
* fix: monitorUpstreamConnectionState CPU consumption `monitorUpstreamConnectionState()` is a goroutine that listens for GRPC client connection changes using GRPC's `WaitForStateChange` method. `monitorUpstreamConnectionState()` was consuming the a lot of CPU. It was continuously running and not actually waiting for state changes. The `state` for `monitorUpstreamConnectionState()` was not getting correctly updated which caused the loop to continuously run instead of waiting for new state changes. Update GRPC `WaitForStateChange` method to use the same `state` that gets updated.
This commit is contained in:
1 parent
1c330543a7
commit
5741807b4a
2 files changed
+6
-3
No files matched your search
@@ -4,6 +4,9 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
|
||||
|
||||
## Next
|
||||
|
||||
### Bug Fixes
|
||||
* monitorUpstreamConnectionState CPU consumption: `monitorUpstreamConnectionState()` is a goroutine that listens for GRPC client connection changes using GRPC's `WaitForStateChange` method. `monitorUpstreamConnectionState()` was consuming the a lot of CPU. It was continuously running and not actually waiting for state changes. The `state` for `monitorUpstreamConnectionState()` was not getting correctly updated which caused the loop to continuously run instead of waiting for new state changes.
|
||||
|
||||
## 0.14.1 (2023/10/17)
|
||||
|
||||
### Security
|
||||
|
||||
@@ -434,13 +434,13 @@ func monitorUpstreamConnectionState(ctx context.Context, cc *grpc.ClientConn, co
|
||||
}
|
||||
|
||||
for cc.WaitForStateChange(ctx, state) {
|
||||
newState := cc.GetState()
|
||||
state = cc.GetState()
|
||||
|
||||
// if the client is shutdown, exit function
|
||||
if newState == connectivity.Shutdown {
|
||||
if state == connectivity.Shutdown {
|
||||
return
|
||||
}
|
||||
|
||||
connectionState.Store(newState)
|
||||
connectionState.Store(state)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user