Skip to content

bug: turn_coordinator eviction stalls when oldest lock is held #40

@G9000

Description

@G9000

Summary

turn_coordinator.py:39-43 — the LRU eviction loop breaks at the first locked entry. If the oldest thread lock is held (long-running turn), no eviction happens even if many newer unlocked entries exist. With 512+ concurrent threads and the oldest always busy, the dict grows beyond _MAX_THREAD_LOCKS.

Fix

Continue scanning past locked entries:

while len(_thread_locks) > _MAX_THREAD_LOCKS:
    evicted = False
    for k, v in list(_thread_locks.items()):
        if not v.locked():
            _thread_locks.pop(k)
            evicted = True
            break
    if not evicted:
        break

Files

  • apps/server/src/anima_server/services/agent/turn_coordinator.py:39-43

Severity

Low — memory growth beyond intended cap under extreme concurrency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions