Repository navigation
fix(bigtable): count pre-OpenSessionResponse stream failures in ChannelPoolDpImpl - #15039
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors channel failure tracking in ChannelPoolDpImpl by introducing a sessionEstablished flag to ensure that consecutive failures are only reset when a session is successfully opened or closed with an OK status, and incremented if a failure occurs before session establishment. A corresponding unit test has been added to verify this behavior. The review feedback correctly identifies a concurrency issue where sessionEstablished is read outside of a synchronized block but written inside one, and suggests declaring it as volatile to guarantee proper memory visibility.
| return new SessionStreamImpl(innerCall) { | ||
| // null until onBeforeSessionStart fires | ||
| @Nullable AfeId afeId = null; | ||
| boolean sessionEstablished = false; |
There was a problem hiding this comment.
The sessionEstablished field is read outside of a synchronized block in onMessage (line 332) but written inside a synchronized block (line 334). To ensure proper memory visibility and prevent thread-local caching or instruction reordering under the Java Memory Model (JMM), this field should be declared volatile.
| boolean sessionEstablished = false; | |
| volatile boolean sessionEstablished = false; |
References
- Ensure that fields used for cross-thread state checks, such as exceptions set by background threads and read by application threads, are declared as volatile to guarantee memory visibility and establish a proper happens-before relationship under the Java Memory Model.
d5c4ee1 to
b9617c3
Compare
b9617c3 to
c626c8b
Compare
c626c8b to
952a289
Compare
| @Override | ||
| public void onMessage(SessionResponse msg) { | ||
| if (!sessionEstablished && msg.hasOpenSession()) { | ||
| synchronized (ChannelPoolDpImpl.this) { |
There was a problem hiding this comment.
why does this need to synchronized?
|
|
||
| @Override | ||
| public void onMessage(SessionResponse msg) { | ||
| if (!sessionEstablished && msg.hasOpenSession()) { |
There was a problem hiding this comment.
please add a comment why doing this onBeforeSessionStart is not enough.
…ization and comments
…f inspecting onMessage
…ed by ChannelPoolDpImpl
Part 2 of 2 for b/584671437 (stacked on #15038).
What changed
ChannelPoolDpImplwhenOpenSessionResponsearrives (onMessage), rather than when initialPeerInfoheaders arrive (onBeforeSessionStart).OpenSessionResponseas consecutive failures and evict the failedrouteObservationsentry so subsequentOpenSessionattempts do not remain pinned to a failing AFE/subzone.