fix(MULTIVERSION-0001): fix multi-version indexing — jobs never created or triggered for secondary versions
Two bugs prevented secondary versions from ever being indexed: 1. JobQueue.enqueue() and RepositoryService.createIndexingJob() deduplication only checked repository_id, so a queued default-branch job blocked all version-specific jobs for the same repo. Fix: include version_id in the WHERE clause so only exact (repository_id, version_id) pairs are deduped. 2. POST /api/v1/libs/:id/versions used repoService.createIndexingJob() which inserts a job record but never triggers queue processing. Fix: use queue.enqueue() (same fallback pattern as the libs endpoint) so setImmediate fires processNext() after the job is inserted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,14 +36,17 @@ export class JobQueue {
|
||||
* existing job instead of creating a duplicate.
|
||||
*/
|
||||
enqueue(repositoryId: string, versionId?: string): IndexingJob {
|
||||
// Return early if there's already an active job for this repo.
|
||||
// Return early if there's already an active job for this exact (repo, version) pair.
|
||||
const resolvedVersionId = versionId ?? null;
|
||||
const activeRaw = this.db
|
||||
.prepare<[string], IndexingJobEntity>(
|
||||
.prepare<[string, string | null, string | null], IndexingJobEntity>(
|
||||
`${JOB_SELECT}
|
||||
WHERE repository_id = ? AND status IN ('queued', 'running')
|
||||
WHERE repository_id = ?
|
||||
AND (version_id = ? OR (version_id IS NULL AND ? IS NULL))
|
||||
AND status IN ('queued', 'running')
|
||||
ORDER BY created_at DESC LIMIT 1`
|
||||
)
|
||||
.get(repositoryId);
|
||||
.get(repositoryId, resolvedVersionId, resolvedVersionId);
|
||||
|
||||
if (activeRaw) {
|
||||
// Ensure the queue is draining even if enqueue was called concurrently.
|
||||
|
||||
Reference in New Issue
Block a user