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

Probably Concurency Issues with the default SQLAlchemyDataLayer, #1903

Open
rudolf-erdei opened this issue Feb 17, 2025 · 0 comments
Open

Probably Concurency Issues with the default SQLAlchemyDataLayer, #1903

rudolf-erdei opened this issue Feb 17, 2025 · 0 comments
Labels
bug Something isn't working data layer Pertains to data layers. needs-triage

Comments

@rudolf-erdei
Copy link

Describe the bug
I'm starting out with Chainlit, learning how to create a langchain Agent with it. After setting up the login part, using the example implementation from the documentation (SQLAlchemyDataLayer with BaseStorageClient, using it with docker image postres:latest),

To Reproduce
Steps to reproduce the behavior:

  1. Implement database saving with SQLAlchemyDataLayer and BaseStorageClient. Using any user and pass, as it will be just for saving conversations.
  2. Define a LangChain agent (from langchain.agents import Tool, initialize_agent), with DuckDuckFoSearchRun (from langchain_community.tools import DuckDuckGoSearchRun)
  3. Try a complex query, which will force the platform to create more than one step.

Expected behavior
The platform working smootly, without issues and returning a relevant result.

Screenshots
Not applicable. Log entries below.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Firefox (although not relevant, as problem is in the backend
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version: "aiohttp>=3.11.12",
    "asyncpg>=0.30.0",
    "chainlit>=2.2.1",
    "greenlet>=3.1.1",
    "langchain-google-genai>=2.0.9",
    "langchain>=0.3.18",
    "sqlalchemy>=2.0.38",
    "langchain-community>=0.3.17",
    "wikipedia>=1.4.0",
    "duckduckgo-search>=7.4.2",
    "numexpr>=2.10.2",

Additional context
Error logs extract:

025-02-17 14:46:11 - SQLAlchemy: create_step, step_id=fd6923c1-efb9-449a-a57a-e8a70ac83c53
Thought: The prompt asks for use for a 3D printer in my home. It also provides a format for the output, including an execution plan and rest of needed information. I need to create an execution plan to find the most creative use for a 3D printer and then provide any additional information.

Action:

{
  "action": "Web Search",
  "action_input": "uses for 3D printer at home"
}
```2025-02-17 14:46:11 - SQLAlchemy: create_step, step_id=bc940f63-791b-44b9-8166-c2982952db47
2025-02-17 14:46:11 - SQLAlchemy: create_step, step_id=260c53bc-bcdd-45a0-bea8-db23ce7b32a2
2025-02-17 14:46:11 - An unexpected error occurred: Task <Task pending name='Task-918' coro=<SQLAlchemyDataLayer.create_step() running at D:\Projects\researcher\.venv\Lib\site-packages\chainlit\data\utils.py:25>> got Future <Future pending cb=[BaseProtocol._on_waiter_completed()]> attached to a different loop
2025-02-17 14:46:12 - HTTP Request: POST https://lite.duckduckgo.com/lite/ "HTTP/2 200 OK"
2025-02-17 14:46:12 - SQLAlchemy: update_step, step_id=260c53bc-bcdd-45a0-bea8-db23ce7b32a2
2025-02-17 14:46:12 - SQLAlchemy: create_step, step_id=260c53bc-bcdd-45a0-bea8-db23ce7b32a2
2025-02-17 14:46:12 - An unexpected error occurred: Task <Task pending name='Task-937' coro=<SQLAlchemyDataLayer.update_step() running at D:\Projects\researcher\.venv\Lib\site-packages\chainlit\data\utils.py:25>> got Future <Future pending cb=[BaseProtocol._on_waiter_completed()]> attached to a different loop
2025-02-17 14:46:12 - SQLAlchemy: update_step, step_id=bc940f63-791b-44b9-8166-c2982952db47

further down...

2025-02-17 14:46:19 - SQLAlchemy: create_step, step_id=0953c1ba-0c8a-441a-b6cb-ef976ba55ebf
2025-02-17 14:46:20 - An error occurred: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.DeadlockDetectedError'>: deadlock detected
DETAIL:  Process 1364 waits for ShareLock on transaction 1131; blocked by process 1361.
Process 1361 waits for ShareLock on transaction 1136; blocked by process 1364.
HINT:  See server log for query details.
[SQL:
            INSERT INTO steps ("name", "type", "id", "threadId", "parentId", "streaming", "metadata", "input", "isError", "output", "createdAt", "start", "end", "defaultOpen", "showInput", "generation")
            VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
            ON CONFLICT (id) DO UPDATE
            SET "name" = $1, "type" = $2, "threadId" = $4, "parentId" = $5, "streaming" = $6, "metadata" = $7, "input" = $8, "isError" = $9, "output" = $10, "createdAt" = $11, "start" = $12, "end" = $13, "defaultOpen" = $14, "showInput" = $15, "generation" = $16;
        ]
[parameters: ('LLMChain', 'undefined', '5fcd21be-b8fc-4b04-a67a-3e3d2b4a3d1f', '7c8b7eb2-018f-4493-a07f-6e4fd975148e', 'ea756a5d-5c88-443e-ae14-5b92a1c4997e', False, '{"language": "json"}', '{\'input\': StringPromptValue(text="Prepare plan for task execution. (e.g. retrieve current date to find weather forecast)\n\n    Tools to use: wikip ... (7443 characters truncated) ...  With rising demand, customizable tools offer personalized solutions, merging function with unique design.\nThought:\', \'stop\': [\'Observation:\']}', False, '```json\n{\n  "action": "Web Search",\n  "action_input": "innovative 3D printed home solutions"\n}\n```', '2025-02-17T12:46:18.436626Z', '2025-02-17T12:46:18.436626Z', '2025-02-17T12:46:19.096666Z', False, 'json', 'null')]
(Background on this error at: https://sqlalche.me/e/20/dbapi)
@dosubot dosubot bot added bug Something isn't working data layer Pertains to data layers. labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data layer Pertains to data layers. needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant