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

Đang mở
#14,180 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
2k
Fork
903
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
135

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/trafficserver

Tất cả issue của apache/trafficserver

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.