feat: updating concurrency limits#99
Conversation
|
| Filename | Overview |
|---|---|
| app/workers/concurrency/fair_dispatch.py | New round-robin workspace dispatcher — has a critical issue where store_evaluation_transcribe_overwrite is never cleared after transcription completes, causing repeated re-transcription until the 20-minute TTL expires. |
| app/workers/concurrency/eval_dispatch.py | New per-row dispatch helpers — slot acquire/release is correctly guarded; _try_dispatch_single_row returns distinct dispatched/skip/at_capacity values that fix the previous starvation bug. |
| app/workers/concurrency/limits.py | New Redis Lua-backed inflight-slot manager — acquire and release scripts are atomic and correctly guard against underflow. |
| app/workers/tasks/transcribe_call_import_row.py | Removes direct eval-chain enqueue and adds _apply_eval_chain_transcribe_cleanup in finally; cleanup correctly clears celery_task_id but does not clear the transcribe_overwrite flag, leading to repeated re-transcription. |
| app/workers/tasks/evaluate_call_import_row.py | Adds _eval_slot_task_id param and calls finish_eval_work_and_redispatch in finally; slot release is correctly handled for both new-style and legacy tasks. |
| app/api/v1/routes/call_import_evaluations.py | Replaces direct fan-out with a call to _enqueue_eval_rows_with_optional_transcribe + schedule_fair_dispatch; the refactoring is clean and removes the previous N-dispatcher-tasks-per-N-evaluations bug. |
| app/workers/config.py | Moves eval/transcribe tasks to dedicated evaluations/diarization queues and updates task routes; routing is consistent with explicit queue overrides in apply_async calls. |
Comments Outside Diff (1)
-
app/workers/concurrency/fair_dispatch.py, line 807-812 (link)transcribe_overwritekey never cleared — causes infinite re-transcription loopstore_evaluation_transcribe_overwritewrites the key with a 20-minute TTL, but nothing ever explicitly deletes it. After the first transcription completes,_apply_eval_chain_transcribe_cleanupclearseval_row.celery_task_id = Noneand returns the row to thependingpool. On the very next dispatcher turnevaluation_transcribe_overwrite(evaluation.id)still returnsTrue, so_needs_transcribe_for_eval(..., transcribe_overwrite=True)returnsTrueagain (becausenot existing_dia or transcribe_overwriteis alwaysTruewhen the flag is set). A new transcription slot is acquired and the row is re-transcribed — this repeats every ~<transcription time>minutes until the 20-minute TTL expires, meaning each audio row can be transcribed ~10+ times before evaluation ever starts. Adding aclear_evaluation_transcribe_overwrite(evaluation_id)call inside_apply_eval_chain_transcribe_cleanup(or immediately after a successful dispatch in_dispatch_batch_for_workspace) would stop the loop.
Reviews (5): Last reviewed commit: "fix: some misses" | Re-trigger Greptile
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
What Changed?
Briefly describe what this PR changes.
Why?
Explain the problem this solves and why this approach was chosen.
How to Test?
List clear steps for reviewers to verify the change.
Release Label
Select one semantic version bump intent for this PR:
major- breaking change, next release bumps major versionminor- backward-compatible feature, next release bumps minor versionfix- backward-compatible bug fix, next release bumps patch versionIf you do not have permission to apply labels, mention the intended release label here and a maintainer will set it.
Checklist
CONTRIBUTING.mdguide.