Repository navigation
rbd-mirror: prune obsolete primary mirror snapshots after relocation - #68161
Conversation
a2b5c84 to
7aecd83
Compare
Current behavior of image replayer, without changes:Initially: Here, This PR addresses removal of primary and demote primary snapshots post relocation. Currently this primary snapshot gets removed on next promote call of Behavior of image replayer with proposed changes:Initially: pool1/img3 is primary on cluster1 and secondary on cluster2 Relocating: As per the expectation, the image replayer removed old primary snapshots that are no longer needed. |
dc4d75e to
bba032a
Compare
| if (mirror_ns->mirror_peer_uuids.empty() || | ||
| mirror_ns->mirror_peer_uuids.count(m_primary_peer_uuid) == 1) { | ||
| // old primary snapshots can be removed when remote becomes primary | ||
| prune_snap_ids.insert(local_snap_id); | ||
| } |
There was a problem hiding this comment.
you should not be editing get_peer_uuids() logic and the interface IMHO, it is intended.
This is what we want right?
A snapshot is marked for deletion if:
- No peer is associated (uuids.empty()), OR
- It belongs to the same peer
| if (mirror_ns->mirror_peer_uuids.empty() || | |
| mirror_ns->mirror_peer_uuids.count(m_primary_peer_uuid) == 1) { | |
| // old primary snapshots can be removed when remote becomes primary | |
| prune_snap_ids.insert(local_snap_id); | |
| } | |
| const auto& uuids = mirror_ns->mirror_peer_uuids; | |
| bool is_same_peer = | |
| (uuids.size() == 1 && | |
| std::find(m_peer_uuids.begin(), m_peer_uuids.end(), uuids.front()) != m_peer_uuids.end()); | |
| if (uuids.empty() || is_same_peer) { | |
| prune_snap_ids.insert(local_snap_id); | |
| } |
There was a problem hiding this comment.
Ah! Sorry, The above won't work. It is like even if the uuids.size() == 1 what is the guaranty that that uuid in the snapshot belongs to primary peer uuid, the above condition can only say like "this UUID is one of the known peers", it doesn't guaranty of the its primary's peer uuid.
There was a problem hiding this comment.
It looks like what we pass to bootstap code today is also a TODO :-)
template <typename I>
void ImageReplayer<I>::bootstrap() {
dout(10) << dendl;
std::unique_lock locker{m_lock};
if (m_peers.empty()) {
┆ locker.unlock();
┆ dout(5) << "no peer clusters" << dendl;
┆ on_start_fail(-ENOENT, "no peer clusters");
┆ return;
}
// TODO need to support multiple remote images
ceph_assert(!m_peers.empty());
m_remote_image_peer = *m_peers.begin();
There was a problem hiding this comment.
I agree @pkalever. For now I have used m_remote_image_peer to get uuid for comparison. PTAL.
| } | ||
|
|
||
| return uuids; | ||
| return uuid; | ||
| } |
There was a problem hiding this comment.
As mentioned this filtering doesn't work when we have multiple peers. And the intention of get_peer_uuids() is to get all the peer uuids and what the Replayer is doing with them is up to it. You shouldn't be changing get_peer_uuids(), its intentionally returning all the peer uuids associated with it.
bba032a to
12e6452
Compare
| @@ -431,13 +427,17 @@ template <typename I> | |||
| void ImageReplayer<I>::start_replay() { | |||
| dout(10) << dendl; | |||
|
|
|||
| std::string peer_uuid = m_remote_image_peer.uuid; | |||
There was a problem hiding this comment.
Rather than supporting multiple peers which we discussed, you are just using the m_remote_image_peer which is a TODO as mentioned before:
// TODO need to support multiple remote images
ceph_assert(!m_peers.empty());
m_remote_image_peer = *m_peers.begin();
There was a problem hiding this comment.
Correct. It is already a TODO but my recent change will reduce dependencies. Currently trying to find a way to know about primary cluster to remove existing TODO.
There was a problem hiding this comment.
Just want to clear an another conceptual ideology, We had a hope that we could fetch it from a object header otherwise, I looked from that lens too the fact is that only rbd_mirroring object header holds it but I expect it to have the peer list again, where you cannot differentiate b/w primary and others.
88388bd to
221a0e2
Compare
|
Old primary snapshots are safe to prune when their It is unsafe to combine these two conditions for below multi-peer scenario (theoretical): Here, it is unsafe to remove s1 from cluster1 using below diff: |
221a0e2 to
b945a89
Compare
ajarr
left a comment
There was a problem hiding this comment.
We need a tracker ticket for this bug, if one does not already exist. And the link to the tracker needs to be in the Fixes tag of the commit message.
| mirror_ns->state == cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED)) { | ||
| // old primary snapshots are safe to prune when mirror_peer_uuids is empty | ||
| // old demote primary snapshots are safe to prune when mirror_peer_uuids has | ||
| // only one entry of current primary |
There was a problem hiding this comment.
@abitdrag I think we should be able to verify that the value of the demote peer uuid.
a) list the local peer sites
std::vector<cls::rbd::MirrorPeer> mirror_peers;
r = librbd::cls_client::mirror_peer_list(local_image_ctx->md_ctx, &mirror_peers);
b) pick the peer site whose mirror_uuid field matches m_state_builder->remote_mirror_uuid
auto it = std::find_if(mirror_peers.begin(), mirror_peers.end(),
[&](const auto& peer) {
return peer.mirror_uuid == m_state_builder->remote_mirror_uuid;
});
if (it == mirror_peers.end()) {
// handle peer not found
}
const auto& matched_peer = *it;
c) this chosen peer site's uuid field should match the demote peer uuid
if (*mirror_ns->mirror_peer_uuids.begin() == match_peer.uuid) {
// match
}
I have not tested this code. I think this should work.
There was a problem hiding this comment.
I understand this, @pkalever have created PR to include peer UUID 68267
But, the issue is:
m_state_builder->remote_mirror_uuid is assigned in
PrepareRemoteImageRequest<I>::finalize_snapshot_state_builder() from m_remote_image_peer.remote_pool_meta of ImageReplayer in ImageReplayer<I>::bootstrap()
currently we assign m_remote_image_peer as:
// TODO need to support multiple remote images
ceph_assert(!m_peers.empty());
m_remote_image_peer = *m_peers.begin();
Here, we have made assumption that first element in m_peers is remote and primary (for two peers scenario). This is not valid for multi-peer scenario.
So, we wanted to reduce dependency on this TODO. As it can be done using @idryomov's suggested approach without identifying current primary.
There was a problem hiding this comment.
But in a single peer scenario it can be assumed that m_remote_image_peer corresponds to the primary, right? In case there is only one element in the primary demote snapshot's mirror_peer_uuids set, can it be cross-checked against m_remote_image_peer?
There was a problem hiding this comment.
@abitdrag if we can include this commit 951665c,
then m_remote_image_peer.uuid would be the value we want, right? I don't think we need the second commit in his PR 66c5233
As discussed, we don't have to worry about m_remote_image_peer being incorrect for multi-peers. It'd have to be fixed eventually to correspond to primary peer from which the image replayer is syncing.
Considering this, I would close #68267 . And just include Prasanna's initial commit in this PR. It'd hasten the PR review process.
There was a problem hiding this comment.
Sure, I'm fine with dropping the second commit for now. We'll likely need to revisit it once we settle on a way to determine primary peer details, and extend ReplayerListener with appropriate get_*_uuid() so the Replayer can retrieve that information cleanly. Thanks.
63e72bc to
e95b85a
Compare
ajarr
left a comment
There was a problem hiding this comment.
I see unit test failure in the logs of the make check job
/ceph/src/tools/rbd_mirror/ImageReplayer.cc:432:20: error: no member named 'remote_image_peer' in 'rbd::mirror::image_replayer::StateBuilder<librbd::MockTestImageCtx>'
b52e04f to
4f3a0ab
Compare
|
jenkins test make check |
|
jenkins test make check arm64 |
Initialize the uuid member in the Peer constructor and include it in stream output operator to ensure correct peer identification in logs. Signed-off-by: Prasanna Kumar Kalever <[email protected]>
ab290bf to
623eec1
Compare
2c28957 to
9233b44
Compare
9233b44 to
e8ae8d8
Compare
Previously, obsolete primary and demoted primary snapshots on the secondary cluster were not cleaned up immediately after relocation. Instead, old primary snapshots remained until a subsequent promote operation triggered their cleanup, while old demoted primary snapshots persisted until a later demote operation removed them. Adding changes for proactive cleanup of obsolete primary and demoted primary snapshots that are no longer required after relocation. Also adding test coverage to validate the cleanup behavior. Fixes: https://tracker.ceph.com/issues/76154 Signed-off-by: Miki Patel <[email protected]>
e8ae8d8 to
a10f58d
Compare
|
jenkins test make check arm64 |
|
jenkins test windows |
1 similar comment
|
jenkins test windows |
rbd-mirror: prune obsolete primary mirror snapshots after relocation
Previously, obsolete primary and demoted primary snapshots on the
secondary cluster were not cleaned up immediately after relocation.
Instead, old primary snapshots remained until a subsequent promote
operation triggered their cleanup, while old demoted primary snapshots
persisted until a later demote operation removed them.
Adding changes for proactive cleanup of obsolete primary and demoted
primary snapshots that are no longer required after relocation.
Also adding test coverage to validate the cleanup behavior.
Fixes: https://tracker.ceph.com/issues/76154
Signed-off-by: Miki Patel [email protected]
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.