Repository navigation
Fix #1395: Scheduler initialized but not processing tasks (uvicorn vs direct call differenc - #1982
Merged
Merged
Conversation
handle_scheduler_allstatus only aggregated per-stream entries whose key starts with "scheduler:" — these only exist for the Redis-backed message queue. Under DEFAULT_USE_REDIS_QUEUE=false (Docker, no Redis) the TaskScheduleMonitor returns just the flat top-level totals (running, remaining, pending) without any per-stream entries, so the prefix filter collapsed the summary to zero regardless of actual queue depth or dispatcher in-flight count. Users observed scheduler "initialized but not processing tasks" because /product/scheduler/allstatus always reported all zeros even though the consumer thread was alive and dispatching MEM_READ tasks. Detect whether per-stream entries are present; if not and mem_scheduler.use_redis_queue is False, fall back to the flat totals so in_progress / waiting / pending reflect the live state of the local queue and dispatcher. Redis-queue aggregation is unchanged. Fixes #1395
Memtensor-AI
requested review from
CarltonXiang,
MatthewZhuang,
World-controller and
syzsunshine219
June 30, 2026 07:21
Collaborator
Author
✅ Automated Test Results: PASSEDNo applicable test scope for the changed files — automated tests skipped. Changed paths do not map to any configured scope (env.yaml source_mapping). Manual review recommended. Branch: |
Collaborator
Author
|
Automated Test Results: PASSED Cloud test-engine rerun against
This replaces the earlier no-scope signal for this PR. Manual code review is still required before merge. |
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes issue #1395: under Docker + uvicorn with the local in-memory message queue (DEFAULT_USE_REDIS_QUEUE=false), GET /product/scheduler/allstatus always returned {waiting:0, in_progress:0, pending:0, ...} even though the consumer thread was alive and dispatching MEM_READ tasks. Root cause: handle_scheduler_allstatus only aggregated per-stream entries whose key starts with "scheduler:" — these only exist for the Redis-backed queue monitor. The local queue monitor returns just flat top-level totals (running, remaining, pending), so the prefix filter collapsed the summary to zero regardless of actual queue depth or dispatcher state.
Fix: in
src/memos/api/handlers/scheduler_handler.py::handle_scheduler_allstatus, detect whether per-stream entries are present; if not andmem_scheduler.use_redis_queue is False, fall back to the flat totals soin_progress,waiting, andpendingreflect live local-queue state. Redis-queue aggregation is untouched. The API response model is unchanged, so no OpenAPI regeneration is required;completed/failed/cancelledremain zero for local queues (documented behavior — persistent task status tracking is Redis-only).Tests: added 3 regression tests in
tests/api/test_scheduler_handler_allstatus.pycovering local-non-zero, local-empty, and Redis per-stream paths. Initial run of the local-non-zero test produced the expected RED (assert 0 == 2); after the fix all three pass. Wider regression sweep acrosstests/api/test_server_router.py+tests/mem_scheduler/+ the new file: 79 passed / 1 skipped. Four pre-existing failures intests/api/test_mcp_serve.pyare unrelated to this change (confirmed by stashing the diff and reproducing on the base branch HEAD). Ruff lint + format clean on the touched files. The secondary symptom in the issue (missing scheduler INFO logs on Docker stdout) is caused bymemos/log.pypinning the console handler to WARNING when DEBUG=False; this is documented in the design doc as out of scope to avoid a broader operational change.Related Issue (Required): Fixes #1395
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist