This commit is contained in:
Alvin Tang 2026-03-24 11:31:54 +08:00 committed by GitHub
commit e39bca2038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -681,6 +681,16 @@ class IndexingRunner:
embedding_model_instance: ModelInstance | None,
):
with flask_app.app_context():
# Re-query dataset and document in the current thread's session to avoid
# "Instance is not bound to a Session" errors when the parent thread's
# session expires or closes these objects.
dataset = db.session.query(Dataset).filter_by(id=dataset.id).first()
if not dataset:
raise ValueError("no dataset found")
dataset_document = db.session.get(DatasetDocument, dataset_document.id)
if not dataset_document:
raise ValueError("no dataset document found")
# check document is paused
self._check_document_paused_status(dataset_document.id)