Bug #58417
closedmsgr: missed message on a lossless connection
0%
Description
handle_message missed message? skipped from seq 0 to xxx
was seen on a connection between OSD-OSD via the cluster msgr instances of OSDs.
https://bugzilla.redhat.com/show_bug.cgi?id=2157104.
RZ Updated by Radoslaw Zarzynski almost 4 years ago
- Project changed from mgr to Ceph
- Backport set to pacific,quincy
KS Updated by Konstantin Shalygin over 2 years ago
- Backport changed from pacific,quincy to quincy
KS Updated by Konstantin Shalygin almost 2 years ago
- Backport deleted (
quincy)
BS Updated by Bill Scales about 1 year ago
We've seen something that looks very similar to the BZ when testing fast EC on main (we're just before tentacle GA). Our tests are with a vstart cluster running on a single node, so there are no network issues, however we are running an error inject that issues "ceph osd down <id>". We've done 10,000s of these error injects over the last few months and not seen this issue. We see the same assert as mentioned in the BZ with add_log_entry complaining that the log entry being added is already in the log, like the BZ we see that this occurs because an OSD->OSD message has been delivered twice. In this case its an ECSubOpWrite message being sent by fast EC instead of a RepOp message being sent by Replica - but this is essentially the same code path in EC instead or Replica. Just like the BZ we see a "missed message" log just before the message is delivered a 2nd time with an expected sequence of 0
Here is a log extract when the 1st message is received, we can see that the OSD is just starting the switch to epoch 945 and has discovered it is not in the map because of the error inject:
2025-09-17T23:10:27.847+0100 7f6753291640 10 osd.5 944 _committed_osd_maps 945..945 2025-09-17T23:10:27.847+0100 7f6753291640 10 osd.5 944 advance to epoch 945 (<= last 945 <= newest_map 945) 2025-09-17T23:10:27.848+0100 7f6753291640 0 log_channel(cluster) log [WRN] : Monitor daemon marked osd.5 down, but it is still running 2025-09-17T23:10:27.848+0100 7f6753291640 0 log_channel(cluster) log [DBG] : map e945 wrongly marked me down at e945 2025-09-17T23:10:27.848+0100 7f6753291640 1 osd.5 945 start_waiting_for_healthy 2025-09-17T23:10:27.848+0100 7f67632b1640 15 osd.5 945 enqueue_op MOSDECSubOpWrite(4.5s5 944/942 ECSubWrite(tid=107355, reqid=client.4354.0:148224, at_version=944'38206, trim_to=693'28203, pg_committed_to=944'38205)) v2 prio 127 type 108 cost 0 latency 0.000044 epoch 944 2025-09-17T23:10:27.848+0100 7f67632b1640 20 osd.5 op_wq(0) _enqueue OpSchedulerItem(4.5s5 PGOpItem(op=MOSDECSubOpWrite(4.5s5 944/942 ECSubWrite(tid=107355, reqid=client.4354.0:148224, at_version=944'38206, trim_to=693'28203, pg_committed_to=944'38205)) v2) class_id 2 prio 127 cost 0 e944) 2025-09-17T23:10:27.848+0100 7f6754bff640 2 osd.5 945 ms_handle_reset con 0x563ced228000 session 0x563cf9a0fb80
a couple of milliseconds later we see the reply to this message being sent and then see the same message being delivered a second time (you can see that the MOSDECSubOpWrite message is identical to above). Note also the "handle_message missed message? skipped from seq 0 to 4517" log message:
2025-09-17T23:10:27.850+0100 7f6749a7e640 20 osd.5 944 send_message_osd_cluster MOSDECSubOpWriteReply to osd.6 from_epoch 944
2025-09-17T23:10:27.850+0100 7f6749a7e640 20 osd.5 944 get_nextmap_reserved map_reservations: {945=1}
2025-09-17T23:10:27.850+0100 7f6747a7a640 20 osd.5 op_wq(0) _process empty q, waiting
2025-09-17T23:10:27.850+0100 7f6749a7e640 20 osd.5 944 release_map epoch: 945
2025-09-17T23:10:27.850+0100 7f674827b640 20 osd.5 op_wq(0) _process empty q, waiting
2025-09-17T23:10:27.850+0100 7f6749a7e640 20 osd.5 op_wq(0) _process empty q, waiting
2025-09-17T23:10:27.851+0100 7f6754bff640 10 osd.5 945 ms_handle_connect con 0x563ced66b800
2025-09-17T23:10:27.852+0100 7f6762ab0640 10 osd.5 945 new session (outgoing) 0x563cf7e5bb80 con=0x563ced66b800 addr=v2:127.0.0.1:6812/850924585
2025-09-17T23:10:27.852+0100 7f6762ab0640 0 --2- [v2:127.0.0.1:6804/2095322727,v1:127.0.0.1:6805/2095322727] >> [v2:127.0.0.1:6812/850924585,v1:127.0.0.1:6813/850924585] conn(0x563ced66b800 0x563cf0079180 crc :-1 s=READ_MESSAGE_COMPLETE pgs=445 cs=0 l=0 rev1=1 crypto rx=0 tx=0 comp rx=0 tx=0).handle_message missed message? skipped from seq 0 to 4517
2025-09-17T23:10:27.852+0100 7f6762ab0640 15 osd.5 945 enqueue_op MOSDECSubOpWrite(4.5s5 944/942 ECSubWrite(tid=107355, reqid=client.4354.0:148224, at_version=944'38206, trim_to=693'28203, pg_committed_to=944'38205)) v2 prio 127 type 108 cost 0 latency 0.000060 epoch 944
2025-09-17T23:10:27.852+0100 7f6762ab0640 20 osd.5 op_wq(0) _enqueue OpSchedulerItem(4.5s5 PGOpItem(op=MOSDECSubOpWrite(4.5s5 944/942 ECSubWrite(tid=107355, reqid=client.4354.0:148224, at_version=944'38206, trim_to=693'28203, pg_committed_to=944'38205)) v2) class_id 2 prio 127 cost 0 e944)
We then hit the same assert as the BZ trying to add the same log entry a second time:
2025-09-17T23:10:27.865+0100 7f674927d640 -1 /work/ceph/src/osd/PeeringState.cc: In function 'void PeeringState::add_log_entry(const pg_log_entry_t&, ObjectStore::Transaction&, bool)' thread 7f674927d640 time 2025-09-17T23:10:27.853475+0100 /work/ceph/src/osd/PeeringState.cc: 4673: FAILED ceph_assert(e.version > info.last_update) ceph version 20.3.0-2760-g10e3db372cf (10e3db372cf69255de95de1feba357bed673d9e8) tentacle (dev - Debug) 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x119) [0x563ce4e37ff8] 2: (ceph::__ceph_assert_fail(ceph::assert_data const&)+0x17) [0x563ce4e3833c] 3: /work/ceph/build/bin/ceph-osd(+0x14aa647) [0x563ce4938647] 4: (PeeringState::add_log_entry(pg_log_entry_t const&, ceph::os::Transaction&, bool)+0xe2) [0x563ce49442cc] 5: (PeeringState::append_log(std::vector<pg_log_entry_t, std::allocator<pg_log_entry_t> >&&, eversion_t, eversion_t, eversion_t, ceph::os::Transaction&, bool, bool)+0x39d) [0x563ce4966e29] 6: (PrimaryLogPG::log_operation(std::vector<pg_log_entry_t, std::allocator<pg_log_entry_t> >&&, std::optional<pg_hit_set_history_t> const&, eversion_t const&, eversion_t const&, eversion_t const&, bool, ceph::os::Transaction&, bool)+0x146) [0x563ce4810c24] 7: (ECBackend::handle_sub_write(pg_shard_t, boost::intrusive_ptr<OpRequest>, ECSubWrite&, ZTracer::Trace const&, ECListener&)+0x986) [0x563ce4a7eac6] 8: (ECBackend::_handle_message(boost::intrusive_ptr<OpRequest>)+0x246) [0x563ce4a83df4] 9: (ECSwitch::_handle_message(boost::intrusive_ptr<OpRequest>)+0x44) [0x563ce483e478] 10: (PGBackend::handle_message(boost::intrusive_ptr<OpRequest>)+0x55) [0x563ce4836cb9] 11: (PrimaryLogPG::do_request(boost::intrusive_ptr<OpRequest>&, ThreadPool::TPHandle&)+0x93e) [0x563ce47b6c60] 12: (OSD::dequeue_op(boost::intrusive_ptr<PG>, boost::intrusive_ptr<OpRequest>, ThreadPool::TPHandle&)+0x4af) [0x563ce45da3f9] 13: (ceph::osd::scheduler::PGOpItem::run(OSD*, OSDShard*, boost::intrusive_ptr<PG>&, ThreadPool::TPHandle&)+0x62) [0x563ce4929aac] 14: (OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*)+0x30f0) [0x563ce460ae40] 15: (ShardedThreadPool::shardedthreadpool_worker(unsigned int)+0x949) [0x563ce4e22a11] 16: (ShardedThreadPool::WorkThreadSharded::entry()+0x13) [0x563ce4e25847] 17: (Thread::entry_wrapper()+0x2f) [0x563ce4e0eca7] 18: (Thread::_entry_func(void*)+0x9) [0x563ce4e0ecb9]
Presumable the sequence being 0 instead of the expect 4517 is because of the connection being reset. My guess is that there is a race hazard in messenger when we reset the connections because an OSD has been marked as down that might corrupt a list or something resulting in the same message being delivered more that once.
I'm fairly certain that the message was not sent twice by the other OSD - it's log shows us sending ECSubOpWrite messages to 5 other OSDs and receiving 5 replies (including the reply from the OSD that crashes) before it receives the new OSDMap for epoch 945. Unfortunately we are running with default logging levels in messenger so don't have the detailed traces of it sending and receiving messages so can't prove this. The timings on the receiving side (1st message received just as the OSD learns its not in the map and starts resetting connections) and the complaint about the sequence number all suggest its the receiving side that has broken.
The fact we haven't seen this before in all our error injects suggests that it is a locking problem and a very very slim timing window
BS Updated by Bill Scales about 1 year ago
Looking further at messenger I'm not so convinced that the problem is just on the receiving side - it doesn't keep the messages it receives for very long, they get delivered and forgotten about. On the sending side I'm sure that the OSD only asked messenger to send the message once, but messenger keeps hold of messages after they have been sent until it gets an ack back from the destination and there are error paths where if the ack is not received the message can be resent. It is much more likely that this mechanism is part of duplicating the message.
I now suspect that the receiving side is closing the connection before the ack has been sent, the connection is being re-established (goes down the reconnect code path) but somehow the receiving side's sequence number has been reset and this confuses the sending side into re-issuing the message with its next sequence number that has not been reset. The receiving side then logs the missed message because its sequence number is 0 (fairly good evidence that the receive sequence number has been reset but the sending sides sequence number has not) and delivers the message a second time.
All this has to happen before the receiving side manages to process the new OSDMap and the PG's start the new epoch - if it gets this far the OSD will discard the messages because they have a stale epoch.
BS Updated by Bill Scales about 1 year ago
Had another recreate of this problem, except this time it was an ECSubOpWriteReply message that got delivered twice (message in opposite direction between OSDs) resulting in this stacktrace:
1: /ceph/build/bin/ceph-osd(+0x1c9781e) [0x55c1fb06081e] 2: /lib64/libc.so.6(+0x3fc30) [0x7f1a404d1c30] 3: /lib64/libc.so.6(+0x8d03c) [0x7f1a4051f03c] 4: raise() 5: abort() 6: /lib64/libstdc++.so.6(+0xa1b21) [0x7f1a40836b21] 7: /lib64/libstdc++.so.6(+0xad53c) [0x7f1a4084253c] 8: /lib64/libstdc++.so.6(+0xad5a7) [0x7f1a408425a7] 9: /lib64/libstdc++.so.6(+0xad809) [0x7f1a40842809] 10: (std::__throw_out_of_range(char const*)+0x41) [0x7f1a40839533] 11: /ceph/build/bin/ceph-osd(+0x1a5db27) [0x55c1fae26b27] 12: (ECBackend::handle_sub_write_reply(pg_shard_t, ECSubWriteReply const&, ZTracer::Trace const&)+0x39) [0x55c1fae22605] 13: (ECBackend::_handle_message(boost::intrusive_ptr<OpRequest>)+0x1fc) [0x55c1fae24716] 14: (ECSwitch::_handle_message(boost::intrusive_ptr<OpRequest>)+0x3c) [0x55c1fac8f3e4] 15: (PGBackend::handle_message(boost::intrusive_ptr<OpRequest>)+0x5e) [0x55c1fac8a2a4] 16: (PrimaryLogPG::do_request(boost::intrusive_ptr<OpRequest>&, ThreadPool::TPHandle&)+0x7e9) [0x55c1fac2d3d1]
The out of range exception is because the TID in the write reply message is no longer in the map because we completed the write when we got the 1st reply.
It has the same warning from messenger:
2025-10-01T16:18:14.029+0100 7f1a3d7f9640 0 --2- [v2:127.0.0.1:6804/3813473292,v1:127.0.0.1:6805/3813473292] >> [v2:127.0.0.1:6828/2502010080,v1:127.0.0.1:6829/2502010080] conn(0x55c210ead800 0x55c203887600 crc :-1 s=READ_MESSAGE_COMPLETE pgs=97 cs=0 l=0 rev1=1 crypto rx=0 tx=0 comp rx=0 tx=0).handle_message missed message? skipped from seq 0 to 1241
and happened just after an OSD was marked down:
2025-10-01T16:18:14.027+0100 7f1a2d7d9640 0 log_channel(cluster) log [WRN] : Monitor daemon marked osd.0 down, but it is still running 2025-10-01T16:18:14.027+0100 7f1a227c3640 20 osd.0 op_wq(0) _process empty q, waiting 2025-10-01T16:18:14.027+0100 7f1a2d7d9640 0 log_channel(cluster) log [DBG] : map e256 wrongly marked me down at e256
but before the PG could process the new epoch and start discarding messages.
BS Updated by Bill Scales 11 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=2427169 is another recreate, this time it is a recovery delete message that got duplicated, but the mechanism is the same.
LS Updated by Lee Sanders 8 months ago
There are quite a few failures similar to this assert in:
/a/skanta-2026-03-25_08:03:35-rados-wip-bharath8-testing-2026-03-24-2323-distro-default-trial
and this appeared on the Top 10 watcher list this week as it occurred 17x during a QA run.
The configuration is Erasure Code - ISAL with optimizations disabled.
PeeringState::add_log_entry - src/osd/PeeringState.cc: 4682: FAILED ceph_assert(e.version > info.last_update) assert
/a/*/121087 is one instance of it within the above directory
BS Updated by Bill Scales 8 months ago
Had a look at /a/*/121087 and this is NOT a duplicate of this issue, even though it hits the same assert. In particular there is no evidence of the monitor marking the OSD down incorrectly and a message like this "Monitor daemon marked osd.0 down, but it is still running" in the log which will always be present in the logs for this issue.
For this issue there was a replica-2 pool which processed two write I/Os, the second being a delete that failed with ENOENT. The primary OSD 0 processes these I/Os and generates two log entries 19'1 and 19'2 which it applies in order. It also sends messages for both these writes to OSD 3. OSD 3 receives and processes the messages out of order, applying log entry 19'2 first and then trying to apply log entry 19'1 and asserting. The fact this assert happened so early, and because there are no error injects (both writes were in the same epoch), and because there have been many teuthology tests in the same run failing with this issue suggests that one of the new PRs being tested in the run has caused a regression.
BS Updated by Bill Scales 7 months ago
- Category set to OSD
- The Bug
Location: The race occurs in `src/osd/OSD.cc` between lines 8790 and 8816
This is a race hazard when an OSD discovers it has been marked down in a new OSDMap (but is still running). The OSD calls messenger->rebind() to reset messenger before it has called consume_map() to update the epoch. This leaves a window where a sending OSD can reconnect and resend one of its messages which gets delivered a 2nd time.
- The Race Condition Sequence
1. Message arrives with old epoch (e.g., epoch N):
- Message is received and dispatched to OSD
- OSD processes message in old epoch N
- Message has not yet been acked
2. New OSDMap arrives (epoch N+1) marking OSD as down:
- OSD processes new map in `handle_osd_map()`
- Line 8760: `bind_epoch = osdmap->get_epoch()` sets bind_epoch to N+1
- Line 8761: `service.set_epochs(NULL, &up_epoch, &bind_epoch)` updates bind_epoch
- Line 8790: `cluster_messenger->rebind(avoid_ports)` is called
- This calls `mark_down_all()` (AsyncMessenger.cc:663) which resets all connections
- ack for message received at step 1 will not be sent
- BUT: Line 8811: `map_lock.unlock()` - map lock is released
- Line 8816: `consume_map()` is called
3. The race window (lines 8790-8816):
- `rebind()` has reset messenger connections (line 8790)
- But `consume_map()` hasn't been called yet (line 8816)
- Shards still have old epoch map (shard_osdmap not updated until line 10714)
4. Connection re-establishes:
- Peer reconnects after `rebind()`
- `send_server_ident()` resets `in_seq = 0` (ProtocolV2.cc:2950)
- Sender retransmits message from step 1 (wasn't acked due to connection reset)
5. Duplicate message delivered:
- Retransmitted message arrives with old epoch N
- Receiver's `in_seq` is now 0 (was reset in step 4)
- Message passes duplicate check (seq > 0, cur_seq = 0)
- Triggers "missed message? skipped from seq 0 to xxx" log (ProtocolV2.cc:1482)
- Message is enqueued to shard
- BUG: Shard still has old epoch N map (hasn't consumed new map yet)
- Message with old epoch N is NOT filtered out (check at line 11291 only filters if `qi.get_map_epoch() > osdmap->get_epoch()`)
- Message is processed again!
6. Eventually (after race):
- `consume_map()` updates shard maps (line 10714)
- Future messages with old epoch would be filtered (line 10759-10768)
- But the duplicate already got through
- Why It's Rare
The bug requires this precise timing:
1. Message must be in-flight when OSD is marked down
2. `rebind()` must complete and connection re-establish before `consume_map()` updates shard maps
3. Sender must retransmit before shard epoch is updated
4. The retransmitted message must arrive and be enqueued in the narrow window between `rebind()` (line 8790) and when `consume_map()` updates the shard's osdmap (line 10714)
- The Fix
Move `cluster_messenger->rebind()` to AFTER `consume_map()`:
BS Updated by Bill Scales 7 months ago
- Assignee set to Bill Scales
KS Updated by Konstantin Shalygin 7 months ago
- Target version set to v21.0.0
- Source set to Development
- Backport set to squid tentacle
BS Updated by Bill Scales 5 months ago
- Status changed from New to Fix Under Review
- Pull request ID set to 70231
KS Updated by Konstantin Shalygin 5 months ago
- Target version changed from v21.0.0 to v22.0.0
- Backport changed from squid tentacle to squid tentacle umbrella
UB Updated by Upkeep Bot 4 months ago
- Status changed from Fix Under Review to Pending Backport
- Merge Commit set to 33a2cbcd2dba7d5482aafca65f3e993673626d2a
- Fixed In set to v21.3.0-1491-g33a2cbcd2d
- Upkeep Timestamp set to 2026-07-28T23:45:29+00:00
UB Updated by Upkeep Bot 4 months ago
- Copied to Backport #78799: squid: msgr: missed message on a lossless connection added
UB Updated by Upkeep Bot 4 months ago
- Copied to Backport #78800: umbrella: msgr: missed message on a lossless connection added
UB Updated by Upkeep Bot 4 months ago
- Copied to Backport #78801: tentacle: msgr: missed message on a lossless connection added
UB Updated by Upkeep Bot 4 months ago
- Tags (freeform) set to backport_processed
UB Updated by Upkeep Bot 3 months ago
- Status changed from Pending Backport to Backporting
- Tags (freeform) deleted (
backport_processed) - Upkeep Timestamp changed from 2026-07-28T23:45:29+00:00 to 2026-08-27T18:43:24+00:00