osd: Fix an endless retry of a chained read when the object state goes away #167

Open
koolkhel wants to merge 2 commits from koolkhel/vitastor:chain-read-eio-loop into master
Contributor

Description

A chained read (a clone or a snapshot child) keeps the object state of each layer it reads in chain_states[]. submit_chained_read_requests() refreshed it only while the PG was not exactly PG_ACTIVE, and the replicated bitmap fast path doesn't refresh it either.

So when the parent object is the last unclean object of its PG and its recovery finishes while the read subop is in flight, the PG becomes PG_ACTIVE and the kept pointer is stale (the state is already freed). If the local copy then answers EIO, check_corrupted_chained() passes the stale pointer to mark_object(), which sees a changed state and skips the mark, and the unconditional retry in continue_chained_read() reads the same copy again. The client op never finishes; the OSD re-reads the object back to back until the PG state changes.

Fix: take the state of every read layer through get_object_osd_set() on each attempt. In a clean PG it returns NULL and cur_set, so the read target is the same as before. The read then marks the failing copy on the next EIO and reads the other one.

  • The fix takes no pin, so nothing has to be released when a chained read finishes early (for example with EPIPE in a stopping PG).
  • EC was judged from the code, not tested: EC chained reads never take the bitmap fast path, and collect_bitmap_requests() takes every layer's state on each attempt, so a vanished state costs at most one extra round there.
  • The test touches capturing_bs_t::read_bitmap() in the fixture, as #158 does; whichever of the two goes in second, I'll rebase it.

Tested: new test_chained_read_eio_after_recovery_finishes in osd_test (replicated PG; recovery of the parent object finishes while the chained read is in flight; the local copy keeps answering EIO). Without the fix the read is still retrying after 10 EIO answers (also after 1000); with it the read is served from the other OSD after 2. The whole osd_test passes.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description A chained read (a clone or a snapshot child) keeps the object state of each layer it reads in `chain_states[]`. `submit_chained_read_requests()` refreshed it only while the PG was not exactly `PG_ACTIVE`, and the replicated bitmap fast path doesn't refresh it either. So when the parent object is the last unclean object of its PG and its recovery finishes while the read subop is in flight, the PG becomes `PG_ACTIVE` and the kept pointer is stale (the state is already freed). If the local copy then answers EIO, `check_corrupted_chained()` passes the stale pointer to `mark_object()`, which sees a changed state and skips the mark, and the unconditional retry in `continue_chained_read()` reads the same copy again. The client op never finishes; the OSD re-reads the object back to back until the PG state changes. Fix: take the state of every read layer through `get_object_osd_set()` on each attempt. In a clean PG it returns NULL and `cur_set`, so the read target is the same as before. The read then marks the failing copy on the next EIO and reads the other one. - The fix takes no pin, so nothing has to be released when a chained read finishes early (for example with EPIPE in a stopping PG). - EC was judged from the code, not tested: EC chained reads never take the bitmap fast path, and `collect_bitmap_requests()` takes every layer's state on each attempt, so a vanished state costs at most one extra round there. - The test touches `capturing_bs_t::read_bitmap()` in the fixture, as #158 does; whichever of the two goes in second, I'll rebase it. Tested: new `test_chained_read_eio_after_recovery_finishes` in `osd_test` (replicated PG; recovery of the parent object finishes while the chained read is in flight; the local copy keeps answering EIO). Without the fix the read is still retrying after 10 EIO answers (also after 1000); with it the read is served from the other OSD after 2. The whole `osd_test` passes. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-23 22:14:06 +03:00
A chained read keeps the object state of each layer in chain_states[]
and refreshed it only while the PG was not exactly PG_ACTIVE. When the
last unclean object's recovery finished during the read, the kept
pointer was stale, so a read error never marked the failing copy
(mark_object() saw a changed state and skipped the mark), and the
unconditional retry read the same copy again, forever.

Take the state of every read layer on each attempt. In a clean PG it is
NULL and the read target is cur_set, as before.
koolkhel added 1 commit 2026-11-23 23:59:00 +03:00
Scrub asks read_bitmap() only for the version and passes no bitmap.
This pull request has changes conflicting with the target branch.
  • src/test/osd_test.cpp
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u chain-read-eio-loop:koolkhel-chain-read-eio-loop
git checkout koolkhel-chain-read-eio-loop
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#167
No description provided.