fix(execution): release the lease when abort races an undetermined acquisition - #7237
Merged
Conversation
…quisition The cancellation return for an aborted execution ran before `releaseLease` was declared, so it exited without releasing. An undetermined acquisition can still be registered by Redis after the deadline abandons the local wait, and that member then counted against the owner for the whole TTL, denying later executions that had capacity. Declare the release before the early returns so every exit path that can leave a registration behind reaches it, and call it on the cancellation path. The over-limit return still skips it: the script answers that before its ZADD, so nothing was ever registered.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThe PR ensures cancellation after an undetermined distributed-lease acquisition attempts to release the lease before returning.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/execution/isolated-vm.ts | Moves lease cleanup before early returns and invokes it when cancellation follows an undetermined acquisition. |
| apps/sim/lib/execution/isolated-vm.test.ts | Adds regression coverage for aborting an undetermined acquisition and verifies over-limit acquisitions remain unreleased. |
Sequence Diagram
sequenceDiagram
participant Caller
participant Executor
participant Redis
Caller->>Executor: Start execution
Executor->>Redis: Acquire owner lease
Note over Executor,Redis: Local deadline expires while acquisition is undetermined
Caller->>Executor: Abort
Executor->>Redis: Release unique lease ID
Executor-->>Caller: Cancelled result
Reviews (2): Last reviewed commit: "fix(execution): keep the over-limit abor..." | Re-trigger Greptile
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 5/5
- In
apps/sim/lib/execution/isolated-vm.ts, the abortedlimit_exceededpath callsreleaseLease()without a registered lease, which could make cleanup fail or add misleading lease-release errors; restrict the call toundeterminedresults.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/execution/isolated-vm.ts">
<violation number="1" location="apps/sim/lib/execution/isolated-vm.ts:1439">
P3: When Redis returns `limit_exceeded` while the signal is already aborted, this branch still calls `releaseLease()` even though no lease was registered. Restrict the call to `undetermined` results so over-limit aborts keep the documented no-release behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
The abort guard fires for any non-acquired result, so an over-limit acquisition that was already aborted also released — contradicting the rule stated two lines below, where the same result returns without releasing because the script answers before its ZADD. Restrict the release to undetermined results and assert the no-release behavior in the existing over-limit abort test.
Collaborator
Author
Collaborator
Author
|
@cubic review |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
releaseLeasewas declared, so it exited without releasing the distributed owner lease.ZADD, so nothing was ever registered. Noted inline so it is not "corrected" later.Type of Change
Testing
vitest run lib/execution/isolated-vm.test.ts— 16 passing, including a new case asserting that an abort racing an undetermined acquisition still issues the release. Verified it fails against the previous behavior while the existing over-limit abort case keeps passing.bun run type-check,bun run lint, andbun run check:audits(39 audits) pass.Checklist