meilisearch icon indicating copy to clipboard operation
meilisearch copied to clipboard

Meilisearch does not respect `--max-indexing-memory` argument

Open vaites opened this issue 1 year ago • 6 comments

Describe the bug The Meilisearch process is killed by Linux kernel (Out of memory) because uses a lot of memory. Even using --max-indexing-threads and --max-indexing-memory arguments (or config) the process uses more memory than the specified. We set 100MB and grows up to 600-700MB.

To Reproduce Steps to reproduce the behavior:

  1. Use a Linux VPS/VM with 1 CPU and 2GB of RAM (we use Debian 11)
  2. Run ./meilisearch-linux-amd64 --log-level=debug --max-indexing-threads=1 --max-indexing-memory=104857600
  3. Add documents (we have ~10.000 records, ~75MB of plain text)
  4. Wait for documents to be indexed
  5. See the Killed output

Expected behavior Process not being killed

Meilisearch version: v1.0.2, v1.1.1

Additional context

Meilisearch debug output:

[2023-05-04T11:51:12Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 6, total_databases: 12 }
[2023-05-04T11:51:12Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 7, total_databases: 12 }
[2023-05-04T11:51:12Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 8, total_databases: 12 }
[2023-05-04T11:51:12Z DEBUG TimerFinished] WordsPrefixesFst::execute(), Elapsed=74.215858ms
[2023-05-04T11:51:12Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 9, total_databases: 12 }
[2023-05-04T11:51:12Z DEBUG milli::update::index_documents::helpers::grenad_helpers] Writing MTBL sorter...
[2023-05-04T11:51:13Z DEBUG milli::update::index_documents::helpers::grenad_helpers] MTBL sorter writen in 684.22ms!
[2023-05-04T11:51:13Z DEBUG TimerFinished] WordPrefixDocids::execute(), Elapsed=821.728114ms
[2023-05-04T11:51:13Z DEBUG milli::update::index_documents::helpers::grenad_helpers] Writing MTBL sorter...
[2023-05-04T11:51:13Z DEBUG milli::update::index_documents::helpers::grenad_helpers] MTBL sorter writen in 117.05µs!
[2023-05-04T11:51:13Z DEBUG TimerFinished] WordPrefixDocids::execute(), Elapsed=1.085624ms
[2023-05-04T11:51:13Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 10, total_databases: 12 }
[2023-05-04T11:51:13Z DEBUG milli::update::prefix_word_pairs::word_prefix] Computing and writing the word prefix pair proximity docids into LMDB on disk...
[2023-05-04T11:51:21Z DEBUG TimerFinished] index_word_prefix_database(), Elapsed=8.591115147s
[2023-05-04T11:51:21Z DEBUG milli::update::prefix_word_pairs::prefix_word] Computing and writing the word prefix pair proximity docids into LMDB on disk...
[2023-05-04T11:51:26Z DEBUG TimerFinished] index_prefix_word_database(), Elapsed=4.967866167s
[2023-05-04T11:51:26Z DEBUG TimerFinished] WordPrefixPairProximityDocids::execute(), Elapsed=13.568378347s
[2023-05-04T11:51:26Z DEBUG index_scheduler::batch] update: MergeDataIntoFinalDatabase { databases_seen: 11, total_databases: 12 }
[2023-05-04T11:51:26Z DEBUG milli::update::words_prefix_position_docids] Computing and writing the word levels positions docids into LMDB on disk...
Killed

Debian log output:

May 04 11:51:30 vps kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-144716.scope,task=meilisearch-lin,pid=2406696,uid=1000
May 04 11:51:30 vps kernel: Out of memory: Killed process 2406696 (meilisearch-lin) total-vm:2170918328kB, anon-rss:766100kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:3108kB oom_score_adj:0
May 04 11:51:30 vps systemd[1]: session-144716.scope: A process of this unit has been killed by the OOM killer.

vaites avatar May 04 '23 12:05 vaites