Skip to content

Content Drive: start bulk uploads without waiting on the job queue's idle poll #38378

Open

Description

@zJaaal

Description

Bulk uploads in Content Drive feel slow because the job that processes them waits to be picked up. The upload should start right away while keeping what the job gives us.

How it works today

  • POST /api/v1/assets/_bulkupload (BulkUploadResource) stages the files and submits a BulkUploadProcessor job.
  • Workers in JobQueueManagerAPIImpl.processJobs() poll jobQueue.nextJob(). When the queue is empty each worker sleeps with an exponential backoff (calculateBackoffTime: 1s, 2s, 4s... capped at 30s).
  • Nothing wakes the workers when a job is created. After a quiet period a new upload waits up to ~30s per poll before it starts. Users report waits closer to a minute; the cause of the gap between the 30s cap and that report still needs measuring.

What the job gives us and must keep

  • Persistence of the run, and survival across restarts
  • Progress and completion reporting (BulkUploadCompletionListener, system events)
  • Cancellation, and the retry policy
  • Distribution across cluster nodes

Acceptance Criteria

Preliminary, to be refined:

  • Measure the current submit-to-start latency on an idle server and record the baseline.
  • On the node that accepted the upload, the job starts within ~1-2s of submission.
  • Persistence, progress, cancellation, retry behavior and cluster distribution keep working.
  • Idle polling load on the database does not grow meaningfully.
  • Other queues (folder delete, folder duplicate, content import) keep working, and ideally get faster too.

Priority

Medium

Additional Context

Candidate directions, not decided:

  1. Wake local workers on job creation: replace the plain Thread.sleep backoff with a wait that createJob can signal. Fixes same-node submits for every queue, small change.
  2. Wake other nodes: a PostgreSQL LISTEN/NOTIFY or a system event, with the backoff kept as fallback.
  3. Lower or configure the backoff cap: cheapest, but trades latency for more DB polling.
  4. Run small batches inline, job above a threshold: fastest for small uploads but splits the code path and loses the job's guarantees for those runs; least preferred.

Relevant code: JobQueueManagerAPIImpl (processJobs, calculateBackoffTime, MAX_EMPTY_QUEUE_COUNT), JobQueueConfigProducer (JOB_QUEUE_THREAD_POOL_SIZE), BulkUploadResource, BulkUploadProcessor.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions