Commit cb1519a
Add exception handler on HTTP/2 parent channel to suppress WARN logs (#48890)
* Add exception handler on HTTP/2 parent channel to suppress WARN logs
In HTTP/2, reactor-netty multiplexes streams on a shared parent TCP connection.
The parent channel pipeline has no ChannelOperationsHandler (unlike HTTP/1.1),
so TCP-level exceptions like Connection reset by peer (ECONNRESET) propagate to
Netty's TailContext, which logs them as WARN.
This adds Http2ParentChannelExceptionHandler to the parent channel via
doOnConnected (accessing channel.parent()). The handler consumes exceptions
at DEBUG level WITHOUT closing the channel or altering connection lifecycle,
matching HTTP/1.1 logging behavior.
Changes:
- Handler logs cause.toString() (not getMessage()) for null-safe diagnostics
- Defensive try-catch for duplicate handler name on concurrent stream creation
- Before/after verified with EmbeddedChannel unit tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Revert azure-cosmos-tests pom.xml changes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Clarify why duplicate-name is the only possible IAE in handler install
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Move static utility method to bottom of test file
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address Copilot review: fix comment accuracy, remove duplicate cause.toString(), update changelog
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add tests for activeStreams > 0 path (WARN branch)
Address Bhaskar's review: add two tests covering the else branch where
activeStreams > 0 on an active channel, exercising the WARN log path.
- withHandler_activeStreams_consumedAtWarn: creates an active H2 stream
via codec.connection().local().createStream(), fires an exception, and
verifies it is consumed (does not reach TailContext).
- withHandler_activeStreams_channelNotClosed: same setup, verifies the
handler does not close the channel even with active streams.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add test for codec-absent fallback path
When Http2FrameCodec is absent from the pipeline, getActiveStreamCount()
returns -1. Since -1 != 0 and channelActive == true, the handler takes
the safe WARN path. This test covers that fallback behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: nullable getActiveStreamCount, Error propagation, debug log in catch
- Change getActiveStreamCount() to return Integer (nullable) instead of
int with -1 sentinel. null explicitly means 'could not determine' and
takes the safe WARN path. (Addresses Fabian's review)
- Add logger.debug in catch block so codec retrieval failures are
observable instead of silently swallowed.
- Add Error guard in exceptionCaught: Error types (OOM, SOF) propagate
to TailContext instead of being consumed. (Addresses Xinlian's review)
- Add withHandler_errorNotConsumed_propagatesToTail test.
- Update Javadoc to reflect Exception-only consumption and Error passthrough.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: install H2 exception handler on correct channel
In reactor-netty's H2 path, doOnConnected fires once per TCP connection
and connection.channel() IS the parent channel (channel.parent() is null).
The previous code assumed doOnConnected fires for child/stream channels
where channel.parent() would return the TCP parent.
Fix: resolve the H2 parent as channel.parent() ?? channel, handling both
the observed case (parent=null, channel IS the parent) and the alternate
case (parent!=null, install on parent).
Verified with integration test:
- Linux/epoll with TCP RST proxy (SO_LINGER=0, 30s idle timeout)
- 4.79.1 baseline: TailContext WARN appeared (Connection reset by peer)
- Fixed build: WARN suppressed, handler logged at DEBUG (activeStreams=0)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Simplify handler installation — use channelPipeline directly
doOnConnected fires for the parent TCP channel in reactor-netty's H2 path,
so connection.channel() IS the parent. No need for channel.parent() resolution.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address Kushagra review: log addresses, make handler @sharable singleton
- Add local/remote address to WARN and DEBUG log messages for
diagnostic parity with RNTBD connection loggers
- Mark handler @ChannelHandler.Sharable with singleton INSTANCE
(handler is stateless - no instance fields)
- Update ReactorNettyClient to use INSTANCE instead of new
- Update tests to use INSTANCE
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use string append for log messages, pass channel directly
Matches PartitionProcessor/HealthChecker patterns - avoids SLF4J
inline formatting issues. Channel.toString() provides L:/R: addresses.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use channel= prefix in log messages for clarity
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add clientVmId to exception handler log messages
Resolve vmId lazily via ClientTelemetry.getMachineId(null) on first
access from non-event-loop thread. Store as immutable field in the
@sharable handler singleton.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: resolve vmId eagerly on caller thread, not event loop
Remove lazy singleton pattern (getOrCreateInstance) that could call
ClientTelemetry.getMachineId() on the Netty event loop (5s blocking).
Instead, create handler eagerly in configureChannelPipelineHandlers()
which runs on the caller's setup thread. The @sharable handler instance
is captured by the doOnConnected lambda.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: use non-blocking getCachedMachineId() for vmId
Remove all blocking calls. Add ClientTelemetry.getCachedMachineId()
which reads a volatile field populated by getMachineId() during client
init. Handler reads it at log time - pure volatile read, zero blocking.
Restores static INSTANCE singleton (handler is stateless again).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use n/a fallback for unresolved vmId in logs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent d3eead7 commit cb1519a
5 files changed
Lines changed: 385 additions & 0 deletions
File tree
- sdk/cosmos
- azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/http
- azure-cosmos
- src/main/java/com/azure/cosmos/implementation
- clienttelemetry
- http
Lines changed: 246 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
124 | 139 | | |
125 | 140 | | |
126 | 141 | | |
| |||
136 | 151 | | |
137 | 152 | | |
138 | 153 | | |
| 154 | + | |
139 | 155 | | |
140 | 156 | | |
141 | 157 | | |
| |||
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments