You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Re-reviewed the exponential scaling PR. All 4 previous findings remain unresolved: fire-and-forget task without exception handling, unbounded RPM history and good concurrency stack, and race condition on burst backoff flag.
⚠️Bug: Fire-and-forget task may cause unhandled exceptions
The asyncio.create_task(self._immediate_burst_backoff()) call creates an unmanaged task. If _immediate_burst_backoff() raises an exception, it will be silently ignored (or logged as "Task exception was never retrieved" depending on Python version and settings).
Impact: Errors during burst backoff won't be visible to the caller or properly logged, making debugging production issues difficult.
Suggested fix: Either:
Store the task reference and handle exceptions explicitly
Add exception handling within _immediate_burst_backoff() (partially done, but could still raise during _try_backoff())
Use asyncio.ensure_future() with a done callback to log exceptions
# Option 1: Store and handletask=asyncio.create_task(self._immediate_burst_backoff())
task.add_done_callback(lambdat: t.exception() ifnott.cancelled() elseNone)
# Option 2: More robust error handling in _immediate_burst_backoffasyncdef_immediate_burst_backoff(self):
try:
logger.info("Executing immediate burst backoff...")
awaitself._try_backoff()
exceptExceptionase:
logger.error("Burst backoff failed: %s", e)
finally:
self._burst_backoff_in_progress=False
⚠️Edge Case: RPM history unbounded, may cause memory growth
Impact: Memory leak in long-running inference jobs that may run for hours or days.
Suggested fix: Use a deque with a maximum length or periodically prune old entries:
# Option 1: Use deque with maxlenself._rpm_history: deque[tuple[float, int, float]] =deque(maxlen=100)
# Option 2: Keep only the best few entries# When appending, also prune if needed:iflen(self._rpm_history) >100:
# Keep only top 10 by RPMself._rpm_history=sorted(self._rpm_history, key=lambdax: x[0], reverse=True)[:10]
The flag _burst_backoff_in_progress is checked and set inside record_error() while holding _outcome_lock, but it's also cleared in _immediate_burst_backoff() without any lock. This could cause race conditions where:
Thread A sets _burst_backoff_in_progress = True and creates the task
The task clears _burst_backoff_in_progress = False
Thread B sees False and creates a duplicate burst backoff
Impact: Potential duplicate burst backoffs or skipped backoffs due to unsynchronized flag access.
Suggested fix: Either:
Use asyncio.Lock to protect the flag access in _immediate_burst_backoff()
Or rely on the time-based rate limiting (last_burst_backoff_time) as the primary guard and document that _burst_backoff_in_progress is best-effort
asyncdef_immediate_burst_backoff(self):
try:
logger.info("Executing immediate burst backoff...")
awaitself._try_backoff()
finally:
asyncwithself._outcome_lock: # Use same lockself._burst_backoff_in_progress=False
💡 Edge Case: `_good_concurrency_stack` unbounded, could grow indefinitely
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
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.
Description
Related issues
Fixes # (issue)
Before submitting
Reviewers
At least one review from a member of
oumi-ai/oumi-staffis required.