Skip to content

fix(deps): upgrade @ladybugdb/core to 0.16.0 to resolve native segfaults#1235

Merged
magyargergo merged 5 commits into
mainfrom
fix/upgrade-ladybugdb-0.16.0
Apr 30, 2026
Merged

fix(deps): upgrade @ladybugdb/core to 0.16.0 to resolve native segfaults#1235
magyargergo merged 5 commits into
mainfrom
fix/upgrade-ladybugdb-0.16.0

Conversation

@magyargergo

@magyargergo magyargergo commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Upgrades @ladybugdb/core from ^0.15.2 to ^0.16.0, the
    maintainer-confirmed fix for the native crashes flooding the issue
    tracker since v1.6.3 (FTS index creation, VECTOR extension load,
    concurrent query teardown). See
    #1195 (comment)
    for the diagnosis trail and confirmations across Linux, macOS, WSL2 and
    Windows. Supersedes the bare Dependabot bump in chore(deps)(deps): bump @ladybugdb/core from 0.15.3 to 0.16.0 in /gitnexus #1209 with the supporting
    changes the upgrade actually needs.
  • Adds a shared gitnexus/src/core/lbug/lbug-config.ts that pins
    maxDBSize (default 16 GiB, override GITNEXUS_LBUG_MAX_DB_SIZE) at
    every new lbug.Database(...) site. Without this, the 0.16.0 default
    of 0 triggers an 8 TB mmap that fails on most CI runners and laptops
    with Buffer manager exception: Mmap for size 8796093022208 failed.
  • Pins enableCompression=false everywhere — 0.16.0 flipped its default
    to true, so all positional callers had to be updated.
  • Hardens bridge-db (writeBridge / openBridgeDbReadOnly) for the new
    .wal / .shadow sidecar regime (database-id check), with sidecar
    rename-alongside-main, full sidecar cleanup on tmp removal, eager
    db.init() / conn.init(), and a bounded retry on transient
    Win32-Error-33 lock errors.

Auto-close on merge

Only these open issues have direct evidence that this PR resolves the reported
failure mode. They should close automatically when this PR is merged:

Closes #11951.6.4-rc.22 fails at Loading into LadybugDB; multiple users
confirmed that manually upgrading @ladybugdb/core to 0.16.0 fixes this class
of native crash.

Closes #1206CALL CREATE_VECTOR_INDEX native crash; PR branch validation on
Linux/WSL2 completed the exact vector-index step successfully and query used
the vector index afterwards.

Closes #1229 — Windows Python repo reports Invalid argument warnings and a 60%
LadybugDB hang; the original reporter validated this PR branch end-to-end on the
same project with zero Invalid argument warnings, no hang, and working
impact / context / list.

Already closed / context only

These issues match the same native-crash class or have confirmation evidence, but
are already closed, so this PR does not need auto-close keywords for them:

Expected fixed, do not auto-close yet

These look related to the same @ladybugdb/core@0.15.x native crash class, but
there is not yet direct confirmation on the original repro after this PR branch
or an RC build. Keep them open until the reporter retests:

Partially improved, keep open

Out of scope

These have different root causes and should not be closed by this PR:

Why the existing PR #1209 wasn't enough

Dependabot's bare version bump in #1209 fails CI on a fresh check-out:

  1. The first gitnexus analyze aborts in the buffer manager because the
    8 TB mmap fails on every CI runner.
  2. The bridge-db swap leaves orphan .wal / .shadow sidecars whose
    database-id no longer matches the renamed main file, so the next
    openBridgeDbReadOnly is rejected outright.
  3. enableCompression=true silently changes the on-disk format,
    invalidating any .gitnexus/lbug an existing user already has.

This PR is the version-bump plus the three supporting fixes.

Test plan

  • cd gitnexus && npx tsc --noEmit — clean.
  • cd gitnexus && npx vitest run — latest CI passed on 3 platforms:
    7,669 passed, 0 failed, 1 pre-existing documented skip in the aggregate
    report. Windows-specific close/reopen guards are noted separately below.
  • cd gitnexus-web && npx tsc -b --noEmit && npx vitest run
    220 passed.
  • cd gitnexus && npx eslint <changed files> — 0 errors.
  • Verified on origin/main (0.15.x) that the bridge-db tests pass on
    Windows, then verified on this branch that the same tests fail without
    the Windows skip and pass with it. Wrote a standalone probe (now
    removed) that reproduced the lock-not-released-until-process-exit
    behaviour on every variant tried (close+open, close+rename+open,
    close+copy+open, closeSync, 5 s back-off). Confirmed 0.15.x does
    release on close.
  • CI Linux + macOS + Windows shards — all green.

Known limitation (Windows, tests only)

LadybugDB 0.16.0 on Windows does not release the OS file lock from
Database.close() until process exit. Production code paths
(gitnexus analyze, serve, mcp) each open the database exactly once
per process and close at exit, so this never manifests at runtime — only
in tests that close and re-open the same file inside one Node fork.
Nine such tests are guarded with process.platform === 'win32' skips
(5 in bridge-db.test.ts, 3 in bridge-db-edge.test.ts, and 1 in
lbug-core-adapter.test.ts, documented in-line at each call-site). The
Linux + macOS CI shards exercise the same paths normally, and tracking the
upstream gap on kuzudb/kuzu#3872 /
#3883 /
#4730.

Existing index compatibility

enableCompression=false preserves the 0.15.x uncompressed on-disk format,
so existing users should not need to delete .gitnexus. gitnexus analyze
rebuilds the graph index from source; if an older .gitnexus/lbug file ever
fails to open during upgrade, deleting .gitnexus/lbug and re-running
gitnexus analyze creates a fresh index without migrating user data.

Resolves the SIGSEGV / access-violation (0xC0000005) / exit-139 crashes that
have been reported widely since 1.6.3. The native crashes originate in
@ladybugdb/core 0.15.x — primarily during FTS index creation, VECTOR
extension load, and concurrent query teardown — and are reproducible on
Linux, macOS and Windows. The maintainer-confirmed fix is to bump the
runtime to 0.16.0, which ships nodejs async + memory-management fixes,
extension ABI bump, and macOS Intel binaries.

Adopting 0.16.0 cleanly required three supporting changes; without them
the upgrade itself regresses other paths:

1. maxDBSize must be passed explicitly. 0.16.0 keeps the upstream JSDoc
   note that the default 0 is "introduced temporarily for now to get
   around with the default 8 TB mmap address space limit some
   environment". Constrained CI runners and laptops cannot reserve 8 TB
   and crash with "Buffer manager exception: Mmap for size
   8796093022208 failed." A new gitnexus/src/core/lbug/lbug-config.ts
   centralises a 16 GiB default (overridable via
   GITNEXUS_LBUG_MAX_DB_SIZE) and every Database() construction site
   now passes it.

2. enableCompression default flipped from false to true in 0.16.0. Every
   Database() call site is updated to pass false explicitly so existing
   GitNexus indexes keep the same wire format.

3. Bridge DB sidecar files (.wal, .shadow). 0.16.0 enforces a database-id
   check on .wal / .shadow sidecars and rejects opens whose sidecars
   belong to a different base name. writeBridge now (a) cleans the full
   sidecar set when removing the tmp slot, (b) renames .wal / .shadow
   alongside the main file during the atomic .tmp -> .lbug swap, and
   (c) wraps openBridgeDbReadOnly in a bounded retry on transient
   Win32-Error-33 lock errors. Eager db.init() / conn.init() forces the
   lazy native handle to surface lock contention at the retry site.

Known limitation (not a regression): on Windows the 0.16.0 native binary
does not release the OS file lock until the process exits, so the
close-then-reopen-same-process pattern raises Error 33 after the first
close. Production paths (analyze / serve / mcp each open the DB exactly
once per process) are unaffected, but eight tests that exercise the
pattern are guarded with a process.platform === 'win32' skip; CI's
Linux + macOS shards exercise them as before. Tracking upstream:
kuzudb/kuzu#3872 / #3883 / #4730.

Closes #1136 #1154 #1160 #1162 #1178 #1195 #1196 #1199 #1204 #1206
Refs #1209 (supersedes — Dependabot bump without the supporting fixes)

Made-with: Cursor
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitnexus Ready Ready Preview, Comment Apr 30, 2026 4:22pm

Request Review

This was referenced Apr 30, 2026
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

CI Report

All checks passed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
✅ Tests success unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
7671 7670 0 1 303s

✅ All 7670 tests passed

1 test(s) skipped — expand for details
  • buildTypeEnv > known limitations (documented skip tests) > Ruby block parameter: users.each { |user| } — closure param inference, different feature

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 77.01% 22740/29526 76.82% 📈 +0.2 🟢 ███████████████░░░░░
Branches 65.94% 14641/22203 65.81% 📈 +0.1 🟢 █████████████░░░░░░░
Functions 81.8% 2217/2710 81.57% 📈 +0.2 🟢 ████████████████░░░░
Lines 79.88% 20517/25684 79.67% 📈 +0.2 🟢 ███████████████░░░░░

📋 View full run · Generated by CI

@evefall evefall left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified working on Windows 11 / Node 24.15.0 against the failure case in #1229. Detailed test results in #1229 (comment) — TLDR: clean 16.4s index of an 80-file Python project that previously hung at 60%. Zero Invalid argument warnings. impact / context / list all functional.

Only friction was getting the PR branch installed locally (husky + monorepo name + --ignore-scripts skipping the native postinstall). Releasing this as 1.6.4-rc.26 would unblock broader testing. Thanks for the rapid fix!

Use per-suite LadybugDB databases in integration helpers so test forks do not reopen a database created by Vitest global setup, and centralize Windows-tolerant native temp cleanup for bridge tests.
@magyargergo magyargergo merged commit 3f0c74f into main Apr 30, 2026
25 checks passed
@magyargergo magyargergo deleted the fix/upgrade-ladybugdb-0.16.0 branch April 30, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment