gitnexus 1.6.4-rc.65 → 1.6.4-rc.66
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.
|
@@ -206,6 +206,15 @@ export const withLbugDb = async (dbPath, operation) => {
|
|
|
206
206
|
// Close stale connection inside the session lock to prevent race conditions
|
|
207
207
|
// with concurrent operations that might acquire the lock between cleanup steps
|
|
208
208
|
await runWithSessionLock(async () => {
|
|
209
|
+
// CHECKPOINT before close to flush WAL contents (same rationale as closeLbug)
|
|
210
|
+
if (conn) {
|
|
211
|
+
try {
|
|
212
|
+
await conn.query('CHECKPOINT');
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
/* best-effort */
|
|
216
|
+
}
|
|
217
|
+
}
|
|
209
218
|
try {
|
|
210
219
|
if (conn)
|
|
211
220
|
await conn.close();
|
|
@@ -245,6 +254,15 @@ const ensureLbugInitialized = async (dbPath) => {
|
|
|
245
254
|
const doInitLbug = async (dbPath) => {
|
|
246
255
|
// Different database requested — close the old one first
|
|
247
256
|
if (conn || db) {
|
|
257
|
+
// CHECKPOINT before close to flush WAL contents (same rationale as closeLbug)
|
|
258
|
+
if (conn) {
|
|
259
|
+
try {
|
|
260
|
+
await conn.query('CHECKPOINT');
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
/* ignore — older LadybugDB or schemaless DB may not accept it */
|
|
264
|
+
}
|
|
265
|
+
}
|
|
248
266
|
try {
|
|
249
267
|
if (conn)
|
|
250
268
|
await conn.close();
|
|
@@ -931,6 +949,22 @@ export const fetchExistingEmbeddingHashes = async (execQuery) => {
|
|
|
931
949
|
}
|
|
932
950
|
};
|
|
933
951
|
export const closeLbug = async () => {
|
|
952
|
+
// CHECKPOINT before close so the WAL/.shadow contents are flushed into
|
|
953
|
+
// the main database file. Without this, LadybugDB 0.16.0's non-blocking
|
|
954
|
+
// checkpoint thread can outlive the close call and leave sidecar pages
|
|
955
|
+
// pending on disk, which makes a subsequent read-side open either race
|
|
956
|
+
// with the WAL replay or trip the database-id check on the sidecars.
|
|
957
|
+
// This is especially critical after embedding writes, which generate
|
|
958
|
+
// large amounts of WAL data. CHECKPOINT is a no-op when there's nothing
|
|
959
|
+
// pending, so it's cheap on the happy path.
|
|
960
|
+
if (conn) {
|
|
961
|
+
try {
|
|
962
|
+
await conn.query('CHECKPOINT');
|
|
963
|
+
}
|
|
964
|
+
catch {
|
|
965
|
+
/* ignore — older LadybugDB or schemaless DB may not accept it */
|
|
966
|
+
}
|
|
967
|
+
}
|
|
934
968
|
if (conn) {
|
|
935
969
|
try {
|
|
936
970
|
await conn.close();
|
package/package.json
CHANGED