Skip to content

Reading is not allowed after reader was completed #2692

@nathanmascitelli

Description

@nathanmascitelli

Hi,

We are getting the following exception intermittently in production:

at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_NoReadingAllowed()
at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined)
at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined)
at StackExchange.Redis.PhysicalConnection.ReadFromPipe() in /_/src/StackExchange.Redis/PhysicalConnection.cs:line 1850

When this happens its alway after we have called IDatabase.StreamAddAsync.

Looking at PhysicalConnection I'm wondering if there is a race condition between ReadFromPipe and something calling Dispose?
image

Does that make sense? I'm pretty sure this class is used by multiple threads and so I think the above is posslbe. Looking at the exception handler it seems like we don't even really want to report this exception?
image

So to sum up:

  • Is this error happening due to the described race condition?
  • Do we even want to report this exception up to the caller?

We have seen this happen on multiple OS, dotnet, and package versions:

  • Ubuntu 20.04 and 22.04
  • Dotnet 7.0.17 and 8.0.3
  • StackExchange.Redis 2.7.20 and 2.7.33

Let me know if you need more info.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions