refactor(lbug): rel COPY uses the captured writeConn, matching node COPY (#2264 review P3)

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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm
This commit is contained in:
Gergo Magyar 2026-06-21 08:34:53 +00:00
parent c2275c81e6
commit 17b0b93e35

View file

@ -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;