mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[PR #23758] [CLOSED] perf: optimize SQLite WAL connection pragmas #27357
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23758
Author: @Algorithm5838
Created: 4/15/2026
Status: ❌ Closed
Base:
dev← Head:perf/sqlite-wal-pragmas📝 Commits (1)
26469a8perf: optimize SQLite WAL connection pragmas📊 Changes
1 file changed (+19 additions, -19 deletions)
View changed files
📝
backend/open_webui/internal/db.py(+19 -19)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Changelog Entry
Description
SQLite's default connection settings are tuned for embedded use, not a web server. When WAL is enabled, only
journal_modewas being set; other impactful PRAGMAs were left at their conservative defaults. This meant unnecessary fsyncs on every write (synchronous=FULL), no retry on lock contention (causing spuriousdatabase is lockederrors under concurrent load), and no query planner stats being maintained.This PR sets the right PRAGMAs on every connection.
Also fixes a bug: the async engine had no
elsebranch, soDATABASE_ENABLE_SQLITE_WAL=falsewas silently ignored for async connections.Added
Changed
on_connecthandlers into shared_sqlite_on_connect, registered on both engines; cursor cleanup is exception-safe viacontextlib.closing().synchronous=NORMAL(removes per-write fsync; safe on app crash, may lose last transactions on power loss)journal_size_limit=67108864(64 MB WAL cap)cache_size=-32768(32 MB page cache, per connection)temp_store=MEMORYbusy_timeout=5000(5 s retry on lock contention)Deprecated
Removed
Fixed
journal_mode=DELETEwhen WAL is disabled, matching sync engine behavior.Security
Breaking Changes
Additional Information
integrity_checkpasses, and no lock errors appear in logs.Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.