From: Kamoltat Sirivadhna Date: Fri, 18 Jul 2025 05:00:18 +0000 (+0000) Subject: msg/async: ProtocolV2::send_server_ident update ProtocolV2::global_seq X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df1105c1a8b9ed4620b6ac335d88e69763b0d6e8;p=ceph.git msg/async: ProtocolV2::send_server_ident update ProtocolV2::global_seq In ProtocolV2::send_server_ident(), the global_seq was being fetched from messenger->get_global_seq() and used in the ServerIdentFrame, however, it is stored in a local var and not the private class var ProtocolV2::global_seq. This causes problems like where the receiving peer sees a peer_global_seq that appears older than expected, triggering a false-positive reconnect logic: ``` 2025-07-15T11:40:50.927+0000 mon.c handle_existing_connection client has clearly restarted (peer_global_seq < ex_peer_global_seq && cookie changed), dropping existing connection=0x563ffe9a9000 in favor of new one ``` In this case, mon.c received a peer_global_seq=75, which was already logged by mon.d as gs=79 in its send_server_ident()—but ProtocolV2::global_seq was never updated, resulting in inconsistent state and premature connection teardown. This commit fixes the issue by assigning the freshly incremented messenger->get_global_seq() value to the local global_seq field in ProtocolV2 as well, ensuring consistency in the protocol. Fixes: https://tracker.ceph.com/issues/71344 Signed-off-by: Kamoltat Sirivadhna --- diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 639b59937065..97568a0779e2 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -1082,9 +1082,12 @@ __u32 AsyncMessenger::get_global_seq(__u32 old_global_seq) } // release lock if (did_update_to_old) { - ldout(cct, 10) << __func__ << " old_global_seq=" << old_global_seq + ldout(cct, 10) + << __func__ << " old_global_seq=" << old_global_seq << " > global_seq=" << global_seq - << "; new global_seq=" << updated_to << dendl; + << "; new global_seq=" << updated_to + << " (was " << prev_global << ")" + << dendl; } ldout(cct, 10) << __func__ << " increment to global_seq=" << global_seq << dendl; return ret; diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 134f5e274836..2b6f5d929e69 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -465,7 +465,7 @@ void ProtocolV2::send_message(Message *m) { m->trace.event("async enqueueing message"); out_queue[m->get_priority()].emplace_back( out_queue_entry_t{is_prepared, m}); - ldout(cct, 15) << __func__ << " inline write is denied, reschedule m=" << m + ldout(cct, 15) << __func__ << " message queued for async transmission m=" << m << dendl; if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) { write_in_progress = true; @@ -2958,11 +2958,11 @@ CtPtr ProtocolV2::send_server_ident() { flags = flags | CEPH_MSG_CONNECT_LOSSY; } - uint64_t gs = messenger->get_global_seq(); + global_seq = messenger->get_global_seq(); auto server_ident = ServerIdentFrame::Encode( messenger->get_myaddrs(), messenger->get_myname().num(), - gs, + global_seq, connection->policy.features_supported, connection->policy.features_required | msgr2_required, flags, @@ -2971,7 +2971,7 @@ CtPtr ProtocolV2::send_server_ident() { ldout(cct, 5) << __func__ << " sending identification:" << " addrs=" << messenger->get_myaddrs() << " gid=" << messenger->get_myname().num() - << " global_seq=" << gs << " features_supported=" << std::hex + << " global_seq=" << global_seq << " features_supported=" << std::hex << connection->policy.features_supported << " features_required=" << (connection->policy.features_required | msgr2_required) diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 1ef114aba3a1..ce79401e1e4e 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -83,7 +83,7 @@ private: uint64_t client_cookie; uint64_t server_cookie; - uint64_t global_seq; + uint64_t global_seq; // Snapshot of AsyncMessenger::global_seq uint64_t connect_seq; uint64_t peer_global_seq; uint64_t message_seq;