[PR #20868] [MERGED] Fix idle in transaction leaks in Open WebUI #80676

Closed
opened 2026-05-13 14:52:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20868
Author: @Classic298
Created: 1/22/2026
Status: Merged
Merged: 2/12/2026
Merged by: @tjbck

Base: devHead: claude/fix-idle-transaction-leaks-z8fdE


📝 Commits (2)

  • 6f72bb6 fix: add ScopedSession.remove() to prevent idle transaction leaks
  • 3ab0385 Delete IDLE_TRANSACTION_ANALYSIS.md

📊 Changes

1 file changed (+7 additions, -1 deletions)

View changed files

📝 backend/open_webui/main.py (+7 -1)

📄 Description

The HTTP middleware was calling ScopedSession.commit() but not ScopedSession.remove(), causing database connections to remain "checked out" from the pool indefinitely. This resulted in "idle in transaction" connections in PostgreSQL that could persist for 30-50+ minutes.

With SQLAlchemy's scoped_session:

  • commit() commits but keeps the session active
  • remove() is required to return the connection to the pool

This fix adds the missing remove() call, ensuring connections are properly returned after each HTTP request.

Also includes IDLE_TRANSACTION_ANALYSIS.md documenting the full root cause analysis and additional recommendations.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/20868 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/22/2026 **Status:** ✅ Merged **Merged:** 2/12/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `claude/fix-idle-transaction-leaks-z8fdE` --- ### 📝 Commits (2) - [`6f72bb6`](https://github.com/open-webui/open-webui/commit/6f72bb6578247cde5d8d1e0aa30f9c3a8f9bfdcc) fix: add ScopedSession.remove() to prevent idle transaction leaks - [`3ab0385`](https://github.com/open-webui/open-webui/commit/3ab038562cf0e316ee4c07b22574c17607f29227) Delete IDLE_TRANSACTION_ANALYSIS.md ### 📊 Changes **1 file changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+7 -1) </details> ### 📄 Description The HTTP middleware was calling ScopedSession.commit() but not ScopedSession.remove(), causing database connections to remain "checked out" from the pool indefinitely. This resulted in "idle in transaction" connections in PostgreSQL that could persist for 30-50+ minutes. With SQLAlchemy's scoped_session: - commit() commits but keeps the session active - remove() is required to return the connection to the pool This fix adds the missing remove() call, ensuring connections are properly returned after each HTTP request. Also includes IDLE_TRANSACTION_ANALYSIS.md documenting the full root cause analysis and additional recommendations. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-13 14:52:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#80676