Skip to content

fix: reclaim unused session locks - #1381

Merged
mnajafian-nv merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/reclaim-unused-session-locks
Oct 16, 2026
Merged

mnajafian-nv merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/reclaim-unused-session-locks

Conversation

@willkill07

@willkill07 willkill07 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Overview

Long-lived workers retain a session-lock entry for every distinct session ID, even after callers release the lock. Reclaim unused entries during the existing five-second idle sweep while preserving locks referenced by active or waiting operations.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Remove session gates whose only remaining owner is the directory. Acquisitions clone under the same directory mutex, preventing cleanup from replacing a lock while a caller holds or awaits it.
  • Run cleanup before the no-idle-sessions early return.
  • Add regression coverage for reclaiming 1,000 unused gates, references obtained before acquisition, held and queued locks, and safe recreation after removal.
  • Session retention and lifecycle events remain unchanged. No public API changes.

Validation:

  • The churn regression failed before the fix; all three focused regressions pass with it.
  • just test-rust: all 5,912 tests passed.
  • Staged code and audit hooks passed. Documentation link validation passed with authenticated GitHub requests; intermittent GitHub 503 responses required skipping only its redundant commit-time check.
  • Binding suites were not run because the change is confined to CLI session management.

Where should the reviewer start?

Start with close_idle_sessions_from_parts in crates/cli/src/sessions/idle.rs, then the three session-gate regressions in crates/cli/tests/coverage/shared/session_tests.rs. The key safety condition is holding the directory mutex while checking Arc::strong_count and removing entries.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Relates to: none

Summary by CodeRabbit

  • Bug Fixes
    • Idle-session cleanup now removes unused session gates, including when no sessions are eligible for cleanup, while preserving gates that are still in use.

@willkill07
willkill07 requested a review from a team as a code owner October 16, 2026 19:14
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 846d935f-0a02-48aa-a379-593d6fb0a608
📥 Commits

Reviewing files that changed from the base of the PR and between 2abc4f5 and 9bcbbfe.

📒 Files selected for processing: 2
  • crates/cli/src/sessions/idle.rs
  • crates/cli/tests/coverage/shared/session_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 1
  • GitHub Check: Changes / Detect
🧰 Additional context used
📚 Code guidelines: 1
CONTRIBUTING.md — configured
📓 Path-based instructions: 2
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
Applicability reference: AGENTS.md: # NeMo Relay Repository Guidance See `CONTRIBUTING.md` and `docs/contribute/testing-and-docs.mdx` for contributor details, and `.agents/skills/README.md` for the maintainer skill boundary.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/cli/src/sessions/idle.rs
  • crates/cli/tests/coverage/shared/session_tests.rs
🔇 Additional comments: 2
crates/cli/src/sessions/idle.rs: 1

48-54: LGTM!

crates/cli/tests/coverage/shared/session_tests.rs: 1

36-125: LGTM!

Walkthrough

The idle-session sweep now removes unused session gates before checking for idle sessions. Tests verify that it retains gates with external references, including gates that are held or have queued waiters.

Changes

Idle session-gate cleanup

Layer / File(s) Summary
Prune unused gates during the idle sweep
crates/cli/src/sessions/idle.rs, crates/cli/tests/coverage/shared/session_tests.rs
The sweep removes gates with no external references, even when there are no idle sessions. Tests cover cleanup, gate retention during locking and queued waits, and later gate recreation.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9bcbb

The change appears ready to merge after normal checks; no unresolved issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title uses the allowed fix type, follows Conventional Commits syntax, uses an imperative summary, and is under 72 characters without a trailing period.
Description check Passed The description includes all required sections, completed contribution and duplication checks, implementation details, reviewer guidance, related-issue syntax, and validation results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@willkill07 willkill07 added this to the 0.10 milestone Oct 16, 2026
@willkill07 willkill07 self-assigned this Oct 16, 2026

@mnajafian-nv mnajafian-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mnajafian-nv
mnajafian-nv merged commit 70fb50b into NVIDIA:release/0.10 Oct 16, 2026
46 checks passed
@willkill07
willkill07 deleted the fix/reclaim-unused-session-locks branch October 30, 2026 14:47

This branch was previously deployed

1 inactive deployment
fern — 9bcbbfe0 Deployed Oct 16, 2026 by mnajafian-nv via Clean up docs preview #5911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants