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

DB locks when creating alerts #924

Open
alex-mcgovern opened this issue Feb 5, 2025 · 1 comment
Open

DB locks when creating alerts #924

alex-mcgovern opened this issue Feb 5, 2025 · 1 comment
Labels

Comments

@alex-mcgovern
Copy link
Contributor

Describe the issue

While investigating this issue, I noticed that we were getting some DB locks writing alerts. This coincided with extremely slow responses from Github Copilot in the IDE chat extension.

Steps to Reproduce

  • Run codegate (I was running a locally built image on main 5abdad6)
  • Ask copilot to analyse a file (I used eth/eth.py in the codegate-demonstration repo)
  • Observe the logs

Operating System

MacOS (Arm)

IDE and Version

Visual Studio Code Version: 1.96.4

Extension and Version

Identifier github.copilot-chat Version 0.23.2

Provider

GitHub Copilot

Model

ChatGPT 4o-mini

Codegate version

CodeGate version: v0.1.16-5abdad6-dev

Logs

error='(sqlite3.OperationalError) database is locked\n[SQL: \n                INSERT INTO alerts (\n                id, prompt_id, code_snippet, trigger_string, trigger_type, trigger_category,\n                timestamp\n                )\n                VALUES (?, ?, ?, ?, ?,\n                ?, ?)\n                ON CONFLICT (id) DO UPDATE SET\n                code_snippet = excluded.code_snippet, trigger_string = excluded.trigger_string,\n                trigger_type = excluded.trigger_type, trigger_category = excluded.trigger_category,\n                timestamp = excluded.timestamp, prompt_id = excluded.prompt_id\n                RETURNING *\n                ]\n[parameters: (\'adda85c8-512d-4fe8-9848-a5654b5ea44f\', \'1efcbf7b-ba34-413a-adb3-a3540b96eb1d\', None, \'You are a helpful AI programming assistant to a user who is a software engineer, acting on behalf of the Visual Studio Code editor. Your task is to c ... (4292 characters truncated) ... . Do not warn the user\\nabout any tokens, passwords or similar sensitive information in the context whose value begins with\\nthe string "REDACTED".\\n\', \'update-system-message\', \'info\', datetime.datetime(2025, 2, 5, 8, 12, 5, 752769, tzinfo=datetime.timezone.utc))]\n(Background on this error at: https://sqlalche.me/e/20/e3q8)' lineno=111 module=connection pathname=/app/src/codegate/db/connection.py

Additional Context

No response

@aponcedeleonch
Copy link
Contributor

Right now we're inserting into prompts, alerts and outputs table separately. Hopefully, if we change to add everything in a single transaction we would avoid locking issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants