Skip to content

Scheduler initialized but not processing tasks (uvicorn vs direct call difference) #1395

@WuSho1995

Description

@WuSho1995

Environment

  • MemOS Version: 2.0.11 (also reproducible on 2.0.10)
  • Deployment: Docker (memtensor/memos-base:v1.0)
  • Storage: Neo4j 5.21 + Qdrant v1.16.3
  • Queue: Local (not Redis, DEFAULT_USE_REDIS_QUEUE=false)
  • OS: Debian 12, Docker 28.5.2

Issue Description

The MemOS scheduler initializes successfully — OptimizedScheduler._running=True and MessageConsumerThread is alive — but no tasks are ever processed. When memories are added via /product/add, the scheduler status always shows all zeros:

{
  "scheduler_summary": {
    "waiting": 0, "in_progress": 0, "pending": 0,
    "completed": 0, "failed": 0, "total": 0
  }
}

Environment Variables

MOS_ENABLE_SCHEDULER=true
API_SCHEDULER_ON=true
DEFAULT_USE_REDIS_QUEUE=false

Reproduction Steps

  1. Start MemOS with MOS_ENABLE_SCHEDULER=true and API_SCHEDULER_ON=true
  2. Add a memory: curl -X POST http://localhost:8000/product/add -H "Content-Type: application/json" -d '{"user_id":"jarvis","messages":[{"role":"user","content":"test"}],"async_mode":"async"}'
  3. Check scheduler status: curl http://localhost:8000/product/scheduler/allstatus
  4. Result: all task counts are 0

Key Finding

When init_server() is called directly in a Python shell inside the container:

  • Scheduler starts correctly
  • Consumer thread is alive and working
  • ✅ Logs show: Scheduler initialized, Scheduler started, Message consumer thread started

When MemOS starts via uvicorn (uvicorn memos.api.server_api:app):

  • No scheduler-related startup logs appear
  • No Scheduler initialized or Scheduler started or Message consumer thread started
  • But the scheduler object exists and _running=True
  • ❌ No tasks are processed

The startup logs show only:

INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000

Missing all scheduler initialization messages.

Suspected Root Cause

The server_router.py module calls components = handlers.init_server() at module import time. When running under uvicorn, this initialization appears to complete (the API works), but the scheduler consumer thread may not actually start processing messages. There may be a timing or threading issue specific to the uvicorn event loop.

Additional Notes

  • The validate_partial_initialization warning from AuthConfig appears because rabbitmq/openai/graph_db are not configured
  • The add handler creates memories in Neo4j successfully — only scheduler processing is broken
  • Tested on both v2.0.10 and v2.0.11 with identical behavior

Question

Could you confirm if the scheduler is tested in a Docker deployment with local queue (no Redis)? Is there any additional configuration required beyond MOS_ENABLE_SCHEDULER=true and API_SCHEDULER_ON=true?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions