{"record":{"id":"11279a15e26178e9","repo":"gastownhall/beads","slug":"verify-proxy-spawn-owner-pid-d-w","errorCode":null,"errorMessage":"verify proxy spawn owner pid %d: %w","messagePattern":"verify proxy spawn owner pid (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/proxy/endpoint.go","lineNumber":1038,"sourceCode":"\t\treturn nil, fmt.Errorf(\"decode %s: %w\", path, err)\n\t}\n\tif marker.Schema != 1 || marker.PID <= 0 || marker.Birth == \"\" {\n\t\treturn nil, fmt.Errorf(\"invalid spawn marker %s\", path)\n\t}\n\treturn &marker, nil\n}\n\nfunc inspectSpawnMarkerLocked(rootDir string) (bool, error) {\n\tmarker, err := readSpawnMarker(rootDir)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"inspect proxy spawn marker: %w\", err)\n\t}\n\tif marker == nil {\n\t\treturn false, nil\n\t}\n\tmatched, err := procid.Verify(marker.PID, procid.Token(marker.Birth))\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"verify proxy spawn owner pid %d: %w\", marker.PID, err)\n\t}\n\tif matched {\n\t\treturn true, nil\n\t}\n\tif err := os.Remove(filepath.Join(rootDir, spawnMarkerFileName)); err != nil && !errors.Is(err, fs.ErrNotExist) {\n\t\treturn false, fmt.Errorf(\"remove dead spawn marker: %w\", err)\n\t}\n\treturn false, nil\n}\n\nfunc clearSpawnMarkerAfterLock(rootDir string) error {\n\terr := os.Remove(filepath.Join(rootDir, spawnMarkerFileName))\n\tif err != nil && !errors.Is(err, fs.ErrNotExist) {\n\t\treturn err\n\t}\n\treturn nil\n}\n","sourceCodeStart":1020,"sourceCodeEnd":1056,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/proxy/endpoint.go#L1020-L1056","documentation":"This error wraps a failure from procid.Verify when checking whether the PID recorded in a proxy spawn marker file still belongs to a live process with the recorded birth token. The library throws it when the spawn-owner liveness check cannot be performed (e.g. the process table cannot be consulted or the recorded PID is malformed), so the caller cannot safely conclude whether a stale proxy marker is owned by a running process.","triggerScenarios":"Calling the spawn-marker verification path in internal/storage/dbproxy/proxy/endpoint.go when a spawn marker file exists but procid.Verify(marker.PID, procid.Token(marker.Birth)) returns an error — typically a corrupted marker containing a non-numeric/invalid PID, or an OS failure reading process info for the recorded PID.","commonSituations":"A leftover spawn marker in the database directory after a crash, a marker file manually edited or truncated, or a container/OS environment where /proc lookups fail (restricted procfs, chroot, seccomp filters blocking process queries).","solutions":["Delete the stale spawn marker file (<dbdir>/<spawnMarkerFileName>) and retry, since the marker is advisory cleanup state","Inspect the marker contents; if the PID or birth token is malformed, remove the file rather than re-running verification","Check the wrapped cause (%w) — if it is an OS-level process-lookup failure, verify the process filesystem (e.g. /proc) is mounted and readable","Ensure no external tooling rewrites PID files with padded or non-numeric values"],"exampleFix":"// before\nmatched, err := procid.Verify(marker.PID, procid.Token(marker.Birth))\n// after\nif marker.PID <= 0 {\n    _ = os.Remove(filepath.Join(rootDir, spawnMarkerFileName))\n    return false, nil\n}\nmatched, err := procid.Verify(marker.PID, procid.Token(marker.Birth))","handlingStrategy":"validation","validationCode":"func markerLooksValid(rootDir string) bool {\n    data, err := os.ReadFile(filepath.Join(rootDir, \"spawn.marker\"))\n    if err != nil || len(bytes.TrimSpace(data)) == 0 {\n        return false\n    }\n    pid, err := strconv.Atoi(strings.TrimSpace(string(data)))\n    return err == nil && pid > 0\n}","typeGuard":"func isSpawnOwnerVerifyError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"verify proxy spawn owner pid\")\n}","tryCatchPattern":"if err := verifySpawnOwner(rootDir); err != nil {\n    var target *fs.PathError\n    if errors.As(err, &target) {\n        // OS-level lookup failure: inspect cause before deciding\n        _ = target\n    }\n    // Safe fallback: treat marker as stale and remove it\n    _ = os.Remove(filepath.Join(rootDir, \"spawn.marker\"))\n}","preventionTips":["Never hand-edit spawn marker files","Validate PID files are numeric and positive before relying on them","Ensure /proc (or equivalent) is mounted in containers","Clean stale markers after unclean shutdowns"],"tags":["process","pidfile","spawn-marker","filesystem"],"backgroundTag":"process-liveness-check-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}