Skip to content

<fix>[storage]: delete image cache shadow with local storage#4339

Open
zstack-robot-2 wants to merge 1 commit into
zsv_5.1.0from
sync/tao.gan/ZSV-7712-fix-full-vm-clone@@2
Open

<fix>[storage]: delete image cache shadow with local storage#4339
zstack-robot-2 wants to merge 1 commit into
zsv_5.1.0from
sync/tao.gan/ZSV-7712-fix-full-vm-clone@@2

Conversation

@zstack-robot-2

Copy link
Copy Markdown
Collaborator

Resolves: ZSV-7712

Test: CleanImageCacheOnLocalPrimaryStorageCase

Change-Id: I67fa5c8bba2cc8e3a0b6bc8f94e28546b42e4467

sync from gitlab !10300

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@MatheMatrix, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 1 second. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 830ee6e6-4609-4dc9-9dc7-22d3d8323986

📥 Commits

Reviewing files that changed from the base of the PR and between 1fdc06b and e3ab18d.

📒 Files selected for processing (2)
  • conf/db/zsv/V5.1.0__schema.sql
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/local/CleanImageCacheOnLocalPrimaryStorageCase.groovy

Walkthrough

迁移脚本将 fkImageCacheShadowVOPrimaryStorageEO 外键移到 ImageCacheShadowVO 并设置级联删除。集成测试新增对本地主存储删除后 ImageCacheShadowVO 自动清理的验证。

Changes

ImageCacheShadow 级联清理

Layer / File(s) Summary
外键迁移
conf/db/zsv/V5.1.0__schema.sql
迁移脚本从 ImageCacheVO 移除 fkImageCacheShadowVOPrimaryStorageEO,并在 ImageCacheShadowVO 上重新创建该外键,指向 PrimaryStorageEO.uuid 且启用 CASCADE 删除。
级联删除测试
test/src/test/groovy/org/zstack/test/integration/storage/primary/local/CleanImageCacheOnLocalPrimaryStorageCase.groovy
新增数据库持久化与查询相关导入,test() 调用新测试方法,并验证删除本地主存储后 ImageCacheShadowVO 数量从 1 变为 0。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 我蹦进草丛看迁移,
影子缓存跟着风儿飞。
一删主存,级联咔哒响,
胡萝卜味的测试最香🍃

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题明确指出了本地存储删除时清理 image cache shadow 的核心变更,且与补丁内容一致。
Description check ✅ Passed 描述中的工单号、测试用例和同步来源都与本次存储级联删除修复相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/tao.gan/ZSV-7712-fix-full-vm-clone@@2

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@conf/db/zsv/V5.1.0__schema.sql`:
- Around line 264-265: `ImageCacheShadowVO.primaryStorageUuid` is being
constrained before historical rows are cleaned up; update the migration flow
around `ADD_CONSTRAINT`/`DROP_FOREIGN_KEY` for `ImageCacheShadowVO` so any
orphaned `primaryStorageUuid` values are backfilled or removed first, then add
the foreign key. Make the fix in the schema migration path that introduces
`fkImageCacheShadowVOPrimaryStorageEO`, ensuring the `NOT NULL` column will not
cause upgrade failure when old invalid references exist.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5bbd1aa0-c054-42fa-bad8-ef3dc3461068

📥 Commits

Reviewing files that changed from the base of the PR and between da7f310 and 1fdc06b.

📒 Files selected for processing (2)
  • conf/db/zsv/V5.1.0__schema.sql
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/local/CleanImageCacheOnLocalPrimaryStorageCase.groovy

Comment thread conf/db/zsv/V5.1.0__schema.sql
@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/ZSV-7712-fix-full-vm-clone@@2 branch 3 times, most recently from a0c5340 to 49780ba Compare June 26, 2026 06:55
Resolves: ZSV-7712

Test: CleanImageCacheOnLocalPrimaryStorageCase

Change-Id: I67fa5c8bba2cc8e3a0b6bc8f94e28546b42e4467
@MatheMatrix MatheMatrix force-pushed the sync/tao.gan/ZSV-7712-fix-full-vm-clone@@2 branch from 49780ba to e3ab18d Compare June 26, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants