Skip to content

fix: release the key lease when a pooled call is cancelled - #1369

Merged
n24q02m merged 1 commit into
mainfrom
fix/key-lease-leak-20261112
Nov 12, 2026
Merged

n24q02m merged 1 commit into
mainfrom
fix/key-lease-leak-20261112

Conversation

@n24q02m

@n24q02m n24q02m commented Nov 12, 2026

Copy link
Copy Markdown
Owner

A pooled provider call cancelled mid-flight (the server's 45 s EMBED_CALL_DEADLINE_S, a shutdown) raises CancelledError, which is a BaseException. KeyPool.arun releases the lease only on Exception, so the credential stayed leased for LEASE_SECONDS (60 s) and the next call failed with pool exhausted (... leased=1) even though the provider was healthy.

The attempt wrapper now reports a non-Exception escape as report_failure(credential, None): classify_status(None) is fatal, which takes hull's release path and never blames, cools down or disables the key.

Regression test test_cancelled_call_releases_the_only_lease cancels a single-key call with wait_for and asserts the next call is served. It fails before the change (leased=1) and passes after.

The root fix belongs in hull's KeyPool.arun; this wrapper can be dropped once a hull release carries it.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@n24q02m
n24q02m merged commit fd146bf into main Nov 12, 2026
13 checks passed
@n24q02m
n24q02m deleted the fix/key-lease-leak-20261112 branch November 12, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant