Skip to content

fix: set COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS=256 to prevent "too many open files" error#300

Merged
HumanBean17 merged 1 commit into
masterfrom
fix/too-many-open-files
Jun 8, 2026
Merged

fix: set COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS=256 to prevent "too many open files" error#300
HumanBean17 merged 1 commit into
masterfrom
fix/too-many-open-files

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

Summary

  • Fixes Install error #2 #293 by setting COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS=256 before invoking cocoindex
  • Prevents "Too many open files (os error 24)" error during indexing on systems with default OS file descriptor limits
  • Applied to both code paths: java_codebase_rag/pipeline.py and server.py

Root Cause

CocoIndex's default concurrency (1024 inflight rows) opens too many file handles simultaneously, exceeding OS file descriptor limits (typically 256-1024). This is not user error - even with fresh OS startup and single terminal window.

Changes

  • java_codebase_rag/pipeline.py: Set default in run_cocoindex_update()
  • server.py: Set default in _cocoindex_subprocess_env()

Test plan

  • Ruff checks pass
  • Existing tests pass
  • Users can verify fix resolves the indexing error

🤖 Generated with Claude Code

…open files" error

Fixes #293. Users experienced "Too many open files (os error 24)" during
indexing because CocoIndex's default concurrency (1024 inflight rows) opens
more file handles than OS limits allow (typically 256-1024).

Set COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS=256 in both code paths that invoke
cocoindex (pipeline.run_cocoindex_update and server._cocoindex_subprocess_env).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@HumanBean17 HumanBean17 merged commit 08b81c8 into master Jun 8, 2026
1 check failed
HumanBean17 added a commit that referenced this pull request Jun 13, 2026
The #293 fix (#300) set COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS — an env var
CocoIndex never reads. The real semaphore var is
COCOINDEX_MAX_INFLIGHT_COMPONENTS (default 1024, see
cocoindex/_internal/app.py), so the throttle was a no-op and the EMFILE
"Too many open files (os error 24)" recurred (#306).

Layer A (correctness): centralize the throttle in
cocoindex_subprocess_env_defaults() using the real env var; both cocoindex
subprocess sites (pipeline.run_cocoindex_update + server._cocoindex_subprocess_env)
apply it via setdefault so an operator override still wins.

Layer B (deterministic): raise_fd_limit() raises the process soft
RLIMIT_NOFILE toward its hard limit (capped 65536, never infinity) at
cli.main / server.main startup. rlimits are inherited across fork+exec, so
cocoindex children get headroom regardless of launch context — macOS
GUI/launchd/IDE-launched processes inherit a 256 FD ceiling, not the shell's
raised limit, which is why the error recurred even on hosts whose terminal
shows a high ulimit.

No ontology/schema/re-index impact.

Fixes #306.

Co-Authored-By: Claude <noreply@anthropic.com>
HumanBean17 added a commit that referenced this pull request Jun 13, 2026
The #293 fix (#300) set COCOINDEX_SOURCE_MAX_INFLIGHT_ROWS — an env var
CocoIndex never reads. The real semaphore var is
COCOINDEX_MAX_INFLIGHT_COMPONENTS (default 1024, see
cocoindex/_internal/app.py), so the throttle was a no-op and the EMFILE
"Too many open files (os error 24)" recurred (#306).

Layer A (correctness): centralize the throttle in
cocoindex_subprocess_env_defaults() using the real env var; both cocoindex
subprocess sites (pipeline.run_cocoindex_update + server._cocoindex_subprocess_env)
apply it via setdefault so an operator override still wins.

Layer B (deterministic): raise_fd_limit() raises the process soft
RLIMIT_NOFILE toward its hard limit (capped 65536, never infinity) at
cli.main / server.main startup. rlimits are inherited across fork+exec, so
cocoindex children get headroom regardless of launch context — macOS
GUI/launchd/IDE-launched processes inherit a 256 FD ceiling, not the shell's
raised limit, which is why the error recurred even on hosts whose terminal
shows a high ulimit.

No ontology/schema/re-index impact.

Fixes #306.

Co-authored-by: Claude <noreply@anthropic.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.

Install error #2

1 participant