Skip to content

Content-Length mismatch randomly on high throughput when using Output Caching #51009

Closed
@vasicvuk

Description

@vasicvuk

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using StackExchange Redis Output Caching we randomly get an error:

System.InvalidOperationException: Response Content-Length mismatch: too few bytes written (0 of 5468).

We analyzed the key value, and we see that the Content-Length is not part of the cache, this means that this 5468 is calculated from the cached entry, but for some reason, the response is not written and this error appears.

Output caching with Memory works without this issue.

UPDATE

The number of threads does not meter. The difference is the .NET Version (on the local we had Preview 7 and, on the environment, the latest nightly build). It seems the issue is introduced after RC1 version

Expected Behavior

No System.InvalidOperationException happening.

Steps To Reproduce

For the test, we created an Apache JMeter test with 10, 25, and 50 threads calling the API each of the tests contained this error.
We could reproduce the issue when using Output caching on the Debug level, only in the environment with the Docker container connecting to the Redis database.

Exceptions (if any)

No response

.NET Version

8.0.0-rc.2.23466.4

Anything else?

Host:
Version: 8.0.0-rc.2.23466.4
Architecture: x64
Commit: 287c10d253
RID: linux-musl-x64

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.0-rtm.23468.24 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.0-rc.2.23466.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

Labels

area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-output-caching

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions