Getting "Index was outside the bounds of the array" exception when publishing to Redis stream using StreamAddAsync with StreamTrimMode.Acknowledged. The same code works fine with StreamTrimMode.KeepReference.
Environment:
- StackExchange.Redis version: 2.8.58
- .NET version: .NET 5.0
- Redis server version: 8.2.0 (running on Docker)
Code that fails:
await database.StreamAddAsync(
streamName,
maxLength: maxLength,
useApproximateMaxLength: true,
trimMode: StreamTrimMode.Acknowledged, // Throws exception
streamPairs: nameValueEntries);
Code that works:
await database.StreamAddAsync(
streamName,
maxLength: maxLength,
useApproximateMaxLength: true,
trimMode: StreamTrimMode.KeepReference, // Works fine
streamPairs: nameValueEntries);
Stack Trace:
Index was outside the bounds of the array.
at StackExchange.Redis.RedisDatabase.GetStreamAddMessage(RedisKey key, RedisValue entryId, Nullable`1 maxLength, Boolean useApproximateMaxLength, NameValueEntry[] streamPairs, Nullable`1 limit, StreamTrimMode mode, CommandFlags flags)
at StackExchange.Redis.RedisDatabase.StreamAddAsync(RedisKey key, NameValueEntry[] streamPairs, ...)
Expected behavior: StreamTrimMode.Acknowledged should work without throwing array bounds exceptions.
Getting "Index was outside the bounds of the array" exception when publishing to Redis stream using
StreamAddAsyncwithStreamTrimMode.Acknowledged. The same code works fine withStreamTrimMode.KeepReference.Environment:
Code that fails:
Code that works:
Stack Trace:
Expected behavior:
StreamTrimMode.Acknowledgedshould work without throwing array bounds exceptions.