Fix stale DB session after long embedding pre-load
The embedding pre-load for 4998 existing controls takes ~16 minutes, causing the SQLAlchemy session to become invalid. Added rollback after pre-load completes to reset the session before subsequent DB operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1391,6 +1391,12 @@ Gib ein JSON-Array zurueck mit GENAU {len(chunks)} Objekten. Jedes Objekt hat di
|
|||||||
loaded = sum(1 for emb in embeddings if emb)
|
loaded = sum(1 for emb in embeddings if emb)
|
||||||
logger.info("Pre-loaded %d/%d embeddings", loaded, len(texts))
|
logger.info("Pre-loaded %d/%d embeddings", loaded, len(texts))
|
||||||
|
|
||||||
|
# Reset DB session after long-running embedding operation to avoid stale connections
|
||||||
|
try:
|
||||||
|
self.db.rollback()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def _load_existing_controls(self) -> list[dict]:
|
def _load_existing_controls(self) -> list[dict]:
|
||||||
"""Load existing controls from DB (cached per pipeline run)."""
|
"""Load existing controls from DB (cached per pipeline run)."""
|
||||||
if self._existing_controls is not None:
|
if self._existing_controls is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user