Commit c905251
Gate HTTP/2 PING failure-based connection close exception rewraps to PING enablement flag. (#49403)
* perf: install Http2PingCloseRewrapHandler in doOnConnected, not doOnRequest
The previous .doOnRequest() chained onto the HTTP/2 HttpClient builder
wrapped every outgoing request's Mono in a Reactor operator. That paid
per-request costs even when the rewrap handler was already installed:
* MonoPeekTerminal wrap + per-request subscriber allocation
(InternalMonoOperator.subscribe +2.60% in alloc profile)
* per-request BiConsumer lambda invocation
(Http2Pool\$\...run +1.16% in alloc profile)
* per-request channel pipeline String-key walk via pipeline.get(...)
Long-run async-profiler diff vs v4.80.0 on D2 attributed the PR's
-7.6% QPS / +14.5% mean / +166% tail-max regression primarily to a
+10.2% allocation rate -- with the operators above dominating the delta.
Move the install into the existing .doOnConnected() block, which
already runs once per HTTP/2 child stream (the customHeaderCleaner
install right above it relies on the same contract). The rewrap
handler is @sharable, so installing once per stream is correct and
amortizes the install + pipeline-walk away from the hot path.
The ch.parent() != null guard is kept so the install only targets
child streams, never the parent TCP channel (which uses
Http2ParentChannelExceptionHandler instead).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* perf: gate Http2PingCloseRewrapHandler install on isPingHealthEffectivelyEnabled
Follow-up to the doOnConnected install move (previous commit on this PR).
The rewrap handler translates Http2MultiplexHandler's per-child-stream
channelInactive into a typed Http2PingTimeoutChannelClosedException when
the PING sender closes the parent TCP channel after consecutive PING-ACK
timeouts. If the PING sender is disabled there is no such signal to
translate, so the install adds per-child-stream pipeline-add cost and an
extra pipeline hop on every inbound frame for zero behavioral benefit.
Empirical motivation: long-run perf matrix on a 2 vCPU D2s_v5 VM
(point-read workload, Gateway+H2, ~98% CPU steady state, baseline =
v4.80.0):
baseline (v4.80.0) : 9010 QPS
ping-prefix (PR before doOnConnected fix) : 8301 QPS (-7.9%)
ping-postfix (doOnConnected install only) : 8170 QPS (-9.3%)
ping-off (postfix + HTTP2_PING_HEALTH=false): 8102 QPS (-10.1%)
Toggling the documented kill switch did not recover baseline because
the rewrap install was unconditional -- the kill switch only suppressed
the PING sender, not the per-child-stream rewrap install. async-profiler
CPU diffs ping-off-vs-baseline and ping-off-vs-postfix were essentially
identical, confirming the rewrap install dominates the residual cost.
Consolidating both PING-sender install and rewrap install under
Http2PingHandler.isPingHealthEffectivelyEnabled makes
HTTP2_PING_HEALTH_ENABLED=false a true revert-to-baseline.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(cosmos): install HTTP/2 PING rewrap handler via observe(STREAM_CONFIGURED)
The rewrap handler install lived inside .doOnConnected(...), which reactor-netty fires only on the H2 parent TCP channel (State.CONFIGURED, parent==null). The install was gated on ch.parent()!=null, so it never ran on the parent and never reached a child stream -- the handler was installed 0 times and PING-timeout parent closes surfaced as bare PrematureCloseException instead of the typed Http2PingTimeoutChannelClosedException.
Move the install to .observe((connection, state) -> ...) keyed on HttpClientState.STREAM_CONFIGURED, the per-child-stream lifecycle event. The handler is now added at the head of each H2 child-stream pipeline, where it intercepts channelInactive ahead of HttpClientOperations and rewraps the close into the typed exception so ClientRetryPolicy can suppress region mark-down. Keeps the PING-health gate, ch.parent()!=null defensive check, get(HANDLER_NAME)==null guard, and TOCTOU try/catch. Also fixes stale doc-comments referencing the old install hook.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs(cosmos): tighten Http2PingCloseRewrapHandler class-doc wording
The handler is a single @sharable instance installed per H2 child stream, not a per-request object. Reword the class-doc summary from 'Per-request' to 'Per-child-stream' for consistency with the rest of the doc.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add CI unit test for HTTP/2 PING close-rewrap install gate
Extract the inline .observe() install decision into a package-private static
installHttp2PingCloseRewrapHandlerIfNeeded(...) so the per-child-stream gate is
unit-testable without a live HTTP/2 connection. Add a TestNG unit test (group
"unit") that drives the real method via an EmbeddedChannel and proves the
disablement path (kill-switch off, non-positive PING interval, HTTP/2 disabled,
non-STREAM_CONFIGURED state, parent-less channel) is a true revert-to-baseline
that installs nothing -- plus positive install, head-of-pipeline position,
idempotency, and state-before-predicate short-circuit ordering.
Behavior-preserving refactor; no user-facing change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update CHANGELOG.md
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4ff3741 commit c905251
4 files changed
Lines changed: 354 additions & 32 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/http
Lines changed: 256 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 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
0 commit comments