brain/index: refuse --rebuild while a live brain holds the db - #67
Merged
Conversation
Deleting kb.lbug under a running brain-serve leaves it serving the removed inode and can lock the service out of the fresh db (observed with the compose container bind-mounting var/ as another uid). Two probes before removal, both overridable with --force: - /proc fd scan by device+inode: catches same-namespace holders and deleted-inode staleness (internal/brain.LiveHolders) - for the repo-default db only: an API answering on 127.0.0.1:$KB_PORT, since cross-uid container fds are invisible to host /proc KB_INDEX_ALLOW_LIVE=1 opts out for sanctioned swap+restart flows; the compose index service sets it. Runbook updated.
eSlider
added a commit
that referenced
this pull request
Aug 21, 2026
fix(onlyoffice/import-contact): library client, idempotent E2E (#67)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
index --rebuilddeletesvar/kb.lbugeven while a livebrain-serveholds it open. With the compose brain bind-mounting~/2dph/varat/data/var, a host-side rebuild replaces the file under the running service:OpenDatabase: failed to open database with status 1on every ingest)Recovery required fishing the old db out of
/proc/<pid>/fd/4and chown-ing the restored file.Fix
Refuse
--rebuildwhen the db is live. Two probes before removal:internal/brain.LiveHolders(path)— scans/proc/<pid>/fd, compares device+inode of each fd target against the db. Crosses bind mounts and container PID namespaces for same-uid processes; also flags deleted-inode holders (stale server). Cgo-free, unit-tested./statson127.0.0.1:$KB_PORT; cross-uid container fds are unreadable from host/proc.Scoped via git-repo root (independent of
KB_ROOT) so throwaway/test roots stay unblocked; CI sees neither probe fire.Escapes:
--forceper-invocation;KB_INDEX_ALLOW_LIVE=1env opt-out — set in the composeindexservice since its swap+restart flow is sanctioned. Runbook warning added.Test plan