Skip to main content
RunBook Academy

CephLXII · Inconsistent PGsInconsistent PGs

Deciding how to repair

Advanced⏱ ~17 minceph

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

Not yet marked complete on this device.

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

OptionWhen
ceph pg repaira clear majority exists and the device is understood
Replace the device first, then repairthe OSD is failing and would corrupt again
Drain the OSD, let recovery rebuildthe whole device is suspect
Restore the object from backupno correct copy exists in the cluster
Accept the lossthe 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

ConditionWhy
size=2 with no external evidencerepair may keep the corrupt copy
All shards disagreethere is no correct copy to repair from
The primary is on the suspect hostrepair sources from the primary’s view
Multiple PGs inconsistent on one hostthe 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

  1. Q1. Inconsistent PGs appear across several different OSDs on one host. What does this indicate?

  2. Q2. `ceph pg repair` consults device health evidence when choosing the authoritative copy.

  3. 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.

  4. 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