Skip to content

Conversation

@aparajita31pandey
Copy link
Contributor

@aparajita31pandey aparajita31pandey commented Oct 27, 2025

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 ContextPreservingActionListener

With 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

  • Functionality includes testing.

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.

@aparajita31pandey aparajita31pandey requested a review from a team as a code owner October 27, 2025 04:27
@aparajita31pandey aparajita31pandey marked this pull request as draft October 27, 2025 04:27
@github-actions
Copy link
Contributor

❌ 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?

@aparajita31pandey aparajita31pandey force-pushed the InterceptorThreadContext branch 2 times, most recently from d2985ea to ab49942 Compare October 27, 2025 05:41
@github-actions
Copy link
Contributor

❌ 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?

@aparajita31pandey aparajita31pandey changed the title Draft: Preserve Context For Thread by Interceptor Draft: Preserve Thread Context by gRPC Interceptor Nov 4, 2025
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

❌ 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>
@aparajita31pandey aparajita31pandey changed the title Draft: Preserve Thread Context by gRPC Interceptor Preserve Thread Context by gRPC Interceptor Nov 5, 2025
@aparajita31pandey aparajita31pandey marked this pull request as ready for review November 5, 2025 14:09
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

❌ 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?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

❌ 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>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

❌ 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>
@github-actions
Copy link
Contributor

❌ 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>
@github-actions
Copy link
Contributor

❌ 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?

@aparajita31pandey
Copy link
Contributor Author

Flaky test - #15813

Signed-off-by: Aparajita Pandey <37636092+aparajita31pandey@users.noreply.github.com>
@github-actions
Copy link
Contributor

✅ Gradle check result for 5859ce9: SUCCESS

@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 94.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.27%. Comparing base (b08de24) to head (5859ce9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ansport/grpc/interceptor/GrpcInterceptorChain.java 90.47% 2 Missing ⚠️
...java/org/opensearch/transport/grpc/GrpcPlugin.java 96.29% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants