]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
msg/async/ProtocolV2: Server drops existing connection when client restarts
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Mon, 23 Jun 2025 19:55:23 +0000 (19:55 +0000)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Fri, 18 Jul 2025 05:13:03 +0000 (05:13 +0000)
commitd8e8ac6bcc1f62749c4c2ff4d2f1de8f9c993337
tree5b802311c10d0caff8db23b4735e738e269746db
parent668c9c5a6034e5f4f3f824e3f05cdc90f9b9706d
msg/async/ProtocolV2: Server drops existing connection when client restarts

When a client is restarted, it loses its state including global_seq and gets a new client_cookie. This creates an issue during reconnection because the server has an existing connection with a higher global_seq value, causing it to reject the new connection as "stale" with the error:

"this is a stale connection, peer_global_seq="

This commit adds detection logic in ProtocolV2::handle_existing_connection() that identifies client restarts by checking for:

1. peer_global_seq < exproto->peer_global_seq

The reason is because global sequence should only increase during a
session. A decrease strongly indicates a restart.

2. client_cookie has changed (client generated a new cookie)

When these conditions are met, the server now drops the existing connection and accepts the new one (via, sending server ident to client, client happily accepts and both are ready to exchange messages), making events such as Monitor restarts & rejoin the quorum faster, preventing MON_NETSPLIT waring from poping up.

This allows clients to successfully reconnect after a restart without having to wait for server-side call-back handler to trigger (server will also try to connect, and will be successful since server will use the reconnect path instead since it contains the client's cookie) or for global_seq _id of the client to catch up to that of the server's .

Fixes: https://tracker.ceph.com/issues/71344
Signed-off-by: Kamoltat Sirivadhna <ksirivad@redhat.com>
src/msg/async/ProtocolV2.cc