Manager: stream handler defaultdicts grow unbounded across kernel lifecycle
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in src/ai/backend/manager/api/rest/stream/handler.py, inspecting the four per-kernel stream defaultdicts and handle_kernel_terminating(). Verify cleanup for kernels with and without opened streams; done means all four outer keys are removed on termination and their sizes remain bounded by live kernels.
Written by the indexing model from the issue text.
Description
Objective
The four per-kernel stream defaultdicts (stream_pty_handlers, stream_execute_handlers, stream_proxy_handlers, stream_stdin_socks in src/ai/backend/manager/api/rest/stream/handler.py) never delete their outer keys. handle_kernel_terminating() uses a bare stream_stdin_socks[stream_key] access, so defaultdict.missing inserts an empty key on every kernel termination, including kernels that never opened a stream.
Evidence (live worker, Linux + memray)
- Real session create->terminate cycles left rest/stream/handler.py and defaultdict missing frames in the memray --leaks (un-freed) set.
- Shutdown cleanup only iterates .values(); outer dict keys are never removed.
Fix
- Use .get() instead of bare defaultdict access in handle_kernel_terminating.
- Delete all four per-kernel dict keys on kernel termination.
Acceptance Criteria
- Per-kernel dict keys are removed on termination.
- Stream defaultdict sizes are bounded by the number of live kernels.
JIRA Issue: BA-6804
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 20h 35m
- Merged PRs (30d)
- 429
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lablup/backend.ai
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
lablup/backend.ai#14890 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
lablup/backend.ai#14886 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
lablup/backend.ai#14485 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
lablup/backend.ai#14101 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
lablup/backend.ai#14080 ·
All issues in lablup/backend.ai
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100