-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Preserve Thread Context by gRPC Interceptor #19776
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
Preserve Thread Context by gRPC Interceptor #19776
Conversation
|
❌ Gradle check result for 371161d: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
d2985ea to
ab49942
Compare
|
❌ Gradle check result for ab49942: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcPlugin.java
Show resolved
Hide resolved
...es/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java
Show resolved
Hide resolved
...sport-grpc/src/main/java/org/opensearch/transport/grpc/interceptor/GrpcInterceptorChain.java
Show resolved
Hide resolved
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
dd0261d to
adca9b9
Compare
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
|
❌ Gradle check result for 13a82b7: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
|
❌ Gradle check result for df61802: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
❌ Gradle check result for df61802: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Aparajita Pandey <37636092+aparajita31pandey@users.noreply.github.com>
|
❌ Gradle check result for d5f9a71: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Aparajita Pandey <37636092+aparajita31pandey@users.noreply.github.com>
|
❌ Gradle check result for 8356875: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
|
❌ Gradle check result for 1db65d5: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Flaky test - #15813 |
Signed-off-by: Aparajita Pandey <37636092+aparajita31pandey@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #19776 +/- ##
============================================
- Coverage 73.27% 73.27% -0.01%
+ Complexity 71641 71600 -41
============================================
Files 5785 5785
Lines 326935 326961 +26
Branches 47295 47296 +1
============================================
- Hits 239576 239570 -6
- Misses 68179 68193 +14
- Partials 19180 19198 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This change is build on top of #19005, where gRPC interceptor was introduced. It add ThreadContext to be accessed by the interceptors and also thread context preservation between interceptor and grpc Service execution
Problem: gRPC callbacks run on different threads than interceptors. OpenSearch's ThreadContext added by interceptor are in thread-local and gets lost during thread switches, when reaches gRPC ServiceImpl. In this diff,
After interceptors populate ThreadContext, we capture it using threadContext.newRestorableContext(false) and wrap all gRPC listener callbacks to restore the captured context before execution, following the same pattern as
ContextPreservingActionListenerWith this change, it bridges the gap between gRPC's async threading model and OpenSearch's thread-local context model.
Related Issues
Builds on #19005
Check List
Test Plan
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.