Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the limitation of Schema Cache #19039

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions schema-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ summary: TiDB 对于 schema 信息采用基于 LRU 的缓存机制,在大量
- `SHOW FULL TABLES`
- `FLASHBACK`
- `ALTER TABLE ... SET TIFLASH MODE ...`
- 对于设置了 [`AUTO_INCREMENT`](/auto-increment.md) 或 [`AUTO_RANDOM`](/auto-random.md) 属性的表,如果 schema 缓存设置过小,这些表的元信息可能会在内存中被频繁地缓存和淘汰。这种频繁的缓存变动可能导致未使用完的 ID 段失效,从而引发 ID 跳变。在写入量较大的场景下,甚至可能导致 ID 段耗尽。为减少此类问题并提升系统稳定性,建议采取以下措施:

- 通过监控面板查看 schema 缓存的命中率和大小,以评估缓存设置是否合理。并适当调大 schema 缓存大小,以减少频繁的缓存淘汰。
- 将 [`AUTO_ID_CACHE`](/auto-increment.md#auto_id_cache) 设置为 `1`,以防止 ID 跳变。
- 合理设置 `AUTO_RANDOM` 的分片位和保留位,避免可分配 ID 范围过小。