-
Notifications
You must be signed in to change notification settings - Fork 6
bug: [后端] RenderPostHTML 对含表情包帖子逐实体执行 ResolveURLs 查询,形成 N+1 #706
Copy link
Copy link
Closed
Labels
area:backendoryn:kind: 🐛 bugBehavior differs from the intended result.Behavior differs from the intended result.oryn:priority: 🟡 P2Normal-priority work.Normal-priority work.oryn:proof: 🔎 supportedEvidence supports this conclusion; see the report for source vs live proof.Evidence supports this conclusion; see the report for source vs live proof.oryn:status: 🧭 needs inputA maintainer decision or additional information is required.A maintainer decision or additional information is required.priority:P2type:bug🐛 bugReported defect requiring investigationReported defect requiring investigation
Description
Activity
Metadata
Metadata
Assignees
Labels
area:backendoryn:kind: 🐛 bugBehavior differs from the intended result.Behavior differs from the intended result.oryn:priority: 🟡 P2Normal-priority work.Normal-priority work.oryn:proof: 🔎 supportedEvidence supports this conclusion; see the report for source vs live proof.Evidence supports this conclusion; see the report for source vs live proof.oryn:status: 🧭 needs inputA maintainer decision or additional information is required.A maintainer decision or additional information is required.priority:P2type:bug🐛 bugReported defect requiring investigationReported defect requiring investigation
Type
Projects
- StatusShow more project fieldsDone
问题概述
rendered_html.go的RenderPostHTML对每个实体调用一次,而该块在每次调用时都执行一次stickerservice.ResolveURLsDB 查询。由于ensureRenderedHTML对任何包含[:sticker:的帖子都会绕过版本缓存,一个含 K 个表情包帖子的主题页现在每次请求产生 K 次额外 DB 查询(此前的缓存 HTML 服务不存在该 N+1 模式)。影响
证据
urls, err := stickerservice.ResolveURLs(names)在RenderPostHTML内[:sticker:时绕过缓存持久化预期行为
含表情包的帖子也应从缓存服务(或每请求级批处理解析),避免逐实体 N+1 查询。
实际行为
每个含表情包的帖子每次渲染都执行一次独立的
ResolveURLsDB 查询。建议修复
来源:OCR review session
b0a6067d(HEAD~30..HEAD)medium 级发现。