nextcloud / nextcloud/files_fulltextsearch

ELASTICSEARCH_HEAP_SIZE on mastercontainer fails to set Elasticsearch child container heap size, stuck at 512MB causing OOM

Open
#322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug
Dominant language
PHP
Stars
72
Forks
41
Avg merge
1d 3h
Merged PRs (30d)
9

Description

Problem Description:

According to the official Nextcloud AIO documentation (Containers.md#elasticsearch), it should be possible to adjust the JVM heap size of the Elasticsearch child container by setting the ELASTICSEARCH_HEAP_SIZE environment variable on the nextcloud-aio-mastercontainer. However, testing reveals that regardless of how this variable is set (e.g., to 4g), the ES_JAVA_OPTS environment variable in a newly created nextcloud-aio-fulltextsearch container is consistently fixed at -Xms512M -Xmx512M. This causes Elasticsearch to crash frequently due to insufficient memory (java.lang.OutOfMemoryError: Java heap space), rendering the full-text search feature unusable.

Expected Behavior:

When the nextcloud-aio-mastercontainer is started with, for example, --env ELASTICSEARCH_HEAP_SIZE=4g, the nextcloud-aio-fulltextsearch container it creates should receive the corresponding heap memory configuration (e.g., ES_JAVA_OPTS should reflect -Xms4g -Xmx4g or an equivalent configuration).

Actual Behavior:

  1. The nextcloud-aio-mastercontainer's environment variables are confirmed to include ELASTICSEARCH_HEAP_SIZE=4g (verified via Config.Env from docker inspect nextcloud-aio-mastercontainer).
  2. Even after deleting the old nextcloud-aio-fulltextsearch container, a new nextcloud-aio-fulltextsearch container recreated by the aforementioned mastercontainer still has ES_JAVA_OPTS set to -Xms512M -Xmx512M in its Config.Env (verified via docker inspect nextcloud-aio-fulltextsearch).
  3. Logs from the nextcloud-aio-fulltextsearch container confirm its JVM heap size is 512MB, and it exits due to java.lang.OutOfMemoryError: Java heap space.
  4. The Nextcloud AIO admin interface does not offer an option to adjust the Elasticsearch JVM heap size.

Steps to Reproduce:

  1. Stop and remove any existing nextcloud-aio-mastercontainer and nextcloud-aio-fulltextsearch containers.
    sudo docker stop nextcloud-aio-mastercontainer
    sudo docker rm nextcloud-aio-mastercontainer
    sudo docker rm nextcloud-aio-fulltextsearch
    
  2. Start the nextcloud-aio-mastercontainer with the following command (using ELASTICSEARCH_HEAP_SIZE=4g as an example, and /home/ncdata as the data directory):
    sudo docker run \
    --init \
    --sig-proxy=false \
    --name nextcloud-aio-mastercontainer \
    --restart always \
    --publish 80:80 \
    --publish 8080:8080 \
    --publish 8443:8443 \
    --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
    --volume /var/run/docker.sock:/var/run/docker.sock:ro \
    --env NEXTCLOUD_DATADIR="/home/ncdata" \
    --env ELASTICSEARCH_HEAP_SIZE=4g \
    ghcr.io/nextcloud-releases/all-in-one:latest
    
  3. Wait for the nextcloud-aio-mastercontainer to start and create the nextcloud-aio-fulltextsearch container.
  4. Inspect the environment variables of the nextcloud-aio-mastercontainer:
    sudo docker inspect nextcloud-aio-mastercontainer
    
    (Verify that ELASTICSEARCH_HEAP_SIZE=4g is present in Config.Env)
  5. Inspect the environment variables of the newly created nextcloud-aio-fulltextsearch container:
    sudo docker inspect nextcloud-aio-fulltextsearch
    
    (Observe that ES_JAVA_OPTS in Config.Env is still -Xms512M -Xmx512M)
  6. Check the logs of the nextcloud-aio-fulltextsearch container:
    sudo docker logs nextcloud-aio-fulltextsearch
    
    (Observe the reported heap size on startup and any OOM errors)

Environment Details:

Impact:

Due to the inability to correctly configure Elasticsearch's memory, the full-text search feature cannot operate stably. The Elasticsearch container continuously crashes due to OutOfMemoryError, impacting system stability and generating numerous error logs. This effectively makes the documented feature for adjusting Elasticsearch memory unusable.

Relevant Log Snippets:

  • nextcloud-aio-fulltextsearch OOM error log snippet:
    java.lang.OutOfMemoryError: Java heap space
    Dumping heap to data/java_pidXX.hprof ...
    Terminating due to java.lang.OutOfMemoryError: Java heap space
    ERROR: Elasticsearch exited unexpectedly, with exit code 3
    
  • nextcloud-aio-fulltextsearch JVM arguments on startup (from docker logs ...):
    {"@timestamp":"...","message":"JVM arguments [..., -Xms512M, -Xmx512M, ...]"}
    {"@timestamp":"...","message":"heap size [512mb]..."}
    
  • Key part of Config.Env from docker inspect nextcloud-aio-fulltextsearch:
    "Env": [
        // ...
        "ES_JAVA_OPTS=-Xms512M -Xmx512M",
        // ...
    ]
    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the mastercontainer code path that creates nextcloud-aio-fulltextsearch, and compare its environment handling with Containers.md#elasticsearch. Reproduce the issue with ELASTICSEARCH_HEAP_SIZE=4g, then verify with docker inspect and container logs that the child container receives the requested heap settings and no longer remains fixed at 512MB.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, elasticsearch, php
Domain
backend, devops, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.