Repository navigation
crimson/osd: fix backfill deadlock in BackfillState::Waiting - #69824
Conversation
| // Enqueuing and re-checks budget_available() fresh. | ||
| DEBUGDPP("backfill budget unavailable with nothing in flight, " | ||
| "rescanning instead of entering Waiting", pg()); | ||
| post_event(RequestPrimaryScanning{}); |
There was a problem hiding this comment.
I understand the problem - Waiting with nothing in flight deadlocks. I'm not sure if triggering a primary scan is the best solution.
Is it being used because the scan path waits on get_backfill_throttle()?
There was a problem hiding this comment.
Yes exactly but not because of this patch, the throttler was implemented in request primary scan via other pull request.I will try to find some other solution but do u have any approach how to wakeup after reach in Waiting state.
There was a problem hiding this comment.
RequestPrimaryScanning would create repeated scans:
- In
Enqueuing- no budget AND no tracked objects RequestPrimaryScanningPrimaryScannedgoes back toEnqueuing- Back to 1
The problem here I think is the fact that Waiting is only suitable when there's an event that should wake it (i.e ObjectPushed).
As @amathuria suggested above, we should instead create a dedicated state that instead of reusing the existing Waiting one.
For example:
- In
Enqueuing- no budget AND no tracked objects RequestBudgetBlockedgoes toBudgetBlockedBudgetBlockedwaits for a real retry path (e.g. budget becoming available / recovery requeue / explicit trigger).- That event transitions back to
Enqueuing(now thatbudget_available()should be true)
Matan-B
left a comment
There was a problem hiding this comment.
Great catch! Though I think we should avoid busy looping over scanning - See comment.
| // Enqueuing and re-checks budget_available() fresh. | ||
| DEBUGDPP("backfill budget unavailable with nothing in flight, " | ||
| "rescanning instead of entering Waiting", pg()); | ||
| post_event(RequestPrimaryScanning{}); |
There was a problem hiding this comment.
RequestPrimaryScanning would create repeated scans:
- In
Enqueuing- no budget AND no tracked objects RequestPrimaryScanningPrimaryScannedgoes back toEnqueuing- Back to 1
The problem here I think is the fact that Waiting is only suitable when there's an event that should wake it (i.e ObjectPushed).
As @amathuria suggested above, we should instead create a dedicated state that instead of reusing the existing Waiting one.
For example:
- In
Enqueuing- no budget AND no tracked objects RequestBudgetBlockedgoes toBudgetBlockedBudgetBlockedwaits for a real retry path (e.g. budget becoming available / recovery requeue / explicit trigger).- That event transitions back to
Enqueuing(now thatbudget_available()should be true)
| "(pg cleaned or interval changed)", *pg->get_dpp()); | ||
| return; | ||
| } | ||
| backfill_state->process_event( |
There was a problem hiding this comment.
When posting BudgetAvailable from the async throttle callback, let's use the same is_triggered() / post_event vs process_event pattern as enqueue_push does for ObjectPushed?
process_event runs the event immediately. post_event queues it until the current dispatch finishes. If the get_backfill_throttle grants a slot right away, the callback can run while we're still entering BudgetBlocked (processing RequestBudgetBlocked). Calling process_event there would nest one event inside another and can confuse the state machine.
| struct BudgetBlocked : sc::state<BudgetBlocked, BackfillMachine>, | ||
| StateHelper<BudgetBlocked> { | ||
| using reactions = boost::mpl::list< | ||
| sc::transition<BudgetAvailable, Enqueuing>, |
There was a problem hiding this comment.
BudgetAvailable probably needs a custom_reaction here — with a direct
transition we'd enter Enqueuing even while suspended. Should match
Waiting::react(ObjectPushed) and check if (!backfill_state().is_suspended()).
| LOG_PREFIX(PGRecovery::request_budget_retry); | ||
| DEBUGDPP("budget unavailable with nothing in flight, " | ||
| "waiting for throttle slot", *pg->get_dpp()); | ||
| std::ignore = get_backfill_throttle() |
There was a problem hiding this comment.
nit: Could we coroutinise this to match do_request_primary_scan /
do_request_replica_scan? A do_request_budget_retry() coroutine would make
interruption handling cleaner and keeps the backfill listener code consistent
| LOG_PREFIX(PGRecovery::request_budget_retry); | ||
| DEBUGDPP("budget unavailable with nothing in flight, " | ||
| "waiting for throttle slot", *pg->get_dpp()); | ||
| std::ignore = get_backfill_throttle() |
There was a problem hiding this comment.
we probably should not drop the releaser immediately. instead, we should release it after done with the requested budget.
|
@mohit84 make check seems to be failing on test_backfill.cc, could you check it out? |
|
jenkins test make check |
done |
There was a problem hiding this comment.
@mohit84 I had a doubt here - remove_on_peers() only calls enqueue_drop(). budget_retry_releaser is only reset in enqueue_push(), so a delete-only pass through Enqueuing → Waiting can leave the slot held until on_activate_complete? Is that okay? Just checking.
There was a problem hiding this comment.
I agree we can release a slot in enqueue_drop also otherwise it is unnecessary waste the slot.
amathuria
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments!
LGTM
|
jenkins retest windows |
|
jenkins test windows |
Matan-B
left a comment
There was a problem hiding this comment.
"crimson/osd: Resolved reviewer comment" is not a proper commit message. Please see https://github.com/ceph/ceph/blob/main/SubmittingPatches.rst#describe-your-changes
| } catch (const crimson::common::interruption& e) { | ||
| DEBUGDPP("budget retry interrupted: {}", *pg->get_dpp(), e.what()); | ||
| co_return; |
There was a problem hiding this comment.
interrupts are not caught using try catch.
Please see test_crimson_coroutine.cc for examples or crimson/common/coroutine.h for the implementation.
BackfillState::Enqueuing unconditionally posts RequestWaiting{}
when budget available return false. Waiting can exit only via
ObjectPushed which requires an in-flight push. If the budget
is exhausted with no pushes in flight no objectPush will ever
arrive and the PG stalls permanently.
Solution: Introduce a dedicated BudgetBlocked state. When budget_available()
is false and tracked_objects_completed()==true post RequestBudgetBlocked{}
instead of RequestWaiting{}.BudgetBlocked calls get_backfill_throttle()
to suspend until a slots free up, then fires BudgetAvailable{} which
transitions directly back to Enqueuing to dispatch the next batch of pushes.
Fixes: https://tracker.ceph.com/issues/77804
Signed-off-by: Mohit Agrawal <[email protected]>
Signed-off-by: Mohit Agrawal <[email protected]>
done |
1 similar comment
done |
|
jenkins test windows |
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
crimson/osd: fix backfill deadlock in BackfillState::Waiting
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.