fix(scheduler): drop cross-task mutex, quiet window + retry
Incident: evening full snapshot could be recorded as ok with already_completed/elapsed=0 after mutual skip with hourly sync, then next_run jumped to the next day. - Full-site snapshot never skips because another task is running - 23:00-01:00 Asia/Shanghai: defer discovery / snapshot_recent / candidate_cleanup to after 01:00; fans never defers - Skip records ok=false + skipped=true (not success / not completed) - Skip/fail reschedule soon (~5m); daily success still next snapshot_at - TaskControl return value drives next_run; system UI shows skip fields
This commit is contained in:
1 parent
39378c65b2
commit
9969e65202
10 files changed
+411
-84
No files matched your search
@@ -11,7 +11,10 @@ sys.stdout.reconfigure(encoding="utf-8")
|
||||
from reaction_board.timeutil import ( # noqa: E402
|
||||
SHANGHAI_TZ,
|
||||
day_bounds,
|
||||
in_snapshot_quiet_window,
|
||||
interval_next_run,
|
||||
is_date,
|
||||
next_after_snapshot_quiet_window,
|
||||
next_daily_run,
|
||||
parse_hhmm,
|
||||
shanghai_date,
|
||||
@@ -72,11 +75,40 @@ def test_day_bounds_and_date_validation():
|
||||
raise AssertionError("非法日期应失败")
|
||||
|
||||
|
||||
|
||||
def test_snapshot_quiet_window():
|
||||
assert in_snapshot_quiet_window(ts("2026-11-02 23:00:00"))
|
||||
assert in_snapshot_quiet_window(ts("2026-11-02 23:59:59"))
|
||||
assert in_snapshot_quiet_window(ts("2026-11-03 00:00:00"))
|
||||
assert in_snapshot_quiet_window(ts("2026-11-03 00:59:59"))
|
||||
assert not in_snapshot_quiet_window(ts("2026-11-03 01:00:00"))
|
||||
assert not in_snapshot_quiet_window(ts("2026-11-02 22:59:59"))
|
||||
assert not in_snapshot_quiet_window(ts("2026-11-02 12:00:00"))
|
||||
|
||||
assert next_after_snapshot_quiet_window(ts("2026-11-02 22:00:00")) == ts(
|
||||
"2026-11-02 22:00:00"
|
||||
)
|
||||
assert next_after_snapshot_quiet_window(ts("2026-11-02 23:15:00")) == ts(
|
||||
"2026-11-03 01:00:00"
|
||||
)
|
||||
assert next_after_snapshot_quiet_window(ts("2026-11-03 00:30:00")) == ts(
|
||||
"2026-11-03 01:00:00"
|
||||
)
|
||||
# 22:50 + 60min = 23:50 → 推到次日 01:00
|
||||
assert interval_next_run(ts("2026-11-02 22:50:00"), 3600) == ts(
|
||||
"2026-11-03 01:00:00"
|
||||
)
|
||||
assert interval_next_run(ts("2026-11-02 12:00:00"), 3600) == ts(
|
||||
"2026-11-02 13:00:00"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
test_shanghai_date_boundary()
|
||||
test_parse_hhmm()
|
||||
test_next_daily_run()
|
||||
test_day_bounds_and_date_validation()
|
||||
test_snapshot_quiet_window()
|
||||
print("OK: 上海时区与每日时间计算测试全部通过")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user