Skip to content

Add Optional User Configurable File Handler Soft Limit#395

Open
krkeegan wants to merge 3 commits intohassio-addons:mainfrom
krkeegan:fix_383
Open

Add Optional User Configurable File Handler Soft Limit#395
krkeegan wants to merge 3 commits intohassio-addons:mainfrom
krkeegan:fix_383

Conversation

@krkeegan
Copy link

@krkeegan krkeegan commented Jan 23, 2026

Proposed Changes

This adds a user configurable option for the file handler soft limit. As discussed in #383 the default soft limit of 1024 file handlers introduced in HAOS 16 is too low for some users. This results in a constant barrage of too many open files errors and a lot of CPU usage.

InfluxDB itself doesn't set or request any changes to the limits on the number of file handlers. Nor do they provide any guidance on what the expectations should be. Best I can find are forum comments here and here suggest anything from 500,000 to 65,536 are used by users.

The config option is also "hidden" in that the user has to click Show unused optional configuration options in order to see the option.

By default, the option is unset and defaults to whatever the container has set, I believe 1024 for HAOS users.

I added safety checks to ensure that the requested soft limit is below the hard limit, and provided log messages to the user.

I was personally affected by this error. I tested this by leaving the soft limits undefined, which resulted in the same error appearing. When I changed the limit to 65536, the error went away. I also tested setting the soft limit to an absurd number and the safety checks limited it to the HAOS maximum.

I am happy to make whatever suggested changes are required.

For reference, I considered using the available addon container config as documented here such as:

ulimits:
  nofile:
    soft: 65536

However this would have affected all users and it seems like many are not affected by this issue.

Of course if the hard limit of 524,288 proves to be too low for anyone, then we would need to adjust the hard limit in the configuration. But that seems unlikely.

Related Issues

Fixes #383

Summary by CodeRabbit

  • New Features

    • Added a configurable file-descriptor soft limit that is validated at startup, clamped to the system hard limit, and logs a warning for invalid values.
  • Documentation

    • Updated docs and examples to describe the new file limit configuration, default behavior, and allowed range.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a configurable nofile_soft_limit option: documented in DOCS, added to the config schema, and applied at container startup with validation, hard-limit clamping, logging, and warnings before launching InfluxDB.

Changes

Cohort / File(s) Summary
Documentation
influxdb/DOCS.md
Added nofile_soft_limit example and a dedicated section describing purpose, defaults, allowed range, and usage guidance.
Configuration Schema
influxdb/config.yaml
Added optional integer field nofile_soft_limit to the configuration schema (int?).
Startup Script Logic
influxdb/rootfs/etc/services.d/influxdb/run
Declared nofile_soft_limit and nofile_hard_limit; validate provided value (>0), read hard limit via ulimit -H -n, clamp soft to hard if needed, attempt ulimit -S -n, and log/warn on failure; invoked before starting InfluxDB.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Config (yaml)
    participant Init as init script (run)
    participant Kernel as Kernel limits
    participant Influx as InfluxDB service

    Config->>Init: supply `nofile_soft_limit`
    Init->>Init: validate value (>0)
    Init->>Kernel: query hard limit (`ulimit -H -n`)
    Kernel-->>Init: return hard_limit
    Init->>Init: soft_limit = min(soft_limit, hard_limit)
    Init->>Kernel: set soft limit (`ulimit -S -n`)
    Kernel-->>Init: success / failure
    Init->>Influx: start InfluxDB (with adjusted limits)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nudged the file-count ceiling wide,
Checked the hard bound, then set my stride.
A gentle clamp, a hopeful hum,
Influx wakes up — no errors to come. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding an optional, user-configurable file handler soft limit.
Linked Issues check ✅ Passed The PR fully addresses issue #383 by implementing a configurable nofile soft limit to mitigate 'too many open files' errors.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the configurable soft limit feature—documentation, configuration schema, and startup script logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
influxdb/DOCS.md (1)

34-45: Fix example key to match the actual option name. The example uses nofile, but the schema and option are nofile_soft_limit, which will confuse users.

✅ Proposed doc fix
 log_level: info
 auth: true
 reporting: true
 ssl: true
 certfile: fullchain.pem
 keyfile: privkey.pem
-nofile: 65536
+nofile_soft_limit: 65536
 envvars:
   - name: INFLUXDB_HTTP_LOG_ENABLED
     value: "true"
🤖 Fix all issues with AI agents
In `@influxdb/DOCS.md`:
- Around line 100-105: Fix the typo in the DOCS.md sentence that reads "The
default value in Home Assistant OS is 1024 and the maximum. value is 524,288."
by removing the stray period so it becomes "The default value in Home Assistant
OS is 1024 and the maximum value is 524,288." — locate and edit that exact
sentence in the InfluxDB docs content to ensure the sentence is not broken.

krkeegan and others added 2 commits January 22, 2026 19:07
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

too many open files after update to HAOS16

1 participant