{"record":{"id":"18ba8731c886208a","repo":"abhigyanpatwari/GitNexus","slug":"lbug-load-node-copy-also-failed-while-relationsh","errorCode":null,"errorMessage":"[lbug-load] node COPY also failed while relationship emit was failing","messagePattern":"\\[lbug-load\\] node COPY also failed while relationship emit was failing","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/lbug/lbug-adapter.ts","lineNumber":1185,"sourceCode":"      nodeCopyError = e;\n    });\n  };\n\n  log('Streaming CSVs to disk...');\n  let csvResult: StreamedCSVResult;\n  try {\n    csvResult = SERIAL\n      ? await streamAllCSVsToDisk(graph, repoPath, csvDir)\n      : await streamAllCSVsToDisk(graph, repoPath, csvDir, beginNodeCopy);\n  } catch (emitErr) {\n    // Relationship emit failed. In overlap mode a node COPY may be in flight —\n    // settle it (the .catch above means this never rejects) before rethrowing so\n    // it cannot leak as an unhandled rejection.\n    if (nodeCopyPromise) await nodeCopyPromise;\n    // If node COPY ALSO failed, emitErr wins the throw — log the swallowed node\n    // error so a half-loaded DB isn't misattributed to the emit failure alone.\n    if (nodeCopyError) {\n      logger.warn(\n        { err: nodeCopyError },\n        '[lbug-load] node COPY also failed while relationship emit was failing',\n      );\n    }\n    throw emitErr;\n  }\n  const tCsv = mark();\n\n  // Merge the streamed PDG-emit per-pair rel CSVs (#2202) into the COPY plan —\n  // collision-guarded. Done BEFORE node COPY so the serial escape hatch detects a\n  // manifest/structural pair collision before committing any node rows (legacy\n  // parity with the pre-overlap path), and the overlap path detects it as early\n  // as csvResult is available. When a manifest is present, streaming was on and\n  // the in-memory graph held zero BasicBlocks, so a structural collision means a\n  // streaming-invariant violation — fail loudly rather than load corrupt data.\n  if (pdgEmitManifest) {\n    for (const [pairKey, meta] of pdgEmitManifest.relsByPair) {\n      if (csvResult.relsByPair.has(pairKey)) {","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/lbug/lbug-adapter.ts#L1167-L1203","documentation":"During graph load (loadGraphToLbug-style path), relationship CSV streaming failed and, in overlap mode, the concurrently running node COPY had ALSO failed. The node error was swallowed by a .catch to avoid an unhandled rejection, so this warn preserves the attribution: the rethrown emitErr is the headline failure, but the DB is half-loaded for two independent reasons. Expect the load to fail with emitErr after this line.","triggerScenarios":"streamAllCSVsToDisk throws (disk full while writing rel CSVs, serialization crash) while the overlapped node COPY into LadybugDB independently fails (same full disk, engine error, lock). nodeCopyPromise is settled, nodeCopyError is non-null, and the warn fires right before `throw emitErr`.","commonSituations":"Disk exhaustion mid-index on the volume holding either csvDir or the DB; LadybugDB native faults under memory pressure; SERIal/overlap differences masking which stage actually died; very large repos filling tmp space with CSVs.","solutions":["Check free space on BOTH the CSV temp directory and the DB volume (`df -h`); free space and re-run analyze.","Read the two errors separately: emitErr is the thrown one, the `{ err: nodeCopyError }` field of this warn holds the other — fix whichever is environmental first.","If the native engine crashed, reinstall/repair the gitnexus install so the vendored LadybugDB binary matches your platform.","Point TMPDIR/csvDir at a volume with enough headroom for full-graph CSVs."],"exampleFix":"# before: load dies with emit error plus this warn (both stages failing)\ndf -h /tmp /repo/.gitnexus   # find the full volume\nexport TMPDIR=/bigdisk/tmp && npx gitnexus analyze   # after: CSVs and DB on volumes with headroom","handlingStrategy":"try-catch","validationCode":"// Before load: headroom on BOTH csv temp dir and db dir\nimport { statfs } from 'node:fs/promises';\nfor (const dir of [csvDir, path.dirname(dbPath)]) {\n  const { bavail, bsize } = await statfs(dir);\n  if (bavail * bsize < estimatedGraphBytes) throw new Error(`low disk: ${dir}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await loadGraphToLbug(graph, repoPath, dbPath);\n} catch (emitErr) {\n  // a preceding '[lbug-load] node COPY also failed' warn means BOTH stages died:\n  // fix the environmental cause (usually disk) before retrying, and expect a partial DB\n  await cleanupPartialDb(dbPath);\n  throw emitErr;\n}","preventionTips":["Size temp space for full-graph CSVs before starting big repos.","Treat any load failure accompanied by this warn as environment-level, not data-level.","Remove partially loaded DBs after failed loads so retries start clean."],"tags":["ladyugdb","ladybugdb","bulk-load","disk-full","csv","diagnostics"],"backgroundTag":"bulk-load-failed","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}