Skip to content

[Bug]: 部分用户设置修改后不会立即失效需要 10 分钟才生效 #589

Description

@qingchunnh

Affected area

Backend / API

Version or commit

026c877

Environment

OS: MacOS
Browser: Chrome
Deployment: Docker
PostgreSQL: 18.4
Redis: 8.8.1

Reproduction steps

回传推理上下文开关为例:

  1. 使用支持推理回传的模型进行多轮对话
  2. 发送一条消息后,再发送第二条消息,观察预计token或模型输出完成后显示的输入token数量(GLM和DeepSeek好像不会把回传推理内容当作输入token,所以我测试使用的是 kimi k3 和 qwen3.8max)
  3. 进入设置关闭回传推理上下文开关
  4. 在10分钟内发送消息和10分钟以后发送消息观察预计token或模型输出完成后显示的输入token

Expected behavior

用户设置修改后应立即生效

Actual behavior

关闭开关后,10 分钟内设置不会生效

根本原因是后端为减少数据库查询,给用户设置加了一层进程内缓存:某个设置第一次被读取时会从数据库取出并在内存中保留 10 分钟,期间发消息直接返回缓存值。而设置更新接口只负责把新值写入数据库,没有任何清除或刷新这层缓存的逻辑。因此修改设置后,后端在最长 10 分钟内仍使用缓存中的旧值,直到缓存过期重新读库才生效。

查看代码得知受影响的设置为

  • chat.reasoning_content_passback
  • chat.context_compact_auto
  • chat.file_mode

Logs, screenshots, or request samples

No response

Configuration and deployment context

No response

Pre-submit checklist

  • I searched existing issues and pull requests.
  • I removed secrets, tokens, credentials, and personal data from this report.
  • This is not a security vulnerability report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions