abhigyanpatwari/GitNexus · warning

[lbug-load] node COPY also failed while relationship emit wa

Error message

[lbug-load] node COPY also failed while relationship emit was failing

What it means

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.

Source

Thrown at gitnexus/src/core/lbug/lbug-adapter.ts:1185

      nodeCopyError = e;
    });
  };

  log('Streaming CSVs to disk...');
  let csvResult: StreamedCSVResult;
  try {
    csvResult = SERIAL
      ? await streamAllCSVsToDisk(graph, repoPath, csvDir)
      : await streamAllCSVsToDisk(graph, repoPath, csvDir, beginNodeCopy);
  } catch (emitErr) {
    // Relationship emit failed. In overlap mode a node COPY may be in flight —
    // settle it (the .catch above means this never rejects) before rethrowing so
    // it cannot leak as an unhandled rejection.
    if (nodeCopyPromise) await nodeCopyPromise;
    // If node COPY ALSO failed, emitErr wins the throw — log the swallowed node
    // error so a half-loaded DB isn't misattributed to the emit failure alone.
    if (nodeCopyError) {
      logger.warn(
        { err: nodeCopyError },
        '[lbug-load] node COPY also failed while relationship emit was failing',
      );
    }
    throw emitErr;
  }
  const tCsv = mark();

  // Merge the streamed PDG-emit per-pair rel CSVs (#2202) into the COPY plan —
  // collision-guarded. Done BEFORE node COPY so the serial escape hatch detects a
  // manifest/structural pair collision before committing any node rows (legacy
  // parity with the pre-overlap path), and the overlap path detects it as early
  // as csvResult is available. When a manifest is present, streaming was on and
  // the in-memory graph held zero BasicBlocks, so a structural collision means a
  // streaming-invariant violation — fail loudly rather than load corrupt data.
  if (pdgEmitManifest) {
    for (const [pairKey, meta] of pdgEmitManifest.relsByPair) {
      if (csvResult.relsByPair.has(pairKey)) {

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Check free space on BOTH the CSV temp directory and the DB volume (`df -h`); free space and re-run analyze.
  2. 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.
  3. If the native engine crashed, reinstall/repair the gitnexus install so the vendored LadybugDB binary matches your platform.
  4. Point TMPDIR/csvDir at a volume with enough headroom for full-graph CSVs.

Example fix

# before: load dies with emit error plus this warn (both stages failing)
df -h /tmp /repo/.gitnexus   # find the full volume
export TMPDIR=/bigdisk/tmp && npx gitnexus analyze   # after: CSVs and DB on volumes with headroom
Defensive patterns

Strategy: try-catch

Validate before calling

// Before load: headroom on BOTH csv temp dir and db dir
import { statfs } from 'node:fs/promises';
for (const dir of [csvDir, path.dirname(dbPath)]) {
  const { bavail, bsize } = await statfs(dir);
  if (bavail * bsize < estimatedGraphBytes) throw new Error(`low disk: ${dir}`);
}

Try / catch

try {
  await loadGraphToLbug(graph, repoPath, dbPath);
} catch (emitErr) {
  // a preceding '[lbug-load] node COPY also failed' warn means BOTH stages died:
  // fix the environmental cause (usually disk) before retrying, and expect a partial DB
  await cleanupPartialDb(dbPath);
  throw emitErr;
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-08-20). Data as JSON: /api/errors/18ba8731c886208a. Report an issue: GitHub.