{"record":{"id":"dd29831ad91f58a4","repo":"paperclipai/paperclip","slug":"embedded-postgresql-process-pid-did-not-stop-wi","errorCode":null,"errorMessage":"Embedded PostgreSQL process ${pid} did not stop within ${POSTGRES_STOP_TIMEOUT_MS}ms.","messagePattern":"Embedded PostgreSQL process (.+?) did not stop within (.+?)ms\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/workspace-instance-cleanup.ts","lineNumber":183,"sourceCode":"  const canonicalRecordedDataDir = await fs.realpath(recordedDataDir).catch(() => path.resolve(recordedDataDir));\n  if (canonicalRecordedDataDir !== canonicalDataDir) {\n    throw new Error(`Refusing to remove ${dataDir}: postmaster.pid points at a different PostgreSQL data directory.`);\n  }\n  if (!dependencies.processIsAlive(pid)) return false;\n  if (await dependencies.readVerifiedPostgresCommand(pid, canonicalDataDir) === null) return false;\n\n  try {\n    dependencies.signalProcess(pid, \"SIGINT\");\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ESRCH\") return false;\n    throw error;\n  }\n  const deadline = Date.now() + POSTGRES_STOP_TIMEOUT_MS;\n  while (Date.now() < deadline) {\n    if (!dependencies.processIsAlive(pid)) return true;\n    await dependencies.wait(100);\n  }\n  throw new Error(`Embedded PostgreSQL process ${pid} did not stop within ${POSTGRES_STOP_TIMEOUT_MS}ms.`);\n}\n\nexport async function readWorktreeInstancePointer(workspacePath: string): Promise<WorktreeInstancePointer | null> {\n  const envPath = path.join(workspacePath, \".paperclip\", \".env\");\n  try {\n    return {\n      envPath,\n      envContents: await fs.readFile(envPath, \"utf8\"),\n    };\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw error;\n  }\n}\n\nfunction resolveConfiguredInstanceRoot(pointer: WorktreeInstancePointer, expectedInstanceId?: string):\n  | { instanceRoot: string; instanceId: string }\n  | { warning: string; instanceRoot: string | null; refusalReason: string | null } {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/services/workspace-instance-cleanup.ts#L165-L201","documentation":"During worktree instance cleanup, the embedded PostgreSQL process (pid from postmaster.pid) was sent SIGINT but was still alive after the POSTGRES_STOP_TIMEOUT_MS grace period. Cleanup aborts rather than delete a data directory under a live postmaster.","triggerScenarios":"Thrown at server/src/services/workspace-instance-cleanup.ts:161 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The embedded PostgreSQL process ignored SIGTERM. Investigate why it is stuck (hung connections) and consider force-killing the PID, then retry cleanup."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}