mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
reset embedding_queue where objects are "isprocessing"
This commit is contained in:
parent
3d70a6c42e
commit
0707266dc1
@ -3,6 +3,29 @@ import options from "../../options.js";
|
||||
import { initEmbeddings } from "./index.js";
|
||||
import providerManager from "./providers.js";
|
||||
import sqlInit from "../../sql_init.js";
|
||||
import sql from "../../sql.js";
|
||||
|
||||
/**
|
||||
* Reset any stuck embedding queue items that were left in processing state
|
||||
* from a previous server shutdown
|
||||
*/
|
||||
async function resetStuckEmbeddingQueue() {
|
||||
try {
|
||||
const stuckCount = await sql.getValue(
|
||||
"SELECT COUNT(*) FROM embedding_queue WHERE isProcessing = 1"
|
||||
) as number;
|
||||
|
||||
if (stuckCount > 0) {
|
||||
log.info(`Resetting ${stuckCount} stuck items in embedding queue from previous shutdown`);
|
||||
|
||||
await sql.execute(
|
||||
"UPDATE embedding_queue SET isProcessing = 0 WHERE isProcessing = 1"
|
||||
);
|
||||
}
|
||||
} catch (error: any) {
|
||||
log.error(`Error resetting stuck embedding queue: ${error.message || error}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the embedding system
|
||||
@ -17,6 +40,9 @@ export async function initializeEmbeddings() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset any stuck embedding queue items from previous server shutdown
|
||||
await resetStuckEmbeddingQueue();
|
||||
|
||||
// Initialize default embedding providers
|
||||
await providerManager.initializeDefaultProviders();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user