Conversation
📝 WalkthroughWalkthroughFiberQueue::Run() now wraps its dequeue/execute loop in a try/catch that fatally logs on std::exception. FiberQueue::blocked_submitters() changed from an instance const method to static. FiberQueueThreadPool::Add() now increments/decrements blocked_submitters_ around the push_ec_ wait. ChangesFiberQueue reliability and accounting
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
PR Summary by QodoHarden FiberQueueThreadPool worker loop and blocked-submitter tracking
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
11 rules✅ Cross-repo context Explored:
repo: dragonflydb/dragonfly (sha: bc82e529) 1. FiberQueue::Run() catches std::exception
|
There was a problem hiding this comment.
🧹 Nitpick comments (3)
util/fibers/fiberqueue_threadpool.cc (1)
41-61: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a
catch (...)fallback alongsidecatch (const std::exception&).Verified
Tasklet'sIsThrowing=falsetemplate parameter only governs behavior on empty-callable invocation (abort vs.fu2::bad_function_call), not whether a valid, non-empty callable's thrown exception propagates — so this try/catch does correctly intercept exceptions thrown frombatch[i](). However, onlystd::exception-derived types are caught; anything else (e.g., a non-standard thrown type) will escapeRun()with no handler up the call stack inWorkerFunction, leading to an opaquestd::terminate()with no diagnostic log, unlike the intendedLOG(FATAL)path.🛡️ Proposed fix
} catch (const std::exception& ex) { LOG(FATAL) << "Exception " << ex.what(); + } catch (...) { + LOG(FATAL) << "Unknown exception in FiberQueue::Run"; }🤖 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 `@util/fibers/fiberqueue_threadpool.cc` around lines 41 - 61, Add a non-standard exception fallback in fiberqueue_threadpool.cc so FiberQueueThreadPool::Run does not let unknown thrown types escape WorkerFunction; keep the existing catch (const std::exception&) path for diagnostics and add a catch-all handler alongside it that logs a fatal error before terminating, using the existing LOG(FATAL) reporting pattern around batch[i]().util/fibers/fiberqueue_threadpool.h (2)
176-178: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate blocking-wait accounting pattern; consider a shared RAII guard.
This increment/wait/decrement sequence is identical to the existing pattern in
FiberQueue::Add(lines 74-77). Extracting a small RAII guard (e.g., viaabsl::Cleanup) would remove the duplication and also make the decrement exception-safe ifpush_ec_.wait()ever throws. As per coding guidelines, "Use smart pointers (std::unique_ptr) and RAII (absl::Cleanup) for resource management."♻️ Proposed refactor sketch
- main_w.q->blocked_submitters_++; - main_w.q->push_ec_.wait(key.epoch()); - main_w.q->blocked_submitters_--; + main_w.q->blocked_submitters_++; + absl::Cleanup dec = [&] { main_w.q->blocked_submitters_--; }; + main_w.q->push_ec_.wait(key.epoch());🤖 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 `@util/fibers/fiberqueue_threadpool.h` around lines 176 - 178, The blocked_submitters_ increment/wait/decrement sequence in FiberQueue::Add and the matching path in FiberQueue::FiberQueueThreadPool should be deduplicated and made exception-safe. Introduce a small RAII guard, preferably using absl::Cleanup, around the push_ec_.wait(key.epoch()) call so the decrement always runs even if waiting throws, and reuse the same helper/pattern in both FiberQueue::Add and the threadpool blocking path.Source: Coding guidelines
111-113: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDocument the thread-local scope of
blocked_submitters()
It returns the calling thread’sblocked_submitters_, not per-FiberQueuestate; a short comment or clearer name would make that explicit.🤖 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 `@util/fibers/fiberqueue_threadpool.h` around lines 111 - 113, The blocked_submitters() accessor currently reads thread-local blocked_submitters_ but its name and declaration do not make that scope explicit. Update the FiberQueueThreadPool API by adding a short comment or renaming blocked_submitters() to clearly indicate it returns the calling thread’s value, not per-FiberQueue state. Keep the change close to the blocked_submitters() method and the blocked_submitters_ member so the thread-local behavior is obvious to callers.
🤖 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.
Nitpick comments:
In `@util/fibers/fiberqueue_threadpool.cc`:
- Around line 41-61: Add a non-standard exception fallback in
fiberqueue_threadpool.cc so FiberQueueThreadPool::Run does not let unknown
thrown types escape WorkerFunction; keep the existing catch (const
std::exception&) path for diagnostics and add a catch-all handler alongside it
that logs a fatal error before terminating, using the existing LOG(FATAL)
reporting pattern around batch[i]().
In `@util/fibers/fiberqueue_threadpool.h`:
- Around line 176-178: The blocked_submitters_ increment/wait/decrement sequence
in FiberQueue::Add and the matching path in FiberQueue::FiberQueueThreadPool
should be deduplicated and made exception-safe. Introduce a small RAII guard,
preferably using absl::Cleanup, around the push_ec_.wait(key.epoch()) call so
the decrement always runs even if waiting throws, and reuse the same
helper/pattern in both FiberQueue::Add and the threadpool blocking path.
- Around line 111-113: The blocked_submitters() accessor currently reads
thread-local blocked_submitters_ but its name and declaration do not make that
scope explicit. Update the FiberQueueThreadPool API by adding a short comment or
renaming blocked_submitters() to clearly indicate it returns the calling
thread’s value, not per-FiberQueue state. Keep the change close to the
blocked_submitters() method and the blocked_submitters_ member so the
thread-local behavior is obvious to callers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 73cbed0f-3944-4a01-ae86-45fe4043c481
📒 Files selected for processing (2)
util/fibers/fiberqueue_threadpool.ccutil/fibers/fiberqueue_threadpool.h
Summary by CodeRabbit