question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaking: Consumer always faults randomly on high throughput with ReadOnlySequence<byte> exceptions

See original GitHub issue

Let me start by saying that IMHO the project looks great, uses most of the best and latest features of .NET Core, and code looks nice. So congrats @blankensteiner and all other contributors, on a most excellent start!

Under high throughput the Consumer always faults randomly (sometimes sooner sometimes later) but always 100% of the times and while trying to read a ReadOnlySequence<T> (MacOs + SDK 3.1.101)

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'start')
   at DotPulsar.Internal.Extensions.ReadOnlySequenceExtensions.StartsWith[T](ReadOnlySequence`1 sequence, ReadOnlyMemory`1 target)

While stress testing I have seen it happen in these areas of the code but only when consuming:

It is reproducible by simply using the Samples solution, running the Producer to produce a large number of messages - say 50K, and starting the Consumer.

I tried to fix everything by attempting several solutions without success:

  • Using SequenceReader<byte>
  • Using sequence.TryGet(ref position, out var memory) in a while loop

Researching .Net issues I did find a lot of potentially related issues, some already fixed, but not available until the next releases of the framework:

Potential solutions:

  • Retrofit these fixes until it works and release a new version.
  • Don’t use Pipes and go old school.
  • Use Pipes but without exposing the ReadOnlySequence but instead streams, spans, memory and arrays, whatever is necessary.

I would happily contribute with a fix if I can indeed fix it, because this is a show stopper for me, my team and our new solution design.

Currently I’m going deeper and up the call stack (PulsarStream, Connector,ConsumeChannel, etc…) trying to figure out if are corrupting the memory or have a memory leak.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
RagingKorecommented, Feb 27, 2020

I’ll try to get a PR in later today for you to check it out.

2reactions
janpieterzcommented, Feb 26, 2020

I think we’re seeing exactly the same on our end, I’m trying to get a reliable(ish) reproduction ready, with access to a Pulsar instance. In contact with @blankensteiner about this as well. Your finds have been super useful. Do you reckon these fixes in the patch release could be it @RagingKore ? Seems a 3.1.2 release got out that I am not using yet (https://dotnet.microsoft.com/download/dotnet-core)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipe Dreams, part 2 - Marc Gravell
Buffer on ReadAsync() - which is a ReadOnlySequence<byte> , i.e some number of segments of data. So what actually happens?
Read more >
System.IO.Pipelines — a little-known tool for lovers of high ...
The problem with the original MemoryStream is an excessive number of copies, which is obvious if you remember that a private byte array...
Read more >
System.IO.Pipelines in .NET
Learn how to efficiently use I/O pipelines in .NET and avoid problems in your code.
Read more >
MediaCentral | Cloud UX
Reasonable care has been taken in preparing this guide; however, it may contain omissions, technical inaccuracies, or typographical errors. Avid ...
Read more >
JavaScript APIs
The Acrobat multimedia plug-in displays error alerts under various conditions such as a missing media file. JavaScript code can customize these alerts, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found