osd: fix degraded check in add_object_to_set on replicated pools #92

Merged
vitalif merged 1 commits from changwei.ye/vitastor:fix-add-object-to-set into master 2026-10-17 21:23:37 +03:00
Contributor

Description

osd: fix degraded check in add_object_to_set on replicated pools

In replicated pools, all replicas have role 0, so n_roles is set to 1
as long as at least one healthy copy exists. Comparing
n_roles < pg.pg_cursize was therefore always true for multi-replica
pools (e.g. 1 < 3 or 1 < 2), incorrectly marking healthy objects as
OBJ_DEGRADED and shadowing the OBJ_MISPLACED check below.

Conversely, directly using n_copies is also insufficient because
n_copies includes corrupted copies (n_corrupted). If a replica is
corrupted, n_copies remains equal to pg_cursize, preventing the object
from being marked as OBJ_DEGRADED and leaving it unrepaired.

Fix this by using (n_copies - n_corrupted) for replicated pools to count
only healthy copies, ensuring accurate degradation detection and
recovery.

Contributor Name

Changwei Ye (Datatom, https://www.datatom.com/)

CLA

### Description osd: fix degraded check in add_object_to_set on replicated pools In replicated pools, all replicas have role 0, so n_roles is set to 1 as long as at least one healthy copy exists. Comparing n_roles < pg.pg_cursize was therefore always true for multi-replica pools (e.g. 1 < 3 or 1 < 2), incorrectly marking healthy objects as OBJ_DEGRADED and shadowing the OBJ_MISPLACED check below. Conversely, directly using n_copies is also insufficient because n_copies includes corrupted copies (n_corrupted). If a replica is corrupted, n_copies remains equal to pg_cursize, preventing the object from being marked as OBJ_DEGRADED and leaving it unrepaired. Fix this by using (n_copies - n_corrupted) for replicated pools to count only healthy copies, ensuring accurate degradation detection and recovery. ### Contributor Name Changwei Ye (Datatom, https://www.datatom.com/) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
changwei.ye added 1 commit 2026-10-15 07:07:41 +03:00
In replicated pools, all replicas have role 0, so n_roles is hardcoded to 1
as long as at least one healthy copy exists. Comparing n_roles < pg.pg_cursize
was therefore always true for multi-replica pools (e.g. 1 < 3 or 1 < 2),
incorrectly marking healthy objects as OBJ_DEGRADED and shadowing the
OBJ_MISPLACED check below.

Fix this by using n_copies for replicated pools, matching the logic in
calc_object_states() in osd_peering_pg.cpp.
changwei.ye requested review from vitalif 2026-10-15 07:07:43 +03:00
changwei.ye force-pushed fix-add-object-to-set from 4fa967eb96 to 7803052788 2026-10-16 07:18:33 +03:00 Compare
changwei.ye changed title from osd: use n_copies for degraded check in add_object_to_set on replicated pools to osd: fix degraded check in add_object_to_set on replicated pools 2026-10-16 07:22:23 +03:00
changwei.ye force-pushed fix-add-object-to-set from 7803052788 to 5826de7e05 2026-10-16 09:33:11 +03:00 Compare
vitalif approved these changes 2026-10-17 21:23:30 +03:00
vitalif merged commit 4d34da9483 into master 2026-10-17 21:23:37 +03:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#92
No description provided.