Skip to content

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

@wolfgangyu

Description

@wolfgangyu

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",
        // ...
    ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions