Skip to content

bug(redis): KB initialization fails with 'coroutine' object has no attribute 'ping' #3962

@mrveiss

Description

@mrveiss

Summary

Knowledge base initialization consistently fails with error:

Failed to initialize Redis connections: 'coroutine' object has no attribute 'ping'

Root Cause (Unresolved - needs investigation)

During KB initialization in knowledge/base.py:337-342:

self.aioredis_client = await get_redis_client(
    async_client=True, database="knowledge"
)
await self.aioredis_client.ping()  # Line 342 fails

The error "'coroutine' object has no attribute 'ping'" indicates that self.aioredis_client is a coroutine object AFTER awaiting, not the actual Redis client.

Investigation Results

What we know:

  • get_redis_client(async_client=True, database="knowledge") returns _get_connection_manager().get_async_client(database)
  • get_async_client() is properly defined as async def (line 903 of connection_manager.py)
  • Calling an async function returns a coroutine ✓
  • Line 337 correctly awaits the coroutine ✓
  • But somehow self.aioredis_client remains a coroutine after the await

Double-coroutine scenario (most likely):

The only way awaiting a coroutine results in another coroutine is if the async function returns a coroutine object directly instead of a result.

This could happen if:

  1. _create_and_verify_async_client() or one of its callees is returning a coroutine instead of awaiting it
  2. _ensure_async_pool_exists() is not properly awaited internally
  3. An exception handler is returning an unawaited coroutine

Reproduction path:

  1. Start backend
  2. Knowledge base initialization triggers
  3. _init_redis_connections() executes
  4. Line 337-339 awaits get_redis_client(async_client=True, ...)
  5. Line 342 fails: await self.aioredis_client.ping() with "'coroutine' object has no attribute 'ping'"

Files Affected

Evidence

Full backtrace not available in logs (logger configured for message-only output), but error is consistent and reproducible on every backend startup.

Next Steps

  1. Add detailed logging to trace the actual type of value returned at each step
  2. Add test case for async Redis client initialization
  3. Check recent changes to async retry mechanism (Issue refactor(retry): standardize all retry/backoff logic on retry_mechanism.py — eliminate 4 independent implementations #3830)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions