Bug Fix where - in exceptional cases - a connection without correct search path could be used (out of the connection pool).

This commit is contained in:
Josako
2025-10-24 11:42:50 +02:00
parent a43825f5f0
commit b3ee2f7ce9
3 changed files with 115 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ from dataclasses import dataclass
from flask import current_app
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import joinedload
from sqlalchemy import text
from common.extensions import db, cache_manager
from common.models.interaction import ChatSession, Interaction
@@ -111,6 +112,14 @@ class ChatSessionCacheHandler(CacheHandler[CachedSession]):
Note:
Only adds the interaction if it has an answer
"""
# Log connection context right before any potential lazy load of interaction properties
try:
sp = db.session.execute(text("SHOW search_path")).scalar()
cid = id(db.session.connection().connection)
current_app.logger.info(f"DBCTX before_lazy_load conn_id={cid} search_path={sp}")
except Exception:
pass
if not interaction.specialist_results:
return # Skip incomplete interactions