mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 23:01:11 +08:00
The _on_query method was calling db.session.commit() on the Flask-scoped SQLAlchemy session, which committed all pending dirty state from the current request — not just the DatasetQuery audit rows. This broke transaction isolation: if the downstream workflow failed, the subsequent db.session.rollback() could not revert the already-committed modifications (e.g. token deductions, partial node executions), leaving dirty data in the database. The same file already demonstrates the correct pattern in _on_retrieval_end, which uses sessionmaker(bind=db.engine).begin() with an independent session. This change applies the same approach to _on_query. Additionally fixed a latent bug where dataset_queries.add_all() was called inside the loop on every iteration, re-adding previously accumulated rows. Fixes #37886 |
||
|---|---|---|
| .. | ||
| output_parser | ||
| router | ||
| __init__.py | ||
| dataset_retrieval.py | ||
| retrieval_methods.py | ||
| template_prompts.py | ||