mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +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 |
||
|---|---|---|
| .. | ||
| cleaner | ||
| data_post_processor | ||
| datasource | ||
| docstore | ||
| embedding | ||
| entities | ||
| extractor | ||
| index_processor | ||
| models | ||
| pipeline | ||
| rerank | ||
| retrieval | ||
| splitter | ||
| summary_index | ||
| __init__.py | ||