fix(critical): Event-Loop-Blockade — ThreadPool-Saturation + Pulse-Interval + Classifier-Timeout
Root-Cause (Rainer): Pulse-Thread + Adapter-Calls + DDP-Fallback-Lawine sättigen den ThreadPool (asyncio.to_thread). Der Loop-Selector kann Watchdog-Probes nicht ausführen → 3 Strikes → Kill. Änderungen: - adapter.py: classify_and_route in asyncio.wait_for(4s), Timeout → STAY - adapter.py: ThreadPoolExecutor max_workers=32 in on_connected_cb - presence_engine.py: pulse_interval 1.5→5.0, sync-default, 2-stufiger CB - classifier.py: _llm_raw/_llm_classify/verify_confidence in wait_for(25s)
This commit is contained in:
+32
-2
@@ -151,7 +151,7 @@ if _MULTIROOM():
|
||||
from archivar.adapter_integration import ArchivarMessageHandler
|
||||
from archivar.conversation_history import ConversationHistory
|
||||
from archivar.multiroom_context import MultiRoomContextRing
|
||||
from archivar.router import room_name_to_topic
|
||||
from archivar.router import room_name_to_topic, RoutingDecision
|
||||
|
||||
# Routing-Counter: immer importieren (keine schweren Abhängigkeiten)
|
||||
from archivar.routing_counter import routing_counter
|
||||
@@ -1232,6 +1232,19 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
P1b: Starts DetectionTimer after DDP connection is established
|
||||
to prevent race condition with gateway_state.json.
|
||||
"""
|
||||
# P0-CRITICAL: ThreadPoolExecutor mit 32 Workers — verhindert
|
||||
# Event-Loop-Blockade durch ThreadPool-Saturation (Pulse + Adapter
|
||||
# + DDP-Fallback-Lawine). Der Default-Executor hat nur
|
||||
# min(32, os.cpu_count()+4) Workers, was bei vielen concurrent
|
||||
# to_thread-Calls zur Sättigung führt.
|
||||
try:
|
||||
_loop = asyncio.get_event_loop()
|
||||
_executor = concurrent.futures.ThreadPoolExecutor(max_workers=32)
|
||||
_loop.set_default_executor(_executor)
|
||||
logger.info("[rocketchat] ThreadPoolExecutor max_workers=32 gesetzt (on_connected_cb)")
|
||||
except Exception as e:
|
||||
logger.warning("[rocketchat] ThreadPoolExecutor set_default_executor failed: %s", e)
|
||||
|
||||
if self.ddp:
|
||||
# B3: Bewusst sync — first status after connect does not need
|
||||
# await-confirmation. PulseController takes over with
|
||||
@@ -3104,7 +3117,24 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# room_type wird in L1579 aus self._room_info gelesen.
|
||||
_is_dm = (room_type == "d")
|
||||
# P0: routing_text (ohne Quote) für Klassifikation verwenden
|
||||
decision = await self.archivar.classify_and_route(routing_text, origin_room_id=room_id, is_dm=_is_dm)
|
||||
# P0-CRITICAL: asyncio.wait_for(4s) — verhindert Event-Loop-Blockade
|
||||
# durch ThreadPool-Saturation (Pulse + Adapter + DDP-Fallback-Lawine).
|
||||
try:
|
||||
decision = await asyncio.wait_for(
|
||||
self.archivar.classify_and_route(routing_text, origin_room_id=room_id, is_dm=_is_dm),
|
||||
timeout=4.0,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning("[rocketchat] Archivar classify_and_route() timed out (4s) — STAY fallback")
|
||||
global _question_counter
|
||||
decision = RoutingDecision(
|
||||
category='direct_question',
|
||||
target_room=room_id,
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
with _question_counter_lock:
|
||||
_question_counter += 1
|
||||
# V8.3.3: Telemetrie nach jeder Routing-Entscheidung flushen
|
||||
routing_telemetry.flush()
|
||||
if decision and decision.category:
|
||||
|
||||
Reference in New Issue
Block a user