From 17b0b93e35e538fcbdc3e7f2c57cba553dd93dbb Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Sun, 21 Jun 2026 08:34:53 +0000 Subject: [PATCH] refactor(lbug): rel COPY uses the captured writeConn, matching node COPY (#2264 review P3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The relationship COPY passed the module-level `conn` to copyCsvWithRetry while the node COPY uses the captured `writeConn`. Use `writeConn` for both — one captured reference for the whole bulk load, removing the latent identity dependency. Same object during analyze (`conn` is only reassigned at open/close under the session lock), so the queryAndDrain `targetConn === conn` lock gate still engages. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm --- gitnexus/src/core/lbug/lbug-adapter.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitnexus/src/core/lbug/lbug-adapter.ts b/gitnexus/src/core/lbug/lbug-adapter.ts index 134121ead..72b6bdd13 100644 --- a/gitnexus/src/core/lbug/lbug-adapter.ts +++ b/gitnexus/src/core/lbug/lbug-adapter.ts @@ -1136,7 +1136,12 @@ export const loadGraphToLbug = async ( log(`Loading edges: ${pairIdx}/${relsByPair.size} types (${fromLabel} -> ${toLabel})`); } - await copyCsvWithRetry(conn, copyQuery, (retryErr) => { + // Use the captured `writeConn` (not the module-level `conn`) for the rel + // COPY, matching the node COPY above — one captured reference for the whole + // bulk load (#2264 review P3). Same object during analyze (`conn` is only + // reassigned at open/close under the session lock, never mid-load), so the + // queryAndDrain `targetConn === conn` lock gate still engages. + await copyCsvWithRetry(writeConn, copyQuery, (retryErr) => { const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr); warnings.push(`${fromLabel}->${toLabel} (${rows} edges): ${retryMsg.slice(0, 80)}`); failedPairEdges += rows;