ERR redis data_error ai_generated true

流 'mystream' 条目过多,因 MAXLEN 限制旧条目将被丢弃

ERR Stream 'mystream' has too many entries, old entries will be dropped due to MAXLEN

ID: redis/stream-entries-maxlen-dropped

其他格式: JSON · Markdown 中文 · English
88%修复率
85%置信度
1证据数
2023-12-15首次发现

版本兼容性

版本状态引入弃用备注
7.2.0 active
7.4.0 active
8.0.0 active

根因分析

流达到配置的 MAXLEN 限制,导致自动淘汰最旧条目。

English

Stream reached its configured MAXLEN limit, causing automatic eviction of oldest entries.

generic

官方文档

https://redis.io/docs/data-types/streams/

解决方案

  1. 将 MAXLEN 增加到更高值:XTRIM mystream MAXLEN ~ 1000000。使用 ~(波浪号)进行近似修剪以减少开销。
  2. 使用 MINID 设置基于时间的保留策略:XTRIM mystream MINID ~ 1715000000(Unix 时间戳)。

无效尝试

常见但无效的做法:

  1. 40% 失败

    Setting MAXLEN to 0 disables the limit entirely, but may cause unbounded memory growth and eventual OOM.

  2. 60% 失败

    Manually deleting entries with XDEL does not reduce the stream length counter; only XTRIM works.