P-041b: DDP-Stabilität + Puls-Cache-Lockerung + PULSE_INTERVAL_S=2.5
DDPFirstSender: - H1: connected-Check VOR Future — connected=False → sofort REST-Fallback - H2: DDP_TIMEOUT_S 1.5s → 3.0s (+0.5s Buffer = 3.5s total) - ddp_healthy State Machine: True nach Erfolg, False nach 3 Fehlern - E4: Nach 3× 429 trotz DDP → DDP untrusted, REST-only - H3 Watchdog: is_ddp_healthy() prüft Alter (<60s) Mediator: - PULSE_INTERVAL_S 5.0s → 2.5s (Pulsieren sichtbar) - 3-Schichten-Cache: P3/P4+ddp_healthy→kein Cache, P3/P4+!ddp_healthy→Cache, P1/P2→Cache - E3: pulse_lock serialisiert Pulse-Ticks (max 3s block) - E1: DDP-Fail-Mid-Pulse → Reconciliation sendet REST-Call - E5: Reconciliation-Skip prüft (last_phase, last_status) Adapter: - H3 Watchdog: Reader-Liveness, Frame-Timeout >60s, Health-Ping alle 60s Tests: 27 neue Tests (test_p041b_ddp_stability.py), 111 total grün
This commit is contained in:
@@ -7550,6 +7550,86 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
len(self._subscribed_rooms),
|
||||
self.ddp.connected,
|
||||
)
|
||||
|
||||
# ── P-041b H3: Watchdog — aktiver Health-Ping ──────
|
||||
# Health-Ping alle 60s: No-Op DDP-Call prüft
|
||||
# Reader-Liveness. Bei Miss → Reader restart,
|
||||
# connected=False setzen.
|
||||
reader_alive = (
|
||||
self.ddp._reader_thread is not None
|
||||
and self.ddp._reader_thread.is_alive()
|
||||
)
|
||||
if not reader_alive:
|
||||
logger.warning(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Reader-Thread tot (alive=%s) → "
|
||||
"connected=False, reconnect",
|
||||
reader_alive,
|
||||
)
|
||||
self.ddp.connected = False
|
||||
if await self._reconnect_ddp():
|
||||
self._reconnect_backoff = 0
|
||||
logger.info(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Reconnect nach Reader-Death erfolgreich"
|
||||
)
|
||||
else:
|
||||
logger.error(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Reconnect nach Reader-Death fehlgeschlagen"
|
||||
)
|
||||
await self._reconnect_backoff_sleep()
|
||||
continue
|
||||
|
||||
# H3: Wenn >60s kein DDP-Frame → Reader killen, neu starten
|
||||
now = time.time()
|
||||
if self.ddp._last_rx_time > 0 and (now - self.ddp._last_rx_time) > 60.0:
|
||||
logger.warning(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
">60s kein DDP-Frame (last_rx=%.0fs ago) → "
|
||||
"Reader killen, reconnect",
|
||||
now - self.ddp._last_rx_time,
|
||||
)
|
||||
self.ddp.connected = False
|
||||
if await self._reconnect_ddp():
|
||||
self._reconnect_backoff = 0
|
||||
logger.info(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Reconnect nach Frame-Timeout erfolgreich"
|
||||
)
|
||||
else:
|
||||
logger.error(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Reconnect nach Frame-Timeout fehlgeschlagen"
|
||||
)
|
||||
await self._reconnect_backoff_sleep()
|
||||
continue
|
||||
|
||||
# H3: Health-Ping via No-Op DDP-Call (set_status_async)
|
||||
# Prüft ob DDP-Loop + Reader noch antworten.
|
||||
if self.ddp.connected and self.ddp._loop and not self.ddp._loop.is_closed():
|
||||
try:
|
||||
future = asyncio.run_coroutine_threadsafe(
|
||||
self.ddp.set_status_async("online", timeout=5.0),
|
||||
self.ddp._loop,
|
||||
)
|
||||
result = future.result(timeout=5.5)
|
||||
if result:
|
||||
logger.debug(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Health-Ping OK (DDP responsive)"
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Health-Ping returned False"
|
||||
)
|
||||
except Exception as ping_err:
|
||||
logger.warning(
|
||||
"[rocketchat] P-041b H3: Watchdog — "
|
||||
"Health-Ping fehlgeschlagen: %s",
|
||||
ping_err,
|
||||
)
|
||||
if self.ddp and self.ddp.connected and not self.ddp.is_alive(self.HEALTH_SILENT_LIMIT):
|
||||
logger.warning(
|
||||
"[rocketchat] Silent death detected: no DDP traffic for %.0fs — forcing reconnect",
|
||||
|
||||
Reference in New Issue
Block a user