Repository navigation
Refactor: enahnce retry and timeout - #14983
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Graphrag retry/backoff and per-phase timeout/lock configuration, introduces orchestration helpers (_has_cancel_and_exit, _run_with_retry, _acquire_lock), and integrates them into run_graphrag_for_kb and phase functions with cancellation checkpoints and user-facing chunk numbering fixes. ChangesGraphRAG Retry, Timeout, and Locking Orchestration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/graphrag/general/index.py`:
- Around line 175-180: The backoff sleep should be interruptible so cancellation
is responsive: replace the one-shot await asyncio.sleep(wait) at the end of the
retry block with a short-chunk loop that repeatedly sleeps for a small interval
(e.g., 0.1s or min(wait, 0.1)) and checks for cancellation (via
asyncio.current_task().cancelled() or by letting asyncio.CancelledError
propagate) between chunks; ensure you re-raise CancelledError so cancellation
isn't swallowed. Update the code around the variables backoff_max_seconds,
backoff_seconds, attempt, attempts, wait and the callback/logging section to use
the chunked sleep loop instead of await asyncio.sleep(wait).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aef2609b-d2bc-436e-8cb0-fce9b21ca545
📒 Files selected for processing (7)
api/utils/api_utils.pyapi/utils/validation_utils.pyrag/graphrag/general/graph_extractor.pyrag/graphrag/general/index.pyrag/graphrag/light/graph_extractor.pyrag/graphrag/ner/graph_extractor.pyrag/svr/task_executor.py
| wait = min(backoff_max_seconds, backoff_seconds * (2 ** (attempt - 1))) | ||
| if callback: | ||
| callback(msg=f"[GraphRAG] {label} failed attempt {attempt}/{attempts}: {error_msg}; retrying in {wait:.1f}s") | ||
| logging.warning("GraphRAG %s failed attempt %s/%s: %s", label, attempt, attempts, error_msg) | ||
| if wait > 0: | ||
| await asyncio.sleep(wait) |
There was a problem hiding this comment.
Check cancellation during retry backoff sleep.
Backoff currently sleeps in one shot, so cancellation can be delayed until the full wait elapses. Poll cancellation during sleep to keep stop behavior responsive.
Proposed fix
- if wait > 0:
- await asyncio.sleep(wait)
+ if wait > 0:
+ slept = 0.0
+ while slept < wait:
+ _has_cancel_and_exit(task_id, f"Task {task_id} cancelled during {label} backoff.", callback)
+ interval = min(1.0, wait - slept)
+ await asyncio.sleep(interval)
+ slept += interval🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/graphrag/general/index.py` around lines 175 - 180, The backoff sleep
should be interruptible so cancellation is responsive: replace the one-shot
await asyncio.sleep(wait) at the end of the retry block with a short-chunk loop
that repeatedly sleeps for a small interval (e.g., 0.1s or min(wait, 0.1)) and
checks for cancellation (via asyncio.current_task().cancelled() or by letting
asyncio.CancelledError propagate) between chunks; ensure you re-raise
CancelledError so cancellation isn't swallowed. Update the code around the
variables backoff_max_seconds, backoff_seconds, attempt, attempts, wait and the
callback/logging section to use the chunked sleep loop instead of await
asyncio.sleep(wait).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14983 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Type of change