Skip to content

fix(op): invalidate new path cache on meta path update#2322

Merged
jyxjjj merged 1 commit intoOpenListTeam:mainfrom
Lanfei:fix/meta-path-cache-invalidation
Apr 9, 2026
Merged

fix(op): invalidate new path cache on meta path update#2322
jyxjjj merged 1 commit intoOpenListTeam:mainfrom
Lanfei:fix/meta-path-cache-invalidation

Conversation

@Lanfei
Copy link
Copy Markdown
Contributor

@Lanfei Lanfei commented Apr 8, 2026

问题

修改 meta 的路径后,新路径不会立即生效。

根因:UpdateMeta 更新路径时,只清除了旧路径的缓存(old.Path),
但未清除新路径可能已存在的缓存。如果新路径曾被访问过(缓存了 nil
即"不存在"),该负缓存不会被清除,导致访问新路径时仍命中缓存返回
MetaNotFound,最长持续 1 小时(缓存 TTL)。

修复

UpdateMeta 中同时清除新路径的缓存,确保下次访问时从数据库重新加载。

变更

  • internal/op/meta.goUpdateMeta 增加 metaCache.Del(u.Path)

UpdateMeta only cleared the old path from cache, leaving a stale nil
entry at the new path if it had been accessed before. Now also clears
the new path's cache entry so changes take effect immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jyxjjj jyxjjj merged commit da26e72 into OpenListTeam:main Apr 9, 2026
14 checks passed
@Lanfei Lanfei deleted the fix/meta-path-cache-invalidation branch April 9, 2026 18:04
lyy2005a2 pushed a commit to lyy2005a2/OpenList that referenced this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants