Skip to content

fix(code): prevent native parser startup failure on macOS - #1818

Merged
Teingi merged 3 commits into
oceanbase:masterfrom
beatenevo:fix/macos-native-parser-memory
Oct 2, 2026
Merged

Teingi merged 3 commits into
oceanbase:masterfrom
beatenevo:fix/macos-native-parser-memory

Conversation

@beatenevo

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #1817.

Discovered while implementing and validating #1789. This fix is independent of the continuity-hint feature.

Rationale for this change

On macOS, the native parser worker fails to initialize RLIMIT_AS, exiting before parsing begins. Index builds that need the worker then fail with code_parser_failed.

What changes are included in this PR?

  • Keep Linux’s existing RLIMIT_AS limit; enforce a sampled RSS memory budget from the parent process on macOS.
  • Terminate workers that exceed the budget and abort builds when memory monitoring fails.
  • Preserve the previous index on startup failure; retain text evidence with failed structural coverage when parsing is interrupted.
  • Add a macOS-only psutil dependency, regression tests, and English/Chinese documentation.

Are there any user-facing changes?

Native parser workers can start successfully on macOS.

Linux limits virtual address space; macOS monitors resident memory. These mechanisms are not equivalent. RSS sampling runs approximately every 100 ms under normal scheduling and may permit temporary overshoot.

No public API or persisted format changes.

How was this change tested?

  • uv run pytest tests/builtin/test_native_code.py -q: 62 passed on macOS / Apple Silicon, Python 3.12.14.
  • uv run prek run -a: passed, including Ruff and type checks.
  • git diff --cached --check: passed before committing.

Memory-budget tests use real child processes with substituted worker commands to verify monitoring, termination, and index preservation. Ordinary indexing tests exercise the actual parser worker. Linux behavior was not executed locally.

AI usage statement

OpenAI Codex assisted with investigation, implementation, regression tests, documentation, and PR preparation. Validation commands were executed locally.

@Teingi
Teingi merged commit 502ce0a into oceanbase:master Oct 2, 2026
23 of 24 checks passed
@hidb4ai hidb4ai added the 1.3.0 label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: native parser worker fails to initialize RLIMIT_AS on macOS

2 participants