forked from googleapis/google-cloud-go
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(profiler): avoid 100% CPU usage when missing certs
The previous implementation relied on .createProfile() sleeping a bit, which in turn relies on gax.Invoke's retry behavior and the initial backoff in the retryer used. This works most times, except gax.Invoke has logic to ignore the retryer and immediately fail when the error is certificate validation. Consequently, .createProfile() returns immediately, and pollProfilerService() will consume 100% CPU. To avoid any possibility of the endless loop in pollProfilerService() from consuming 100% CPU, a ticker is added. This addresses this particular instance, and also any unanticipated or future cases that might arise with changes in gax, etc. It also seemed like a good idea to exit pollProfilerService() when the context is cancelled. In the current implementation the context is always ctx.Background() so I don't see how this could happen, but you never know how things might change in the future. Fixes googleapis#3158
- Loading branch information
Showing
2 changed files
with
47 additions
and
11 deletions.
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