Skip to content

ops: track mempalace-backup script + units in repo (#87) - #89

Merged
jphein merged 1 commit into
mainfrom
fix/87-backup-oom
May 30, 2026
Merged

ops: track mempalace-backup script + units in repo (#87)#89
jphein merged 1 commit into
mainfrom
fix/87-backup-oom

Conversation

@jphein

@jphein jphein commented May 30, 2026

Copy link
Copy Markdown
Collaborator

What

Closes the config drift flagged in #87 (Tail 2): the nightly mempalace pg_dump OOM fix was hand-deployed to /usr/local/bin/mempalace-backup.sh on familiar and not tracked in this repo, so a host rebuild/reimage would silently lose it.

Mirrors the established familiar-watchdog pattern:

File Purpose
ops/familiar/mempalace-backup.sh Verbatim capture of the deployed script (executable logic byte-identical to /usr/local/bin/mempalace-backup.sh; only a header comment added).
ops/familiar/mempalace-backup.service The oneshot unit + defense-in-depth resource hygiene.
ops/familiar/mempalace-backup.timer Nightly 02:15, Persistent=true.
ops/scripts/install-mempalace-backup.sh Idempotent installer (matches install-familiar-watchdog.sh).

Why the fix works

familiar (15.5G) is RAM-oversubscribed. With llama-server-extractor (~3.1G) running, the pg_dump COPY of the embedding-laden 410K-row drawers table tipped the host below earlyoom's ~10%-free threshold, and earlyoom SIGTERM'd the postgres backend mid-COPY. The script stops llama-server-extractor for the dump window and restores its prior state via an EXIT trap (so it never resurrects a deliberately-stopped llama, e.g. during a benchmark). kg-extract retries against the dead endpoint (mempalace#307), so no triples are lost.

Defense-in-depth nuance (honest framing)

The service unit adds Nice=10, ionice best-effort/7, and OOMScoreAdjust=-500. The unit comment is explicit that these protect the host-side pg_dump/gzip pipeline only — earlyoom kills the postgres backend running the COPY inside the mempalace-db container (separate process tree, separate oom_score), which OOMScoreAdjust on this unit cannot reach. So the llama-stop in the script remains the real guard; the resource controls just reduce the dump's own footprint and keep it from starving interactive work.

Verification

  • bash -n clean on both scripts; systemd-analyze verify parsed the unit directives without complaint (only flagged the on-host ExecStart path, expected off-host).
  • Executable logic confirmed byte-identical to the deployed /usr/local/bin/mempalace-backup.sh via diff.
  • Live state on familiar: last run 2026-05-29 09:19 dumped 1.1G cleanly in 2m22s; host RAM healthy. The fix is already deployed and working — this PR captures it so it survives a rebuild.

Not in scope / open tail

🤖 Generated with Claude Code

The nightly pg_dump OOM fix was hand-deployed to
/usr/local/bin/mempalace-backup.sh on familiar and not tracked here, so a
host rebuild/reimage would silently lose it. Mirror the familiar-watchdog
pattern to close the drift:

- ops/familiar/mempalace-backup.sh — verbatim capture of the deployed
  script (logic byte-identical; added a header comment only). Stops
  llama-server-extractor for the dump window and restores its prior state
  via an EXIT trap, freeing ~3.1G so earlyoom doesn't SIGTERM the dump's
  postgres backend mid-COPY.
- ops/familiar/mempalace-backup.{service,timer} — the oneshot unit + 02:15
  nightly timer, plus defense-in-depth resource hygiene (Nice=10, ionice
  best-effort/7, OOMScoreAdjust=-500). The comment is explicit that these
  protect the host-side dump pipeline only — earlyoom kills the in-container
  postgres backend, so the llama-stop in the script remains the real guard.
- ops/scripts/install-mempalace-backup.sh — idempotent installer matching
  install-familiar-watchdog.sh; copies script to /usr/local/bin, units to
  /etc/systemd/system, arms the timer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 30, 2026 06:47
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jphein
jphein merged commit 6938b3c into main May 30, 2026
1 check failed
@jphein
jphein deleted the fix/87-backup-oom branch May 30, 2026 06:50
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.

2 participants