]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/journal: skip disconnected clients when finding min_commit_position 44601/head
authorMykola Golub <mgolub@suse.com>
Fri, 14 Jan 2022 18:21:29 +0000 (18:21 +0000)
committerMykola Golub <mgolub@suse.com>
Mon, 17 Jan 2022 18:41:34 +0000 (18:41 +0000)
When a new journal client is registered, all already registered
clients are checked, and a client with min position is selected
as a position for the new client. Thus we may expect that
starting from the registered position all journal entries will be
available (not trimmed) for the new client.

But when looking for a min commit position, the client_register
function did not take into account that a registered client might
be in disconnected state, and in that case the journal entries
might be trimmed for this client.

Fixes: https://tracker.ceph.com/issues/53888
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/cls/journal/cls_journal.cc

index db5a6854ad0de3beba977c3b856c080485808c3c..1479e1de6b5fc0e96b0d7933a8c3ec59051ec1c4 100644 (file)
@@ -271,11 +271,12 @@ int find_min_commit_position(cls_method_context_t hctx,
     }
 
     start_after = batch.rbegin()->id;
-
     // update the (minimum) commit position from this batch of clients
-    for(std::set<cls::journal::Client>::iterator it = batch.begin();
-        it != batch.end(); ++it) {
-      cls::journal::ObjectSetPosition object_set_position = (*it).commit_position;
+    for (const auto &client : batch) {
+      if (client.state == cls::journal::CLIENT_STATE_DISCONNECTED) {
+        continue;
+      }
+      const auto &object_set_position = client.commit_position;
       if (object_set_position.object_positions.empty()) {
        *minset = cls::journal::ObjectSetPosition();
        break;