Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDatabase.StreamConsumerInfoAsync throws for consumers which have been idle for > Int32.MaxValue milliseconds #1567

Closed
chrnola opened this issue Sep 9, 2020 · 0 comments · Fixed by #1568

Comments

@chrnola
Copy link
Contributor

chrnola commented Sep 9, 2020

I recently observed the following exception in an application that calls IDatabase.StreamConsumerInfoAsync:

System.AggregateException: One or more errors occurred. (Arithmetic operation resulted in an overflow.)
 ---> System.OverflowException: Arithmetic operation resulted in an overflow.
    at StackExchange.Redis.ResultProcessor.KeyValuePairParser.TryRead(Sequence`1 pairs, CommandBytes\u0026 key, Int32\u0026 value) in /_/src/StackExchange.Redis/ResultProcessor.cs:line 1571
       at StackExchange.Redis.ResultProcessor.StreamConsumerInfoProcessor.ParseItem(RawResult\u0026 result) in /_/src/StackExchange.Redis/ResultProcessor.cs:line 1559
          at StackExchange.Redis.ResultProcessor.InterleavedStreamInfoProcessorBase`1.\u003c\u003ec.\u003cSetResultCore\u003eb__1_0(RawResult\u0026 item, InterleavedStreamInfoProcessorBase`1\u0026 obj) in /_/src/StackExchange.Redis/ResultProcessor.cs:line 1648
             at Pipelines.Sockets.Unofficial.Arenas.SequenceExtensions.TryCopyTo[TFrom,TState,TTo](Sequence`1\u0026 source, Span`1 destination, Projection`3 projection, TState\u0026 state) in /_/src/Pipelines.Sockets.Unofficial/Arenas/SequenceExtensions.cs:line 322
                at Pipelines.Sockets.Unofficial.Arenas.SequenceExtensions.CopyTo[TFrom,TState,TTo](Sequence`1\u0026 source, Span`1 destination, Projection`3 projection, TState\u0026 state) in /_/src/Pipelines.Sockets.Unofficial/Arenas/SequenceExtensions.cs:line 199
                   at Pipelines.Sockets.Unofficial.Arenas.SequenceExtensions.ToArray[TFrom,TState,TTo](Sequence`1\u0026 source, Projection`3 projection, TState\u0026 state) in /_/src/Pipelines.Sockets.Unofficial/Arenas/SequenceExtensions.cs:line 174
                      at StackExchange.Redis.ResultProcessor.InterleavedStreamInfoProcessorBase`1.SetResultCore(PhysicalConnection connection, Message message, RawResult\u0026 result) in /_/src/StackExchange.Redis/ResultProcessor.cs:line 1648
                         at StackExchange.Redis.ResultProcessor.SetResult(PhysicalConnection connection, Message message, RawResult\u0026 result) in /_/src/StackExchange.Redis/ResultProcessor.cs:line 255
                            at StackExchange.Redis.Message.ComputeResult(PhysicalConnection connection, RawResult\u0026 result) in /_/src/StackExchange.Redis/Message.cs:line 612
                               --- End of inner exception stack trace ---
                                  at Microsoft.FSharp.Control.AsyncResult`1.Commit() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 350
                                     at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 882
                                        at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 890
                                           at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1154
                                              at RedisStreamsMonitor.Main.main(String[] _argv) in /App/Program.fs:line 95

Upon manually inspecting the Redis which caused the exception via redis-cli I discovered that there was an orphaned consumer who's idle time in milliseconds was 2148383219, which would definitely overflow an Int32. The stack trace above lead me to believe that the library was attempting to parse this field an Int32, and now that I've reviewed the implementation of ResultProcessor.cs I'm quite certain of it.

Fortunately StreamConsumerInfo already defines IdleTimeInMilliseconds as a long so we just need to fix the parsing logic in ResultProcessor.KeyValuePairParser.TryRead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant