Files
Nexus/docs/changelog/2026-06-12-watch-ttl-expiry-race-fix.md
T
Nexus Agent 32a1885f0d feat(watch): 监测槽开关、8h/24h、到期暂停与探针修复
支持随时暂停/恢复实时监测并保留槽位;TTL 到期自动暂停不占删槽;修复到期竞态导致空槽与唯一约束冲突;探针 parse_error 与中文错误;移除失败 snackbar。
2026-06-12 03:47:56 +08:00

1.2 KiB
Raw Blame History

Changelog — 监测槽 TTL 到期竞态修复

日期2026-06-12

摘要

修复 TTL 到期与后台 expire_due_pins(5s 探针循环)之间的竞态窗口:槽位短暂显示为空、无法添加/移除、可能触发唯一约束冲突。

动机

list_active_pins_for_adminmonitoring_enabled=trueexpires_at<=now 时排除 pin,但 DB 行仍在且 monitoring_enabled 仍为 true,直到探针循环执行 expire_due_pins。此窗口内 UI 显示空槽,但 create_pin 会因 uq_watch_pins_admin_slot 失败。

变更

  • WatchService._finalize_due_pins():在读/写路径同步到期 pin(暂停 + end session + 按需清 Redis
  • list_slotspin_serverreplace_slotremove_slotset_slot_monitoringset_slot_ttl 入口调用
  • 新增单测:test_watch_pin_ttl_expiry_list_syncs_before_displaytest_watch_pin_ttl_expiry_pin_server_no_duplicate
  • P2WatchSlotRow.onRemove 失败时 snackbar 提示

涉及文件

  • server/application/services/watch_service.py
  • frontend/src/components/watch/WatchSlotRow.vue
  • tests/test_watch_pins.py

迁移 / 重启

  • 无需迁移
  • 需重启 API

验证

.venv/bin/pytest tests/test_watch_pins.py -q