Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow trace error #12117

Closed
5 tasks done
wy96f opened this issue Dec 26, 2024 · 2 comments
Closed
5 tasks done

Workflow trace error #12117

wy96f opened this issue Dec 26, 2024 · 2 comments
Assignees
Labels
🌊 feat:workflow Workflow related stuff.

Comments

@wy96f
Copy link
Contributor

wy96f commented Dec 26, 2024

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.14.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. configure langfuse
  2. execute workflow

✔️ 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

@dosubot dosubot bot added the 🌊 feat:workflow Workflow related stuff. label Dec 26, 2024
Copy link

dosubot bot commented Dec 26, 2024

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:

  1. 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).

  2. 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.

  3. 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.

  4. 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].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@laipz8200
Copy link
Member

fixed in #12071

@laipz8200 laipz8200 self-assigned this Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 feat:workflow Workflow related stuff.
Projects
None yet
Development

No branches or pull requests

2 participants