|
10 | 10 | // |
11 | 11 | // Both flow through `ingestImpl`, which splits the work into three |
12 | 12 | // phases: PLAN (read-only diff against the current DB) → DELETE (drop |
13 | | -// stale documents/chunks; close + reopen the DB) → INSERT (write new |
14 | | -// rows). The close/reopen between DELETE and INSERT is a workaround |
15 | | -// for an engine bug where the HNSW chunk index panics when rows are |
16 | | -// deleted and re-inserted in the same connection lifetime — see the |
17 | | -// "Known limitations" section of this example's README. |
| 13 | +// stale documents/chunks) → INSERT (write new rows). |
18 | 14 |
|
19 | 15 | import { readFile, readdir, stat } from 'node:fs/promises'; |
20 | 16 | import { createHash } from 'node:crypto'; |
@@ -192,23 +188,13 @@ async function ingestImpl({ db, root, embedder, logger, chunkOpts, mode }) { |
192 | 188 |
|
193 | 189 | // ---------------------------------------------------------------- |
194 | 190 | // PHASE 2 — deletes (and replacing-deletes). |
195 | | - // |
196 | | - // The engine's HNSW index has a bug where rows deleted and re- |
197 | | - // inserted within the same connection lifetime can corrupt the |
198 | | - // index's stored vectors (see ../README.md "Known limitations"). |
199 | | - // Closing + reopening the connection between the delete-pass and |
200 | | - // the insert-pass forces a full index rebuild on next open, |
201 | | - // sidestepping the issue. We only pay this cost when there's |
202 | | - // actually something to delete; pure-INSERT runs (first `init`) |
203 | | - // skip this hop entirely. |
204 | 191 | if (hasMutations) { |
205 | 192 | db.transaction(() => { |
206 | 193 | for (const id of planDeletes) db.deleteDocument(id); |
207 | 194 | for (const e of embedded) { |
208 | 195 | if (e.plan.priorId !== null) db.deleteDocument(e.plan.priorId); |
209 | 196 | } |
210 | 197 | }); |
211 | | - db.reopen(); |
212 | 198 | } |
213 | 199 |
|
214 | 200 | // ---------------------------------------------------------------- |
|
0 commit comments