records.snap version check ignores the major version once it has two digits

未关闭
#14,180 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
cpp
领域
backend

调研方向

Start with RecFile.cc and P_RecCore.cc, especially the RecSnapFileWrite() and CheckSnapFileVersion() locations linked in the issue. Trace how the five-byte header is written and checked, then review the version constants and snapshot reader behavior. Done means snapshots from incompatible formats are rejected while compatible releases keep the intended persistent stats.

由索引模型根据 Issue 内容生成。

描述

Records

RecSnapFileWrite() starts records.snap with five version bytes, 'V', PACKAGE_VERSION[0], PACKAGE_VERSION[2], PACKAGE_VERSION[4] and '\0' (RecFile.cc). At startup CheckSnapFileVersion() compares the same three characters and removes the file when they differ (P_RecCore.cc).

The check was added when the major version had one digit, so those characters were major, minor and patch: 9.2.5 writes 9, 2, 5. With a two-digit major they are the first digit of the major and two dots. 10.2.1 and 11.0.0 both write 1, ., ., so every 10.x and 11.x release accepts a snapshot written by any other, and the file is never removed on an upgrade between them.

No harm today: the RecRecord layout that the snapshot stores has not changed since 10.2.1. Once it changes, an 11.x server will read records written with the old layout, and only the reader's own bounds and type checks (added in #14147) stand between those bytes and the restore. Those checks keep the reader inside the buffer, but they cannot tell that a field moved, so a stat could come back with a wrong value.

A fix would compare what actually identifies the format. Two options that keep the five-byte header:

  • Write the major, minor and patch numbers as byte values (TS_VERSION_MAJOR, TS_VERSION_MINOR, TS_VERSION_MICRO) instead of characters of the version string, and compare all three. A file from a release with the old encoding then differs and is removed once, on the upgrade.
  • Write a snapshot format number that is bumped whenever RecRecord or the message layout changes, so a patch release does not throw away persistent stats for nothing.

Comparing the whole PACKAGE_VERSION string would also work, but needs a longer header.

Raised by Damian (brbzull0) in review of #14147.

主要语言
C++
星标
2k
派生
903
平均合并
4 天 4 小时
30 天内合并 PR
135

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/trafficserver 的其他 Issue

查看 apache/trafficserver 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。