forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[snapshot]: idempotent commit-delete via status=Deleting latch #4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zstack-robot-2
wants to merge
1
commit into
zsv_5.1.0
Choose a base branch
from
sync/tao.gan/fix/ZSV-10538-idempotent-delete
base: zsv_5.1.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- ZSV-10538 snapshot commit-delete idempotency: latch column | ||
| CALL ADD_COLUMN('VolumeSnapshotVO', 'deletingSince', 'TIMESTAMP', 1, NULL); |
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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
storage/src/main/java/org/zstack/storage/snapshot/SnapshotReconcileOnStart.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package org.zstack.storage.snapshot; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowire; | ||
| import org.springframework.beans.factory.annotation.Configurable; | ||
| import org.zstack.core.db.Q; | ||
| import org.zstack.header.managementnode.ManagementNodeReadyExtensionPoint; | ||
| import org.zstack.header.storage.snapshot.VolumeSnapshotStatus; | ||
| import org.zstack.header.storage.snapshot.VolumeSnapshotVO; | ||
| import org.zstack.header.storage.snapshot.VolumeSnapshotVO_; | ||
| import org.zstack.utils.Utils; | ||
| import org.zstack.utils.logging.CLogger; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * ZSV-10538: passive reconcile for snapshots stuck in Deleting status. | ||
| * | ||
| * When MN crashes mid-deletion, the VolumeSnapshotVO row stays in Deleting (this is the | ||
| * persistent latch designed in docs/snapshot-single-delete/18-idempotency-design-status-deleting.md). | ||
| * On the next MN startup we scan for such rows and emit a WARN log per stuck snapshot so | ||
| * operators can decide whether to resume by re-issuing DeleteVolumeSnapshot{,Group}. | ||
| * | ||
| * NOTE: we deliberately do NOT auto-retry. SBLK host failover / lock conflicts make | ||
| * unattended retry risky; the safer choice is to let the operator re-issue the same API | ||
| * which routes through the idempotent resume path in VolumeSnapshotTreeBase. | ||
| */ | ||
| @Configurable(preConstruction = true, autowire = Autowire.BY_TYPE) | ||
| public class SnapshotReconcileOnStart implements ManagementNodeReadyExtensionPoint { | ||
| private static final CLogger logger = Utils.getLogger(SnapshotReconcileOnStart.class); | ||
|
|
||
| @Override | ||
| public void managementNodeReady() { | ||
| List<VolumeSnapshotVO> stuck = Q.New(VolumeSnapshotVO.class) | ||
| .eq(VolumeSnapshotVO_.status, VolumeSnapshotStatus.Deleting) | ||
| .list(); | ||
| if (stuck.isEmpty()) { | ||
| return; | ||
| } | ||
| logger.warn(String.format( | ||
| "[ZSV-10538] Found %d snapshot(s) in Deleting status at MN startup. " + | ||
| "These were left mid-deletion by a previous MN session. No automatic action taken. " + | ||
| "Re-issue APIDeleteVolumeSnapshot{,Group} to resume; the API is idempotent.", | ||
| stuck.size())); | ||
| for (VolumeSnapshotVO v : stuck) { | ||
| logger.warn(String.format( | ||
| " - snapshot[uuid:%s, name:%s, volumeUuid:%s, treeUuid:%s, deletingSince:%s, installPath:%s]", | ||
| v.getUuid(), v.getName(), v.getVolumeUuid(), v.getTreeUuid(), | ||
| v.getDeletingSince(), v.getPrimaryStorageInstallPath())); | ||
| } | ||
| } | ||
| } |
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议在“消息列表”前补充分隔符,避免占位符直连文本。
当前中文文案为“当前状态允许的消息列表{3}”,建议改为“当前状态允许的消息列表:{3}”,提升用户阅读体验。
🤖 Prompt for AI Agents