Skip to content

librbd: localize snap_remove op for mirror snapshots - #51166

Merged
idryomov merged 1 commit into
ceph:mainfrom
chrisphoffman:wip-rbd-59393
May 10, 2023
Merged

idryomov merged 1 commit into
ceph:mainfrom
chrisphoffman:wip-rbd-59393

Conversation

@chrisphoffman

@chrisphoffman chrisphoffman commented Apr 20, 2023 •

Copy link
Copy Markdown
Contributor

A client may attempt a lock request not quickly enough to obtain exclusive lock for operations when another competing client responds quicker. This can happen when a peer site has different performance characteristics or latency. Instead of relying on this unpredictable behavior, localize operation to primary cluster.

Fixes: https://tracker.ceph.com/issues/59393
Signed-off-by: Christopher Hoffman [email protected]

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@chrisphoffman
chrisphoffman requested a review from a team as a code owner April 20, 2023 19:53

@trociny trociny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I agree with the approach. To me it looks like we are just hiding the real problem (transfering an operation from a lock owner that does not support it may not work) instead of fixing it. And we may step on it in some other place.

Comment thread src/cls/rbd/cls_rbd.cc Resolved
@idryomov

Copy link
Copy Markdown
Contributor

I am not sure I agree with the approach. To me it looks like we are just hiding the real problem (transfering an operation from a lock owner that does not support it may not work) instead of fixing it.

I wouldn't deny that there is a bit of that here ;) But, at a high level, I think the approach is sound. Even if all clients out there in the field supported all operations, it would still be entirely possible for rbd-mirror daemon on the secondary cluster to end up owning the lock on the primary image and perform operations such as primary mirror snapshot creation and removal on primary cluster's behalf. Architecturally this doesn't make sense to me: I don't see why rbd-mirror daemon on the secondary cluster should ever hold the exclusive lock/perform any operation that requires the exclusive lock on the primary image (and vice versa).

And we may step on it in some other place.

Yeah, the fundamental issue with exclusive lock transfers is that the lock is not actually transferred. When the lock requested by a peer, the lock owner just releases it. Any peer, not necessarily the requestor, is able to grab it -- and, in the presence of uneven network latency between clients, the original lock owner just ends up grabbing it back. There is no provision for fairness in the protocol. The kernel client does try to go easier in its implementation:

	__rbd_release_lock(rbd_dev);

	/*
	 * Give others a chance to grab the lock - we would re-acquire
	 * almost immediately if we got new IO while draining the running
	 * list otherwise.  We need to ack our own notifications, so this
	 * lock_dwork will be requeued from rbd_handle_released_lock() by
	 * way of maybe_kick_acquire().
	 */
	cancel_delayed_work(&rbd_dev->lock_dwork);

but I don't think librbd has something similar. And, regardless, this wouldn't cover a two order of magnitude difference in network latency between local and cross-AZ traffic, which is what we are going to be contending with in snapshot-based mirroring scenarios.

@trociny

trociny commented Apr 21, 2023

Copy link
Copy Markdown
Contributor

Fair enough. Although I still don't like it I can't think of anything better that wouldn't require changes on the client (kernel/librbd) side, which might be troublesome.

@idryomov

idryomov commented Apr 21, 2023 •

Copy link
Copy Markdown
Contributor

I can't think of anything better that wouldn't require changes on the client (kernel/librbd) side, which might be troublesome.

If you have ideas around introducing some notion of fairness to the exclusive lock or perhaps actual peer-to-peer transfers, I would be interested in hearing them!

I consider this PR to be a bug fix for snapshot-based mirroring (almost unrelated to the exclusive lock behavior and more to do with making the secondary cluster touch the primary cluster as little as possible) but we may need to tackle the exclusive lock problem in the future.

@trociny

trociny commented Apr 21, 2023 •

Copy link
Copy Markdown
Contributor

If you have ideas around introducing some notion of fairness to the exclusive lock or perhaps actual peer-to-peer transfers, I would be interested in hearing them!

We could add a flag to RequestLockPayload, which would tell the lock owner after releasing the lock to send a special notification (AllowToLock or something like this), and until a response is received to this notification or it is timed out, the former lock owner will not try to acquire the lock. The sender of RequestLock, will expect to receive AllowToLock and will respond only when it gets the lock.

Not sure it is a very nice approach and how easy it would be to implement, still it seems it could work. And it could be used only for specific cases like this (i.e. when the current lock owner does not support an OP).

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@trociny trociny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no issues noticed

@chrisphoffman
chrisphoffman force-pushed the wip-rbd-59393 branch 2 times, most recently from ea55ab8 to f867f7a Compare May 3, 2023 22:52
@chrisphoffman
chrisphoffman requested review from idryomov and trociny May 3, 2023 22:54

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM!

@idryomov

idryomov commented May 6, 2023

Copy link
Copy Markdown
Contributor

jenkins test make check

@idryomov

idryomov commented May 6, 2023

Copy link
Copy Markdown
Contributor

jenkins test windows

@idryomov

idryomov commented May 7, 2023

Copy link
Copy Markdown
Contributor

TestClsRbd.mirror_snapshot needs adjustment:

diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc
index 4d6f9bd89b00..2f553a0f4338 100644
--- a/src/test/cls_rbd/test_cls_rbd.cc
+++ b/src/test/cls_rbd/test_cls_rbd.cc
@@ -2275,14 +2275,14 @@ TEST_F(TestClsRbd, mirror_snapshot) {
   ASSERT_EQ(1U, sn->mirror_peer_uuids.size());
   ASSERT_EQ(1U, sn->mirror_peer_uuids.count("peer2"));
 
-  ASSERT_EQ(-ERESTART,
-            mirror_image_snapshot_unlink_peer(&ioctx, oid, 1, "peer2"));
+  ASSERT_EQ(0, mirror_image_snapshot_unlink_peer(&ioctx, oid, 1, "peer2"));
+  ASSERT_EQ(-ENOENT, mirror_image_snapshot_unlink_peer(&ioctx, oid, 1,
+                                                       "peer2"));
   ASSERT_EQ(0, snapshot_get(&ioctx, oid, 1, &snap));
   sn = std::get_if<cls::rbd::MirrorSnapshotNamespace>(
     &snap.snapshot_namespace);
   ASSERT_NE(nullptr, sn);
-  ASSERT_EQ(1U, sn->mirror_peer_uuids.size());
-  ASSERT_EQ(1U, sn->mirror_peer_uuids.count("peer2"));
+  ASSERT_EQ(0U, sn->mirror_peer_uuids.size());
 
   ASSERT_EQ(0, snapshot_get(&ioctx, oid, 2, &snap));
   auto nsn = std::get_if<cls::rbd::MirrorSnapshotNamespace>(

A client may attempt a lock request not quickly enough to
obtain exclusive lock for operations when another competing
client responds quicker. This can happen when a peer site has
different performance characteristics or latency. Instead of
relying on this unpredictable behavior, localize operation to
primary cluster.

Fixes: https://tracker.ceph.com/issues/59393
Signed-off-by: Christopher Hoffman <[email protected]>
@idryomov

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants