Conversation
When hermes runs as root with local_embedded mode, the embedded PostgreSQL daemon cannot start because initdb refuses to run as root. The daemon retries endlessly (~3 min per cycle), consuming CPU and memory in a loop, with the only visible symptom being hermes hanging on startup. This patch detects root at daemon startup time and skips the daemon with a clear warning message pointing the user to either run as a non-root user or switch to cloud/local_external mode.
Collaborator
|
Salvaged and merged via #50308 (commit 7bc6f18 on main) — your authorship is preserved in git log. Your branch had gone stale: it wrapped the pre-refactor |
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.
What does this PR do?
When hermes runs as root with
local_embeddedmemory mode, the embedded PostgreSQL daemon (hindsight-api --daemon) cannot start becauseinitdbrefuses to run as root. The daemon then retries endlessly (~3 minutes per cycle), consuming CPU and memory in a tight loop. The only visible symptom is hermes hanging on startup with no clear error message.This patch adds an early
os.geteuid() == 0check in the daemon startup path. When running as root, it skips the daemon entirely and logs a clear warning message telling the user to either:cloudorlocal_externalmode viahermes memory setupRelated Issue
Distinct from #13101 (which addresses missing
hindsight-allpackage). This PR addresses the root-user daemon hang.Type of Change
Changes Made
plugins/memory/hindsight/__init__.py: Addedos.geteuid()check before daemon startup ininitialize(). When root is detected, logs warning and skips daemon instead of entering an infinite retry loop.How to Test
local_embeddedmodehindsight-api --daemonprocess spins at ~30% CPU with log showinginitdb: error: cannot be run as rootrepeating every ~3 minuteslocal_embeddedstill works (no regression)Checklist
os.geteuid()(POSIX) withhasattrguard