[PR #23046] [CLOSED] fix: add pagination to chat list endpoints to prevent OOM #50043

Closed
opened 2026-04-30 02:32:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23046
Author: @yang1002378395-cmyk
Created: 3/26/2026
Status: Closed

Base: devHead: fix-oom-pagination


📝 Commits (1)

  • efb0f9a fix: add pagination to chat list endpoints to prevent OOM

📊 Changes

2 files changed (+34 additions, -15 deletions)

View changed files

📝 backend/open_webui/models/chats.py (+19 -9)
📝 backend/open_webui/routers/chats.py (+15 -6)

📄 Description

Summary

Fixes #22206

Adds pagination to chat list endpoints to prevent Out of Memory (OOM) crashes when users have large numbers of chats.

Problem

When calling /api/v1/chats/all or /api/v1/chats/all/archived without pagination, the server loads ALL chats into memory. For users with thousands of chats, this can cause OOM crashes.

Changes

  • models/chats.py: Added skip and limit parameters to get_chats() and get_archived_chats_by_user_id()
  • routers/chats.py: Updated /chats/all, /chats/all/archived, /chats/all/db endpoints with pagination parameters
  • Default limit of 50 prevents loading unbounded data

API Changes

GET /api/v1/chats/all?skip=0&limit=50
GET /api/v1/chats/all/archived?skip=0&limit=50
GET /api/v1/chats/all/db?skip=0&limit=50

Testing

Tested locally with:

  • 1000+ chats in database
  • Verified memory usage stays constant
  • Verified pagination returns correct subsets

Based on closed PR #22464 with formatting fixes.


Contributor License Agreement

By submitting this pull request, I confirm that my contributions are made under the Apache 2.0 license.


🔄 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/23046 **Author:** [@yang1002378395-cmyk](https://github.com/yang1002378395-cmyk) **Created:** 3/26/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-oom-pagination` --- ### 📝 Commits (1) - [`efb0f9a`](https://github.com/open-webui/open-webui/commit/efb0f9a6f29ce9afa1ee50b7e6bb3d628e636fd2) fix: add pagination to chat list endpoints to prevent OOM ### 📊 Changes **2 files changed** (+34 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/chats.py` (+19 -9) 📝 `backend/open_webui/routers/chats.py` (+15 -6) </details> ### 📄 Description ## Summary Fixes #22206 Adds pagination to chat list endpoints to prevent Out of Memory (OOM) crashes when users have large numbers of chats. ## Problem When calling `/api/v1/chats/all` or `/api/v1/chats/all/archived` without pagination, the server loads ALL chats into memory. For users with thousands of chats, this can cause OOM crashes. ## Changes - **models/chats.py**: Added `skip` and `limit` parameters to `get_chats()` and `get_archived_chats_by_user_id()` - **routers/chats.py**: Updated `/chats/all`, `/chats/all/archived`, `/chats/all/db` endpoints with pagination parameters - Default limit of 50 prevents loading unbounded data ## API Changes ``` GET /api/v1/chats/all?skip=0&limit=50 GET /api/v1/chats/all/archived?skip=0&limit=50 GET /api/v1/chats/all/db?skip=0&limit=50 ``` ## Testing Tested locally with: - 1000+ chats in database - Verified memory usage stays constant - Verified pagination returns correct subsets ## Related Based on closed PR #22464 with formatting fixes. --- ### Contributor License Agreement By submitting this pull request, I confirm that my contributions are made under the Apache 2.0 license. --- <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-04-30 02:32:13 -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#50043