Skip to content
Merged
Prev Previous commit
Next Next commit
fix maxvalue overflow PR feedback
  • Loading branch information
mgravell committed Jul 28, 2026
commit 462370d286acc2e055b5e5b7b886cb283dd9a05a
3 changes: 3 additions & 0 deletions src/NRedisStack/TimeSeries/TimeSeriesCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ public IEnumerable<TimeSeriesTuple> ReadEnumerable(string key, TimeStamp fromTim
// stop when the page is not full (drained); otherwise advance the cursor past the last sample.
if (batchSize is not { } size || batch.Count < size) yield break;
long last = batch[batch.Count - 1].Time;
// a full page ending at the max timestamp is drained: nothing can exist beyond it, and last + 1
// would overflow to a negative cursor and issue an invalid TS.READ. Terminate cleanly instead.
if (last == long.MaxValue) yield break;
cursor = last + 1;
Comment thread
mgravell marked this conversation as resolved.
Resolved
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/NRedisStack/TimeSeries/TimeSeriesCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ public async IAsyncEnumerable<TimeSeriesTuple> ReadAsyncEnumerable(string key, T
// stop when the page is not full (drained); otherwise advance the cursor past the last sample.
if (batchSize is not { } size || batch.Count < size) yield break;
long last = batch[batch.Count - 1].Time;
// a full page ending at the max timestamp is drained: nothing can exist beyond it, and last + 1
// would overflow to a negative cursor and issue an invalid TS.READ. Terminate cleanly instead.
if (last == long.MaxValue) yield break;
cursor = last + 1;
}
}
Expand Down
Loading