Skip to content

[claude] Cap hgweb's mod_wsgi daemon memory at the container limit - #2876

Closed
myieye wants to merge 1 commit into
developfrom
claude/hgweb-wsgi-memory-limit
Closed

myieye wants to merge 1 commit into
developfrom
claude/hgweb-wsgi-memory-limit

Conversation

@myieye

@myieye myieye commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

[Claude, autonomous]

Sets mod_wsgi memory-limit (RLIMIT_DATA) on the hgweb daemon to the container's memory limit, via a new HGWEB_MEMORY_LIMIT env var, so a runaway request gets a MemoryError and fails alone instead of the kernel OOM-killing the daemon and every in-flight Send/Receive on it.

  • Verified in the published image under a 600 MiB cgroup: without the limit a 45 MB rewrite diff got the daemon SIGKILLed; with it the request failed with MemoryError and the daemon kept serving.
  • RLIMIT_DATA also counts the daemon's non-resident thread stacks (~170 MB measured idle), so resident use trips ~150 MB below the container limit, which leaves room for Apache and the CGI hg commands.
  • Trade-off: the error lands on whichever thread allocates past the limit, so a concurrent push could be the one to fail. Still gentler than today's SIGKILL (hg rolls the transaction back instead of leaving it abandoned).
  • If the env var is missing, httpd logs a warning and runs without a limit (checked); the Dockerfile sets a default anyway.
  • Independent of [claude] Refuse hgweb diff pages too large to render #2873 (the diff guard) but meant to go with it; they touch different lines of the Dockerfile.

Generated by Claude Code

A request that outgrows the pod now fails with a MemoryError instead of the
kernel OOM-killing the daemon (and every in-flight Send/Receive on it).
RLIMIT_DATA also counts the daemon's non-resident thread stacks (~170 MB
measured), so resident use trips well below the container limit, leaving
room for Apache and the CGI hg commands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AM78WDGRwYjhxtfmrFr3az
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e23f0d7d-117c-4824-85eb-cd56d5d3a204
Commits

Reviewing files that changed from the base of the PR and between 5efc48f and 3f64cf3.

Files selected for processing: 4
  • deployment/base/hg-deployment.yaml
  • deployment/production/hg-deployment.yaml
  • hgweb/Dockerfile
  • hgweb/hg.conf
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added the 📦 Lexbox issues related to any server side code, fw-headless included label Oct 30, 2026

myieye commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

[Claude, autonomous]

Closing: CI disproved this. In the kind cluster (600Mi hgweb, so a 600 MB RLIMIT_DATA) the daemon hit MemoryError in changegroup.generate two minutes into the run while serving an ordinary pull of the test project, FwHeadless's clone failed, and 65 integration tests failed downstream (job). RLIMIT_DATA counts thread stacks and malloc arenas that are not resident, so it trips far below the container limit under normal Send/Receive concurrency and is not a usable proxy for the cgroup limit. The diff guard in #2873 stands on its own; a daemon-level cap would need a different mechanism.


Generated by Claude Code

@myieye myieye closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 Lexbox issues related to any server side code, fw-headless included

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants