You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a similar open issue related to a workflow trace error in Dify. The error message "Instance '<Workflow at 0x7f7800591750>' is not persistent within this Session" suggests that the Workflow instance is not associated with the current SQLAlchemy session when db.session.refresh() is called. Here are some steps that were suggested to resolve this issue:
Ensure the Instance is Added to the Session: Before calling db.session.refresh(), make sure that the Workflow instance is added to the session using db.session.add(workflow_instance).
Check for Session Expiry: If the session was closed or expired before the refresh operation, you might need to reopen or reattach the instance to a new session.
Verify the Instance State: Use db.session.is_modified(workflow_instance) to check if the instance is in a state that can be refreshed. If it returns False, the instance might not be in a persistent state.
Review Transaction Boundaries: Ensure that the session is not being prematurely committed or rolled back, which could detach the instance from the session.
By ensuring that the Workflow instance is properly managed within the session lifecycle, you should be able to resolve this error [1].
Self Checks
Dify version
0.14.2
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ Expected Behavior
trace successfully sended to langfuse
❌ Actual Behavior
2024-12-26 [2024-12-26 11:54:50,469][ERROR][trace_manager_timer_2024-12-26 03:54:45][ops_trace_manager.py:739] Error processing trace tasks
2024-12-26 Traceback (most recent call last):
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 737, in run
2024-12-26 self.send_to_celery(tasks)
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 753, in send_to_celery
2024-12-26 trace_info = task.execute()
2024-12-26 ^^^^^^^^^^^^^^
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 330, in execute
2024-12-26 return self.preprocess()
2024-12-26 ^^^^^^^^^^^^^^^^^
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 352, in preprocess
2024-12-26 return preprocess_map.get(self.trace_type, lambda: None)()
2024-12-26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 335, in
2024-12-26 TraceTaskName.WORKFLOW_TRACE: lambda: self.workflow_trace(
2024-12-26 ^^^^^^^^^^^^^^^^^^^^
2024-12-26 File "/app/api/core/ops/ops_trace_manager.py", line 363, in workflow_trace
2024-12-26 db.session.refresh(workflow_run)
2024-12-26 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/scoping.py", line 1767, in refresh
2024-12-26 return self._proxied.refresh(
2024-12-26 ^^^^^^^^^^^^^^^^^^^^^^
2024-12-26 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 3143, in refresh
2024-12-26 self._expire_state(state, attribute_names)
2024-12-26 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 3269, in _expire_state
2024-12-26 self._validate_persistent(state)
2024-12-26 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4138, in _validate_persistent
2024-12-26 raise sa_exc.InvalidRequestError(
2024-12-26 sqlalchemy.exc.InvalidRequestError:Instance '<WorkflowRun at 0x7fb237659bb0>' is not persistent within this Session
2024-12-26 [2024-12-26 11:55:08,350][DEBUG][Dummy-40][_trace.py:47] close.started
2024-12-26 [2024-12-26 11:55:08,350][DEBUG][Dummy-40][_trace.py:47] close.complete
2024-12-26 [2024-12-26 11:56:45,503][DEBUG][Dummy-91][_trace.py:47] close.started
2024-12-26 [2024-12-26 11:56:45,503][DEBUG][Dummy-91][_trace.py:47] close.complete
The text was updated successfully, but these errors were encountered: