fix(spanner): scope server-timing metrics per call and guard interceptor lifecycle callbacks - #14053
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors HeaderInterceptor to make it thread-safe by moving latency state variables from the class level to the call listener level. It also enhances robustness in both HeaderInterceptor and SpannerErrorInterceptor by wrapping header and close processing in try-catch-finally blocks, ensuring downstream gRPC notifications are always executed even if unexpected exceptions occur. Additionally, comprehensive unit tests are introduced for both interceptors to verify their behavior and error handling. I have no feedback to provide as there are no review comments.
…tor lifecycle callbacks - Scope gfeLatency and afeLatency to per-call listener instances in HeaderInterceptor to eliminate data races and cross-RPC telemetry pollution. - Guard onHeaders and onClose in HeaderInterceptor with try...finally to guarantee downstream callback propagation (preventing hung futures) and RequestIdTargetTracker cleanup. - Catch Throwable in SpannerErrorInterceptor.onClose to prevent unexpected metadata parsing errors from escaping into gRPC transport threads. The above changes should guarantee that all interceptors in the entire chain of interceptors are always executed, and that no exceptions escape to the gRPC thread executing them.
olavloite
force-pushed
the
spanner-fix-race-in-header-interceptor
branch
from
August 12, 2026 08:37
ff9bece to
01b12f6
Compare
rahul2393
approved these changes
Aug 12, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The above changes should guarantee that all interceptors in the entire chain of interceptors are always executed, and that no exceptions escape to the gRPC thread executing them.