-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(cli): repair corrupted LanceDB indexes #12914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Repair code indexes with missing LanceDB data files and prevent startup cleanup from invalidating active index readers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,6 +277,15 @@ export class LanceDBVectorStore implements IVectorStore { | |
| } | ||
|
|
||
| async initialize(): Promise<boolean> { | ||
| return this.init(true) | ||
| } | ||
|
|
||
| private missing(error: unknown): boolean { | ||
| const message = error instanceof Error ? error.message : String(error) | ||
| return message.includes("Object at location ") && message.includes(".lance not found:") | ||
| } | ||
|
|
||
| private async init(repair: boolean): Promise<boolean> { | ||
| try { | ||
| await this.closeConnect() | ||
| const db = await this.getDb() | ||
|
|
@@ -321,7 +330,6 @@ export class LanceDBVectorStore implements IVectorStore { | |
| await this._dropTableIfExists(db, this.metadataTableName) | ||
| await this._createVectorTable(db) | ||
| await this._createMetadataTable(db) | ||
| this.optimizeTable() | ||
|
|
||
| log.info("LanceDB store reinitialized for embedding profile change", { | ||
| workspacePath: this.workspacePath, | ||
|
|
@@ -332,7 +340,6 @@ export class LanceDBVectorStore implements IVectorStore { | |
|
|
||
| return true | ||
| } | ||
| this.optimizeTable() | ||
| log.info("LanceDB store initialized", { | ||
| workspacePath: this.workspacePath, | ||
| dbPath: this.dbPath, | ||
|
|
@@ -341,6 +348,15 @@ export class LanceDBVectorStore implements IVectorStore { | |
| }) | ||
| return false | ||
| } catch (error) { | ||
| if (repair && this.missing(error)) { | ||
| log.warn("Rebuilding LanceDB store with missing data files", { | ||
| workspacePath: this.workspacePath, | ||
| dbPath: this.dbPath, | ||
| error, | ||
| }) | ||
| await this.deleteCollection() | ||
| return this.init(false) | ||
| } | ||
| log.error("Failed to initialize LanceDB store", { error }) | ||
| throw new Error(`Failed to initialize LanceDB store: ${(error as Error).message}`, { cause: error }) | ||
| } | ||
|
|
@@ -577,10 +593,7 @@ export class LanceDBVectorStore implements IVectorStore { | |
| try { | ||
| const table = await this.getTable() | ||
|
|
||
| await table.optimize({ | ||
| cleanupOlderThan: new Date(), | ||
| deleteUnverified: false, | ||
| }) | ||
| await table.optimize() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: With startup optimization removed, version cleanup no longer has a periodic caller Removing the Reply with |
||
| } catch (error) { | ||
| log.error("Failed to optimize table", { error }) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: Consider noting the LanceDB version this error text is matched against
missing()keys off LanceDB's exact error wording (Object at location ... .lance not found:), which is the only signal available since lancedb doesn't expose structured error codes — the gating is reasonable. The risk is that a future@lancedb/lancedbupgrade rewords this message, at which point self-repair silently stops triggering and init falls back to throwing. A short comment pinning the matched format to the current dependency version (0.26.x) would tell future upgraders to re-verify this string.Reply with
@kilocode-bot fix itto have Kilo Code address this issue.