-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[conf]: disaster recovery #4648
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.0.1
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 |
|---|---|---|
|
|
@@ -28,4 +28,14 @@ CREATE TABLE IF NOT EXISTS `zstack`.`L2NetworkHostRefVO` ( | |
| UNIQUE KEY `ukL2NetworkHost` (`l2NetworkUuid`,`hostUuid`) USING BTREE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| ALTER TABLE `zstack`.`L2NetworkClusterRefVO` ADD COLUMN `l2ProviderType` varchar(32) default NULL; | ||
| ALTER TABLE `zstack`.`L2NetworkClusterRefVO` ADD COLUMN `l2ProviderType` varchar(32) default NULL; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`SchedulerJobGroupZoneRefVO` ( | ||
| `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT, | ||
| `schedulerJobGroupUuid` varchar(32) NOT NULL COMMENT 'uuid of schedulerJobGroupUuid', | ||
| `zoneUuid` varchar(32) NOT NULL COMMENT 'uuid of zone', | ||
| `lastOpDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| `createDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
|
Comment on lines
+37
to
+38
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
file="conf/db/upgrade/V4.7.0.4__schema.sql"
echo "== file exists =="
git ls-files "$file"
echo
echo "== line count =="
wc -l "$file"
echo
echo "== relevant excerpt =="
sed -n '1,120p' "$file"
echo
echo "== search for same table / historical backfill / zero-date usage =="
rg -n "lastOpDate|createDate|0000-00-00|CURRENT_TIMESTAMP|ON UPDATE CURRENT_TIMESTAMP|CREATE TABLE|ALTER TABLE" conf/db/upgrade -SRepository: MatheMatrix/zstack Length of output: 50375 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="conf/db/upgrade/V4.7.0.4__schema.sql"
echo "== target excerpt =="
nl -ba "$file" | sed -n '1,120p'
echo
echo "== nearby upgrade files mentioning the same columns =="
rg -n "lastOpDate|createDate|0000-00-00|CURRENT_TIMESTAMP|ON UPDATE CURRENT_TIMESTAMP" conf/db/upgrade/V4.7.0*.sql conf/db/upgrade/V4.6*.sql conf/db/upgrade/V4.5*.sql -S
echo
echo "== table creation / historical backfill markers in target file =="
rg -n "CREATE TABLE|INSERT INTO|UPDATE |ALTER TABLE|PROCEDURE|FUNCTION|BEGIN|END" "$file" -SRepository: MatheMatrix/zstack Length of output: 217 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="conf/db/upgrade/V4.7.0.4__schema.sql"
python3 - <<'PY'
from pathlib import Path
p = Path("conf/db/upgrade/V4.7.0.4__schema.sql")
print("exists:", p.exists())
print("lines:", sum(1 for _ in p.open()))
print("== target excerpt ==")
for i, line in enumerate(p.open(), 1):
if i <= 120:
print(f"{i:4d}: {line.rstrip()}")
PY
echo
echo "== exact matches in target file =="
rg -n "lastOpDate|createDate|0000-00-00|CURRENT_TIMESTAMP|ON UPDATE CURRENT_TIMESTAMP|CREATE TABLE|ALTER TABLE|INSERT INTO|PROCEDURE|FUNCTION" "$file" -S
echo
echo "== nearby version scripts in same area =="
rg -n "0000-00-00|CURRENT_TIMESTAMP|ON UPDATE CURRENT_TIMESTAMP" conf/db/upgrade/V4.7*.sql conf/db/upgrade/V4.6*.sql conf/db/upgrade/V4.5*.sql -SRepository: MatheMatrix/zstack Length of output: 11815 将零日期默认值改成当前时间默认值。 🤖 Prompt for AI AgentsSources: Path instructions, Learnings |
||
| CONSTRAINT `fkSchedulerJobGroupZoneRefVOSchedulerJobGroupVO` FOREIGN KEY (`schedulerJobGroupUuid`) REFERENCES SchedulerJobGroupVO (`uuid`) ON DELETE CASCADE, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class AttachSchedulerJobGroupToZoneAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.AttachSchedulerJobGroupToZoneResult value; | ||
|
|
||
| public Result throwExceptionIfError() { | ||
| if (error != null) { | ||
| throw new ApiException( | ||
| String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details) | ||
| ); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String schedulerJobGroupUuid; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String zoneUuid; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List systemTags; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List userTags; | ||
|
|
||
| @Param(required = false) | ||
| public String sessionId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeyId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeySecret; | ||
|
|
||
| @Param(required = false) | ||
| public String requestIp; | ||
|
|
||
| @NonAPIParam | ||
| public long timeout = -1; | ||
|
|
||
| @NonAPIParam | ||
| public long pollingInterval = -1; | ||
|
|
||
|
|
||
| private Result makeResult(ApiResult res) { | ||
| Result ret = new Result(); | ||
| if (res.error != null) { | ||
| ret.error = res.error; | ||
| return ret; | ||
| } | ||
|
|
||
| org.zstack.sdk.AttachSchedulerJobGroupToZoneResult value = res.getResult(org.zstack.sdk.AttachSchedulerJobGroupToZoneResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.AttachSchedulerJobGroupToZoneResult() : value; | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public Result call() { | ||
| ApiResult res = ZSClient.call(this); | ||
| return makeResult(res); | ||
| } | ||
|
|
||
| public void call(final Completion<Result> completion) { | ||
| ZSClient.call(this, new InternalCompletion() { | ||
| @Override | ||
| public void complete(ApiResult res) { | ||
| completion.complete(makeResult(res)); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getNonAPIParameterMap() { | ||
| return nonAPIParameterMap; | ||
| } | ||
|
|
||
| protected RestInfo getRestInfo() { | ||
| RestInfo info = new RestInfo(); | ||
| info.httpMethod = "POST"; | ||
| info.path = "/scheduler/zone/{zoneUuid}/scheduler-job-group/{schedulerJobGroupUuid}"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = "params"; | ||
| return info; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import org.zstack.sdk.SchedulerJobGroupZoneRefInventory; | ||
|
|
||
| public class AttachSchedulerJobGroupToZoneResult { | ||
| public SchedulerJobGroupZoneRefInventory inventory; | ||
| public void setInventory(SchedulerJobGroupZoneRefInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
| public SchedulerJobGroupZoneRefInventory getInventory() { | ||
| return this.inventory; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class DetachSchedulerJobGroupFromZoneAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.DetachSchedulerJobGroupFromZoneResult value; | ||
|
|
||
| public Result throwExceptionIfError() { | ||
| if (error != null) { | ||
| throw new ApiException( | ||
| String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details) | ||
| ); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String schedulerJobGroupUuid; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String zoneUuid; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List systemTags; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List userTags; | ||
|
|
||
| @Param(required = false) | ||
| public String sessionId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeyId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeySecret; | ||
|
|
||
| @Param(required = false) | ||
| public String requestIp; | ||
|
|
||
| @NonAPIParam | ||
| public long timeout = -1; | ||
|
|
||
| @NonAPIParam | ||
| public long pollingInterval = -1; | ||
|
|
||
|
|
||
| private Result makeResult(ApiResult res) { | ||
| Result ret = new Result(); | ||
| if (res.error != null) { | ||
| ret.error = res.error; | ||
| return ret; | ||
| } | ||
|
|
||
| org.zstack.sdk.DetachSchedulerJobGroupFromZoneResult value = res.getResult(org.zstack.sdk.DetachSchedulerJobGroupFromZoneResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.DetachSchedulerJobGroupFromZoneResult() : value; | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public Result call() { | ||
| ApiResult res = ZSClient.call(this); | ||
| return makeResult(res); | ||
| } | ||
|
|
||
| public void call(final Completion<Result> completion) { | ||
| ZSClient.call(this, new InternalCompletion() { | ||
| @Override | ||
| public void complete(ApiResult res) { | ||
| completion.complete(makeResult(res)); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getNonAPIParameterMap() { | ||
| return nonAPIParameterMap; | ||
| } | ||
|
|
||
| protected RestInfo getRestInfo() { | ||
| RestInfo info = new RestInfo(); | ||
| info.httpMethod = "DELETE"; | ||
| info.path = "/scheduler/zone/{zoneUuid}/scheduler-job-group/{schedulerJobGroupUuid}"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = ""; | ||
| return info; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import org.zstack.sdk.SchedulerJobGroupInventory; | ||
|
|
||
| public class DetachSchedulerJobGroupFromZoneResult { | ||
| public SchedulerJobGroupInventory inventory; | ||
| public void setInventory(SchedulerJobGroupInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
| public SchedulerJobGroupInventory getInventory() { | ||
| return this.inventory; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
|
|
||
|
|
||
| public class SchedulerJobGroupZoneRefInventory { | ||
|
|
||
| public java.lang.Long id; | ||
| public void setId(java.lang.Long id) { | ||
| this.id = id; | ||
| } | ||
| public java.lang.Long getId() { | ||
| return this.id; | ||
| } | ||
|
|
||
| public java.lang.String schedulerJobGroupUuid; | ||
| public void setSchedulerJobGroupUuid(java.lang.String schedulerJobGroupUuid) { | ||
| this.schedulerJobGroupUuid = schedulerJobGroupUuid; | ||
| } | ||
| public java.lang.String getSchedulerJobGroupUuid() { | ||
| return this.schedulerJobGroupUuid; | ||
| } | ||
|
|
||
| public java.lang.String zoneUuid; | ||
| public void setZoneUuid(java.lang.String zoneUuid) { | ||
| this.zoneUuid = zoneUuid; | ||
| } | ||
| public java.lang.String getZoneUuid() { | ||
| return this.zoneUuid; | ||
| } | ||
|
|
||
| public java.sql.Timestamp createDate; | ||
| public void setCreateDate(java.sql.Timestamp createDate) { | ||
| this.createDate = createDate; | ||
| } | ||
| public java.sql.Timestamp getCreateDate() { | ||
| return this.createDate; | ||
| } | ||
|
|
||
| public java.sql.Timestamp lastOpDate; | ||
| public void setLastOpDate(java.sql.Timestamp lastOpDate) { | ||
| this.lastOpDate = lastOpDate; | ||
| } | ||
| public java.sql.Timestamp getLastOpDate() { | ||
| return this.lastOpDate; | ||
| } | ||
|
|
||
| } |
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
为绑定关系增加联合唯一约束。
当前只有自增主键,
(schedulerJobGroupUuid, zoneUuid)可以重复;重试或并发执行 attach 时会插入多条相同关系,导致查询和 detach 语义不确定。`createDate` ..., + UNIQUE KEY `ukSchedulerJobGroupZoneRef` (`schedulerJobGroupUuid`, `zoneUuid`), CONSTRAINT ...Also applies to: 40-40
🤖 Prompt for AI Agents