Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78e2801428
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| SupervisorJob(parent.coroutineContext[Job]) + Dispatchers.Default) | ||
| init { | ||
| // Parent cancellation also ends ownership; wait for all session children before returning credit. | ||
| checkNotNull(scope.coroutineContext[Job]).invokeOnCompletion { stateLease?.close() } |
There was a problem hiding this comment.
Retain admission until removal completes
When removeTorrent(..., deleteFiles = true) encounters an exception or cancellation in store.restore(), recoverOwnership(), or cleanup(), scope.cancel() has already completed this handler and returned the lease, but KotlinTorrentEngine.removeTorrent() never reaches its map removals. The running engine therefore still retains the session and its indexed state while subsequent torrents can consume the supposedly freed capacity, defeating the aggregate state ceiling after a filesystem cleanup failure. Release the lease only after the session is detached, or keep it charged when teardown aborts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1c7f7b2. Admission now belongs to the runtime registry: failed deletion keeps the session charged, successful detachment returns its lease, and runtime completion releases remaining leases after child jobs finish. A failed cleanup remains retryable rather than silently succeeding because network shutdown already occurred. The regression test exercises two failed deletions, blocked readmission, and explicit keep-data removal. All 304 local torrent tests and the native-runtime guard pass; updated-head CI is running.
|
Superseded by #231 (Contracts, verification infrastructure and resource limits) in the consolidated eight-PR stack for #162. The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks. Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment) |
Apply session admission before constructing storage indexes or decoding checkpoint state. A torrent must fit the file-count limit, piece-count limit, individual state allowance, and remaining aggregate capacity. Failure returns any reservation without creating payload storage.
Stack: based on #166 (
torrent-v2-01-admission), following #163–#165. This is the session-admission slice of roadmap #162 step 01.The state allowance accounts conservatively for retained metadata, file/path indexes, scheduler arrays and candidate lists, checkpoint parsing, and checking scratch buffers. Peer/wire buffers remain separately charged. A session retains its reservation while paused; construction failure returns it immediately, and removal/runtime cancellation returns it after all session child jobs finish. Every partition can be full without consuming metadata exchange headroom.
Validation: full torrent JVM conformance and native-runtime guard passed before the workflow-only restack. Tests exercise combined count/memory limits, exhaustion, rejection before filesystem creation, failed-construction rollback, pause retention, removal/readmission, and non-suspending shutdown. CI validates the updated head.
Admission estimates are not measured heap/RSS. Production profiles, deterministic fault harness, performance baseline, and the remaining production release gates stay open in #162.