Conversation
After a replica promote (failover), the previously active replica is
demoted and its old outgoing SnapMirror relationships are supposed to be
released by cleanup_previous_snapmirror_relationships. That release is
best-effort and is skipped when the demoted replica's host is unreachable
at promote time (delete_snapmirror sets src_client=None and returns
without releasing; ESOURCE_IS_DIFFERENT is likewise swallowed).
Once the demoted replica converges to 'in_sync' as a destination of the
new source, update_replica_state no longer attempts any cleanup ("Replicas
already in-sync won't try another cleanup attempt"), so the stale
relationship lingers on the backend as a broken-off orphan indefinitely.
Add DataMotionSession.has_leftover_source_snapmirrors(), which lists the
source-side destinations for the replica and reports whether any point at
another known replica volume (known pairings only). update_replica_state
now runs the existing cleanup once for an in_sync replica when such a
leftover is detected, without altering the reported replica_state. When
the source is still unreachable the check is a no-op and retries next
periodic cycle (self-healing).
AI generated the has_leftover_source_snapmirrors helper, the
update_replica_state gating branch, and the accompanying unit tests;
human reviewed and verified the SnapMirror direction semantics and the
known-pairings safety constraint.
Change-Id: I2741f8394f8e603d9d72c454b6da879216aeca27
Assisted-By: Claude (Anthropic, claude-opus-4-1-20250805)
Signed-off-by: Maurice Escher <maurice.escher@sap.com>
Carthaca
requested review from
chuan137,
crenduchinta88,
kpawar-sap,
skook1 and
sumitarora2786
as code owners
September 16, 2026 09:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a replica promote (DR failover), the previously active replica is
demoted and its old outgoing SnapMirror relationships are supposed to be
released by
cleanup_previous_snapmirror_relationships. That release isbest-effort and is skipped when the demoted replica's host is unreachable
at promote time —
delete_snapmirrorsetssrc_client = Noneand returnswithout releasing (and
ESOURCE_IS_DIFFERENTis likewise swallowed).Once the demoted replica converges to
in_syncas a destination of the newsource,
update_replica_stateno longer attempts any cleanup ("Replicasalready in-sync won't try another cleanup attempt"), so the stale
relationship lingers on the backend as a broken-off orphan indefinitely.
Observed symptom:
manilareports the live replicain_sync(correct — theforward-filtered query never matches the stale reverse orphan), while
snapmirror showon the backend lists aBroken-off,Healthy=falserelationship left over from before the promote. This is not a
mis-classification of the live replica — it is an un-reconciled orphan.
Fix
DataMotionSession.has_leftover_source_snapmirrors(replica, replica_list):lists the source-side destinations for the replica and returns
Trueonly ifone targets another known replica volume (known-pairings only). Returns
Falsewhen the source is unreachable (self-healing — retried next cycle) oron API error.
update_replica_statenow runs the existingcleanup_previous_snapmirror_relationshipsonce for anin_syncreplica whensuch a leftover is detected. The reported
replica_stateis unchanged.This is the relationship-cleanup sibling of 7771edc ("Delete SnapMirror
snapshots left behind after a DR replica promotion"), which addressed only the
orphaned snapshots, not the orphaned relationship.
Testing
test_update_replica_state_in_sync_with_leftover_snapmirrortest_has_leftover_source_snapmirrors_found/_no_known_destination/_source_unreachable/_list_errorin_synccases to pin the new check.tox -e py3fortest_lib_baseandtest_data_motion: green.flake(hacking) on the changed files: clean.AI assistance
AI generated the
has_leftover_source_snapmirrorshelper, theupdate_replica_stategating branch, and the unit tests; human reviewed andverified the SnapMirror direction semantics and the known-pairings safety
constraint. See the
Assisted-Bytrailer on the commit.