mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-19 09:02:27 +08:00
fix requeue errors
This commit is contained in:
parent
d201104662
commit
44cd2ebda6
@ -20,6 +20,7 @@ export async function queueNoteForEmbedding(noteId: string, operation = 'UPDATE'
|
||||
const now = dateUtils.localNowDateTime();
|
||||
const utcNow = dateUtils.utcNowDateTime();
|
||||
|
||||
try {
|
||||
// Check if note is already in queue and whether it's marked as permanently failed
|
||||
const queueInfo = await sql.getRow(
|
||||
"SELECT 1 as exists_flag, failed, isProcessing FROM embedding_queue WHERE noteId = ?",
|
||||
@ -55,6 +56,17 @@ export async function queueNoteForEmbedding(noteId: string, operation = 'UPDATE'
|
||||
[noteId, operation, now, utcNow]
|
||||
);
|
||||
}
|
||||
} catch (error: any) {
|
||||
// If there's a race condition where multiple events try to queue the same note simultaneously,
|
||||
// one of them will succeed and others will fail with UNIQUE constraint violation.
|
||||
// We can safely ignore this specific error since the note is already queued.
|
||||
if (error.code === 'SQLITE_CONSTRAINT_PRIMARYKEY' && error.message.includes('UNIQUE constraint failed: embedding_queue.noteId')) {
|
||||
log.info(`Note ${noteId} was already queued by another process, ignoring duplicate queue request`);
|
||||
return;
|
||||
}
|
||||
// Rethrow any other errors
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user