Re: [PATCH 0/2] libceph: support pg_upmap_primary (the read balancer)

From: Xiubo Li

Date: Thu Dec 03 2026 - 08:25:22 EST


Hi Alex,

Thanks, both points are real. I reproduced each of them on a 5-OSD
cluster with krbd and fixed them in two new patches that come first in
v2. Neither is specific to pg_upmap_primary, though; both predate this
series.

> When pg_temp keeps acting [A,B,C] while an upmap-primary update changes
> the up set from [B,A,C] to [C,B,A], even a read correctly identified as
> sent to replica B is not resent.

Right. PG::can_discard_op() on a replica drops balanced/localized reads
sent before same_interval_since and expects the client to resend on any
interval change, but calc_target() only resends replica reads when the
acting set changes (Objecter does the same). Any up-only change ends
the interval, so it does not need pg_upmap_primary: with nobackfill set
and pg_upmap_items, a PG had up [4,2,0] and acting [4,2,1]; moving the
up set to [4,2,3] (acting unchanged) and reading the 40 objects of the
PG with read_from_replica=balance before the client had the new map
left 28/40 reads hanging on the two replicas on current testing, until
left 28/40 reads hanging on the two replicas on current testing, until
the acting set changed after nobackfill was unset. With "libceph:
resend replica reads on a new interval", which checks
ceph_is_new_interval() for requests that went to a replica, 0/40 hang.

> The new incremental decoder adds a fallible allocation after the live
> map's epoch has advanced.

Also right, and new_pg_temp, new_pg_upmap_items and the others already
allocate after the epoch is bumped. Injecting -ENOMEM into the new
pg_upmap_primary decode showed exactly what you describe: the kernel
map stayed at the new epoch without the entry (also after a later
unrelated incremental), and all 31 reads of the PG went to the old
primary, which dropped them as misdirected. Making the whole
incremental atomic would mean staging every part of it, so v2 takes
your second option instead ("libceph: get a full osdmap after failing
to apply an incremental"): the map is marked invalid, new requests are
paused as for an epoch barrier, incrementals are ignored, and the
latest full map is requested from the monitor (epoch 0 subscription)
and taken even at the same epoch, after which all requests are
recalculated as after a gap. With the same injection the full map
arrives right away, the entry is present and 31/31 reads complete.
If the full map cannot be decoded either, it is asked for again from
the timeout work, once per osd_keepalive_timeout, rather than in a
loop.

v2 will be:

libceph: resend replica reads on a new interval
libceph: get a full osdmap after failing to apply an incremental
libceph: decode and apply pg_upmap_primary mappings
libceph: advertise SERVER_REEF

Thanks,
Xiubo

On Wed, 2 Dec 2026 at 14:11, Alex Markuze <amarkuze@xxxxxxxxxx> wrote:
>
> Hi Xiubo,
>
> Your separate "don't assume the primary leads the acting set for replica
> reads" patch addresses the non-leading-primary replica identity case.
> Even with that patch applied first, two issues remain in this series:
>
> When pg_temp keeps acting [A,B,C] while an upmap-primary update changes
> the up set from [B,A,C] to [C,B,A], even a read correctly identified as
> sent to replica B is not resent. B can discard it after advancing to the
> new interval. Please resend replica reads on relevant up-set interval
> changes when the acting set is unchanged.
>
> The new incremental decoder adds a fallible allocation after the live
> map's epoch has advanced. On failure it can leave an incomplete map at
> the new epoch; a repeat of that epoch is ignored, and an unrelated later
> incremental need not restore the missing primary. Reads and writes may
> then be sent to the wrong OSD and stall. Please make incremental
> application atomic, or invalidate the partial map and obtain a full map
> before using it to route requests.
>
> Thanks,
> Alex