Skip to content

Commit 3509fd7

Browse files
committed
Resolve conflicts
2 parents d9d432e + 57512b4 commit 3509fd7

File tree

8 files changed

+173
-32
lines changed

8 files changed

+173
-32
lines changed

NuGet.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
<clear />
55
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
66
<!-- Begin: Package sources from dotnet-efcore -->
7+
<<<<<<< HEAD
78
<add key="darc-int-dotnet-efcore-f16e454" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-f16e454a/nuget/v3/index.json" />
89
<!-- End: Package sources from dotnet-efcore -->
910
<!-- Begin: Package sources from dotnet-runtime -->
1011
<add key="darc-int-dotnet-runtime-3bcb9f2" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-3bcb9f24/nuget/v3/index.json" />
12+
=======
13+
<add key="darc-int-dotnet-efcore-c20ecc7" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-c20ecc79/nuget/v3/index.json" />
14+
<!-- End: Package sources from dotnet-efcore -->
15+
<!-- Begin: Package sources from dotnet-runtime -->
16+
<add key="darc-int-dotnet-runtime-4a824ef" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-4a824ef3/nuget/v3/index.json" />
17+
>>>>>>> v7.0.12
1118
<!-- End: Package sources from dotnet-runtime -->
1219
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
1320
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
@@ -26,10 +33,17 @@
2633
<clear />
2734
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
2835
<!-- Begin: Package sources from dotnet-efcore -->
36+
<<<<<<< HEAD
2937
<add key="darc-int-dotnet-efcore-f16e454" value="true" />
3038
<!-- End: Package sources from dotnet-efcore -->
3139
<!-- Begin: Package sources from dotnet-runtime -->
3240
<add key="darc-int-dotnet-runtime-3bcb9f2" value="true" />
41+
=======
42+
<add key="darc-int-dotnet-efcore-c20ecc7" value="true" />
43+
<!-- End: Package sources from dotnet-efcore -->
44+
<!-- Begin: Package sources from dotnet-runtime -->
45+
<add key="darc-int-dotnet-runtime-4a824ef" value="true" />
46+
>>>>>>> v7.0.12
3347
<!-- End: Package sources from dotnet-runtime -->
3448
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
3549
</disabledPackageSources>

eng/Version.Details.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@
1111
<ProductDependencies>
1212
<Dependency Name="dotnet-ef" Version="7.0.12">
1313
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
14-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
14+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
1515
</Dependency>
1616
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.12">
1717
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
18-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
18+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
1919
</Dependency>
2020
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="7.0.12">
2121
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
22-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
22+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
2323
</Dependency>
2424
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12">
2525
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
26-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
26+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
2727
</Dependency>
2828
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12">
2929
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
30-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
30+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3131
</Dependency>
3232
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="7.0.12">
3333
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
34-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
34+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3535
</Dependency>
3636
<Dependency Name="Microsoft.EntityFrameworkCore" Version="7.0.12">
3737
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
38-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
38+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
3939
</Dependency>
4040
<Dependency Name="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
4141
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-efcore</Uri>
42-
<Sha>f16e454a752548577728fda7a7b20a8ad7405f36</Sha>
42+
<Sha>c20ecc79b7df3657e186ac52e7fc050beea36c92</Sha>
4343
</Dependency>
4444
<Dependency Name="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0">
4545
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
@@ -177,9 +177,9 @@
177177
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
178178
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
179179
</Dependency>
180-
<Dependency Name="Microsoft.Internal.Runtime.AspNetCore.Transport" Version="7.0.12-servicing.23463.5">
180+
<Dependency Name="Microsoft.Internal.Runtime.AspNetCore.Transport" Version="7.0.12-servicing.23477.20">
181181
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
182-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
182+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
183183
</Dependency>
184184
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22505.1">
185185
<Uri>https://github.com/dotnet/source-build-externals</Uri>
@@ -256,39 +256,39 @@
256256
</Dependency>
257257
<Dependency Name="System.Threading.RateLimiting" Version="7.0.1">
258258
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
259-
<Sha>ecb34f85ec92e1b3c814edf7da83337e199e7f66</Sha>
259+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
260260
</Dependency>
261261
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="7.0.0">
262262
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
263263
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
264264
</Dependency>
265265
<Dependency Name="Microsoft.NETCore.App.Ref" Version="7.0.12">
266266
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
267-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
267+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
268268
</Dependency>
269269
<Dependency Name="Microsoft.NET.Runtime.MonoAOTCompiler.Task" Version="7.0.12">
270270
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
271-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
271+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
272272
</Dependency>
273273
<Dependency Name="Microsoft.NET.Runtime.WebAssembly.Sdk" Version="7.0.12">
274274
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
275-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
275+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
276276
</Dependency>
277277
<!--
278278
Win-x64 is used here because we have picked an arbitrary runtime identifier to flow the version of the latest NETCore.App runtime.
279279
All Runtime.$rid packages should have the same version.
280280
-->
281281
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="7.0.12">
282282
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
283-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
283+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
284284
</Dependency>
285285
<Dependency Name="Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm" Version="7.0.12">
286286
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
287-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
287+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
288288
</Dependency>
289-
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="7.0.12-servicing.23463.5">
289+
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="7.0.12-servicing.23477.20">
290290
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
291-
<Sha>3bcb9f24805914a1a73d9b4ef0c82b28ede106b4</Sha>
291+
<Sha>4a824ef37caa51072221584c64cbf15455f406ca</Sha>
292292
</Dependency>
293293
<Dependency Name="Microsoft.Web.Xdt" Version="7.0.0-preview.22423.2">
294294
<Uri>https://github.com/dotnet/xdt</Uri>

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>7.0.12</MicrosoftNETRuntimeMonoAOTCompilerTaskVersion>
6969
<MicrosoftNETRuntimeWebAssemblySdkVersion>7.0.12</MicrosoftNETRuntimeWebAssemblySdkVersion>
7070
<MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>7.0.12</MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion>
71-
<MicrosoftNETCoreBrowserDebugHostTransportVersion>7.0.12-servicing.23463.5</MicrosoftNETCoreBrowserDebugHostTransportVersion>
71+
<MicrosoftNETCoreBrowserDebugHostTransportVersion>7.0.12-servicing.23477.20</MicrosoftNETCoreBrowserDebugHostTransportVersion>
7272
<MicrosoftExtensionsCachingAbstractionsVersion>7.0.0</MicrosoftExtensionsCachingAbstractionsVersion>
7373
<MicrosoftExtensionsCachingMemoryVersion>7.0.0</MicrosoftExtensionsCachingMemoryVersion>
7474
<MicrosoftExtensionsConfigurationAbstractionsVersion>7.0.0</MicrosoftExtensionsConfigurationAbstractionsVersion>
@@ -103,7 +103,7 @@
103103
<MicrosoftExtensionsOptionsDataAnnotationsVersion>7.0.0</MicrosoftExtensionsOptionsDataAnnotationsVersion>
104104
<MicrosoftExtensionsOptionsVersion>7.0.1</MicrosoftExtensionsOptionsVersion>
105105
<MicrosoftExtensionsPrimitivesVersion>7.0.0</MicrosoftExtensionsPrimitivesVersion>
106-
<MicrosoftInternalRuntimeAspNetCoreTransportVersion>7.0.12-servicing.23463.5</MicrosoftInternalRuntimeAspNetCoreTransportVersion>
106+
<MicrosoftInternalRuntimeAspNetCoreTransportVersion>7.0.12-servicing.23477.20</MicrosoftInternalRuntimeAspNetCoreTransportVersion>
107107
<SystemConfigurationConfigurationManagerVersion>7.0.0</SystemConfigurationConfigurationManagerVersion>
108108
<SystemDiagnosticsDiagnosticSourceVersion>7.0.2</SystemDiagnosticsDiagnosticSourceVersion>
109109
<SystemDiagnosticsEventLogVersion>7.0.0</SystemDiagnosticsEventLogVersion>

src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,31 @@ internal sealed partial class Http2Connection : IHttp2StreamLifetimeHandler, IHt
4646
private const int MaxStreamPoolSize = 100;
4747
private const long StreamPoolExpiryTicks = TimeSpan.TicksPerSecond * 5;
4848

49+
private const string MaximumEnhanceYourCalmCountProperty = "Microsoft.AspNetCore.Server.Kestrel.Http2.MaxEnhanceYourCalmCount";
50+
51+
private static readonly int _enhanceYourCalmMaximumCount = GetMaximumEnhanceYourCalmCount();
52+
53+
private static int GetMaximumEnhanceYourCalmCount()
54+
{
55+
var data = AppContext.GetData(MaximumEnhanceYourCalmCountProperty);
56+
if (data is int count)
57+
{
58+
return count;
59+
}
60+
if (data is string countStr && int.TryParse(countStr, out var parsed))
61+
{
62+
return parsed;
63+
}
64+
65+
return 20; // Empirically derived
66+
}
67+
68+
// Accumulate _enhanceYourCalmCount over the course of EnhanceYourCalmTickWindowCount ticks.
69+
// This should make bursts less likely to trigger disconnects.
70+
private const int EnhanceYourCalmTickWindowCount = 5;
71+
72+
private static bool IsEnhanceYourCalmEnabled => _enhanceYourCalmMaximumCount > 0;
73+
4974
private readonly HttpConnectionContext _context;
5075
private readonly Http2FrameWriter _frameWriter;
5176
private readonly Pipe _input;
@@ -74,6 +99,9 @@ internal sealed partial class Http2Connection : IHttp2StreamLifetimeHandler, IHt
7499
private int _clientActiveStreamCount;
75100
private int _serverActiveStreamCount;
76101

102+
private int _enhanceYourCalmCount;
103+
private int _tickCount;
104+
77105
// The following are the only fields that can be modified outside of the ProcessRequestsAsync loop.
78106
private readonly ConcurrentQueue<Http2Stream> _completedStreams = new ConcurrentQueue<Http2Stream>();
79107
private readonly StreamCloseAwaitable _streamCompletionAwaitable = new StreamCloseAwaitable();
@@ -361,13 +389,20 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
361389
stream.Abort(new IOException(CoreStrings.Http2StreamAborted, connectionError));
362390
}
363391

364-
// Use the server _serverActiveStreamCount to drain all requests on the server side.
365-
// Can't use _clientActiveStreamCount now as we now decrement that count earlier/
366-
// Can't use _streams.Count as we wait for RST/END_STREAM before removing the stream from the dictionary
367-
while (_serverActiveStreamCount > 0)
392+
// For some reason, this loop doesn't terminate when we're trying to abort.
393+
// Since we're making a narrow fix for a patch, we'll bypass it in such scenarios.
394+
// TODO: This is probably a bug - something in here should probably detect aborted
395+
// connections and short-circuit.
396+
if (!IsEnhanceYourCalmEnabled || error is not Http2ConnectionErrorException)
368397
{
369-
await _streamCompletionAwaitable;
370-
UpdateCompletedStreams();
398+
// Use the server _serverActiveStreamCount to drain all requests on the server side.
399+
// Can't use _clientActiveStreamCount now as we now decrement that count earlier/
400+
// Can't use _streams.Count as we wait for RST/END_STREAM before removing the stream from the dictionary
401+
while (_serverActiveStreamCount > 0)
402+
{
403+
await _streamCompletionAwaitable;
404+
UpdateCompletedStreams();
405+
}
371406
}
372407

373408
while (StreamPool.TryPop(out var pooledStream))
@@ -1170,6 +1205,20 @@ private void StartStream()
11701205
// Server is getting hit hard with connection resets.
11711206
// Tell client to calm down.
11721207
// TODO consider making when to send ENHANCE_YOUR_CALM configurable?
1208+
1209+
if (IsEnhanceYourCalmEnabled && Interlocked.Increment(ref _enhanceYourCalmCount) > EnhanceYourCalmTickWindowCount * _enhanceYourCalmMaximumCount)
1210+
{
1211+
Log.Http2TooManyEnhanceYourCalms(_context.ConnectionId, _enhanceYourCalmMaximumCount);
1212+
1213+
// Now that we've logged a useful message, we can put vague text in the exception
1214+
// messages in case they somehow make it back to the client (not expected)
1215+
1216+
// This will close the socket - we want to do that right away
1217+
Abort(new ConnectionAbortedException(CoreStrings.Http2ConnectionFaulted));
1218+
// Throwing an exception as well will help us clean up on our end more quickly by (e.g.) skipping processing of already-buffered input
1219+
throw new Http2ConnectionErrorException(CoreStrings.Http2ConnectionFaulted, Http2ErrorCode.ENHANCE_YOUR_CALM);
1220+
}
1221+
11731222
throw new Http2StreamErrorException(_currentHeadersStream.StreamId, CoreStrings.Http2TellClientToCalmDown, Http2ErrorCode.ENHANCE_YOUR_CALM);
11741223
}
11751224
}
@@ -1241,6 +1290,12 @@ private void AbortStream(int streamId, IOException error)
12411290
void IRequestProcessor.Tick(DateTimeOffset now)
12421291
{
12431292
Input.CancelPendingRead();
1293+
// We count EYCs over a window of a given length to avoid flagging short-lived bursts.
1294+
// At the end of each window, reset the count.
1295+
if (IsEnhanceYourCalmEnabled && ++_tickCount % EnhanceYourCalmTickWindowCount == 0)
1296+
{
1297+
Interlocked.Exchange(ref _enhanceYourCalmCount, 0);
1298+
}
12441299
}
12451300

12461301
void IHttp2StreamLifetimeHandler.OnStreamCompleted(Http2Stream stream)

0 commit comments

Comments
 (0)