Files
archer/openspec/changes/archive/2026-11-06-normalize-state-config/proposal.md
T
voidandClaude Sonnet 4.6 bc4a6b504f Initial commit: archer, a Go-native MySQL/MariaDB table archiver
Renamed from arcdb: module path, cmd/archer, internal/archererr,
docs, build scripts and ARCHER_* environment variables.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-11-06 22:12:17 +08:00

28 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Why
`state.json` 的 `config.source` / `config.dest` 目前由 `dsnFingerprint`(internal/cli/hash.go)用竖线拼成 `tcp|host:3306|db|user`。这既不是 MySQL 生态的标准写法,也无法转义;更严重的是它只读取 `Net/Addr/DBName/User/Params`,导致 `charset`、`collation` 等被驱动收进结构体字段的参数**完全不参与指纹校验**——续跑时把 `charset=utf8mb4` 改成其他编码不会被发现,同一份导出会出现混合编码的分片。
## What Changes
- `state.json` 中的 `config.source` / `config.dest` 改为标准 MySQL DSN(去掉密码),例如 `root@tcp(s1.void01.com:3306)/lexis?charset=utf8mb4`。
- 配置指纹改用同一份规范化 DSN 计算,覆盖驱动解析出的全部连接参数(密码除外),从而把 `charset`、`collation`、`loc` 等纳入续跑校验。
- 与 `--dry-run` 的展示格式(`redactDSN`,internal/app/dryrun.go)保持一致,工具的"用户可见连接串"只有一种写法。
- **BREAKING**:指纹取值变化,旧版本写入的 `state.json` 会被判定为配置不同。续跑旧任务需要一次性传入 `--force-resume`;`state.json` 版本号不变(仍为 1),旧文件仍可读取并展示差异。
## Capabilities
### New Capabilities
(无)
### Modified Capabilities
- `archive-core`: 断点续跑要求中,明确配置指纹必须覆盖源/目标连接的规范化参数(含字符集与排序规则),并规定 `state.json` 中连接信息的存储形态为标准 DSN。
## Impact
- 代码:`internal/cli/hash.go`(`dsnFingerprint` 改为复制配置、清空 `Passwd`、调用 `FormatDSN`)。
- 测试:`internal/cli/cli_test.go` 增加 charset/参数变化的指纹断言与 `state.json` 快照断言。
- 数据:`state.json` 的 `config` 内容形态变化,触发一次性续跑校验失败。
- 文档:README 中关于 `state.json` 记录的描述无需改动;`--dry-run` 输出不变。