-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spanner use custom thread factory #5167
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
Spanner use custom thread factory #5167
Conversation
Using a custom thread factory for the different underlying gRPC clients makes it easier to debug potential thread problems, as the name of the thread indicates to which client it belongs.
|
This looks good, do you think we can add an IT test as well for this? Separately, anything we can test on the transport channel and its threads? |
Setting an executor provider on the stub settings would cause the executors to be shared between the underlying gRPC channels. Instead, each channel should have its own executor. The executor provider is now set on the channel provider again, but the executor provider keeps track of the executors that have been handed out and closes these when the Spanner instance is closed. This approach is equal to the approach that was already used for the spannerWatchdog executor.
Codecov Report
@@ Coverage Diff @@
## master #5167 +/- ##
============================================
+ Coverage 50.38% 50.4% +0.02%
- Complexity 23736 23785 +49
============================================
Files 2248 2251 +3
Lines 226471 226792 +321
Branches 24954 24966 +12
============================================
+ Hits 114109 114320 +211
- Misses 103770 103865 +95
- Partials 8592 8607 +15
Continue to review full report at Codecov.
|
The actual number of threads is too dependent on random factors to be used for testing. Manual testing by calling ThreadPoolExecutor#prestartAllCoreThreads() shows the desired behavior.
Use a custom ThreadFactory for the underlying gRPC clients to make it easier to determine and debug which service has created the threads.