修复(08-28-production-arm-backup-transfer-incident): 纠正partial停止偏移分类
这个提交包含在:
@@ -432,7 +432,8 @@ def stopping_class(samples: list[BatchResult]) -> str:
|
||||
sizes = sorted(item.total_bytes for item in samples[-2:])
|
||||
difference = sizes[1] - sizes[0]
|
||||
relative_limit = sizes[1] * SIMILAR_RELATIVE_PPM // 1_000_000
|
||||
return "similar" if difference <= max(SIMILAR_ABSOLUTE_BYTES, relative_limit) else "different"
|
||||
similar_limit = min(SIMILAR_ABSOLUTE_BYTES, relative_limit)
|
||||
return "similar" if difference <= similar_limit else "different"
|
||||
|
||||
|
||||
def arm(args: argparse.Namespace) -> None:
|
||||
|
||||
@@ -239,7 +239,7 @@ pass "私有诊断只在安全摘要明确为 offhost_transfer 时绑定 rsync
|
||||
ARM_SIMILAR="$TEST_ROOT/arm-similar"
|
||||
mkdir -p "$ARM_SIMILAR/inbox" "$ARM_SIMILAR/archive"
|
||||
make_batch "$ARM_SIMILAR/inbox/hyb-oa-backup-auto-20260827T000000Z.partial" "auto-20260827T000000Z" 1000 1000
|
||||
make_batch "$ARM_SIMILAR/inbox/hyb-oa-backup-auto-20260828T000000Z.partial" "auto-20260828T000000Z" 1100 1000
|
||||
make_batch "$ARM_SIMILAR/inbox/hyb-oa-backup-auto-20260828T000000Z.partial" "auto-20260828T000000Z" 1040 1000
|
||||
rm "$ARM_SIMILAR/inbox/hyb-oa-backup-auto-20260827T000000Z.partial/storage.tar.gz"
|
||||
rm "$ARM_SIMILAR/inbox/hyb-oa-backup-auto-20260828T000000Z.partial/storage.tar.gz"
|
||||
python3 -B "$INSPECTOR" --now-epoch 1787875200 arm --inbox-root "$ARM_SIMILAR/inbox" --archive-root "$ARM_SIMILAR/archive" >"$TEST_ROOT/arm-similar.out"
|
||||
@@ -258,6 +258,31 @@ python3 -B "$INSPECTOR" --now-epoch 1787875200 arm --inbox-root "$ARM_DIFFERENT/
|
||||
assert_line "$TEST_ROOT/arm-different.out" "arm_partial_stop_offset_class=different"
|
||||
pass "两个 partial 明显不同停止偏移分类为 different"
|
||||
|
||||
python3 -B - "$INSPECTOR" <<'PY'
|
||||
import importlib.util
|
||||
import sys
|
||||
|
||||
spec = importlib.util.spec_from_file_location("backup_transfer_incident", sys.argv[1])
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
def sample(total_bytes):
|
||||
return module.BatchResult(False, total_bytes, None, None, total_bytes)
|
||||
|
||||
cases = [
|
||||
("现场量级的 2.68MB 与 0 字节必须不同", [sample(0), sample(2_682_168)], "different"),
|
||||
("大文件差异同时落在 5% 与 64MiB 内才接近", [sample(1_000_000_000), sample(1_040_000_000)], "similar"),
|
||||
("即使落在 64MiB 内但超过 5% 仍不同", [sample(10_000_000), sample(10_600_000)], "different"),
|
||||
("即使落在 5% 内但超过 64MiB 仍不同", [sample(2_000_000_000), sample(2_080_000_000)], "different"),
|
||||
]
|
||||
for label, samples, expected in cases:
|
||||
actual = module.stopping_class(samples)
|
||||
if actual != expected:
|
||||
raise SystemExit(f"{label}: expected {expected}, got {actual}")
|
||||
PY
|
||||
pass "停止偏移分类同时满足相对与绝对阈值并覆盖现场 2.68MB/0 字节回归"
|
||||
|
||||
ARM_COMPLETE="$TEST_ROOT/arm-complete"
|
||||
mkdir -p "$ARM_COMPLETE/inbox" "$ARM_COMPLETE/archive"
|
||||
make_batch "$ARM_COMPLETE/inbox/hyb-oa-backup-auto-20260828T000000Z.partial" "auto-20260828T000000Z"
|
||||
|
||||
在新工单中引用
屏蔽一个用户