Skip to content

chroma: use force_fpcalc=True to prevent fd exhaustion - #6928

Open
slmingol wants to merge 5 commits into
beetbox:masterfrom
slmingol:fix/chroma-fd-leak-force-fpcalc
Open

chroma: use force_fpcalc=True to prevent fd exhaustion#6928
slmingol wants to merge 5 commits into
beetbox:masterfrom
slmingol:fix/chroma-fd-leak-force-fpcalc

Conversation

@slmingol

Copy link
Copy Markdown

Problem

The chroma plugin leaks file descriptors when fingerprinting via audioread's GStreamer backend. When fingerprinting fails or GStreamer encounters an error, the pipeline socket is left open. Across thousands of files this exhausts the process fd limit:

```
OSError: [Errno 24] No file descriptors available
```

This causes `beet import` to crash mid-run on large libraries. Raising `ulimit -n` only delays the inevitable — the leak is unbounded.

Reported in #5171.

Fix

`pyacoustid.fingerprint_file()` accepts a `force_fpcalc=True` parameter (added in pyacoustid 1.2.0) that routes fingerprinting through the `fpcalc` binary, bypassing audioread and GStreamer entirely. `fpcalc` is already a hard dependency of the chroma plugin, so no new requirements are introduced.

Both call sites in `chroma.py` are updated.

Testing

Verified against a library of ~10,000 albums where the previous code consistently crashed with fd exhaustion. With `force_fpcalc=True` the import runs to completion.

audioread's GStreamer backend leaks file descriptors when fingerprinting
fails or errors occur. Across thousands of files this exhausts the process
fd limit (OSError: [Errno 24] No file descriptors available).

pyacoustid.fingerprint_file() accepts force_fpcalc=True (added in
pyacoustid 1.2.0) which routes fingerprinting through the fpcalc binary,
bypassing audioread/GStreamer entirely. fpcalc is already a hard dependency
of the chroma plugin so no new requirements are introduced.

Fixes beetbox#5171

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@slmingol
slmingol requested a review from a team as a code owner August 14, 2026 01:08
Copilot AI lite review requested due to automatic review settings August 14, 2026 01:08
@github-actions github-actions Bot added the chroma chroma plugin label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

grug see PR try fix fd leak in chroma fingerprint by skip audioread/GStreamer path and always go through fpcalc via force_fpcalc=True. this fit beetsplug/chroma.py fingerprint + acoustid lookup path.

Changes:

  • pass force_fpcalc=True in acoustid_match() fingerprint generation
  • pass force_fpcalc=True in fingerprint_item() fingerprint generation
Suppressed comments (1)

beetsplug/chroma.py:445

  • grug see new force_fpcalc kwarg here too. if pyacoustid old, TypeError bubble up and crash fingerprint command/import. grug want catch TypeError and print upgrade hint.
            _, fp = acoustid.fingerprint_file(util.syspath(item.path), force_fpcalc=True)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread beetsplug/chroma.py Outdated
"""
try:
duration, fp = acoustid.fingerprint_file(util.syspath(path))
duration, fp = acoustid.fingerprint_file(util.syspath(path), force_fpcalc=True)
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.84%. Comparing base (1cb3af8) to head (4372595).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/chroma.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6928      +/-   ##
==========================================
+ Coverage   75.78%   75.84%   +0.05%     
==========================================
  Files         164      164              
  Lines       21437    21437              
  Branches     3379     3379              
==========================================
+ Hits        16247    16259      +12     
+ Misses       4387     4374      -13     
- Partials      803      804       +1     
Files with missing lines Coverage Δ
beetsplug/chroma.py 51.11% <66.66%> (+4.47%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

slmingol and others added 4 commits August 13, 2026 21:17
Dockerfile patches chroma.py in the linuxserver/beets base image to use
force_fpcalc=True, fixing fd exhaustion on large libraries (beetbox#5171).

GHA workflow builds and pushes to ghcr.io/slmingol/beets on every push
to master and weekly to pick up upstream linuxserver base updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Multi-line format for fingerprint_file calls (ruff E501)
- Catch TypeError for pyacoustid versions < 1.2.0 without force_fpcalc
- Add changelog entry for beetbox#5171 fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the two code paths added in the beetbox#5171 fix:
- force_fpcalc=True is passed to acoustid.fingerprint_file
- TypeError from old pyacoustid (<1.2.0) is caught and logged, not raised

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chroma chroma plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants