-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[snapshot]: fixed the issue where too many snapshots caused the qmp... #2904
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
base: zsv_4.10.20
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| public class VolumeSnapshotGlobalConfig { | ||
| public static final String CATEGORY = "volumeSnapshot"; | ||
|
|
||
| @GlobalConfigValidation(numberGreaterThan = 0) | ||
| @GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120) | ||
| public static GlobalConfig MAX_INCREMENTAL_SNAPSHOT_NUM = new GlobalConfig(CATEGORY, "incrementalSnapshot.maxNum"); | ||
|
Comment on lines
+14
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain验证约束的上界值需要与业务需求和 SQL 迁移保持一致 当前添加的
建议根据实际业务需求选择以下方案之一: 方案 1:严格限制为 64(与 PR 描述一致) -@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120)
+@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 65)方案 2:保持 120 为上限(需要说明理由) -@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120)
+/**
+ * 增量快照最大数量配置
+ * 有效范围: (0, 120)
+ * 技术限制: [补充具体原因,如 QMP 命令限制等]
+ * 推荐值: 64(超过此值可能导致性能问题)
+ */
+@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120)请确认实际的业务需求和技术限制,并与 SQL 迁移脚本保持一致。 Based on coding guidelines 🏁 Script executed: #!/bin/bash
# Search for SQL migration files related to incremental snapshots or snapshot migrations
echo "=== Searching for SQL files with incremental snapshot references ==="
fd -e sql | xargs grep -l "incrementalSnapshot\|incremental.*snapshot" 2>/dev/null | head -20
echo ""
echo "=== Searching for SQL files with maxNum references ==="
fd -e sql | xargs grep -l "maxNum\|max_num" 2>/dev/null | head -20
echo ""
echo "=== Checking for any PR or migration documentation ==="
fd -type f \( -name "*.md" -o -name "*.txt" \) | xargs grep -l "incrementalSnapshot\|incremental snapshot" 2>/dev/null | head -10Length of output: 425 🏁 Script executed: #!/bin/bash
# Search for references to MAX_INCREMENTAL_SNAPSHOT_NUM in the codebase
echo "=== Searching for MAX_INCREMENTAL_SNAPSHOT_NUM usage ==="
rg -n "MAX_INCREMENTAL_SNAPSHOT_NUM" --type java -C 3
echo ""
echo "=== Searching for incrementalSnapshot.maxNum references ==="
rg -n "incrementalSnapshot\.maxNum" --type java -C 3
echo ""
echo "=== Searching for numberLessThan.*120 or similar patterns ==="
rg -n "numberLessThan\s*=\s*120" --type java -C 2Length of output: 5576 🏁 Script executed: #!/bin/bash
# Get more context about the VolumeSnapshotGlobalConfig file
echo "=== Full content of VolumeSnapshotGlobalConfig.java ==="
fd "VolumeSnapshotGlobalConfig.java" --type f -x cat {}
echo ""
echo "=== Searching for snapshot-related SQL migration files ==="
fd -path "*/db/migration/*" -name "*.sql" | xargs grep -l "snapshot" 2>/dev/null | head -10Length of output: 1673 🏁 Script executed: #!/bin/bash
# Read the SQL migration file to check what value is actually used
echo "=== Content of SQL migration file V4.10.20__schema.sql ==="
cat conf/db/upgrade/V4.10.20__schema.sql | grep -A 5 -B 5 "incrementalSnapshot\|maxNum\|64\|120" | head -100Length of output: 340 🏁 Script executed: #!/bin/bash
# Search for any documentation or comments about snapshot limits
echo "=== Searching for documentation about snapshot limits ==="
rg -n "incremental.*snapshot|snapshot.*limit|qmp.*command|snapshot.*performance" --type java -i | grep -i "limit\|max\|64\|120\|qmp\|performance" | head -30
echo ""
echo "=== Checking commit messages or PR files if available ==="
git log --all --oneline --grep="incremental\|snapshot" 2>/dev/null | head -20
echo ""
echo "=== Looking for any test files related to snapshot configuration ==="
fd -name "*SnapshotGlobalConfig*" --type fLength of output: 4201 🏁 Script executed: #!/bin/bash
# Search for any documentation files mentioning snapshot configuration
echo "=== Searching README or documentation files ==="
find . -name "README*" -o -name "*.md" | xargs grep -l "snapshot\|incremental" 2>/dev/null | head -10
echo ""
echo "=== Checking git diff or recent changes ==="
git diff HEAD~1 HEAD -- "*SnapshotGlobalConfig*" 2>/dev/null || echo "No recent git diff available"
echo ""
echo "=== Looking at the full SQL migration context ==="
cat conf/db/upgrade/V4.10.20__schema.sqlLength of output: 2429 验证约束上界值与 SQL 迁移、业务需求不一致 根据代码审查,发现以下问题: 现状分析:
核心问题:
建议修复方案: 方案 1:调整验证以匹配 SQL 逻辑(推荐) -@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120)
+@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 65)方案 2:添加文档说明技术限制 +/**
+ * 增量快照最大数量,用于防止过多快照导致 QMP 'query block' 命令失败
+ * 有效范围: (0, 120)
+ * 安全推荐值: 64(超过此值可能性能下降;达到 120 可能导致 QMP 命令超时)
+ * @see <a href="...">QMP 命令限制文档</a>
+ */
@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 120)需确认:为什么选择 120 作为验证硬限制,而非直接用 65 以匹配 SQL 迁移的 64 值? 🤖 Prompt for AI Agents |
||
| @GlobalConfigValidation(numberGreaterThan = 0) | ||
| public static GlobalConfig SNAPSHOT_DELETE_PARALLELISM_DEGREE = new GlobalConfig(CATEGORY, "delete.parallelismDegree"); | ||
|
|
||
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.
🧩 Analysis chain
SQL 更新逻辑与 Java 验证约束不一致
当前 SQL 迁移脚本存在以下问题:
条件不一致:SQL 使用
value > 120(仅处理 >= 121 的值),但 Java 验证层添加了numberLessThan = 120(允许最大值为 119)。这意味着:numberLessThan = 120验证条件value >= 120以保持一致性目标值与验证范围不匹配:
numberLessThan = 65;如果允许到 119,需要明确说明为何 SQL 重置为 64 而非 119同时更新 defaultValue 的合理性:SQL 同时更新了
value和defaultValue。请确认是否所有超过 120 的配置,其defaultValue也需要被强制改为 64,还是应该只更新value。数据类型处理:
value字段在数据库中可能存储为字符串类型,使用value > 120进行数值比较可能产生意外结果。建议使用CAST(value AS UNSIGNED) > 120确保正确的数值比较。建议的修复方案(需根据实际业务需求选择):
方案 1:如果最大值确实应该限制为 64
同时修改 Java 验证为:
@GlobalConfigValidation(numberGreaterThan = 0, numberLessThan = 65)方案 2:如果最大值应该是 119(根据 Java 验证)
另外,根据编码规范,当字段存在
NOT NULL约束时,应使用存储过程处理历史数据。请确认value和defaultValue字段是否有NOT NULL约束,如有则需要改用存储过程实现。Based on coding guidelines
生成验证脚本以检查SQL迁移脚本、Java验证约束和数据库schema定义。
Length of output: 38
🏁 Script executed:
Length of output: 63
🏁 Script executed:
Length of output: 6626
🏁 Script executed:
Length of output: 5411
🏁 Script executed:
Length of output: 876
需要继续查找与volumeSnapshot配置相关的Java定义和表结构。
Length of output: 172
🏁 Script executed:
Length of output: 1251
🏁 Script executed:
Length of output: 1264
🏁 Script executed:
Length of output: 1359
🏁 Script executed:
Length of output: 1860
SQL更新条件与Java验证约束存在严重不一致
核心问题已确认:
条件漏洞:Java验证允许的范围是
numberGreaterThan = 0, numberLessThan = 120(即1-119),但SQL条件value > 120仅处理≥121的值。值为120的配置既不会被SQL更新,也无法通过Java验证。建议改为value >= 120。目标值与验证范围矛盾:SQL将超限值重置为64,但Java验证允许的最大值是119。需要明确业务需求:
numberLessThan = 65数据类型隐患:GlobalConfigVO表中
value字段定义为text类型,直接进行value > 120的数值比较依赖隐式转换。建议显式转换:CAST(value AS UNSIGNED) >= 120。defaultValue同步更新:SQL同时修改了
value和defaultValue,需确认所有超过限制的配置是否都需要两个字段都重置为64,还是仅更新value。