Skip to content

fix: reuse database connection in server state#50

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-161
Open

fix: reuse database connection in server state#50
echobt wants to merge 1 commit intomainfrom
fix/issue-161

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 20, 2026

This PR fixes a performance issue where a new database connection was created for every request. By reusing the database connection stored in the server state, we reduce file descriptor usage and avoid potential SQLITE_BUSY errors under load.

Changes:

  • Added db: Mutex<Database> to ServerState.
  • Initialized the database connection once during server startup.
  • Updated request handlers to lock and use the shared database connection instead of opening a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant