CephLXII · Inconsistent PGsInconsistent PGs
Deciding how to repair
What you'll learn
- Enumerate the repair options
- Apply criteria to choose between them
- Recognise when repair is unsafe
- Sequence the repair with device replacement
Prerequisites
None — start here.
Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18
Why this matters in production
There is more than one way to resolve an inconsistency and they have
different consequences. Choosing by default means choosing ceph pg repair regardless of whether it is the right one.
The options
| Option | When |
|---|---|
ceph pg repair | a clear majority exists and the device is understood |
| Replace the device first, then repair | the OSD is failing and would corrupt again |
| Drain the OSD, let recovery rebuild | the whole device is suspect |
| Restore the object from backup | no correct copy exists in the cluster |
| Accept the loss | the object is recreatable — a cache, a scratch object |
The criteria
flowchart TD
A[Inconsistent PG] --> B{Clear majority?}
B -->|yes| C{Device failing?}
B -->|no| D{External evidence identifies good copy?}
C -->|no| E[ceph pg repair]
C -->|yes| F[Drain or replace OSD first, then repair]
D -->|yes| G[Repair deliberately from that copy]
D -->|no| H[Restore from backup]
The question that most often gets skipped is “is the device failing” — repairing onto a device that is about to produce the same error again means doing the work twice and leaving the PG exposed in between.
When repair is unsafe
| Condition | Why |
|---|---|
size=2 with no external evidence | repair may keep the corrupt copy |
| All shards disagree | there is no correct copy to repair from |
| The primary is on the suspect host | repair sources from the primary’s view |
| Multiple PGs inconsistent on one host | the host, not the disk, is implicated |
# how many PGs are inconsistent, and where?
ceph health detail | grep 'pg .* inconsistent'
ceph pg dump pgs | grep inconsistent | awk '{print $1, $16}'
Several inconsistent PGs sharing an OSD points at that device. Several sharing a host but not an OSD points at memory, the HBA, or the cable path — and repairing from that host propagates the problem.
Sequencing with device replacement
# the device is failing: take it out of the acting set first
ceph osd out 12
# wait for the PG to be remapped and backfilled
watch -n 10 'ceph pg 3.1f query | grep -A2 acting'
# now the acting set holds only good copies
ceph pg repair 3.1f
# then replace the hardware
ceph orch osd rm 12 --replace
Draining first means the repair sources from a set that no longer contains the failing device, which is both safer and avoids repeating the work.
Quiz
Knowledge check · 4 questions
Q1. Inconsistent PGs appear across several different OSDs on one host. What does this indicate?
Q2. `ceph pg repair` consults device health evidence when choosing the authoritative copy.
Q3. Sequence a repair with a device replacement.
An inconsistent PG has a read_error on osd.12, whose device shows 74 pending sectors. The other two shards agree. The device is scheduled for replacement next week.
Q4. Name three situations in which `ceph pg repair` is unsafe to run immediately.
Passing score: 75%. Answers are checked in this browser.
Production discipline
Drain a failing device out of the acting set before repairing — repairing onto it repeats the work and leaves the PG exposed between. When inconsistencies span several OSDs on one host, drain the host before touching anything; the shared element is the host, not the disks.
Cross-course references
- Kubernetes: cordoning a suspect node before rescheduling follows the same ordering
- Linux: replacing the failing member before resyncing an array is standard practice