Skip to content

rbd-mirror: Remove old non-primary demoted image snapshots on the local cluster - #68500

Merged
idryomov merged 1 commit into
ceph:mainfrom
abitdrag:wip-non-prim-demote-img-snap-removal
Jun 25, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
abitdrag:wip-non-prim-demote-img-snap-removal

Conversation

@abitdrag

@abitdrag abitdrag commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

When an image is demoted on primary cluster and later promoted again,
a non-primary demoted image snapshot is created on the peer (secondary)
cluster. Each such promote/demote cycle on same cluster results in an
additional non-primary demoted snapshot being created on peer.
As a result, repeated promote/demote cycles on the same cluster can
lead to accumulation of stale non-primary demoted snapshots on the
secondary cluster. These snapshots are not removed immediately because
cleanup is only triggered when peer (secondary) is promoted and then
demoted.

The proposed changes ensures that such snapshots are proactively identified
and removed, preventing unbounded buildup. Also added test coverage to
verify cleanup behavior.

Fixes: https://tracker.ceph.com/issues/76155

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@abitdrag
abitdrag requested a review from a team as a code owner April 21, 2026 12:07
@abitdrag

abitdrag commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor Author

test case changes in rbd_mirror.sh passing with image_replayer.cc's changes from PR:
rbd_mirror_tests.txt

test case changes in rbd_mirror.sh failing without image_replayer.cc changes from PR:
rbd_mirror_tests_failed.txt

@abitdrag

Copy link
Copy Markdown
Contributor Author

Behavior without changes:

Initially: img3 is primary on cluster1 and non-primary on cluster2

root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     3  .mirror.primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.398bc147-be06-4e72-8ef1-8b88d5916878  128 MiB             Tue Apr 21 23:01:29 2026  mirror (primary peer_uuids:[95a85262-ac4a-439f-b65e-94d65ff28670])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                       
     3  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.b42cae89-7dbf-43bb-bb7a-3a4905eda209  128 MiB             Tue Apr 21 23:01:51 2026  mirror (non-primary peer_uuids:[] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:3 copied)

demoting and promoting on same cluster:

root:build# bin/rbd --cluster cluster1 mirror image demote pool1/img3
Image demoted to non-primary
root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     3  .mirror.primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.398bc147-be06-4e72-8ef1-8b88d5916878  128 MiB             Tue Apr 21 23:01:29 2026  mirror (primary peer_uuids:[])                                    
     4  .mirror.primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.41a51455-54aa-4291-82dc-2bd63687dc5a  128 MiB             Tue Apr 21 23:03:55 2026  mirror (demoted peer_uuids:[95a85262-ac4a-439f-b65e-94d65ff28670])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                                                       
     4  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.d29c0923-7b21-4d37-b8ce-02e865a9426d  128 MiB             Tue Apr 21 23:03:56 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:4 copied)
root:build# bin/rbd --cluster cluster1 mirror image promote pool1/img3
Image promoted to primary
root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     4  .mirror.primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.41a51455-54aa-4291-82dc-2bd63687dc5a  128 MiB             Tue Apr 21 23:03:55 2026  mirror (demoted peer_uuids:[95a85262-ac4a-439f-b65e-94d65ff28670])
     5  .mirror.primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.62bfad5d-fc1e-41df-8032-4155cabc306b  128 MiB             Tue Apr 21 23:04:44 2026  mirror (primary peer_uuids:[95a85262-ac4a-439f-b65e-94d65ff28670])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                                                       
     4  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.d29c0923-7b21-4d37-b8ce-02e865a9426d  128 MiB             Tue Apr 21 23:03:56 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:4 copied)
     5  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.b6f49008-5337-4eb5-b09c-945d26859b3c  128 MiB             Tue Apr 21 23:04:49 2026  mirror (non-primary peer_uuids:[] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:5 copied)          

Repeating similar step for 4 more times:

bin/rbd --cluster cluster1 mirror image demote pool1/img3
bin/rbd --cluster cluster1 mirror image promote pool1/img3
bin/rbd --cluster cluster1 mirror image demote pool1/img3
bin/rbd --cluster cluster1 mirror image promote pool1/img3
bin/rbd --cluster cluster1 mirror image demote pool1/img3
bin/rbd --cluster cluster1 mirror image promote pool1/img3
bin/rbd --cluster cluster1 mirror image demote pool1/img3
bin/rbd --cluster cluster1 mirror image promote pool1/img3

Snapshots pile up on cluster2:

root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                                                        
     4  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.d29c0923-7b21-4d37-b8ce-02e865a9426d  128 MiB             Tue Apr 21 23:03:56 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:4 copied) 
     6  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.80ca4972-6806-4f73-aff7-2d9169b72ee2  128 MiB             Tue Apr 21 23:06:18 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:6 copied) 
     8  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.09ae6ec2-eeab-4133-9d94-589cda517612  128 MiB             Tue Apr 21 23:07:09 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:8 copied) 
    10  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.36702f87-f213-4e85-be05-70373f76f4d0  128 MiB             Tue Apr 21 23:07:36 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:10 copied)
    12  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.6f26f9ee-f450-4faa-bc76-ba0e7c972d39  128 MiB             Tue Apr 21 23:08:22 2026  mirror (demoted peer_uuids:[c3eff001-4660-4f1a-a93e-0d12f2832271] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:12 copied)
    13  .mirror.non_primary.83bc272f-f52c-4a5a-952b-d7d2c9003162.0b33973c-8ef2-4d70-b978-aeff404bcd63  128 MiB             Tue Apr 21 23:08:49 2026  mirror (non-primary peer_uuids:[] bfc185de-72af-49d5-a0e1-5f6c9ead4c07:13 copied)     

demoted primary snapshots get piled up on cluster2, they get cleaned up when relocation happens and cluster2 gets demoted. This happens because non-primary demote snapshots dont get unlinked by image_replayer of cluster1. Here, cluster1 never goes into up+replaying state, hence it's image_replayer can not unlink these snapshots. Secondary cluster, i.e. cluster2 has to clear these snapshots.

Behavior with changes:

Initially: img3 is primary on cluster1 and non-primary on cluster2

root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     3  .mirror.primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.d2eb1b9a-d7e0-4892-882b-84b16d237bd4  128 MiB             Tue Apr 21 19:13:59 2026  mirror (primary peer_uuids:[a5473bf0-2fb2-4c87-8d56-729b8c32f5d7])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                       
     3  .mirror.non_primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.92492ed0-fa89-4741-bb98-b10e55f40eb0  128 MiB             Tue Apr 21 19:14:23 2026  mirror (non-primary peer_uuids:[] debe0ab2-4549-4c44-9a55-959b087dfb68:3 copied)

demoting and promoting on same cluster:

root:build# bin/rbd --cluster cluster1 mirror image demote pool1/img3
2026-04-21T22:54:11.923+0530 7fd411a7cbc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:11.923+0530 7fd411a7cbc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:11.929+0530 7fd411a7cbc0 -1 WARNING: all dangerous and experimental features are enabled.
Image demoted to non-primary
root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
2026-04-21T22:54:18.656+0530 7f90a37babc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:18.656+0530 7f90a37babc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:18.663+0530 7f90a37babc0 -1 WARNING: all dangerous and experimental features are enabled.
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     3  .mirror.primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.d2eb1b9a-d7e0-4892-882b-84b16d237bd4  128 MiB             Tue Apr 21 19:13:59 2026  mirror (primary peer_uuids:[])                                    
     4  .mirror.primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.bf8039e5-d8b5-4232-9604-e8129329f24a  128 MiB             Tue Apr 21 22:54:12 2026  mirror (demoted peer_uuids:[a5473bf0-2fb2-4c87-8d56-729b8c32f5d7])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
2026-04-21T22:54:22.503+0530 7fd4cc6d9bc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:22.503+0530 7fd4cc6d9bc0 -1 WARNING: all dangerous and experimental features are enabled.
2026-04-21T22:54:22.509+0530 7fd4cc6d9bc0 -1 WARNING: all dangerous and experimental features are enabled.
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                                                       
     4  .mirror.non_primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.6e6655e0-c5a6-41b6-8325-7eedec28e3e9  128 MiB             Tue Apr 21 22:54:13 2026  mirror (demoted peer_uuids:[57442776-ac34-476e-8c3a-845d65bf2fe7] debe0ab2-4549-4c44-9a55-959b087dfb68:4 copied)
root:build# bin/rbd --cluster cluster1 mirror image promote pool1/img3
Image promoted to primary
root:build# bin/rbd --cluster cluster1 snap list --all pool1/img3
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
     4  .mirror.primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.bf8039e5-d8b5-4232-9604-e8129329f24a  128 MiB             Tue Apr 21 22:54:12 2026  mirror (demoted peer_uuids:[a5473bf0-2fb2-4c87-8d56-729b8c32f5d7])
     5  .mirror.primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.cabc9a00-d4f5-4e77-9147-68afe1272dee  128 MiB             Tue Apr 21 22:55:42 2026  mirror (primary peer_uuids:[a5473bf0-2fb2-4c87-8d56-729b8c32f5d7])
root:build# bin/rbd --cluster cluster2 snap list --all pool1/img3
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                       
     5  .mirror.non_primary.1bbfff0c-8066-4c2a-809d-d471c3f6057d.df9ef524-6b4d-4370-ba14-78e7aad25856  128 MiB             Tue Apr 21 22:55:51 2026  mirror (non-primary peer_uuids:[] debe0ab2-4549-4c44-9a55-959b087dfb68:5 copied)

After applying changes from this PR, when old demoted non-primary snapshots are found, image_replayer clears it.

@@ -514,7 +514,8 @@ void Replayer<I>::scan_local_mirror_snapshots(
m_local_snap_id_start = local_snap_id;
ceph_assert(m_local_snap_id_end == CEPH_NOSNAP);

if (mirror_ns->mirror_peer_uuids.empty()) {
if (mirror_ns->mirror_peer_uuids.empty() ||
mirror_ns->state == cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED) {

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 think this if condition covers all types of non-primary snapshots i.e both normal non-primary snapshots (contains no mirror_peer_uuids) and non_primary_demoted snapshots.

So i think we can just completely remove this if condition and just call m_prune_snap_ids.insert(local_snap_id); unless i am missing something.

Comment thread qa/workunits/rbd/rbd_mirror_helpers.sh Outdated
return 1
}

wait_for_non_prim_snap_with_primary_id_present()

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 think this helper is not needed/used, so we can remove it.

Comment thread qa/workunits/rbd/rbd_mirror.sh Outdated
@@ -227,6 +233,9 @@ wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${image}
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${POOL} ${image}
compare_images ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${image}
if [ "${RBD_MIRROR_MODE}" = "snapshot" ]; then
wait_for_non_prim_snap_with_primary_id_not_present ${CLUSTER1} ${POOL}/${image} ${demote_snap_id}

@VinayBhaskar-V VinayBhaskar-V Apr 27, 2026 •

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 think instead of this it's better to have a separate test case that promotes and demotes same image 20 times in a loop and at the end checks the snapshot count similar to "TEST: failover / failback loop".
We can discuss this with the team

@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch 5 times, most recently from 28d908c to de63c83 Compare April 30, 2026 08:03
Comment thread qa/workunits/rbd/rbd_mirror.sh Outdated
wait_for_status_in_pool_dir ${CLUSTER2} ${POOL} ${image} 'up+stopped'
wait_for_replaying_status_in_pool_dir ${CLUSTER1} ${POOL} ${image}
compare_images ${CLUSTER1} ${CLUSTER2} ${POOL} ${POOL} ${image}
wait_for_non_primary_snap_not_present ${CLUSTER1} ${POOL} ${image} ${demote_snap_id}

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 think here no need to check this this every time, we are directly checking the final count that implies that these non-primary demoted snapshots are getting deleted. So basically no need to add any new helpers and no need to get non-primary snapshot id and check whether it is removed or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to have specific checks because when test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 fails for any future changes, author needs to know which snapshot is not removed correctly. I have one upcoming PR, which not only checks removal of specific snapshot but also checks for unlinking.

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.

Sorry, i am not able to understand properly. This test case needs to checks whether non-primary demoted snapshots are getting deleted or not right. So if the test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 fails means that non-primary demoted snapshots are not getting deleted properly.

@abitdrag abitdrag Apr 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, if test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 or test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 fails, then it doesn't guarantee that non-primary demote snapshot is not removed. It could be any snapshot that is not cleaned up in between. It could be primary, non-primary, primary demoted or non-primary demoted.

In this PR, I have added test to check for removal of non-primary demoted only because that's what the code changes targets. In another PR, I have added test to check for removal of all other kind of snapshots as well. Will share this next PR shortly for review. But point is to have more specific checks for snapshots instead of checking on high level.

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.

The test case above this test case i.e "TEST: failover / failback loop" already checks remaining cases right.

@abitdrag abitdrag Apr 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is also not sufficient. I am creating a test that checks for removal of different kind of snapshots and unlinking, basically testing snapshot removal in more details.

@ajarr ajarr May 5, 2026 •

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.

@abitdrag I agree with @VinayBhaskar-V comment here a7f3848#r3167617528

No, if test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 or test "$(count_mirror_snaps ${CLUSTER1} ${POOL} ${image})" -le 3 fails, then it doesn't guarantee that non-primary demote snapshot is not removed. It could be any snapshot that is not cleaned up in between. It could be primary, non-primary, primary demoted or non-primary demoted.

Yes, that’s true. However, the point is that testing the general case by checking whether the number of snapshots is less than three already covers the scenario where a non-primary demoted snapshot has been removed. Is it possible for the number of snapshots in CLUSTER1 to be fewer than three while a non-primary demoted snapshot is still present?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ajarr, No. With loop, there is no scenario where number of snapshots becomes fewer than 3 while non-primary demoted snapshot is still present. But PTAL these changes:
https://github.com/ceph/ceph/pull/67483/changes

I am still modifying this PR with respect to current changes, but the way I have put checks in this PR, I am planning to put checks for unlink and removal for all kind of snapshots in this scenario as well as relocation scenario. So, anyway this check will be added later, since we are making change related to non-primary demoted snaps here, I have put that check here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

wait_for_non_primary_snap_not_present per loop is strict and doesn't hurt IMHO. I would keep it.

@abitdrag abitdrag May 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with you @pkalever, have kept the cheks stricter.

@ajarr ajarr 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.

In the commit message,

When a primary cluster is demoted and then promoted again,
a demoted non-primary snapshot is created on the secondary
cluster. These snapshots are not cleaned up until the secondary
cluster itself is demoted. Repeated demote/promote cycles on
the same cluster lead to accumulation of such non-primary
demoted snapshots on the secondary.

This change addresses the cleanup of these accumulated
non-primary demoted snapshots and adds test cases to verify the behavior.

I'm unable to follow this sentence, "These snapshots are not cleaned up until the secondary cluster itself is demoted". Can you explain what you mean by demoting a secondary cluster, and how would it clear up the non-primary demoted snapshot?

Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch from de63c83 to d8ae96b Compare May 4, 2026 07:50
@abitdrag

abitdrag commented May 4, 2026 •

Copy link
Copy Markdown
Contributor Author

In the commit message,

When a primary cluster is demoted and then promoted again,
a demoted non-primary snapshot is created on the secondary
cluster. These snapshots are not cleaned up until the secondary
cluster itself is demoted. Repeated demote/promote cycles on
the same cluster lead to accumulation of such non-primary
demoted snapshots on the secondary.

This change addresses the cleanup of these accumulated
non-primary demoted snapshots and adds test cases to verify the behavior.

I'm unable to follow this sentence, "These snapshots are not cleaned up until the secondary cluster itself is demoted". Can you explain what you mean by demoting a secondary cluster, and how would it clear up the non-primary demoted snapshot?

I have changed commit message with better explanation. Have also made changes in test case. @VinayBhaskar-V , @ajarr PTAL.

@abitdrag
abitdrag requested review from VinayBhaskar-V and ajarr May 4, 2026 08:16
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch from d8ae96b to a7f3848 Compare May 4, 2026 08:20
Comment thread qa/workunits/rbd/rbd_mirror_helpers.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
@pkalever

pkalever commented May 7, 2026

Copy link
Copy Markdown

With this changes on top of #68161 after the newly added test here are the list of snaps (as expected and fixed)

# ./bin/rbd -c /tmp/tmp.*/cluster1.conf snap ls mirror/test --all --debug-rbd=0; ./bin/rbd -c /tmp/tmp.*/cluster2.conf snap ls mirror/test --all --debug-rbd=0;                                                                                         
SNAPID  NAME                                                                                           SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                                        
    81  .mirror.non_primary.3efe7629-7c10-4b08-b583-ac14de58cef2.953513a8-1290-4f8b-a67c-dd5489506319  128 MiB             Thu May  7 14:41:58 2026  mirror (non-primary peer_uuids:[] 6e3fdf9a-b59b-4cd3-b591-3e6289f97c71:81 copied)
SNAPID  NAME                                                                                       SIZE     PROTECTED  TIMESTAMP                 NAMESPACE                                                         
    80  .mirror.primary.3efe7629-7c10-4b08-b583-ac14de58cef2.cd2233a2-74ca-4f24-b40d-5ae3e74096a1  128 MiB             Thu May  7 14:41:53 2026  mirror (primary peer_uuids:[])                                    
    81  .mirror.primary.3efe7629-7c10-4b08-b583-ac14de58cef2.9de2e777-bf8a-474e-a9e6-a2073017eb4d  128 MiB             Thu May  7 14:41:57 2026  mirror (primary peer_uuids:[d518c103-8a90-4f73-9c7d-792614ee1797])

So I recommend the order of merging the patches to go in the same fashion and adjust your tests accordingly, by cherry picking the commit from #68161

@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch 2 times, most recently from 1153814 to 3d21990 Compare May 8, 2026 06:00
@abitdrag
abitdrag requested a review from pkalever May 8, 2026 06:01
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror_helpers.sh Resolved
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch from 3d21990 to 65a1d4f Compare May 8, 2026 09:44
@abitdrag
abitdrag requested a review from pkalever May 8, 2026 09:44

@ajarr ajarr 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.

@abitdrag changes mostly look good to me. Have you looked into adding a unit test? Is it too complex? You've added a unit test for #68161

Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
@ajarr

ajarr commented May 21, 2026

Copy link
Copy Markdown
Contributor

@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

@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch from 023641e to 21d152b Compare June 19, 2026 12:34
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch 3 times, most recently from 687f66a to 4a82124 Compare June 19, 2026 15:20
@abitdrag

abitdrag commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Comment thread qa/workunits/rbd/rbd_mirror_helpers.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch 3 times, most recently from 063faa6 to 8508417 Compare June 24, 2026 09:50
@abitdrag
abitdrag requested a review from idryomov June 24, 2026 09:50
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
Comment thread qa/workunits/rbd/rbd_mirror.sh Resolved
…al cluster

When an image is demoted on primary cluster and later promoted again,
a non-primary demoted image snapshot is created on the peer (secondary)
cluster. Each such promote/demote cycle on same cluster results in an
additional non-primary demoted snapshot being created on peer.
As a result, repeated promote/demote cycles on the same cluster can
lead to accumulation of stale non-primary demoted snapshots on the
secondary cluster. These snapshots are not removed immediately because
cleanup is only triggered when peer (secondary) is promoted and then
demoted.

The proposed changes ensures that such snapshots are proactively identified
and removed, preventing unbounded buildup. Also added test coverage to
verify cleanup behavior.

Fixes: https://tracker.ceph.com/issues/76155

Signed-off-by: Miki Patel <[email protected]>
@abitdrag
abitdrag force-pushed the wip-non-prim-demote-img-snap-removal branch from 8508417 to 5a77c4f Compare June 24, 2026 17:42
@abitdrag

Copy link
Copy Markdown
Contributor Author

@abitdrag
abitdrag requested a review from idryomov June 25, 2026 09:50
@idryomov
idryomov dismissed pkalever’s stale review June 25, 2026 10:33

Stale request for changes, there is a later comment: #68500 (review)

The commit messages has been adjusted.

@idryomov
idryomov merged commit 35eb601 into ceph:main Jun 25, 2026
6 checks passed
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.

5 participants