Skip to content

Bound the memory of bleve indexing - #3900

Merged
aduffeck merged 3 commits into
opencloud-eu:mainfrom
aduffeck:search-index-memory
Nov 9, 2026
Merged

aduffeck merged 3 commits into
opencloud-eu:mainfrom
aduffeck:search-index-memory

Conversation

@aduffeck

@aduffeck aduffeck commented Nov 4, 2026

Copy link
Copy Markdown
Member

Reindexing with bleve could run the search service out of memory. At 3 GB, a forced reindex of about 34,000 book-length text files was OOM-killed after five minutes. Two causes:

  • Batches were limited only by document count (50). bleve analyzes a whole batch in memory before writing it, and with term vectors on Content that takes more than ten times the size of the text.
  • --concurrency N writes N batches at once, each keeping its analysis in memory until it is written.

Changes

  • A batch is pushed at 16 MiB of document data, or before a document would overflow it.
  • Only one batch is written at a time.
  • The README describes how much memory bleve needs for merging index segments.

Measurements

8.1.0 with these commits, full --force-rescan of 11 spaces at --concurrency 3, 22 GB index.

3 GB stock this PR
Reindex killed after 5 min completed (2 of 2 runs)
Peak analysis heap 1.86 GB 0.37–0.38 GB
Peak heap outside merging 2.94 GB 0.98–1.10 GB

At 12 GB, indexing took about 5% longer than plain 8.1.0 built the same way, which is within the variation between runs (up to 12%). Without the one-batch-at-a-time change, analysis peaked at 0.84 GB, both 3 GB runs were killed, and 12 GB got no faster.

fixes #3797

Assisted by Claude Opus 5.5

Push a batch at 16 MiB of document data or before a document would overflow
it. Reindexing large text files ran out of memory otherwise.
bleve keeps the analysis of a whole batch in memory until it is written, so
batches of spaces reindexed in parallel stacked up their memory.
@codacy-production

codacy-production Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 18 complexity

Metric Results
Complexity 18

View in Codacy

🟢 Coverage 89.47% diff coverage · +0.02% coverage variation

Metric Results
Coverage variation ✅ +0.02% coverage variation (-1.00%)
Diff coverage ✅ 89.47% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (12d8edb) 93317 26496 28.39%
Head commit (5bda7dd) 93330 (+13) 26514 (+18) 28.41% (+0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3900) 19 17 89.47%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@aduffeck
aduffeck force-pushed the search-index-memory branch from 0ec42c8 to 5bda7dd Compare November 9, 2026 07:22
@aduffeck
aduffeck enabled auto-merge November 9, 2026 07:22
@aduffeck
aduffeck merged commit 2013f81 into opencloud-eu:main Nov 9, 2026
58 of 61 checks passed
@openclouders openclouders mentioned this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bleve full reindex has no checkpoint and OOMs the container despite a memory limit

2 participants