@malloydata/db-duckdb 0.0.388 → 0.0.390

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,10 +64,24 @@ export declare class DuckDBConnection extends DuckDBCommon {
64
64
  close(): Promise<void>;
65
65
  idle(): Promise<void>;
66
66
  /**
67
- * Remove this connection from the shared `activeDBs` entry. When the
68
- * last connection sharing the entry is removed, close the underlying
69
- * `DuckDBInstance` and drop the entry — releasing DuckDB's per-process
70
- * file lock.
67
+ * Drop our entry from the shared `activeDBs` bookkeeping. If we were
68
+ * the last sharer, close the underlying `DuckDBInstance`.
69
+ *
70
+ * NOTE: this does NOT fully release the OS file lock when other
71
+ * processes try to open the same path. `duckdb_close` (= `closeSync`)
72
+ * is a refcount-decrement on `shared_ptr<DatabaseInstance>`; the
73
+ * `fcntl(F_SETLK)` lock on the storage manager's `UnixFileHandle`
74
+ * survives until the last `shared_ptr` ref is gone, and live C++
75
+ * `Connection` objects keep that refcount above zero via their
76
+ * `ClientContext`. To force the lock release we'd need to also
77
+ * `disconnectSync()` the per-connection node-api Connection — but
78
+ * doing so unconditionally (as 0.0.389 did) crashes the language
79
+ * server because malloy's translate/persistence layer retains
80
+ * weak_ptrs to the destroyed C++ Connection. See the commented-out
81
+ * code below and PR #2793 / the revert PR for context.
82
+ *
83
+ * Proper fix needs to coordinate disconnect with invalidation of
84
+ * whatever caches survive idle (manifest reader is the main suspect).
71
85
  */
72
86
  private detachInstance;
73
87
  /**
@@ -295,12 +295,36 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
295
295
  // re-acquire the lock immediately and defeat the point of idling.
296
296
  }
297
297
  /**
298
- * Remove this connection from the shared `activeDBs` entry. When the
299
- * last connection sharing the entry is removed, close the underlying
300
- * `DuckDBInstance` and drop the entry — releasing DuckDB's per-process
301
- * file lock.
298
+ * Drop our entry from the shared `activeDBs` bookkeeping. If we were
299
+ * the last sharer, close the underlying `DuckDBInstance`.
300
+ *
301
+ * NOTE: this does NOT fully release the OS file lock when other
302
+ * processes try to open the same path. `duckdb_close` (= `closeSync`)
303
+ * is a refcount-decrement on `shared_ptr<DatabaseInstance>`; the
304
+ * `fcntl(F_SETLK)` lock on the storage manager's `UnixFileHandle`
305
+ * survives until the last `shared_ptr` ref is gone, and live C++
306
+ * `Connection` objects keep that refcount above zero via their
307
+ * `ClientContext`. To force the lock release we'd need to also
308
+ * `disconnectSync()` the per-connection node-api Connection — but
309
+ * doing so unconditionally (as 0.0.389 did) crashes the language
310
+ * server because malloy's translate/persistence layer retains
311
+ * weak_ptrs to the destroyed C++ Connection. See the commented-out
312
+ * code below and PR #2793 / the revert PR for context.
313
+ *
314
+ * Proper fix needs to coordinate disconnect with invalidation of
315
+ * whatever caches survive idle (manifest reader is the main suspect).
302
316
  */
303
317
  detachInstance() {
318
+ // [PR #2793, reverted] Adding `this.connection?.disconnectSync()`
319
+ // here releases the OS file lock — but it also destroys C++ state
320
+ // that malloy-internal caches (manifest reader, etc.) hold
321
+ // weak_ptrs to. Result: SIGSEGV in the language server during
322
+ // translate, or `bad_weak_ptr` exceptions surfacing as model
323
+ // problems on next op. Left here as a marker for the proper fix.
324
+ //
325
+ // if (this.connection) {
326
+ // this.connection.disconnectSync();
327
+ // }
304
328
  const activeDB = DuckDBConnection.activeDBs[this.shareKey];
305
329
  if (activeDB) {
306
330
  activeDB.connections = activeDB.connections.filter(connection => connection !== this.connection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.388",
3
+ "version": "0.0.390",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@duckdb/duckdb-wasm": "1.33.1-dev13.0",
62
62
  "@duckdb/node-api": "1.4.4-r.1",
63
- "@malloydata/malloy": "0.0.388",
63
+ "@malloydata/malloy": "0.0.390",
64
64
  "@motherduck/wasm-client": "^0.6.6",
65
65
  "apache-arrow": "^17.0.0",
66
66
  "web-worker": "^1.3.0"