fix(mem0_oss): fix misrouted last-attempt lock error in _get_memory

The else branch for non-lock errors was incorrectly triggered on the
final retry attempt of a Qdrant lock error, causing it to log ERROR
and raise immediately rather than fall through to the lock-exhausted
path. This tripped the circuit breaker during startup when WebUI and
gateway processes competed for the lock.

Fix: add a comment to skip the else on last lock-error attempt, and
downgrade the exhausted-retries log from ERROR to WARNING since lock
contention is expected and not a hard failure.
This commit is contained in:
Hermes Local 2026-04-24 10:49:13 +00:00
parent 994c6f9e98
commit 9dca3f1c85

View file

@ -629,11 +629,15 @@ class Mem0OSSMemoryProvider(MemoryProvider):
)
_time.sleep(delay)
continue
# Last attempt also a lock error — fall through to raise below
else:
# Non-lock error — fail fast, no retry
logger.error("mem0_oss: failed to initialize Memory: %s", exc)
raise
logger.error("mem0_oss: failed to initialize Memory after %d attempts: %s", _LOCK_RETRY_ATTEMPTS, last_exc)
logger.warning(
"mem0_oss: Qdrant lock still held after %d attempts — giving up: %s",
_LOCK_RETRY_ATTEMPTS, last_exc,
)
raise last_exc # type: ignore[misc]
# -- Circuit breaker helpers -------------------------------------------