Bug #80828
openmds: backend dirfrag prefetch leaks its throttle slot on fetch failure and refetches whole dirfrags under cache pressure
0%
Description
The backend dirfrag prefetch added by #69832 (mds_dir_prefetch_backend,
https://tracker.ceph.com/issues/77810) has three problems.
1. Throttle slot leak when a background fetch fails
When a background full fetch is launched, CDir::fetch() sets
STATE_BACKEND_FETCH and increments mdcache->num_backend_fetching.
fetch fails (missing dirfrag object, corrupt fnode header, trailing
bytes in the header), _omap_fetched() calls go_bad(), which clears
STATE_FETCHING but leaves STATE_BACKEND_FETCH set and never
decrements num_backend_fetching.
Each failed background fetch permanently takes one slot of
mds_dir_prefetch_backend_max (default 1). Once all slots are gone,
backend prefetch silently stops for the whole rank until the MDS
restarts.
A related race: with backend prefetch, a keyed fetch can run while a
background full fetch of the same dirfrag is still in flight
(fetch_keys() waits only if STATE_FETCHING is set without
STATE_BACKEND_FETCH). If that keyed fetch fails, go_bad(complete=false)
clears STATE_FETCHING anyway. This lets a second full fetch start on
the same dirfrag and, once the leak is fixed, would release the
throttle slot before the first fetch finishes.
2. Repeated full dirfrag fetches under cache pressure
backend_hit_count stops counting at mds_dir_prefetch_backend_hit_threshold
and is never reset. Once a dirfrag has been fetched complete, trimming
any of its dentries clears STATE_COMPLETE (MDCache::trim_dentry()).
Because the counter is still at the threshold, the next keyed miss
immediately launches another full background fetch.
Under cache pressure this becomes a loop: the fetch loads the whole
dirfrag, trimming evicts some of it and clears STATE_COMPLETE, and
the next miss reads the whole dirfrag again. The hit threshold,
which exists to avoid wasted full-omap reads, stops having any
effect for any dirfrag that has reached it once.
3. Background prefetch ignores cache pressure
The background fetch is launched even when the cache is already over
its reservation (MDCache::cache_toofull()). Everything it loads is
trimmed straight back out, so it costs a full omap read on the
metadata pool, adds to cache pressure, and via (2) keeps triggering
more fetches.
Affected configuration: mds_dir_prefetch=false and
mds_dir_prefetch_backend=true. The default configuration
(mds_dir_prefetch=true) is not affected.
Proposed fix (https://github.com/ceph/ceph/pull/<PR>):
- go_bad(): release STATE_BACKEND_FETCH and the throttle slot, and clear
STATE_FETCHING, only when the failed fetch was a full one (complete).
- mark_complete(): reset backend_hit_count.
- CDir::fetch(): skip the background fetch while cache_toofull().
VS Updated by Venky Shankar about 2 months ago
- Related to Feature #77810: mds: add mds_dir_prefetch_backend for non-blocking dirfrag prefetch with configurable lazy trigger added
VS Updated by Venky Shankar about 2 months ago
- Category set to Correctness/Safety
- Component(FS) MDS added
AD Updated by Anthony D'Atri about 1 month ago
- Backport set to umbrella,tentacle
Requesting umbrella and tentacle backports so these fixes can travel with the #77810 backport.
AD Updated by Anthony D'Atri about 1 month ago
If these are backported, #69832, #72036 and #72524 need to be in the same point release on each branch. Backporting #69832 alone ships the problems in #80828 to anyone who sets mds_dir_prefetch=false and mds_dir_prefetch_backend=true: a leaked throttle slot after a failed fetch, and repeated whole-dirfrag fetches under cache pressure. #72524 is the qa change that exercises the backend mode.
AD Updated by Anthony D'Atri about 1 month ago
- Backport deleted (
umbrella,tentacle)
Backport request withdrawn along with 77810's, since items 1-3 depend on #69832. Item 4, the lookup hang in CDir::go_bad(), also affects released branches with mds_dir_prefetch=false; see https://github.com/ceph/ceph/pull/72036.