]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async: ProtocolV2::send_server_ident update ProtocolV2::global_seq
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Fri, 18 Jul 2025 05:00:18 +0000 (05:00 +0000)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Fri, 10 Oct 2025 20:36:43 +0000 (20:36 +0000)
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 <ksirivad@redhat.com>
src/msg/async/AsyncMessenger.cc
src/msg/async/ProtocolV2.cc
src/msg/async/ProtocolV2.h

index 639b59937065f0148ab8410416c86fd2ec0fb5ea..97568a0779e25446ebc506b756b75f2127b10542 100644 (file)
@@ -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;
index 134f5e2748368d023a4ff39b57ca0e1f9aa4fd91..2b6f5d929e6939ce9bcf514d7d8ee67b544653ac 100644 (file)
@@ -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)
index 1ef114aba3a1b9479d43667edc424b131da782c7..ce79401e1e4eaa9771a6f3ce58ddc83454edc0e7 100644 (file)
@@ -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;